Skip to content
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

fix(webpack): add babelUpwardRootMode #15061

Merged
merged 1 commit into from
Feb 17, 2023

Conversation

mandarini
Copy link
Member

Current Behavior

If you try to import a js library in a @nrwl/webpack:webpack project, then the build fails, unless your library contains a .babelrc file. This is due to the rootmode: 'upward' setting that's used in the webpack executor.

Expected Behavior

Libraries that don't specifically need a .babelrc, should not require one.

In this PR, we are adding a flag to allow users to set rootmode: 'upward' if they need to, and only in that case we are using rootmode: 'upward' in the webpack executor. In the other cases, we are setting the .babelrc path to be that of the parent app we are building, so that the executor will not look elsewhere for a .babelrc file.

Related Issue(s)

Fixes #14807

@vercel
Copy link

vercel bot commented Feb 16, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
nx-dev ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 17, 2023 at 4:46PM (UTC)

Copy link
Contributor

@nartc nartc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the following flow:

npx nx g @nrwl/react:app my-react-app
npx nx build my-react-app # fails due to .babelrc is missing in src/.babelrc (generated .babelrc is in project root rather than source root)

-> Fix: turn on babelUpwardRootMode: true in build target

The @nrwl/js code (that gets deleted) might need to readjust but I think it still needs to be there. The following flow fails:

npx nx g @nrwl/js:lib my-js-lib

use myJsLib() in my-react-app

npx nx build my-react-app # fails due to my-js-lib is missing babelrc

--> Fix: add .babelrc manually or generate a lib with --include-babel-rc

@mandarini
Copy link
Member Author

@nartc thanks for the review. It was a stupid typo on my end, instead of project root, I used src root to specify the location of the project's .babelrc file. So, it didn't find it. Now that it finds it, then all else works as expected.

The reason behind this PR is to remove .babelrc from js libs, since it's not really needed.

@github-actions
Copy link

github-actions bot commented Mar 3, 2023

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for the experimental syntax 'flow' isn't currently enabled
3 participants