You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we upgrade NX to version 20.3.2 or later our local plugin executors are not working anymore. They throw an error Cannot find module '/Users/roozenboom/Work/npm/nx-examples/tools/workspace/executors/demo'.
The error originates from packages/nx/src/config/schema-utils.ts L30-33:
After some debugging I found out that the reason for this is that the implementation does not handles index.ts files correctly. All our local plugin executors and generators are configured to use an index.ts file as implementation:
This behavior is introduced by PR 29539, as the TypeScript transpiler is not triggered anymore for our local plugin.
As a workaround i tried to update the implementation to point to the index file directly. This also does not work but throws a different error: implementation is not a function
Renaming index to something else (for example demo.ts) does not solve this issue.
When I looked at the NX repo and the naming convention you are using for executor implementation, I saw you are using <name>.impl.ts and if i change our implementation to use the same convention it works. Successfully ran target demo3 for project cart
The expected behavior is that barrel files (index.ts) are handled correctly and will trigger the TypeScript transpiler when required. It should follow the path as specified in the implementation property of the executors.json and should not depend on an undocumented naming convention.
I created a minimal reproduction path in nx-examples
Checkout the repo
A local plugin is created in tools/workspace
One simple executor 'demo' is added
In the executors.json we have 3 different implementation for this executor
a. point to folder "./executors/demo"
b. point to index file "./executors/demo/index"
c. point to index.impl file "./executors/demo/index.tmpl"
Add new targets to the cart app to be able to use the executors
Run the targets
a. yarn nx run cart:demo will throw 'Module not found' error
b. yarn nx run cart:demo2 will throw 'implementation in not a function' error
c. yarn nx run cart:demo3 will be successful
I can provide a fix for this issue by changing the if statement in packages/nx/src/config/schema-utils.ts, because when I instead of checking for extname(modulePath) === '.ts' change this to the helper pluginTranspilerIsRegistered(), the executor is transpiled in all 3 scenarios. But I am not sure this is the best solution for this issue, as I think its maybe better to solve this on a higher level.
The text was updated successfully, but these errors were encountered:
@AgentEnder I updated the PR with a fix for this root cause of this issue. After more debugging I found the location were it was supposed to call the registerPluginTSTranspiler method.
Current Behavior
When we upgrade NX to version 20.3.2 or later our local plugin executors are not working anymore. They throw an error
Cannot find module '/Users/roozenboom/Work/npm/nx-examples/tools/workspace/executors/demo'
.The error originates from
packages/nx/src/config/schema-utils.ts L30-33
:After some debugging I found out that the reason for this is that the implementation does not handles index.ts files correctly. All our local plugin executors and generators are configured to use an index.ts file as implementation:
This behavior is introduced by PR 29539, as the TypeScript transpiler is not triggered anymore for our local plugin.
As a workaround i tried to update the implementation to point to the index file directly. This also does not work but throws a different error:
implementation is not a function
Renaming index to something else (for example demo.ts) does not solve this issue.
When I looked at the NX repo and the naming convention you are using for executor implementation, I saw you are using
<name>.impl.ts
and if i change our implementation to use the same convention it works.Successfully ran target demo3 for project cart
Expected Behavior
The expected behavior is that barrel files (index.ts) are handled correctly and will trigger the TypeScript transpiler when required. It should follow the path as specified in the implementation property of the executors.json and should not depend on an undocumented naming convention.
GitHub Repo
https://github.com/Roozenboom/nx-examples/tree/feature/nx-20-3-2-module-not-found
Steps to Reproduce
I created a minimal reproduction path in nx-examples
tools/workspace
a. point to folder
"./executors/demo"
b. point to index file
"./executors/demo/index"
c. point to index.impl file
"./executors/demo/index.tmpl"
a.
yarn nx run cart:demo
will throw 'Module not found' errorb.
yarn nx run cart:demo2
will throw 'implementation in not a function' errorc.
yarn nx run cart:demo3
will be successfulNx Report
Failure Logs
NX Cannot find module '/Users/roozenboom/Work/npm/nx-examples/tools/workspace/executors/demo' Require stack: - /Users/roozenboom/Work/npm/nx-examples/node_modules/nx/src/config/schema-utils.js - /Users/roozenboom/Work/npm/nx-examples/node_modules/nx/src/command-line/run/executor-utils.js - /Users/roozenboom/Work/npm/nx-examples/node_modules/nx/src/devkit-internals.js - /Users/roozenboom/Work/npm/nx-examples/node_modules/nx/src/utils/assert-workspace-validity.js - /Users/roozenboom/Work/npm/nx-examples/node_modules/nx/src/project-graph/build-project-graph.js - /Users/roozenboom/Work/npm/nx-examples/node_modules/nx/src/project-graph/project-graph.js - /Users/roozenboom/Work/npm/nx-examples/node_modules/nx/src/project-graph/file-utils.js - /Users/roozenboom/Work/npm/nx-examples/node_modules/nx/src/utils/package-manager.js - /Users/roozenboom/Work/npm/nx-examples/node_modules/nx/src/utils/package-json.js - /Users/roozenboom/Work/npm/nx-examples/node_modules/nx/src/utils/print-help.js - /Users/roozenboom/Work/npm/nx-examples/node_modules/nx/src/command-line/run/run.js - /Users/roozenboom/Work/npm/nx-examples/node_modules/nx/bin/run-executor.js Pass --verbose to see the stacktrace.
Package Manager Version
No response
Operating System
Additional Information
I can provide a fix for this issue by changing the if statement in
packages/nx/src/config/schema-utils.ts
, because when I instead of checking forextname(modulePath) === '.ts'
change this to the helperpluginTranspilerIsRegistered()
, the executor is transpiled in all 3 scenarios. But I am not sure this is the best solution for this issue, as I think its maybe better to solve this on a higher level.The text was updated successfully, but these errors were encountered: