nx: Can't resolve workspace libraries in webpack ts configs in nx@16.10.0
Current Behavior
In the latest release (16.10.0) resolution of local libraries in webpack typescript config doesn’t work anymore. This is a regression from 16.9.1.
Expected Behavior
Resolution works correctly as in 16.9.1.
GitHub Repo
https://github.com/nrwl/nx-examples/pull/304
Steps to Reproduce
- Clone the repo
- Run
yarn nx build cart - See the build failed
Nx Report
> NX Report complete - copy this into the issue template
Node : 20.3.1
OS : linux-x64
yarn : 1.22.19
nx : 16.10.0
@nx/js : 16.10.0
@nx/jest : 16.10.0
@nx/linter : 16.10.0
@nx/workspace : 16.10.0
@nx/angular : 16.10.0
@nx/cypress : 16.10.0
@nx/devkit : 16.10.0
@nx/eslint-plugin : 16.10.0
@nx/react : 16.10.0
@nrwl/tao : 16.10.0
@nx/web : 16.10.0
@nx/webpack : 16.10.0
nx-cloud : 16.4.0
typescript : 5.1.3
---------------------------------------
Community plugins:
@ngrx/component-store : 16.0.0
@ngrx/effects : 16.0.0
@ngrx/entity : 16.0.0
@ngrx/router-store : 16.0.0
@ngrx/store : 16.0.0
@ngrx/store-devtools : 16.0.0
Failure Logs
❯ yarn nx build cart
yarn run v1.22.19
$ nx build cart
> nx run cart:build:production
> NX Unable to load tsconfig-paths, workspace libraries may be inaccessible.
- To fix this, install tsconfig-paths with npm/yarn/pnpm
> NX Falling back to ts-node for local typescript execution. This may be a little slower.
- To fix this, ensure @swc-node/register and @swc/core have been installed
> NX Cannot find module '@nx-example/shared/product/data'
Require stack:
- /home/michal/Documents/projects/nx-examples/apps/cart/webpack.config.ts
- /home/michal/Documents/projects/nx-examples/node_modules/@nx/webpack/src/utils/webpack/custom-webpack.js
- /home/michal/Documents/projects/nx-examples/node_modules/@nx/webpack/src/executors/webpack/webpack.impl.js
- /home/michal/Documents/projects/nx-examples/node_modules/nx/src/config/schema-utils.js
- /home/michal/Documents/projects/nx-examples/node_modules/nx/src/command-line/run/executor-utils.js
- /home/michal/Documents/projects/nx-examples/node_modules/nx/src/command-line/run/run.js
- /home/michal/Documents/projects/nx-examples/node_modules/nx/bin/run-executor.js
Pass --verbose to see the stacktrace.
———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
> NX Ran target build for project cart (2s)
✖ 1/1 failed
✔ 0/1 succeeded [0 read from cache]
View structured, searchable error logs at https://nx.app/runs/VUkLOQSUCg
Package Manager Version
No response
Operating System
- macOS
- Linux
- Windows
- Other (Please specify)
Additional Information
With 16.9.1, a result of the above command looks like this:
❯ yarn nx build cart
yarn run v1.22.19
$ nx build cart
> nx run cart:build:production
products [
{
id: '1',
name: 'A Game of Thrones',
image: '/assets/images/a-game-of-thrones.jpg',
price: 10000
},
{
id: '2',
name: 'A Clash of Kings',
image: '/assets/images/a-clash-of-kings.jpg',
price: 10000
},
{
id: '3',
name: 'A Storm of Swords',
image: '/assets/images/a-storm-of-swords.jpg',
price: 10000
},
{
id: '4',
name: 'A Feast for Crows',
image: '/assets/images/a-feast-for-crows.jpg',
price: 10000
},
{
id: '5',
name: 'A Dance with Dragons',
image: '/assets/images/a-dance-with-dragons.jpg',
price: 10000
}
]
Browserslist: caniuse-lite is outdated. Please run:
npx update-browserslist-db@latest
Why you should do it regularly: https://github.com/browserslist/update-db#readme
Browserslist: caniuse-lite is outdated. Please run:
npx update-browserslist-db@latest
Why you should do it regularly: https://github.com/browserslist/update-db#readme
Entrypoint main 178 KiB = runtime.21173c874b565b9c.js 1.56 KiB main.3bc099ea3b8cf97d.js 177 KiB
Entrypoint polyfills 1.65 KiB = runtime.21173c874b565b9c.js 1.56 KiB polyfills.d68f057feedb4d9a.js 95 bytes
Entrypoint styles 4.37 KiB = runtime.21173c874b565b9c.js 1.56 KiB styles.22517f078c5ba56a.css 2.66 KiB styles.ee2fe116676b7c74.js 148 bytes
chunk (runtime: runtime) main.3bc099ea3b8cf97d.js (main) 459 KiB [initial] [rendered]
chunk (runtime: runtime) polyfills.d68f057feedb4d9a.js (polyfills) 63 bytes [initial] [rendered]
chunk (runtime: runtime) styles.22517f078c5ba56a.css, styles.ee2fe116676b7c74.js (styles) 150 bytes (javascript) 6.93 KiB (css/mini-extract) [initial] [rendered]
chunk (runtime: runtime) runtime.21173c874b565b9c.js (runtime) 4.14 KiB [entry] [rendered]
webpack compiled successfully (fc1c75b2c5599f17)
———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
> NX Successfully ran target build for project cart (7s)
View logs and investigate cache misses at https://nx.app/runs/n2H1NUvNhd
Done in 7.25s.
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Reactions: 10
- Comments: 15 (3 by maintainers)
I’m still facing this error, even though I’m using
"nx": "16.10.0"Same here!
Same, facing this issue on 16.10.0
Guys just pin the
16.9.1version and wait a bit more for the new release 😃 Everything is already fixed on themainbranch by nx team.Unfortunately, it didn’t work for me
It seems every release breaks something else that was working 😦
As mentioned in the thread, it’s fixed in main, either wait for the next release or downgrade to 16.9