-
Notifications
You must be signed in to change notification settings - Fork 2k
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
ESM named exports are not available with "type": "module" #2721
Comments
Hey, @javascriptlabs. It seems that the error message implies the
I believe the issue is that while NodeJS treats your The |
hi @kettanaito looks like webpack 5 doesn't resolve it anymore. I'm getting this error:
|
has happened to me as well when I removed yarn.lock and installed all modules from the scratch. |
I need to rebuild my package-lock.json file because I need packages to use Is there another temporary solution to get webpack 5 to resolve graphql imports @kettanaito ? |
The way I resolved is to add
to the [rules] section. |
I have the same issue and using the solution from @flyandi did not work for me. Webpack 5.7.0. |
In addition to that rule I think your resolve section also needs to look like this: |
This didn't work for me either. Only thing that has worked is to add the extensions. That is, in index.mjs, I have to change It just bit me again. Quite a drag. |
I encountered this problem when adding an amplify back-end to my application. The fix described by @flyandi (THANKS!) worked for me but now my build is slowed because webpack must transpile node_modules . Shouldn't this issue be addressed in graphql imports/exports? changes to my webpack.config.js ...
|
Same MJS problem with Angular and AWS Amplify. |
I confirm that it is now an issue with Angular 12, which had been upgraded to Webpack 5 and released yesterday. Angular doesn't expose |
It is a problem of library. |
@rudyhadoux I also had this with my ng v12 upgrade and I'm also using amplify. I did a manual install of graphql to get it up to v15.5 and all the errors went away.
So I think the issue lies with either graphql-tag or amplify using old deps, not with graphql itself |
@dexster Good information, thanks. |
Did you try npm i -S graphql ? |
I am using
|
Someone told me in an other issue that latest packages work for webpack 5. |
Hmm. I don't use webpack/any build tool - just running typescript with node ES modules with the latest version of node. |
Upgrading
|
Same problem here after upgrading to |
Anyone got a solution to get graphql/amplify working with CRA5? |
I am desperate about this issue, I can reproduce with packages built with Tsup (so Esbuild) loaded in Next, I cannot import See https://stackoverflow.com/questions/70615613/apollo-client-named-export-remove-not-found and https://stackoverflow.com/questions/71370990/apollo-client-using-svelte-named-export-remove-not-found as well This is blocking the adoption of ESM for us. I am putting a bounty on this Stack Overflow ticket |
If in the package.json's graphql I put manually "browser": "index" will work. just saying it |
Thanks, @flyandi - your solution fixed the problem. For anyone interested in resolving the issue without manually modifying the config file, especially if you don't have the option available before publishing the app, I would recommend using the rewiring option which allows you to add the rules to the config file automatically when executing react-script. See below for more details: |
Thanks, this was driving me nuts and it was THAT simple. Being a beginner sucks. |
I upgraded my CRA to
This fixed the error coming from the Example :
Routes.tsx is present, but it throws the above error. |
@stuthib I think |
Where is the [rules] section? What do you mean by that? Please elaborate! |
If using create-react-app, set up CRACO, and set your module.exports = {
webpack: {
configure: (config, { env, paths }) => {
config.module.rules.unshift({
test: /\.m?jsx?$/,
resolve: {
fullySpecified: false,
},
});
return config;
},
}; |
Verify that this is the first rule if you have multiple (It took me some time)
|
I was able to solve this with the following:
|
A
package.json
top-level fieldtype
with a value ofmodule
should make modules load as ES modules.When I used that with graphql, I expected this to work (it didn't):
Importing from
index.mjs
works fine:Shouldn't ESM named exports work out of the box when Node's package type is set to
module
?Reproduce:
The text was updated successfully, but these errors were encountered: