cli
cli copied to clipboard
Don't bundle build output
The problem
Currently, our packages are bundled with ESBuild. This has some strange consequences.
For example, although @code-pushup/cli
depends on other packages like @code-pushup/utils
via dependencies
in package.json
, the distributed cli
package actually doesn't import
any of our other packages, their code is included in the index.js
or bin.js
bundle. The reason ESBuild doesn't treat other @code-pushup
packages as external dependencies is because the imports are treated as relative paths after resolving TypeScript path aliases.
This leads to weird cases like the #834 bug - the @code-pushup/cli
source code doesn't directly import vscode-material-icons
(hence why it should be OK that it's not in its package.json
), but in the bundled code it is imported directly (hence why Yarn 4 complains about it).
Also, bundling the package into one huge file makes it harder to diagnoze errors reported by customers, because the error stack just shows some random line in the massive index.js
file, so it's harder to link to our source code.
Proposal
Our packages are for Node only, not the browser. Therefore it doesn't make sense to use a bundler. All we need is to transpile .ts
files to .js
and .d.ts
files, so plain old tsc
should suffice.
Acceptance criteria
- [ ] replace
@nx/esbuild:esbuild
executor with@nx/js:tsc
- [ ] figure out some alternative to
package.json
generation (previously inesbuild.config.js
) - either some post-build script, or just move this metadata into the sourcepackage.json
s