Skip to content

Webpack 2 bug: "ReferenceError: exports is not defined" #2160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gaearon opened this issue May 15, 2017 · 3 comments
Closed

Webpack 2 bug: "ReferenceError: exports is not defined" #2160

gaearon opened this issue May 15, 2017 · 3 comments

Comments

@gaearon
Copy link
Contributor

gaearon commented May 15, 2017

Cross-posting from webpack/webpack#3974 (comment) for visibility.


I can consistently reproduce this in CRA codebase:

git clone https://github.com/facebookincubator/create-react-app.git
cd create-react-app
git checkout 9e733b57f8ae7ae3df46d95910d255798107448f
npm install

npm start

Then edit packages/react-scripts/template/src/App.js to have an empty block in the render method:

screen shot 2017-05-15 at 4 35 15 pm

Press save. The browser will reload.

Then edit it to remove the empty block and press save.

You will see the error:

screen shot 2017-05-15 at 4 36 23 pm

Unfortunately some internal state appears corrupted because even if I refresh the page, I keep getting the broken bundle. It only gets fixed by a restart of the server.

@gaearon gaearon added this to the 0.10.0 milestone May 15, 2017
@gaearon
Copy link
Contributor Author

gaearon commented May 16, 2017

It looks like a caching issue caused by babel-loader. I probably had some version of the module cached with CommonJS transform applied, and it was getting embedded into the bundle. Deleting node_modules/.cache fixed the issue.

@gaearon gaearon closed this as completed May 16, 2017
@Timer
Copy link
Contributor

Timer commented May 16, 2017

Maybe using #2092 will alleviate future cache problems?

@gaearon
Copy link
Contributor Author

gaearon commented May 16, 2017

I would actually expect the opposite effect 😄 Caches are hard.

@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants