Closed capancheta closed 1 year ago
Hi @capancheta I seem to remember getting this issue in older versions of Nx. Cant remember why tho! 😅
In case it's helpful, I've had to patch Nx myself ( a mod to Nx rollup plugin) for CI environments and did this by using the postinstall
npm script hook in package.json
.
This way, everytime we run npm install
or npm ci
the patch is applied to node_modules
.
something like:
"scripts": {
"ng": "nx",
"postinstall": "node ./decorate-angular-cli.js && ngcc --properties es2020 browser module main && node ./tools/patch-rollup/index.cjs",
"nx": "nx",
...
and then in ./tools/patch-rollup/index.cjs
:
// see https://github.com/nrwl/nx/issues/10395
const fs = require('fs')
function patchNxPlugin() {
const target = './node_modules/@nx/rollup/src/executors/rollup/lib/update-package-json.js'
const data = fs.readFileSync(target, 'utf-8')
const patchMatch = 'const hasEsmFormat'
const patchReplace = `return;${patchMatch}`
if (!data.includes(patchReplace)) {
const output = data.replace(patchMatch, patchReplace)
fs.writeFileSync(target, output, 'utf-8')
console.log(`PATCHED @nx/rollup updatePackageJson`)
} else {
console.log(`ALREADY PATCHED @nx/rollup updatePackageJson`)
}
}
patchNxPlugin()
obviously tweak the patch logic as you need.
Another way of patching is described here: https://dev.to/zhnedyalkow/the-easiest-way-to-patch-your-npm-package-4ece
Lastly, would recommend Nx 16 upgrade if you can convince your higher ups, its the least buggy release they've had in a while.
Thank you @simondotm, this reminds me of when i monkeypatched a component in a django application because the concerned pypi package didnt play nice. Very helpul! And thanks for the tip on the nx version. as soon as our recent golive is deemed stable, i'm raising this.
this concerns v0.3.4 because my nx is stuck at 13.5.1 (cant upgrade, higher ups say) this is caused when nx's calculateProjectDependencies gets a projGraph.nodes[undefined]. now i know this isnt nx-firebases' problem, i can hack the library in node_modules, but of course i cant do that when we're talking ci/cd. so my question is from which specific file do i lookup the entries read by createProjectGraphAsync()? i mean, i've looked into package, tsconfig, angular, nx, and even the project.json but i cant seem to find a pattern. help appreciated. thank you!