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
New @nrwl/node:node doesn't link transitive dependencies correctly #9346
Comments
It does appear that by combining the nx/packages/node/src/executors/execute/execute.impl.ts Lines 76 to 79 in 7a982af
And is now this: nx/packages/node/src/executors/node/node.impl.ts Lines 88 to 100 in fd64546
I am wondering if this is what has changed that could possibly cause this issue.
|
I have verified that changing the function runProcess(event, options, mappings) {
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
subProcess = (0, child_process_1.fork)((0, devkit_1.joinPathFragments)(__dirname, 'node-with-require-overrides'), options.args, {
execArgv: getExecArgv(options),
stdio: 'inherit',
env: Object.assign(Object.assign({}, process.env), { NX_FILE_TO_RUN: event.outfile, NX_MAPPINGS: JSON.stringify(mappings) }),
});
if (!options.watch) {
return new Promise((resolve, reject) => {
subProcess.on('exit', (code) => {
if (code === 0) {
resolve(undefined);
}
else {
reject();
}
});
});
}
});
} to function runProcess(event, options, mappings) {
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
if (subProcess || !event.success) {
return;
}
subProcess = (0, child_process_1.fork)(event.outfile, options.args, {
execArgv: getExecArgv(options),
});
});
} And now everything works just fine |
@jaysoo I believe that I have figured out what is causing the issue. Basically, when the code is being run, it gets a list of mappings for nx specific libraries in the code below: nx/packages/node/src/executors/node/node.impl.ts Lines 61 to 81 in 1b7a3b2
Once it has these libraries, it runs all require/import statements through an extended module loader at the location below:
When it sees an import that has the same name as one of nx mapping generated above, it replaces the import with that mapping. An example of what an obfuscated version of this json looks like is below: {
"<Obfuscated>": "<Obfuscated>/node_modules/qauthentication",
"csurf": "<Obfuscated>/node_modules/csurf",
"express": "<Obfuscated>/node_modules/express",
"crypto-js": "<Obfuscated>/node_modules/crypto-js",
"axios": "<Obfuscated>/node_modules/axios",
"date-fns": "<Obfuscated>/node_modules/date-fns",
"<Obfuscated>/translations": "<Obfuscated>/dist/libs/translations",
"glob": "<Obfuscated>/node_modules/glob",
"dot-prop": "<Obfuscated>/node_modules/dot-prop",
"yargs": "<Obfuscated>/node_modules/yargs",
"deepmerge": "<Obfuscated>/node_modules/deepmerge",
"catalog-ui-context": "<Obfuscated>/node_modules/catalog-ui-context",
"qs": "<Obfuscated>/node_modules/qs",
"rxjs": "<Obfuscated>/node_modules/rxjs",
"<Obfuscated>/plugin-manager": "<Obfuscated>/node_modules/<Obfuscated>/plugin-manager",
"react": "<Obfuscated>/node_modules/react",
"lodash.clonedeep": "<Obfuscated>/node_modules/lodash.clonedeep",
"clone": "<Obfuscated>/node_modules/clone",
"lru-cache": "<Obfuscated>/node_modules/lru-cache",
"winston": "<Obfuscated>/node_modules/winston",
"winston-daily-rotate-file": "<Obfuscated>/node_modules/winston-daily-rotate-file",
"morgan": "<Obfuscated>/node_modules/morgan",
"uuid": "<Obfuscated>/node_modules/uuid",
"prom-client": "<Obfuscated>/node_modules/prom-client",
"@testing-library/react": "<Obfuscated>/node_modules/@testing-library/react",
"node-cache": "<Obfuscated>/node_modules/node-cache",
"cookie-parser": "<Obfuscated>/node_modules/cookie-parser",
"apollo-server-express": "<Obfuscated>/node_modules/apollo-server-express",
"apollo-server": "<Obfuscated>/node_modules/apollo-server",
"graphql": "<Obfuscated>/node_modules/graphql",
"apollo-datasource-rest": "<Obfuscated>/node_modules/apollo-datasource-rest",
"dotenv": "<Obfuscated>/node_modules/dotenv"
} This code is replacing our dependency's module resolution for |
#9284 should fix this issue |
Closed with #9284 |
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. |
Current Behavior
After upgrading to 13.8.4, the new
@nrwl/node:node
executor is doing something to our code that is causing the linking of our transitive dependencies to not be linked correctly. An example is that we includerxjs@7.4.0
in our application, but one of our main dependencies depends onrxjs@5.4.3
. After the 13.8.4 version was implemented with the new version, when our node executor runs to serve our application for development, our dependency getsrxjs@7.4.0
which immediately causes it to crash.We spent about 6 hours digging into everything we can in our application and have figured out that the only difference between when it works and when it breaks is the upgrade of nx from 13.8.3 to 13.8.4 (quick side note, this change doesn't really abide by semantic versioning because the API changed 😄 ). Our current theory is that something is brakes when the new executor creates child processes for node applications.
Expected Behavior
This is a regression and the expected behavior is that our dependencies' dependencies are linked correctly.
Steps to Reproduce
I will attempt to reproduce this, but this is internal code that I can't share. Since the basic functionality is that a dependency is getting the application's version of one of its' dependencies, hopefully, this isn't too hard to reproduce.
Failure Logs
Possibly unhandled TypeError: rxjs_1.Observable.timer is not a function
Environment
The text was updated successfully, but these errors were encountered: