Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Make package importable for type="module" projects #586

Merged
merged 1 commit into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.cjs",
"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"
},
Expand Down
6 changes: 3 additions & 3 deletions rollup.config.js → rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -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/]

Expand All @@ -25,7 +25,7 @@ export default [
],
output: [
{
dir: 'dist',
file: 'dist/index.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.mjs',
format: 'esm',
sourcemap: true,
},
Expand Down
2 changes: 1 addition & 1 deletion test/ProxyBus.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @jest-environment jsdom
*/
const { SimpleBus, ProxyBus } = require('../dist')
const { SimpleBus, ProxyBus } = require('..')

describe('ProxyBus', () => {
test('proxy invalid bus', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/index.test.js
Original file line number Diff line number Diff line change
@@ -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()
Expand Down