-
-
Notifications
You must be signed in to change notification settings - Fork 626
Closed
Description
Facing an issue with @web/dev-server at modernweb-dev/web#1376 where the node resolution breaks for dependencies that are using node's exports map, e.g.
// main.ts
import { highlight } from 'nodemod/dist/lib/prismjs.js'; // nodemod@2.7.3 is using `exports` map in nodeFYI, nodemod's package.json is as follows:
// nodemod's package.json
...
"exports": {
"./dist/*": "./dist/*",
...
}What's happening in @web/dev-server is that files are imported with .ts extension due to the following code as pointed out by the author of @web/dev-server:
plugins/packages/node-resolve/src/index.js
Lines 178 to 184 in 53776ee
| if (importer && importee.endsWith('.js')) { | |
| for (const ext of ['.ts', '.tsx']) { | |
| if (importer.endsWith(ext) && extensions.includes(ext)) { | |
| importSpecifierList.push(importee.replace(/.js$/, ext)); | |
| } | |
| } | |
| } |
Expected behavior
import { highlight } from 'nodemod/dist/lib/prismjs.js'; should resolve to 'node_modules/nodemod/dist/lib/prismjs.js';
Actual behavior
import { highlight } from 'nodemod/dist/lib/prismjs.js'; resolves to 'node_modules/nodemod/dist/lib/prismjs.ts';
Reactions are currently unavailable