Hi there, i suspect its not related to babylonjs but more to how redwoodjs handles compilation of migration files. (i am currently trying to get babylonNull engine to work inside a redwoodJS migration) (Data Migrations | RedwoodJS Docs)
somehow i cannot import “normally” using import {} from… but instead have to import the babylonjs modules like this:
However to my best knowledge adding the js extension (or any other) when importing from a correctly created npm package breaks the standard convention and may confuse the package/module resolution functionality.
I never used an extension with import to import code. Except when I needed to import a non packaged file.
So I still recommend @pcace to try it w/o the extension and I keep my fingers crossed
with ESM it is sometimes essential to do fully specified imports (with file extension) and even directory imports should reference the /index.js. i’ve found this especially in peer imports with type: “module”. for me the standard convention is to include. hopefully you can find a solution without dynamic imports.
We are talking about the issue to import from the @babylonjs/core package here and about npm packages which ones conventionally do have exports and my response was bound to this context.
In this case I citate from Node.js docs:
Including the file extension is only necessary for packages without an "exports" field.
IMHO it’s not a convention to not to use exports.
I am currently getting around the issue by not using the null engine, but instead use rapierjs (i need to shoot some rays to meshes and test the intersection).
Yep! also, if the project’s module resolution is set to nodenext or node16 you HAVE to add extensions. .js will default to the module type of the package.json (commonjs or esm). .mjs will always be loaded as a module, .cjs will always be loaded as commonjs. Extensions are essential in many different project setups. And are optional in others
@pcace check out the repo and follow my recommendations. Import babylonjs stuff like I recommended. One more question: How did you install the babylonjs package? @RaananW and @brianzinn were writing about more advanced scenarios.