nx
nx copied to clipboard
srcRootForCompilationRoot rootDir controls appears removed from @nrwl/node and feature not present in new @nrwl/js
Current Behavior
I can no longer control the output of my buildable/publishable packages to not include src/ in the output (dist/libs/mylib) folder
Expected Behavior
I would like the option returned. The node generator documents it still, but the executor no longer uses the option (It should probably be in the new @nrwl.js packages instead of node) (https://github.com/nrwl/nx/search?q=srcRootForCompilationRoot)
I've just upgraded to v14 and my libraries stopped publishing as expected. It does seem that this option was indeed removed ):
Am I missing something here?
Same here. We rely on this feature for some of our published packages and we cannot upgrade nx to the latest version until this feature is restored.
Hi, I have same issue and just created PR(https://github.com/nrwl/nx/pull/10707).
If you are in a hurry and want to use nx 13, run npm i -D @nx-ddd/executors@3
and use @nx-ddd/executor:tsc
with srcRootForCompilationRoot
option.
Or run nx g @nrwl/js:library executors --buildable --publishable
in your nx workspace and create tsc executor like this.
I really need this out too. For immediate relief, do the following:
Create a new file at the root of your workspace as patches/@nrwl+js+14.5.4.patch
with the following:
diff --git a/node_modules/@nrwl/js/src/executors/tsc/schema.json b/node_modules/@nrwl/js/src/executors/tsc/schema.json
index 0c0d48b..82b649c 100644
--- a/node_modules/@nrwl/js/src/executors/tsc/schema.json
+++ b/node_modules/@nrwl/js/src/executors/tsc/schema.json
@@ -52,6 +52,10 @@
"description": "When `updateBuildableProjectDepsInPackageJson` is `true`, this adds dependencies to either `peerDependencies` or `dependencies`.",
"enum": ["dependencies", "peerDependencies"],
"default": "peerDependencies"
+ },
+ "srcRootForCompilationRoot": {
+ "type": "string",
+ "description": "Sets the rootDir for TypeScript compilation. When not defined, it uses the project's root property"
}
},
"required": ["main", "outputPath", "tsConfig"],
diff --git a/node_modules/@nrwl/js/src/utils/schema.d.ts b/node_modules/@nrwl/js/src/utils/schema.d.ts
index 8e585b0..230d001 100644
--- a/node_modules/@nrwl/js/src/utils/schema.d.ts
+++ b/node_modules/@nrwl/js/src/utils/schema.d.ts
@@ -42,6 +42,7 @@ export interface ExecutorOptions {
transformers: TransformerEntry[];
updateBuildableProjectDepsInPackageJson?: boolean;
buildableProjectDepsInPackageJsonType?: 'dependencies' | 'peerDependencies';
+ srcRootForCompilationRoot?: string;
}
export interface NormalizedExecutorOptions extends ExecutorOptions {
diff --git a/node_modules/@nrwl/js/src/utils/typescript/compile-typescript-files.js b/node_modules/@nrwl/js/src/utils/typescript/compile-typescript-files.js
index eab21d8..b2718e5 100644
--- a/node_modules/@nrwl/js/src/utils/typescript/compile-typescript-files.js
+++ b/node_modules/@nrwl/js/src/utils/typescript/compile-typescript-files.js
@@ -28,6 +28,7 @@ function compileTypeScriptFiles(normalizedOptions, context, postCompilationCallb
outputPath: normalizedOptions.outputPath,
projectName: context.projectName,
projectRoot: normalizedOptions.projectRoot,
+ rootDir: normalizedOptions.srcRootForCompilationRoot,
tsConfig: normalizedOptions.tsConfig,
watch: normalizedOptions.watch,
deleteOutputPath: normalizedOptions.clean,
Install the patch-package module as a dev dependency using npm install patch-package -D
or yarn add patch-package postinstall-postinstall --dev
(yarn needs that extra postinstall-postinstall
package).
Next, add "postinstall": "patch-package"
to your scripts in your root package.json
file.
Now perform an npm install
or yarn install
and you can ignore this issue for now (not sure what will happen with further updates if they override this patch's change). Make sure to check this into your repo so your team can use it. When a fix finally comes out (if it does), you can uninstall patch-package
(and postinstall-postinstall
if you don't need it and use yarn) and remove the patch file and folder. Make sure to do a clean install (delete node_modules folder) after.
The changes were made in this PR (https://github.com/nrwl/nx/pull/10707) that has yet to be accepted due to missing testing files. I used the files from https://github.com/nrwl/nx/pull/10707/files
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.