-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Description
Description
The exports field in three.js package.json is incorrectly specified.
It is specified like this, and missing the .js extensions on the right hand side:
(I should probably file this as reproducible bug instead of as a feature request)
{
"exports": {
".": {
"import": "./build/three.module.js",
"require": "./build/three.cjs"
},
"./examples/fonts/*": "./examples/fonts/*",
"./examples/jsm/*": "./examples/jsm/*",
"./addons/*": "./examples/jsm/*",
"./src/*": "./src/*",
"./nodes": "./examples/jsm/nodes/Nodes.js"
},
}
Solution
The solution is to correctly specify them like this:
{
"exports": {
"./examples/jsm/*": "./examples/jsm/*.js",
"./addons/*": "./examples/jsm/*.js",
"./src/*": "./src/*.js",
}
}
Alternatives
Currently, this must be worked around with a bundler that alleviates this with some sort of aliasing mechanism,
like vite. But it is unfortunate that this issue dictates which bundlers can/can't be used.
Additional context
The issue is discussed on stackoverflow in detail here:
https://stackoverflow.com/questions/77237284/getting-rollup-to-resolve-extensionless-imports-in-node-modules-for-browser-bund/77244840#77244840
I should probably figure out how to file this bug as a proper reproducible bug instead.