Hi,
I’m trying to get Node Modules to work in a Bundle, but without success. As long as the TypeScript files are not in a bundle, it works fine but within a bundle it doesn’t work.
- I can import a “non-bundle” (main) script file into a “bundle script file” (e.g. “test” bundle) without creating a global variable (which is nice!) even though documentation says:
It is recommended that scripts in the different Asset Bundles do not reference each other, otherwise you may not find the corresponding script at runtime. If you need to reference certain classes or variables, you can share them by exposing them in your own global namespace.
- I can NOT reference a node_module path from a bundle, but I can from a “non-bundle” (main).
- I can create a file in the “non-bundle”(main) forwarding the variable of a node_module library, like this:
export const rxjs = import('rxjs');
and using it like this, from the bundle file
const rx = await rxjs;
But this is a very ugly workaround.
How can I just import and reference node_modules without re-assigning a variable for it?
I don’t want the node_module libraries to be cloned into both bundles. I only want it to be in the “non-bundle”(main bundle) or maybe even better in a separate module which loads before main or any other module.
Most important is that I would always be able to just import it straight from node_modules and not having to redirect it into some weird variables depending on from where I load it.
@pandamicro You probably know the solution I’m looking for here
Cocos Creator version: 2.4.6.