-
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
Next.js 8 and RNW Transpilation Issues #7276
Comments
@dcalhoun ant update on this? I have a fully working NextJS 9 repo with RNW etc. But I'm pretty sure it includes ALL of RNW meaning the bundle is... massive |
@Aleksion unfortunately, no, I have not made progress on this. My app is currently frozen on Next.js 7.x for now. |
@dcalhoun @Aleksion I'm able to compile and run your test RNW project by adding babel-plugin-react-native-web. I opened a PR with the changes: https://github.com/dcalhoun/nextjs-rnw-transpile/pull/1/files However, I'm not sure if the end result is exactly what you're looking for, but it definitely compiles and runs. |
I made a PR to add Please confirm. |
@flybayer thanks for the information. I don't have time to confirm the results currently, but I will report back my findings eventually. Hopefully I have time to review later this week. |
Thanks to @flybayer, I was able to resolve my issue. I don't fully understand what is happening deep down in the compilation, but including I did notice one difference between the approach in this PR vs the current Next.js RNW example project. The former uses ESM for both the server and client. The latter uses CJS for the server and ESM for the client. I'm not sure if there is a downside to relying on CJS for the server, it may be fine. For my specific project, I at least need RNW's ESM for the client. Thanks again to @flybayer for the help! |
I don't believe we should close this if it's not clear what is causing the exact issue and the solution doesn't seem correct to me still. You're probably opting out of tree shaking this way for example. |
@timneutkens fair enough. I looked again at this and have discovered that upgrading Next to the latest (e.g. |
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
TL;DR: I need to transpile ESM source with Next.js, but I am unable to get it working with Next.js 8
I am attempting to transpile
react-native-web
source inside of my Next.js project. I succeeded at doing this in the past (see older Next.js RNW example). With Next.js 8, transpiling is no longer working. Note, the current Next.js + RNW example circumvents this issue by not transpiling at all (i.e. it relies on the CJS modules, not the ESM).I have a test case that includes individual commits for attempted usage of custom webpack config, usage of
next-transpile-modules
, and usage of babel config only.For the first two approaches (webpack and
next-transpile-modules
), the compilation fails with the following error:Click to view error details
For the babel-only attempt, compilation succeeds, but it is loading the CJS modules, not the ESM (i.e. it is not transpiling and merely using the already transpiled RNW source, RNW provides both).
At this point, I have been unable to determine what has changed in Next.js that is causing these issues. So, my questions are:
next-transpile-modules
?externals
, how does that potentially impact my goal?To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Expected behavior
The Next.js app successfully compiles
react-native-web
source.System information
Additional context
This was originally reported in the Spectrum community. I posted here as well due to lack of feedback and the potential that it is in fact a bug with Next.
The text was updated successfully, but these errors were encountered: