From dca3a3b4bbb7dc7720d1e9dccd77c72b209e5bc7 Mon Sep 17 00:00:00 2001 From: Cody Olsen Date: Tue, 5 Sep 2023 20:58:37 +0200 Subject: [PATCH] feat: remove `node.import` ESM CJS wrapper support --- playground/babel-plugin/package.json | 1 + playground/custom-dist/package.json | 1 + playground/default-export/package.json | 7 +- playground/dummy-commonjs/node/extra.js | 7 -- playground/dummy-commonjs/node/extra.mjs | 5 -- playground/dummy-commonjs/node/index.js | 7 -- playground/dummy-commonjs/node/index.mjs | 5 -- playground/dummy-commonjs/package.json | 12 +-- playground/dummy-module/node/extra.cjs | 7 -- playground/dummy-module/node/extra.js | 5 -- playground/dummy-module/node/index.cjs | 7 -- playground/dummy-module/node/index.js | 5 -- playground/dummy-module/package.json | 12 +-- playground/multi-export/package.json | 12 +-- .../multi-exports-commonjs/package.json | 13 +-- playground/ts-bundler/package.json | 7 +- playground/ts-node16/package.json | 7 +- playground/ts/package.json | 7 +- playground/use-client-directive/package.json | 1 + src/node/core/pkg/loadPkgWithReporting.ts | 47 +++------- src/node/core/pkg/validatePkg.ts | 2 - src/node/resolveBuildTasks.ts | 30 +------ src/node/tasks/index.ts | 2 - src/node/tasks/node/reexportCjsTask.ts | 87 ------------------- src/node/tasks/types.ts | 9 +- test/parseExports.test.ts | 46 +++++----- 26 files changed, 53 insertions(+), 298 deletions(-) delete mode 100644 playground/dummy-commonjs/node/extra.js delete mode 100644 playground/dummy-commonjs/node/extra.mjs delete mode 100644 playground/dummy-commonjs/node/index.js delete mode 100644 playground/dummy-commonjs/node/index.mjs delete mode 100644 playground/dummy-module/node/extra.cjs delete mode 100644 playground/dummy-module/node/extra.js delete mode 100644 playground/dummy-module/node/index.cjs delete mode 100644 playground/dummy-module/node/index.js delete mode 100644 src/node/tasks/node/reexportCjsTask.ts diff --git a/playground/babel-plugin/package.json b/playground/babel-plugin/package.json index 677d3450..beb6d67d 100644 --- a/playground/babel-plugin/package.json +++ b/playground/babel-plugin/package.json @@ -4,6 +4,7 @@ "private": true, "license": "MIT", "type": "module", + "sideEffects": false, "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/playground/custom-dist/package.json b/playground/custom-dist/package.json index 813a5fbd..bde8951a 100644 --- a/playground/custom-dist/package.json +++ b/playground/custom-dist/package.json @@ -4,6 +4,7 @@ "private": true, "license": "MIT", "type": "module", + "sideEffects": false, "exports": { ".": { "types": "./lib/src/index.d.ts", diff --git a/playground/default-export/package.json b/playground/default-export/package.json index 096804fa..30ecf8e3 100644 --- a/playground/default-export/package.json +++ b/playground/default-export/package.json @@ -4,15 +4,12 @@ "private": true, "license": "MIT", "type": "module", + "sideEffects": false, "exports": { ".": { "source": "./src/index.js", - "require": "./dist/index.cjs", - "node": { - "module": "./dist/index.js", - "import": "./dist/index.cjs.js" - }, "import": "./dist/index.js", + "require": "./dist/index.cjs", "default": "./dist/index.js" }, "./package.json": "./package.json" diff --git a/playground/dummy-commonjs/node/extra.js b/playground/dummy-commonjs/node/extra.js deleted file mode 100644 index c6829719..00000000 --- a/playground/dummy-commonjs/node/extra.js +++ /dev/null @@ -1,7 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires -const cjs = require('../dist/extra') - -module.exports = { - ...cjs, - path: 'node/extra.js', -} diff --git a/playground/dummy-commonjs/node/extra.mjs b/playground/dummy-commonjs/node/extra.mjs deleted file mode 100644 index d2775d5a..00000000 --- a/playground/dummy-commonjs/node/extra.mjs +++ /dev/null @@ -1,5 +0,0 @@ -import cjs from '../dist/extra.js' - -export const format = cjs.format -export const runtime = cjs.runtime -export const path = 'node/extra.mjs' diff --git a/playground/dummy-commonjs/node/index.js b/playground/dummy-commonjs/node/index.js deleted file mode 100644 index 8cb075a3..00000000 --- a/playground/dummy-commonjs/node/index.js +++ /dev/null @@ -1,7 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires -const cjs = require('../dist/index') - -module.exports = { - ...cjs, - path: 'node/index.js', -} diff --git a/playground/dummy-commonjs/node/index.mjs b/playground/dummy-commonjs/node/index.mjs deleted file mode 100644 index 735b12d6..00000000 --- a/playground/dummy-commonjs/node/index.mjs +++ /dev/null @@ -1,5 +0,0 @@ -import cjs from '../dist/index.js' - -export const format = cjs.format -export const runtime = cjs.runtime -export const path = 'node/index.mjs' diff --git a/playground/dummy-commonjs/package.json b/playground/dummy-commonjs/package.json index faee9552..641816da 100644 --- a/playground/dummy-commonjs/package.json +++ b/playground/dummy-commonjs/package.json @@ -4,6 +4,7 @@ "private": true, "license": "MIT", "type": "commonjs", + "sideEffects": false, "exports": { ".": { "types": "./dist/index.d.ts", @@ -13,11 +14,6 @@ "import": "./dist/index.browser.mjs", "require": "./dist/index.browser.js" }, - "node": { - "module": "./dist/index.mjs", - "import": "./node/index.mjs", - "require": "./node/index.js" - }, "import": "./dist/index.mjs", "require": "./dist/index.js", "default": "./dist/index.mjs" @@ -30,11 +26,6 @@ "import": "./dist/extra.browser.mjs", "require": "./dist/extra.browser.js" }, - "node": { - "module": "./dist/extra.mjs", - "import": "./node/extra.mjs", - "require": "./node/extra.js" - }, "import": "./dist/extra.mjs", "require": "./dist/extra.js", "default": "./dist/extra.mjs" @@ -58,7 +49,6 @@ }, "files": [ "dist", - "node", "src" ], "scripts": { diff --git a/playground/dummy-module/node/extra.cjs b/playground/dummy-module/node/extra.cjs deleted file mode 100644 index 48003e6a..00000000 --- a/playground/dummy-module/node/extra.cjs +++ /dev/null @@ -1,7 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires -const cjs = require('../dist/extra.cjs') - -module.exports = { - ...cjs, - path: 'node/extra.cjs', -} diff --git a/playground/dummy-module/node/extra.js b/playground/dummy-module/node/extra.js deleted file mode 100644 index 417760ea..00000000 --- a/playground/dummy-module/node/extra.js +++ /dev/null @@ -1,5 +0,0 @@ -import cjs from '../dist/extra.cjs' - -export const format = cjs.format -export const runtime = cjs.runtime -export const path = 'node/extra.js' diff --git a/playground/dummy-module/node/index.cjs b/playground/dummy-module/node/index.cjs deleted file mode 100644 index 33f0a60a..00000000 --- a/playground/dummy-module/node/index.cjs +++ /dev/null @@ -1,7 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires -const cjs = require('../dist/index.cjs') - -module.exports = { - ...cjs, - path: 'node/index.cjs', -} diff --git a/playground/dummy-module/node/index.js b/playground/dummy-module/node/index.js deleted file mode 100644 index c65188f4..00000000 --- a/playground/dummy-module/node/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import cjs from '../dist/index.cjs' - -export const format = cjs.format -export const runtime = cjs.runtime -export const path = 'node/index.js' diff --git a/playground/dummy-module/package.json b/playground/dummy-module/package.json index 61b8e9ee..f3a97438 100644 --- a/playground/dummy-module/package.json +++ b/playground/dummy-module/package.json @@ -4,6 +4,7 @@ "private": true, "license": "MIT", "type": "module", + "sideEffects": false, "exports": { ".": { "types": "./dist/index.d.ts", @@ -13,11 +14,6 @@ "import": "./dist/index.browser.js", "require": "./dist/index.browser.cjs" }, - "node": { - "module": "./dist/index.js", - "import": "./node/index.js", - "require": "./node/index.cjs" - }, "import": "./dist/index.js", "require": "./dist/index.cjs", "default": "./dist/index.js" @@ -30,11 +26,6 @@ "import": "./dist/extra.browser.js", "require": "./dist/extra.browser.cjs" }, - "node": { - "module": "./dist/extra.js", - "import": "./node/extra.js", - "require": "./node/extra.cjs" - }, "import": "./dist/extra.js", "require": "./dist/extra.cjs", "default": "./dist/extra.js" @@ -58,7 +49,6 @@ }, "files": [ "dist", - "node", "src" ], "scripts": { diff --git a/playground/multi-export/package.json b/playground/multi-export/package.json index 833022ad..bc205078 100644 --- a/playground/multi-export/package.json +++ b/playground/multi-export/package.json @@ -11,23 +11,15 @@ ".": { "types": "./dist/index.d.ts", "source": "./src/index.ts", - "require": "./dist/index.cjs", - "node": { - "module": "./dist/index.js", - "import": "./dist/index.cjs.js" - }, "import": "./dist/index.js", + "require": "./dist/index.cjs", "default": "./dist/index.js" }, "./plugin": { "types": "./dist/plugin.d.ts", "source": "./src/plugin.ts", - "require": "./dist/plugin.cjs", - "node": { - "module": "./dist/plugin.js", - "import": "./dist/plugin.cjs.js" - }, "import": "./dist/plugin.js", + "require": "./dist/plugin.cjs", "default": "./dist/plugin.js" }, "./pure": { diff --git a/playground/multi-exports-commonjs/package.json b/playground/multi-exports-commonjs/package.json index a63bdf64..1212a497 100644 --- a/playground/multi-exports-commonjs/package.json +++ b/playground/multi-exports-commonjs/package.json @@ -4,27 +4,20 @@ "private": true, "license": "MIT", "type": "commonjs", + "sideEffects": false, "exports": { ".": { "types": "./dist/index.d.ts", "source": "./src/index.ts", - "require": "./dist/index.js", - "node": { - "module": "./dist/index.esm.js", - "import": "./dist/index.cjs.mjs" - }, "import": "./dist/index.esm.js", + "require": "./dist/index.js", "default": "./dist/index.esm.js" }, "./plugin": { "types": "./dist/plugin.d.ts", "source": "./src/plugin.ts", - "require": "./dist/plugin.js", - "node": { - "module": "./dist/plugin.esm.js", - "import": "./dist/plugin.cjs.mjs" - }, "import": "./dist/plugin.esm.js", + "require": "./dist/plugin.js", "default": "./dist/plugin.esm.js" }, "./package.json": "./package.json" diff --git a/playground/ts-bundler/package.json b/playground/ts-bundler/package.json index 20cc930b..e83de612 100644 --- a/playground/ts-bundler/package.json +++ b/playground/ts-bundler/package.json @@ -4,16 +4,13 @@ "private": true, "license": "MIT", "type": "module", + "sideEffects": false, "exports": { ".": { "types": "./dist/index.d.ts", "source": "./src/index.ts", - "require": "./dist/index.cjs", - "node": { - "module": "./dist/index.js", - "import": "./dist/index.cjs.js" - }, "import": "./dist/index.js", + "require": "./dist/index.cjs", "default": "./dist/index.js" }, "./package.json": "./package.json" diff --git a/playground/ts-node16/package.json b/playground/ts-node16/package.json index 8df3014b..58a8f294 100644 --- a/playground/ts-node16/package.json +++ b/playground/ts-node16/package.json @@ -4,16 +4,13 @@ "private": true, "license": "MIT", "type": "module", + "sideEffects": false, "exports": { ".": { "types": "./dist/index.d.ts", "source": "./src/index.ts", - "require": "./dist/index.cjs", - "node": { - "module": "./dist/index.js", - "import": "./dist/index.cjs.js" - }, "import": "./dist/index.js", + "require": "./dist/index.cjs", "default": "./dist/index.js" }, "./package.json": "./package.json" diff --git a/playground/ts/package.json b/playground/ts/package.json index 4bbc6650..f90246a7 100644 --- a/playground/ts/package.json +++ b/playground/ts/package.json @@ -4,16 +4,13 @@ "private": true, "license": "MIT", "type": "module", + "sideEffects": false, "exports": { ".": { "types": "./dist/index.d.ts", "source": "./src/index.ts", - "require": "./dist/index.cjs", - "node": { - "module": "./dist/index.js", - "import": "./dist/index.cjs.js" - }, "import": "./dist/index.js", + "require": "./dist/index.cjs", "default": "./dist/index.js" }, "./package.json": "./package.json" diff --git a/playground/use-client-directive/package.json b/playground/use-client-directive/package.json index b3cc223b..ea36be79 100644 --- a/playground/use-client-directive/package.json +++ b/playground/use-client-directive/package.json @@ -4,6 +4,7 @@ "private": true, "license": "MIT", "type": "module", + "sideEffects": false, "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/src/node/core/pkg/loadPkgWithReporting.ts b/src/node/core/pkg/loadPkgWithReporting.ts index ab7047da..a5c67214 100644 --- a/src/node/core/pkg/loadPkgWithReporting.ts +++ b/src/node/core/pkg/loadPkgWithReporting.ts @@ -33,28 +33,14 @@ export async function loadPkgWithReporting(options: { logger.error(`exports["${expPath}"]: the \`types\` property should be the first property`) } - if (exp.node) { - const nodeKeys = Object.keys(exp.node) - - if (!assertOrder('module', 'import', nodeKeys)) { - shouldError = true - logger.error( - `exports["${expPath}"]: the \`node.module\` property should come before the \`node.import\` property`, - ) - } - - if (!assertOrder('import', 'require', nodeKeys)) { - logger.warn( - `exports["${expPath}"]: the \`node.import\` property should come before the \`node.require\` property`, - ) - } - - if (!assertOrder('module', 'require', nodeKeys)) { - logger.warn( - `exports["${expPath}"]: the \`node.module\` property should come before \`node.require\` property`, - ) - } + if (exp.module) { + shouldError = true + logger.error( + `exports["${expPath}"]: the \`module\` condition shouldn't be used as it's not well supported in all bundlers.`, + ) + } + if (exp.node) { if (exp.import && exp.node.import && !assertOrder('node', 'import', keys)) { shouldError = true logger.error( @@ -62,23 +48,22 @@ export async function loadPkgWithReporting(options: { ) } - if (exp.module && exp.node.module && !assertOrder('node', 'module', keys)) { + if (exp.node.module) { shouldError = true logger.error( - `exports["${expPath}"]: the \`node\` property should come before the \`module\` property`, + `exports["${expPath}"]: the \`node.module\` condition shouldn't be used as it's not well supported in all bundlers. A better strategy is to refactor the codebase to no longer be vulnerable to the "dual package hazard"`, ) } if ( + !exp.node.source && exp.node.import && - !exp.node.require && - exp.node.module && - exp.import && - exp.node.module !== exp.import + (exp.node.require || exp.require) && + (exp.node.import.endsWith('.cjs.js') || exp.node.import.endsWith('.cjs.mjs')) ) { shouldError = true logger.error( - `exports["${expPath}"]: the \`node.module\` property should match \`import\``, + `exports["${expPath}"]: the \`node.import\` re-export pattern shouldn't be used as it's not well supported in all bundlers. A better strategy is to refactor the codebase to no longer be vulnerable to the "dual package hazard"`, ) } @@ -99,12 +84,6 @@ export async function loadPkgWithReporting(options: { `exports["${expPath}"]: the \`import\` property should come before the \`require\` property`, ) } - - if (!assertOrder('module', 'import', keys)) { - logger.warn( - `exports["${expPath}"]: the \`module\` property should come before \`import\` property`, - ) - } } if (!assertLast('default', keys)) { diff --git a/src/node/core/pkg/validatePkg.ts b/src/node/core/pkg/validatePkg.ts index f48c1c71..7a6ca04f 100644 --- a/src/node/core/pkg/validatePkg.ts +++ b/src/node/core/pkg/validatePkg.ts @@ -33,12 +33,10 @@ const pkgSchema = z.object({ node: z.optional( z.object({ source: z.optional(z.string()), - module: z.optional(z.string()), import: z.optional(z.string()), require: z.optional(z.string()), }), ), - module: z.optional(z.string()), import: z.optional(z.string()), require: z.optional(z.string()), default: z.string(), diff --git a/src/node/resolveBuildTasks.ts b/src/node/resolveBuildTasks.ts index 11fee026..40478895 100644 --- a/src/node/resolveBuildTasks.ts +++ b/src/node/resolveBuildTasks.ts @@ -2,7 +2,7 @@ import fs from 'fs' import path from 'path' import {BuildContext, PkgExport, PkgFormat, PkgRuntime} from './core' -import {BuildTask, DtsTask, NodeReExportFromCJSTask, RollupTask, RollupTaskEntry} from './tasks' +import {BuildTask, DtsTask, RollupTask, RollupTaskEntry} from './tasks' /** @internal */ export function resolveBuildTasks(ctx: BuildContext): BuildTask[] { @@ -156,33 +156,5 @@ export function resolveBuildTasks(ctx: BuildContext): BuildTask[] { } } - const nodeReexportCjsEntries: NodeReExportFromCJSTask['entries'] = [] - - // Parse tasks to re-export from CommonJS for Node.js - for (const exp of exports) { - if ( - exp.node && - !exp.node.source && - exp.node.import && - (exp.node.require || exp.require) && - (exp.node.import.endsWith('.cjs.js') || exp.node.import.endsWith('.cjs.mjs')) - ) { - const importId = path.join(pkg.name, exp._path) - - nodeReexportCjsEntries.push({ - importId, - import: exp.node.import, - require: (exp.node.require || exp.require)!, - }) - } - } - - if (nodeReexportCjsEntries.length) { - tasks.push({ - type: 'node:reexport-cjs', - entries: nodeReexportCjsEntries, - }) - } - return tasks } diff --git a/src/node/tasks/index.ts b/src/node/tasks/index.ts index 4be0b9b2..1050c5cd 100644 --- a/src/node/tasks/index.ts +++ b/src/node/tasks/index.ts @@ -1,5 +1,4 @@ import {dtsTask, dtsWatchTask} from './dts' -import {nodeReexportCjsTask} from './node/reexportCjsTask' import {rollupTask, rollupWatchTask} from './rollup' import {BuildTaskHandlers, WatchTaskHandlers} from './types' @@ -11,7 +10,6 @@ export * from './types' export const buildTaskHandlers: BuildTaskHandlers = { 'build:dts': dtsTask, 'build:js': rollupTask, - 'node:reexport-cjs': nodeReexportCjsTask, } /** @internal */ diff --git a/src/node/tasks/node/reexportCjsTask.ts b/src/node/tasks/node/reexportCjsTask.ts deleted file mode 100644 index 75bf345c..00000000 --- a/src/node/tasks/node/reexportCjsTask.ts +++ /dev/null @@ -1,87 +0,0 @@ -import chalk from 'chalk' -import {writeFile} from 'fs/promises' -import {mkdirp} from 'mkdirp' -import path from 'path' -import {from} from 'rxjs' - -import {BuildContext} from '../../core' -import {NodeReExportFromCJSTask, TaskHandler} from '../types' - -/** @internal */ -export const nodeReexportCjsTask: TaskHandler = { - name: (_ctx, task) => - [ - `Re-export CommonJS module in ESM wrapper…`, - ` entries:`, - ...task.entries.map((entry) => - [ - ` - ${chalk.cyan(entry.importId)}: `, - `${chalk.yellow(entry.require)} ${chalk.gray('→')} ${chalk.yellow(entry.import)}`, - ].join(''), - ), - ].join('\n'), - exec: (ctx, task) => { - return from(exec(ctx, task)) - }, - complete: () => { - // - }, - error: (_ctx, _task, err) => { - // eslint-disable-next-line no-console - console.error(err) - }, -} - -async function exec(ctx: BuildContext, task: NodeReExportFromCJSTask) { - const {cwd} = ctx - - for (const entry of task.entries) { - const sourcePath = path.resolve(cwd, entry.require) - const targetPath = path.resolve(cwd, entry.import) - const targetDir = path.dirname(targetPath) - - await mkdirp(targetDir) - - // eslint-disable-next-line @typescript-eslint/no-var-requires - const mod = require(sourcePath) - - let relativeImport = `./${path.relative(targetDir, sourcePath)}` - - // Strip leading "./" from relative import - if (relativeImport.startsWith('./.')) { - relativeImport = relativeImport.slice(2) - } - - const code = compileESMWrapper(mod, relativeImport) - - await writeFile(targetPath, code, 'utf8') - } -} - -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function compileESMWrapper(mod: any, relativeImport: string) { - const keys = Object.keys(mod).filter((k) => k !== '__esModule') - - let code = `import cjs from '${relativeImport}';\n` - - if (keys.length) { - code += `\n` - code += keys - .filter((k) => (mod.__esModule ? k !== 'default' : true)) - .map((k) => `export const ${k} = cjs.${k};\n`) - .join('') - } - - code += `\n` - - if (mod.__esModule) { - // If there is no default export, we shouldn't add it as it'll be undefined - if ('default' in mod) { - code += `export default cjs.default;\n` - } - } else { - code += `export default cjs;\n` - } - - return code -} diff --git a/src/node/tasks/types.ts b/src/node/tasks/types.ts index 6b18e8d1..56d4937f 100644 --- a/src/node/tasks/types.ts +++ b/src/node/tasks/types.ts @@ -32,13 +32,7 @@ export interface RollupWatchTask { } /** @internal */ -export interface NodeReExportFromCJSTask { - type: 'node:reexport-cjs' - entries: {importId: string; import: string; require: string}[] -} - -/** @internal */ -export type BuildTask = DtsTask | RollupTask | NodeReExportFromCJSTask +export type BuildTask = DtsTask | RollupTask /** @internal */ export type WatchTask = DtsWatchTask | RollupWatchTask @@ -55,7 +49,6 @@ export type TaskHandler = { export interface BuildTaskHandlers { 'build:dts': TaskHandler 'build:js': TaskHandler - 'node:reexport-cjs': TaskHandler } /** @internal */ diff --git a/test/parseExports.test.ts b/test/parseExports.test.ts index 2f041235..7841724b 100644 --- a/test/parseExports.test.ts +++ b/test/parseExports.test.ts @@ -192,17 +192,6 @@ describe('parseExports', () => { }, `"node" can output both a "import" and "require" condition`, ], - [ - { - require: './dist/index.cjs', - node: { - module: './dist/index.js', - import: './dist/index.cjs.js', - }, - import: './dist/index.js', - }, - `"node" can be used to implement a wrapper that protects against the "dual package hazard"`, - ], ])('%o', (json, msg) => { const extMap = getPkgExtMap({legacyExports: false}) @@ -272,50 +261,55 @@ describe('parseExports', () => { import: './dist/index.js', node: { module: './dist/index.js', - import: './dist/index.cjs.js', }, default: './dist/index.js', }, - `"node.import" must be before "import"`, + `"node.module" considered harmful`, ], [ { source: './src/index.ts', - node: { - module: './dist/index.js', - import: './dist/index.cjs.js', - require: './dist/index.cjs', - }, - import: './dist/index.js', + module: './dist/index.js', require: './dist/index.cjs', + import: './dist/index.js', default: './dist/index.js', }, - `"node.require" is unnecesary if it's the same as "require"`, + `"module" considered harmful`, ], [ { source: './src/index.ts', require: './dist/index.cjs', + import: './dist/index.js', node: { - import: './dist/index.cjs.js', + import: './dist/index.node.js', }, - import: './dist/index.js', default: './dist/index.js', }, - `"node.module" should be specified when a "node.import" dual package hazard is used`, + `"node.import" must be before "import"`, ], [ { source: './src/index.ts', + node: { + import: './dist/index.node.js', + require: './dist/index.cjs', + }, + import: './dist/index.js', + require: './dist/index.cjs', + default: './dist/index.js', + }, + `"node.require" is unnecesary if it's the same as "require"`, + ], + [ + { require: './dist/index.cjs', - module: './dist/index.js', node: { import: './dist/index.cjs.js', }, import: './dist/index.js', - default: './dist/index.js', }, - `"module" should be moved to "node.module" when it's the same as "import"`, + `the "node" re-export pattern considered harmful, protect against the "dual package hazard" in ways that have high ecosystem compatibility`, ], [ {