This is a Rollup plugin that resolves import specifiers in input files:
import packageSubdir from 'my-package/something'
import packageDefault from 'my-package'
import relativeImport from './relative'
To fully ESM-compatible specifiers including file extensions, deferring to
package.json exports
field for imported modules:
// package.json exports: ./* -> ./*/index.js
import packageSubdir from 'my-package/something/index.js'
// package entry is OK
import packageDefault from 'my-package'
// resolve relative import
import relativeImport from './relative.js'
This plugin was developed to turn TypeScript's module: esnext
into valid ESM.
By default, TS emits relative imports like import stuff from './myModule'
, which must be resolved at build-time in order for it to execute
in an ESM context.