-
-
Notifications
You must be signed in to change notification settings - Fork 27k
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
[email protected] - ReferenceError: require is not defined :: due to graphql using .mjs #4637
Comments
Odd, we added a work-around to make support for this explicitly work. Can you get to the bottom of this? |
This is the fix for Jest: #4318 I think there must be a similar issue with the order we're resolving files with the |
The following in the webpack config, just before the file loader, appears to solve the issue:
I can do more testing and get a root cause and solution along with a PR up this evening |
I've just noticed the same pattern: upgrading react-scripts to the latest version (2.0.0-next.3e165448) breaks the build. @christemple could you try to execute those steps and tell us the results? |
@miraage you're correct, clearing out However that's because when I install So you've narrowed it down to a change between those commits 👍 [1] Using |
It all seems to be related to the update to Webpack 4 and it's new defaults.
This currently causes the app to blow up with the experience described above. I believe the So I suspect it's more of an issue with Webpack or graphql (leaning more towards graphql as mjs seems more of an after-thought) I'll follow up with a proposed solution/workaround in #4642 |
I can confirm that adding: {
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto'
}, before transpiling configuration for Other projects like Razzle have applied similar solutions to this. |
We dropped |
@Timer Updating my monorepo to Can you clarify when this should or not occur? Unfortunately, removing Environment: Packages: (wanted => installed) |
Because my api uses different babel versions, I had
|
Is this a bug report?
Yes.
The latest
[email protected]
with Webpack 4 support breaks when bundling dependencies (node_modules
) with.mjs
files, such asgraphql
.Did you try recovering your dependencies?
Yes.
Which terms did you search for in User Guide?
In the User Guide, Issues and PRs I searched for:
ReferenceError: require is not defined
graphql
mjs
Environment
Steps to Reproduce
(Write your steps here:)
npx create-react-app my-app && cd my-app
npm install
npm install graphql [email protected] --save
import "./App.css"
insrc/App.js
npm start
[graphqlCode]
Expected Behavior
Actual Behavior
Reproducible Demo
https://github.com/christemple/create-react-app-graphql-issue
Additional
I noticed this when trying to install the AWS Amplify package, which I noticed has a dependency on
graphql
.I'm happy to raise a PR for a fix, I just wanted to get verification that it's a needed fix before doing so.
Thanks
The text was updated successfully, but these errors were encountered: