Skip to content

Commit

Permalink
fix: Make package importable for type="module" projects
Browse files Browse the repository at this point in the history
Explicitly set the type of the dist files by changing the file
extension to `mjs` or `cjs` respectively.

Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
  • Loading branch information
susnux committed Mar 5, 2023
1 parent 059c30f commit e2537d5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
"name": "@nextcloud/event-bus",
"version": "3.0.2",
"description": "A simple event bus to communicate between Nextcloud components.",
"main": "dist/index.js",
"module": "dist/index.esm.js",
"type": "module",
"main": "dist/index.es5.cjs",
"types": "dist/index.d.ts",
"exports": {
"import": "./dist/index.esm.js",
"require": "./dist/index.js"
".": {
"import": "./dist/index.esm.mjs",
"require": "./dist/index.es5.cjs",
"types": "./dist/index.d.ts"
}
},
"files": [
"dist/"
Expand Down
4 changes: 2 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default [
],
output: [
{
dir: 'dist',
file: 'dist/index.es5.cjs',
format: 'cjs',
sourcemap: true,
},
Expand All @@ -37,7 +37,7 @@ export default [
plugins: [typescript(), replacePlugin],
output: [
{
file: 'dist/index.esm.js',
file: 'dist/index.esm.mjs',
format: 'esm',
sourcemap: true,
},
Expand Down

0 comments on commit e2537d5

Please sign in to comment.