It'd be nice to update import statements so that the lib is easy to import with native ES Modules.
At the moment, this does not work:
<script type="importmap">
{
"imports": {
"@dimforge/rapier3d": "https://cdn.jsdelivr.net/npm/@dimforge/[email protected]/rapier.js"
}
}
</script>
<script type="module">
import * as RAPIER from '@dimforge/rapier3d'
</script>
This will fail with
GET https://cdn.jsdelivr.net/npm/@dimforge/[email protected]/exports net::ERR_ABORTED 404 (Not Found)
This is because https://cdn.jsdelivr.net/npm/@dimforge/[email protected]/exports does not exist. The file https://cdn.jsdelivr.net/npm/@dimforge/[email protected]/exports.js does exist, but appending .js to URLs is not part of native ES Module behavior. A URL to JavaScript can be anything, and only the MIME type determines if it will be executed as JavaScript.
Solving this problem has a potentially easy solution: adding .js to all import statements.
It'd be nice to update import statements so that the lib is easy to import with native ES Modules.
At the moment, this does not work:
This will fail with
This is because
https://cdn.jsdelivr.net/npm/@dimforge/[email protected]/exportsdoes not exist. The filehttps://cdn.jsdelivr.net/npm/@dimforge/[email protected]/exports.jsdoes exist, but appending.jsto URLs is not part of native ES Module behavior. A URL to JavaScript can be anything, and only the MIME type determines if it will be executed as JavaScript.Solving this problem has a potentially easy solution: adding
.jsto all import statements.