nx
nx copied to clipboard
Library multiple entry points
Exactly the same as that issue that was closed by the bot but without any solution.
Description
I want to have the option to publish a library with two endpoints. i.e.
@my-scope/testing/e2e
@my-scope/testing/unit-tests
Where in the e2e
I want to include Cypress
utils (with Cypress dependency)
and in unit-tests
I want to include Jasmine
utils (with Jasmine dependency)
Motivation
Currently, I can't do the above as both Cypress & Jasmine have an expect
global method,
so when I import @my-scope/testing
it imports both dependencies.
And tree-shaking in general.
- worth mentioning - I'm using NX to generate libraries monorepo, and I'm using the libraries in external projects (not inside the monorepo, that's why I can't start it as an Angular-monorepo and only use the basic Node approach).
Suggested Implementation
Same as ng-packager: create a package.json (name, dependencies) under the needed library with index.ts as an entry-point.
Not sure if it exactly what you're looking for, but I made this a while ago: https://github.com/zwarag/nx-poc
In the lib
folder I might have what you're looking for.
Not sure if it exactly what you're looking for, but I made this a while ago: https://github.com/zwarag/nx-poc
In the
lib
folder I might have what you're looking for.
@zwarag seems like you talking about Angular libraries? I want the same solution without Angular builder, if possible.
What is the issue that you are seeing? We do the same within Nx for @nrwl/workspace/generators
: https://github.com/nrwl/nx/blob/master/packages/workspace/generators.ts
What is the issue that you are seeing? We do the same within Nx for
@nrwl/workspace/generators
: https://github.com/nrwl/nx/blob/master/packages/workspace/generators.ts
Im not seeing any issue, I just don't know how to do this with NX (without Angular preset). Sorry I didn't understand how you create 2 end points with nx-generators?
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! ๐
Not stale ๐
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! ๐
Not stale...
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! ๐
Not stale ๐
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! ๐
No no no ... not stale ! ๐คก
Managed to workaround it by doing this:
under my lib directory i created a rollup config that extends nx one
const nrwlConfig = require('@nrwl/react/plugins/bundle-rollup');
module.exports = config => {
const nxConfig = nrwlConfig(config);
if (nxConfig.output.format === 'esm') {
nxConfig.input = {
index: nxConfig.input,
utils: join(__dirname, './src/utils/index.ts'),
};
}
return nxConfig;
};
i do this only for esm as i don't need it for the umd build
in libs/mylib/package.json
i added
"exports": {
".": "./index.esm.js",
"./utils": "./utils/utils.esm.js"
},
"typesVersions": {
"*": {
"utils": [
"utils/index"
]
}
}
and in workspace.json
under the lib build script:
"build": {
"executor": "@nrwl/web:rollup",
"options": {
"rollupConfig": "libs/mylib/rollup.config.js",
}
},
and in order for it to work in the workspace as well, add in tsconfig.base.json
{
"compilerOptions": {
"paths": {
"@my-scope/mylib/utils": ["libs/mylib/src/utils/index.ts"],
}
},
}
Hope it helps ๐
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! ๐
Not stale :)
I'm using rollup to bundle some libraries to be published with esm and cjs entrypoints. I need the @nrwl/web:rollup
executor to be able to compile to a file for a third entrypoint for bin
(one library has cli functionality). Am I at the right issue?
Cli is not an entry point (not consumable)
The way I usually do it is - having a bin file direct to a cli.ts file In this file I import my main entry point api and wrap it with cli capabilities (usually with caporal)
But you'd still want that as separate compilation output to not expose it to anything but the bin file, right?
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! ๐
Not stale
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! ๐
Not stale ๐
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! ๐
Not stale :balloon:
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! ๐
Not stale ๐ด
My use case is to build multiple files in a handlers folder like so:
apps/lambda-service-a/handlers
+--> function1.ts
+--> function2.ts
+--> functionN.ts
So, I have an 'application' for a service composed of multiple related lambdas, and I want each of those lambda entry points to compile independently of one another.
This issue looks like is related to my use case, but I'm not sure if I'm missing anything obvious
this is my project's directory
.
โโโ models
โย ย โโโ README.md
โย ย โโโ application
โย ย โย ย โโโ README.md
โย ย โย ย โโโ application.model.ts
โย ย โย ย โโโ index.ts
โย ย โย ย โโโ ng-package.json
โย ย โโโ application-core
โย ย โย ย โโโ README.md
โย ย โย ย โโโ index.ts
โย ย โย ย โโโ ng-package.json
โย ย โโโ common
โย ย โย ย โโโ README.md
โย ย โย ย โโโ common.model.ts
โย ย โย ย โโโ index.ts
โย ย โย ย โโโ ng-package.json
โย ย โโโ common-core
โย ย โย ย โโโ README.md
โย ย โย ย โโโ common.enum.ts
โย ย โย ย โโโ common.type.ts
โย ย โย ย โโโ constant.ts
โย ย โย ย โโโ index.ts
โย ย โย ย โโโ ng-package.json
โย ย โโโ index.ts
โย ย โโโ jest.config.js
โย ย โโโ ng-package.json
โย ย โโโ package.json
โย ย โโโ project.json
โย ย โโโ tsconfig.json
โย ย โโโ tsconfig.lib.json
โย ย โโโ tsconfig.lib.prod.json
โย ย โโโ tsconfig.spec.json
โย ย โโโ user
โย ย โโโ README.md
โย ย โโโ index.ts
โย ย โโโ ng-package.json
โย ย โโโ user.model.ts
โย ย โโโ project.json
โย ย โโโ test-setup.ts
โย ย โโโ tsconfig.json
โย ย โโโ tsconfig.lib.json
โย ย โโโ tsconfig.lib.prod.json
โย ย โโโ tsconfig.spec.json
just care about models/ng-package.json
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/packages/models",
"lib": {
"entryFile": "index.ts"
}
}
index.ts
declare const _default: undefined
export default _default;
then sub-lib
models/common/ng-package.json
{
"lib": {
"entryFile": "index.ts" // it only export 1 files( who care , just example :)
}
}
then build
.
โโโ README.md
โโโ application
โย ย โโโ README.md
โย ย โโโ application.model.d.ts
โย ย โโโ fone-models-application.d.ts
โย ย โโโ index.d.ts
โย ย โโโ package.json
โโโ application-core
โย ย โโโ README.md
โย ย โโโ fone-models-application-core.d.ts
โย ย โโโ index.d.ts
โย ย โโโ package.json
โโโ common
โย ย โโโ README.md
โย ย โโโ common.model.d.ts
โย ย โโโ fone-models-common.d.ts
โย ย โโโ index.d.ts
โย ย โโโ package.json
โโโ common-core
โย ย โโโ README.md
โย ย โโโ common.enum.d.ts
โย ย โโโ common.type.d.ts
โย ย โโโ constant.d.ts
โย ย โโโ fone-models-common-core.d.ts
โย ย โโโ index.d.ts
โย ย โโโ package.json
โโโ esm2020
โย ย โโโ application
โย ย โโโ ...
โย ย โโโ index.mjs
โย ย โโโ user
โโโ fesm2015
โย ย โโโ fone-models-application-core.mjs
โย ย โโโ ...
โย ย โโโ fone-models.mjs.map
โโโ fesm2020
โย ย โโโ fone-models-application-core.mjs
โย ย โโโ ...
โย ย โโโ fone-models.mjs.map
โโโ fone-models.d.ts
โโโ homepage
โย ย โโโ README.md
โย ย โโโ fone-models-homepage.d.ts
โย ย โโโ homepage.model.d.ts
โย ย โโโ index.d.ts
โย ย โโโ package.json
โโโ homepage-core
โย ย โโโ README.md
โย ย โโโ fone-models-homepage-core.d.ts
โย ย โโโ homepage.enum.d.ts
โย ย โโโ homepage.type.d.ts
โย ย โโโ index.d.ts
โย ย โโโ package.json
โโโ index.d.ts
โโโ package.json
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! ๐
I'd still like to build multiple entry points for a single project, instead of splitting it into different projects