Skip to content

Commit

Permalink
Avoid mjs wrapper and specify esm bundle instead
Browse files Browse the repository at this point in the history
  • Loading branch information
TrySound committed May 25, 2020
1 parent 9502a8b commit 41da746
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 21 deletions.
5 changes: 0 additions & 5 deletions packages/node-resolve/index.mjs

This file was deleted.

8 changes: 4 additions & 4 deletions packages/node-resolve/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"author": "Rich Harris <richard.a.harris@gmail.com>",
"homepage": "https://github.com/rollup/plugins/tree/master/packages/node-resolve/#readme",
"bugs": "https://github.com/rollup/plugins/issues",
"main": "./dist/index.js",
"main": "./dist/cjs/index.js",
"engines": {
"node": ">= 8.0.0"
},
Expand Down Expand Up @@ -76,10 +76,10 @@
]
},
"exports": {
"require": "./dist/index.js",
"import": "./index.mjs"
"require": "./dist/cjs/index.js",
"import": "./dist/es/index.js"
},
"module": "dist/index.es.js",
"module": "./dist/es/index.js",
"type": "commonjs",
"types": "types/index.d.ts"
}
15 changes: 14 additions & 1 deletion packages/node-resolve/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ import json from '@rollup/plugin-json';

import pkg from './package.json';

function emitModulePackageFile() {
return {
name: 'emit-module-package-file',
generateBundle() {
this.emitFile({
type: 'asset',
fileName: 'package.json',
source: `{"type":"module"}`
});
}
};
}

export default {
input: 'src/index.js',
plugins: [
Expand All @@ -23,6 +36,6 @@ export default {
external: Object.keys(pkg.dependencies).concat(['fs', 'path', 'os', 'util']),
output: [
{ file: pkg.main, format: 'cjs', exports: 'named' },
{ file: pkg.module, format: 'es' }
{ file: pkg.module, format: 'es', plugins: [emitModulePackageFile()] }
]
};
9 changes: 7 additions & 2 deletions packages/pluginutils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"bugs": {
"url": "https://github.com/rollup/plugins/issues"
},
"main": "dist/index.js",
"main": "./dist/cjs/index.js",
"engines": {
"node": ">= 8.0.0"
},
Expand Down Expand Up @@ -75,12 +75,17 @@
"!**/types.ts"
]
},
"module": "dist/index.es.js",
"exports": {
"require": "./dist/cjs/index.js",
"import": "./dist/es/index.js"
},
"module": "./dist/es/index.js",
"nyc": {
"extension": [
".js",
".ts"
]
},
"type": "commonjs",
"types": "types/index.d.ts"
}
24 changes: 15 additions & 9 deletions packages/pluginutils/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ import typescript from '@rollup/plugin-typescript';

import pkg from './package.json';

function emitModulePackageFile() {
return {
name: 'emit-module-package-file',
generateBundle() {
this.emitFile({
type: 'asset',
fileName: 'package.json',
source: `{"type":"module"}`
});
}
};
}

export default {
input: 'src/index.ts',
plugins: [
Expand All @@ -13,14 +26,7 @@ export default {
],
external: Object.keys(pkg.dependencies).concat('path', 'util'),
output: [
{
format: 'cjs',
file: pkg.main,
exports: 'named'
},
{
format: 'es',
file: pkg.module
}
{ format: 'cjs', file: pkg.main, exports: 'named' },
{ file: pkg.module, format: 'es', plugins: [emitModulePackageFile()] }
]
};

0 comments on commit 41da746

Please sign in to comment.