Dear all, is there any way to create a “library” to be used in an external website inside an index.html? Such as this typical import:
P.S. We tried creating a @nrwl/node library but we get a lot of errors regarding the import of the external packages. Anyway I’ve noticed that a @nrwl/angular library has the @nrwl/angular:package builder and creates a umd.js bundle. I get no errors importing it but it doesn’t run…
Does anyone have any suggestions? Thank you!
Yes, I’ve been working on this at my company.
Great! So there is a way :slightly_smiling_face:
We are using React so things may work a bit different, but I basically have a library where my components live, and then I have apps under an “entry points” folder that are responsible for doing
ReactDOM.render on my particular component I need on the page. I build those in apps because they generate single bundles with all dependencies included, as opposed to libraries. Since you’re using a pure node library things may work a bit different, but hopefully this is a good starting point for you.
My goal is to work on something, maybe an Nx plugin, that would allow users to do this as a library instead of an app, because it’s not an “app” in a traditional sense, I’m just taking advantage of the single bundle build step.
are you using a @nrwl/angular:package builder ?
The default builder for
@nrwl/react apps appears to be
If you don’t need anything Angular specific then you may want to try that.
ok thank you
:thumbsup: let me know if that works out for you!
You may also want to disable output hashing as your bundle name will be unique for each production build.
Dera I’ve tested it with
@nrwl/web:build but it doesn’t work. Anyway it works now with
@nrwl/angular:package:build but I cannot include in the finel js bundle all the imported libraries such as for example
Anyway for all the apps we are uign webpack and importing the main.js, but it doesn’t build the “big package” if we try to build a lib