diff --git a/package.json b/package.json index d14802bf..8bf75e1d 100644 --- a/package.json +++ b/package.json @@ -2,21 +2,23 @@ "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", + "main": "dist/index.cjs", "types": "dist/index.d.ts", "exports": { - "import": "./dist/index.esm.js", - "require": "./dist/index.js" + ".": { + "import": "./dist/index.mjs", + "require": "./dist/index.js", + "types": "./dist/index.d.ts" + } }, "files": [ "dist/" ], "scripts": { - "build": "rollup --config rollup.config.js", + "build": "rollup --config rollup.config.mjs", "build:doc": "typedoc --out dist/doc lib/index.ts && touch dist/doc/.nojekyll", "check-types": "tsc --noEmit", - "dev": "rollup --config rollup.config.js --watch", + "dev": "rollup --config rollup.config.mjs --watch", "test": "jest", "test:watch": "jest --watchAll" }, diff --git a/rollup.config.js b/rollup.config.mjs similarity index 86% rename from rollup.config.js rename to rollup.config.mjs index 81376b45..53075e81 100644 --- a/rollup.config.js +++ b/rollup.config.mjs @@ -1,7 +1,7 @@ import typescript from '@rollup/plugin-typescript' import replace from '@rollup/plugin-replace' -import pkg from './package.json' +import pkg from './package.json' assert { type: 'json' } const external = [/semver/] @@ -25,7 +25,7 @@ export default [ ], output: [ { - dir: 'dist', + file: 'dist/index.cjs', format: 'cjs', sourcemap: true, }, @@ -37,7 +37,7 @@ export default [ plugins: [typescript(), replacePlugin], output: [ { - file: 'dist/index.esm.js', + file: 'dist/index.mjs', format: 'esm', sourcemap: true, }, diff --git a/test/ProxyBus.test.js b/test/ProxyBus.test.js index 8e5e65d3..895c53e6 100644 --- a/test/ProxyBus.test.js +++ b/test/ProxyBus.test.js @@ -1,7 +1,7 @@ /** * @jest-environment jsdom */ -const { SimpleBus, ProxyBus } = require('../dist') +const { SimpleBus, ProxyBus } = require('..') describe('ProxyBus', () => { test('proxy invalid bus', () => { diff --git a/test/index.test.js b/test/index.test.js index 9170f9f0..9c3aaaa8 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -1,7 +1,7 @@ /** * @jest-environment jsdom */ -const { emit, subscribe, unsubscribe } = require('../dist/index') +const { emit, subscribe, unsubscribe } = require('..') test('readme example', () => { const h = jest.fn()