-
Notifications
You must be signed in to change notification settings - Fork 41
Closed
Labels
status: accepting prsPlease, send a pull request to resolve this!Please, send a pull request to resolve this!type: bugSomething isn't working :(Something isn't working :(
Description
When using dedent in a node ESM environment, a import dedent from 'dedent' statement will result a {default: dedent} object.
> const dedent = await import('dedent')
undefined
> dedent`abc`
Uncaught TypeError: dedent is not a function
> dedent('abc')
Uncaught TypeError: dedent is not a function
> dedent
[Module: null prototype] {
__esModule: undefined,
default: <ref *1> [Function: dedent] { default: [Circular *1] }
}
> dedent.default`abc`
'abc'
This issue comes from several reasones:
- In
package.jsonamodulefiled is specified todist/dedent.mjs, but NodeJS doesn't support this field - The
mainfield inpackage.jsonreferences todist/dedent.jswhich is a CommonJS module, NodeJS's ESM then transformsmodule.exportsinto a default export
To address this, we need a exports field in package.json:
{
"exports": {
".": {
"types": "./index.d.ts",
"import": "./dist/dedent.mjs",
"default": "./dist/dedent.js"
}
}
}This will solve the import issue, but is potentially a breaking change to NodeJS ESM environment, would it worse a major version?
Metadata
Metadata
Assignees
Labels
status: accepting prsPlease, send a pull request to resolve this!Please, send a pull request to resolve this!type: bugSomething isn't working :(Something isn't working :(