-
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
Plugins presets not applied to defaultLoaders.babel.options #5393
Comments
Any news on this? I would gladly submit a PR if I knew where to start (and if I knew if it is a bug or an intentional behavior) (cc @timneutkens) |
I'm not really sure I understand the issue here, when adding next-typescript you're required to add the preset to your .babelrc, it might sound nice having Next.js handle that for you automatically, however then you run into issues with other tools that use babelrc / babel to compile being inconsistent, eg jest. |
You are actually right, I did not notice that you had to create a Then I guess it's on my side to update the documentation of my plugin to make sure people update their I'll investigate a bit more. |
🙌 yeah so we changed next-typescript to use the babel preset instead of ts-loader for performance reasons. |
Then I think we can close this 👍 |
🙏 Let me know if you run into any other issues. |
Bug report
I am not sure if this a Next problem, a Next plugin problem, or a user problem (or maybe a feature?). I am really open to any feedback.
Describe the bug
Similar to #5288. Found when debugging martpie/next-transpile-modules#1
It looks like Next plugins's presets (like
next-typescript
) are not added to next.config.js'soptions.defaultLoaders.babel.options
.I have not a lot of knowledge on how Next's build system actually work, but it looks wrong to me. Because of this, Babel won't transpile specified packages in node_modules.
The two solutions (martpie/next-transpile-modules#1 (comment) and martpie/next-transpile-modules#1 (comment)) are in my opinion lame, because the user should not have to worry about it.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
git clone [email protected]:martpie/monorepo-typescript-next-the-sane-way.git
cd monorepo-typescript-next-the-sane-way
npm install
cd website
babel.config.js
npm install & npm run dev
Babel will throw an error because it cannot transpile files.
To fix it, you can re-enable the custom
babel.config.js
or add the following in yournext.config.js
:or create a
babel.config.js
with a similar contentExpected behavior
The user should not have to write a (potentially error prone)
babel.config.js
or modify the Babel loaders to have this working.Do you think this should be handled by this plugin or by Next.js (genuine question)? If this is a plugin issue, do you see how this could be automated (how could I get all the presets/plugins used by a user in
next.config.js
?Screenshots
System information
Additional context
n/a
The text was updated successfully, but these errors were encountered: