Non hermetic builds
See original GitHub issueScenario A
This works as expected
Targets:
"build": {
"executor": "@nrwl/node:build",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/apps/api",
"main": "apps/api/src/main.ts",
"tsConfig": "apps/api/tsconfig.app.json",
"assets": [
"apps/api/src/assets"
]
},
"configurations": {
"production": {
"optimization": true,
"extractLicenses": true,
"inspect": false,
"fileReplacements": [
{
"replace": "apps/api/src/environments/environment.ts",
"with": "apps/api/src/environments/environment.prod.ts"
}
]
}
}
},
Command I ran
rm -fr node_modules/.cache/nx
rm -fr dist
npx nx build api
cat dist/apps/api/main.js # not minified
npx nx build api --prod
cat dist/apps/api/main.js # minified
npx nx build api
cat dist/apps/api/main.js # not minified
Scenario B
Now I rename build
to base-build
, and create a new build
that calls it
Targets:
"build": {
"executor": "@nrwl/workspace:run-commands",
"options": {
"commands": ["npx nx codegen api", "nx base-build api --prod"],
"parallel": false
}
},
"base-build": {
"executor": "@nrwl/node:build",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/apps/api",
"main": "apps/api/src/main.ts",
"tsConfig": "apps/api/tsconfig.app.json",
"assets": [
"apps/api/src/assets"
]
},
"configurations": {
"production": {
"optimization": true,
"extractLicenses": true,
"inspect": false,
"fileReplacements": [
{
"replace": "apps/api/src/environments/environment.ts",
"with": "apps/api/src/environments/environment.prod.ts"
}
]
}
}
},
In targets, I edited:
"commands": ["npx nx codegen api", "nx base-build api --prod"],
to:
"commands": ["npx nx codegen api", "nx base-build api"],
After editing it back and forth a few times and recompiling after each step, the build is no longer hermetic like in “Scenario A”. It takes a few times before the bug is replicated. First I do a prod build, then a non prod build, then a prod build.
Nx outputs:
Nx read the output from the cache instead of running the command for 1 out of 1 tasks.
However my dist/app/api/main.js
now contains development code, and I’m running the command with --prod
.
Environment
> NX Report complete - copy this into the issue template
Node : 16.13.2
OS : darwin x64
npm : 8.1.2
nx : 13.7.1
@nrwl/angular : undefined
@nrwl/cli : 13.7.1
@nrwl/cypress : 13.7.1
@nrwl/detox : undefined
@nrwl/devkit : 13.7.1
@nrwl/eslint-plugin-nx : 13.7.1
@nrwl/express : 13.8.3
@nrwl/jest : 13.7.1
@nrwl/js : 13.7.1
@nrwl/linter : 13.7.1
@nrwl/nest : undefined
@nrwl/next : undefined
@nrwl/node : 13.7.1
@nrwl/nx-cloud : undefined
@nrwl/react : 13.7.1
@nrwl/react-native : undefined
@nrwl/schematics : undefined
@nrwl/storybook : 13.8.3
@nrwl/tao : 13.7.1
@nrwl/web : 13.7.1
@nrwl/workspace : 13.7.1
typescript : 4.4.4
rxjs : 7.5.4
---------------------------------------
Community plugins:
@nx-tools/nx-docker: 2.3.0
Issue Analytics
- State:
- Created a year ago
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Hermeticity - Bazel
This page covers hermeticity, the benefits of using hermetic builds, and strategies for identifying non-hermetic behavior in your builds.
Read more >How to do hermetic builds - Andreas Zwinkau
When Bazel 1.0 was released, people were happy. One of Bazels features are hermetic builds, which means "dependent only on a known set...
Read more >What's hermetic builds? - Hacker News
Our builds are hermetic, meaning that they are insensitive to the libraries and other software installed on the build machine. Instead, builds depend...
Read more >The power of hermetic builds - Georgi Hristozov
The power of hermetic builds ... Bazel forces your build targets to be hermetic - you must declare all your inputs (source or...
Read more >Hermetic / Non Hermetic Packages in Python - Stack Overflow
"Our builds are hermetic, meaning that they are insensitive to the libraries and other software installed on the build machine.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey, no sorry. I had failed to remove the retry with latest label, so the bot mistakenly labeled your post as stale.
@AgentEnder
I think the blocker there is that I could not get the codegen to run in watch mode, since a target dependency has to exit before the next command. Any way ya’ll can post an example with a codegen working the recommended way (including watch mode in development)?