Open razzeee opened 1 year ago
To my understanding in nodeNext
imports outside the default import need to be listed in the package.json
file which is currently not the case.
Happy to accept a PR that adds this.
Adding this seems to work:
"exports": {
".": {
"import": "./lib/common/api.js",
"require": "./lib/common/api.js",
"types": "./lib/common/api.d.ts"
},
"./node": {
"import": "./lib/node/main.js",
"require": "./lib/node/main.js",
"types": "./lib/node/main.d.ts"
}
}
but I end up with a followup error:
'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
Actually right now I have no idea what is causing this :-)
I'm way out of my depth too :shrug:
This doesn’t work, because there is no export nor file named node
in the vscode-languageserver
package. TypeScript correctly states this import can’t be resolved.
Instead, you should use:
import { createConnection } from "vscode-languageserver/node.js";
Adding the exports as per https://github.com/microsoft/vscode-languageserver-node/issues/1144#issuecomment-1347547590 would break the existing solution, making it a breaking change.
You could use exports
to make this work both in Node and the browser, which is the cleanest solution IMO. However, this would also be breaking, although it can me made non-breaking using a verbose exports
map.
{
"exports": {
".": {
"browser": "./lib/browser/main.js",
"default": "./lib/node/main.js",
}
}
}
This would allow using:
import { createConnection } from "vscode-languageserver";
Anyway, it currently works as-is. No action is required to allow consuming this package in ESM.
Hey,
I've been exploring using nodeNext, but this import seems to fail.
See https://github.com/elm-tooling/elm-language-server/pull/854/files#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80R12
Or just https://github.com/elm-tooling/elm-language-server/pull/854 for the PR