Nx executor to ensure that all the buildable dependencies of a publishable library are part of the final bundle.
npm install -D @altack/nx-bundlefy
Also make sure to install the required peer dependencies:
npm install -D @nrwl/js @nrwl/devkit @nrwl/workspace validate-npm-package-name
To use the executor, make sure to adjust your publishable library's project.json
:
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/publishable-library/src",
"targets": {
"bundlefy": {
"executor": "@altack/nx-bundlefy:run",
"configurations": {},
"dependsOn": ["build"],
"outputs": ["{options.outputFile}"]
},
"build": {
...
}
}
}
Also make sure that buildable & publishable libraries are created using the --import-path
modifier.
nx g lib my-library --buildable --import-path @org/my-library
This will ensure that all the buildable libraries are bundled as part of the library build
nx run publishable-library:bundlefy
For a more detailed explanation, see this Stack Overflow question and the open issue in the Nx's repository