Hi, first of all thanks for great library!
In my case I want to use your library in Node.js. My project is ESM, so when I import Rapier from node_modules it fails with errors like:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/krytoo/Projects/sandbox/node_modules/@dimforge/rapier3d/exports' imported from /Users/krytoo/Projects/sandbox/node_modules/@dimforge/rapier3d/rapier.js
This is because in rapier.js file there is no extensions in import paths:
import * as RAPIER from "./exports"; // here should be extension `.js`
export * from "./exports"; // ...and here
export default RAPIER;
//# sourceMappingURL=rapier.js.map
Also other moment is missing "exports" field in package.json, for example like this:
{
"name": "@dimforge/rapier3d",
"...": "...",
"exports": {
".": "./rapier.js"
}
}
Without exports field it is imposible to import from root of the package, instead I forced to do like this:
// works
import Rapier from '@dimforge/rapier3d/rapier.js';
// not working
import Rapier from '@dimforge/rapier3d';
Package @dimforge/rapier3d works correctly in CommonJS system but that would be really cool to fix import paths and package.json to make it works in ESM projects
If you use TypeScript for building you can use tsc-alias - tiny but great lib to make imports correct after build by tsc
Hi, first of all thanks for great library!
In my case I want to use your library in Node.js. My project is ESM, so when I import Rapier from node_modules it fails with errors like:
This is because in rapier.js file there is no extensions in import paths:
Also other moment is missing "exports" field in
package.json, for example like this:{ "name": "@dimforge/rapier3d", "...": "...", "exports": { ".": "./rapier.js" } }Without exports field it is imposible to import from root of the package, instead I forced to do like this:
Package
@dimforge/rapier3dworks correctly in CommonJS system but that would be really cool to fix import paths and package.json to make it works in ESM projectsIf you use TypeScript for building you can use
tsc-alias- tiny but great lib to make imports correct after build bytsc