Closed linbudu599 closed 1 year ago
I'm using fully specified ESM import paths. @nrwl/web
can handle those with babel, but not with swc.
It seem to be supported by swc/spack - but not configured for rollups' commonjs & node-resolve plugins. Idk.
https://github.com/swc-project/swc/issues/3043
"build": {
"executor": "@nrwl/web:rollup",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/my-lib",
"tsConfig": "libs/my-lib/tsconfig.lib.json",
"project": "libs/my-lib/package.json",
"entryFile": "libs/my-lib/src/index.ts",
"external": ["react/jsx-runtime"],
"rollupConfig": "@nrwl/react/plugins/bundle-rollup",
"compiler": "swc"
}
},
// index.ts
import { abort } from './two.js';
// two.ts
export function two() {};
[!] Error: unfinished hook action(s) on exit:
(commonjs) resolveId "./two.js" "/home/vadistic/work/my-project/libs/my-lib/src/index.ts"
(node-resolve) resolveId "./two.js" "/home/vadistic/work/my-project/libs/my-lib/src/index.ts"
There is issue when you try import other libray files to app that use @nrwl/web:rollup (babel) as executor. Ex. // apps/bundler-js/src/main.ts
// apps/bundler-js/src/main.ts
import '../../../libs/shared-assets-backend/generator/main';
The error will be shown as
Error during bundle: /Users/xxx/yyy/apps/bundler-js/src/main.ts(2,8): semantic error TS6059: File '/Users/xxx/yyy/libs/shared-assets-backend/generator/main.ts' is not under 'rootDir' '/Users/xxx/yyy/apps/bundler-js/src'. 'rootDir' is expected to contain all source files.
The rootDir is set by entryFile folder.
"projectType": "application",
"root": "apps/bundler-js",
"sourceRoot": "apps/bundler-js/src",
"tags": [],
"targets": {
"build": {
"executor": "@nrwl/web:rollup",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"project": "apps/bundler-js/package.json",
"entryFile": "apps/bundler-js/src/main.ts", // <-------------- entry Folder = apps/bundler-js/src
"tsConfig": "apps/bundler-js/tsconfig.gulp.json",
"outputPath": "dist/apps/bundler-js",
"format": ["esm", "cjs"],
"deleteOutputPath": true,
You can see the source code below.
To fix this problem, the entryRoot has to be root folder by default.
The workaround is to move main.ts to root project. and configure project.json and fix entryFile as below.
"options": {
"project": "apps/bundler-js/package.json",
"entryFile": "main.ts",
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
Description
There is now room for a number of enhancements to the rollup plugin, including but not limited to:
rollupConfig
(#8459 )rollupConfig
configuration export (currentConfig
andoptions
)..ts
forrollupConfig
, with corresponding typing support(type RollupConfigFactory = (...) => ValidateRollupConfig
), for.js
file we can also use JSDoc to provide typing tips from IDE(just as how snowpack does), like/** @type {import("@nrwl/web").RollupConfigFactory } */
.nx g @nrwl/web:rollup exist-web-app --rollupConfig=rollup.config.ts
to add a section of target configuration using@nrwl/web:rollup
as build executor.Motivation
Suggested Implementation
Alternate Implementations