-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feat(node): allow executing esm compiled scripts #10414
feat(node): allow executing esm compiled scripts #10414
Conversation
☁️ Nx Cloud ReportWe didn't find any information for the current pull request with the commit e6fdb7f. Check the Nx Cloud Github Integration documentation for more information. Sent with 💌 from NxCloud. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
Why did the build not run? |
@bulldog98 , thank you for the PR. Can you add some e2e tests for this change? |
Sure I first did not see there where e2e tests, but found them now. |
@nartc I was unable to run the e2e test locally, how are they executed? |
aeb56d6
to
cb9ccb1
Compare
cb9ccb1
to
cc0515b
Compare
@bulldog98 I've rebased the branch and kicked off the build which is failing. Can you take a look? To run test locally, you'd need to start
then run the e2e:
|
sure I'm working on fixing the test. |
64c40ce
to
215ea0e
Compare
@nartc I fixed the e2e test it works now |
I had the same problem. |
215ea0e
to
902c406
Compare
902c406
to
4aee47a
Compare
@nartc sorry I had messed up the check to beEqual, but it should be a toContains |
4aee47a
to
e6fdb7f
Compare
@bulldog98 Thanks for the PR. Everything looks good so far. Just one quick question, why did you have the following? ...
const dynamicImport = new Function('specifier', 'return import(specifier)');
... Would this work as well? ...
function dynamicImport(specifier) {
return import(specifier);
}
dynamicImport(fileToRun);
... |
That said, I'm curious why not just |
The problem is that typescript transpiles the |
The "real" fix would be to change "module" to "es2020" in the tsconfig - that would be a much larger change, but also this implicitly breaks environments that don't support the dynamic import syntax natively instead of explicitly. I think all current supported node versions should though? |
@luxaritas yep, that's my concern as well. I also think the real fix is to support ESM across the board. With TS 4.7, we have a more "official" ESM support but we're somewhat waiting for the dust to settle before making substantial changes to all plugins. |
e6fdb7f
to
a1bb4a2
Compare
4bc0aff
to
1abc5d7
Compare
We'll merge this fix, and introduce even more functionality to make sure CJS/ESM compatibility is consistent between the different technologies (webpack, esbuild, tsc, swc, etc.). This is a good workaround until then. |
1abc5d7
to
3d85359
Compare
3d85359
to
64befff
Compare
096f1b9
to
94196a6
Compare
94196a6
to
92aa909
Compare
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. |
Current Behavior
The @nrwl/node:node executor is not able to execute esm module scripts
Expected Behavior
The @nrwl/node:node executor is able to execute esm module scripts
Fixes: #10565
Fixes: #16036