-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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
Babel configuration not being applied to files outside app directory after upgrade 9.3.1 -> 9.4.4 #13980
Comments
@dminkovsky , I think something changed with this version, that does not make it work with next-transpile-modules. I encountered the same problem, and was only able to get it to work by switching to next-plugin-transpile-modules See image below: |
This would be a bug with |
This is not related to next-transpile-modules. That still works. The issue here is that although workspace modules are transpiled, the were not being transpiled with the same babel config that Next.js was being transpiled with. This is, indeed, related to the way fast refresh was added in 9.4 (amazing thing, thing you). Specifically, the client and server webpack configs now have different structures. Under
whereas in client the first rule's
So my code:
which looks for
|
Thanks @nnennajohn! In my case, this was not related to next-transpile-modules. The issue for me was that although workspace modules were being transpiled thanks to that plugin, they were not being transpiled with the same Babel config that Next.js was being transpiled with, because the Babel root was set to my Next.js project and not my Yarn workspaces. I see you are using a plugin for that, but I had code that fixed that and it broke 9.3 -> 9.4. I updated my question and answer above to hopefully make the issue clear. In next.config.js, my webpack config now looks like this:
where
This is really brittle and will break if Next's webpack config structure changes again in the future, but it can be adjusted. |
Hello |
Hi @a93h. I'm not sure, but I don't think so... why do you think it might be the same problem? |
Thanks for the quick response @dminkovsky . If you have any suggestions on where to look, your advice is very welcome. It's weird Example of web-nextjs> yarn workspace @rnwmr/web-nextjs dev
yarn workspace v1.22.10
warning package.json: No license field
yarn run v1.22.10
warning package.json: No license field
$ next
ready - started server on http://localhost:3000
info - Using external babel configuration from C:\Users\me\Documents\GitHub\react-native-web-monorepo\packages\web-nextjs\babel.config.js
event - compiled successfully Example of web-nextjs> yarn workspace @rnwmr/web-nextjs build-out
yarn workspace v1.22.10
warning package.json: No license field
yarn run v1.22.10
warning package.json: No license field
$ yarn clean && yarn build && yarn export
warning package.json: No license field
$ shx rm -rf ./out && shx rm -rf ./.next
warning package.json: No license field
$ next build
Failed to compile.
../components\src\App.tsx:3:3
Type error: Module '"react-native"' has no exported member 'SafeAreaView'.
1 | import React from 'react'
2 | import {
> 3 | SafeAreaView,
| ^
4 | ScrollView,
5 | StatusBar,
6 | StyleSheet,
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed.
Exit code: 1
Command: C:\Program Files\nodejs\node.exe
Arguments: C:\Users\me\AppData\Roaming\npm\node_modules\yarn\lib\cli.js build-out
Directory: C:\Users\me\Documents\GitHub\react-native-web-monorepo\packages\web-nextjs
Output:
info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command. |
Yes it does. |
No idea what this could be. Never seen anything like this before that I remember. I would break it down to something simpler that does work with |
So I found this somewhat old repo. I might try to upgrade the packages and code until it breaks so I can see what's causing the problem. |
Yeah I saw it in your post after I asked.
I don't think this is a monorepo issue? It's definitely not related to this bug, anyway. Also, Next.js works with react-native?? I'm sorry but I don't even understand that at all. Next.js is for creating a universal rendered DOM/browser apps. react-native is ... react-native. I wouldn't have thought the two have any overlap. |
Here's one better, react native with web. React-Native-Web They do overlap. |
The repo I'm working on and the repo that is older are similar except the old one still builds and the new does not build, but both work with |
Far out! Thank you. Anyway, yeah... whenever I have totally bewildering issues like you describe, I reduce the problem to the smallest possible thing, like, maybe something extreme like a fresh, empty install of Next.js, and proceed by adding back my app until I experience the problem. Then most of the time the issue makes itself clear. Sorry if this something you've already done or something you know, but I can't really think of anything else. |
I'll say the reason I think this isn't monorepo related is because your build isn't finding an npm-installed package. All of the monorepo issues I've had have been related to workspace modules, not node_modules modules. |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
Describe the bug
I have a yarn workspace project layout like:
My babel configuration requires:
common
to be transpiled in my Next.js build.So I have the following next.config.js:
rule.use.options.root = resolve('..');
sets the babel root to the workspace root, which allows usingbabel.config.js
as global config and which has the following content:After upgrading 9.3.1 to 9.4.4, this config breaks for some reason. In my browser console I see errors which indicate the styled components plugin is not being used:
Expected
I would expect that as with 9.3.1, the 9.4.4 webpack configuration would allow using the workspace-wide, common babel config in
babel.config.js
.The text was updated successfully, but these errors were encountered: