-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Labels
api:nodeNode API and stdlibNode API and stdliblang:javascriptIssues relating to JavaScriptIssues relating to JavaScript
Description
Summary
Elide doesn't support nested conditional exports in package.json, which prevents many popular npm packages from loading.
Reproduction
// test.ts
import { Collection } from '@discordjs/collection';
console.log(Collection);npm install @discordjs/collection
elide run test.ts
# Error: Unsupported package exports: ''Package.json exports that fail
{
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
}
}Package.json exports that work
{
"exports": {
".": {
"types": "./lib/main.d.ts",
"require": "./lib/main.js",
"default": "./lib/main.js"
}
}
}Expected behavior
Elide should resolve nested conditional exports per the Node.js package exports spec.
For ESM imports, it should resolve:
- Check
exports["."] - Check
exports["."].import(since we're using ESM) - Use
exports["."].import.default
Affected packages
Many packages in the discord.js ecosystem use this pattern:
@discordjs/collection@discordjs/rest@discordjs/ws@discordjs/buildersdiscord.jsitself
Workaround
Currently using esbuild to bundle dependencies, which resolves the exports correctly before Elide sees them.
Metadata
Metadata
Assignees
Labels
api:nodeNode API and stdlibNode API and stdliblang:javascriptIssues relating to JavaScriptIssues relating to JavaScript