Skip to content

Commit

Permalink
chore!: migrate package to ESM (#675)
Browse files Browse the repository at this point in the history
This change transitions the package to be distributed as an ESM (ECMAScript Module)
instead of CommonJS. The main change is the output of ESM-compatible code by the
TypeScript compiler and the modification of the module type in `package.json`.

Given that most bundlers now support ESM-distributed packages, I decided to forgo
adding backward compatibility for CommonJS.

BREAKING CHANGE: The package is now distributed as an ESM module
  • Loading branch information
oyvinmar committed Oct 11, 2023
1 parent 307c0d7 commit 87e42ad
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
extends: ['eslint:recommended', 'prettier', './eslint-typescript.js'],
extends: ['eslint:recommended', 'prettier', './eslint-typescript.cjs'],
plugins: ['prettier', 'import'],
env: {
es6: true,
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"beach",
"rx"
],
"type": "module",
"company": "Ardoq AS",
"homepage": "https://ardoq.github.io/rxbeach/",
"bugs": "https://github.com/ardoq/rxbeach/issues",
Expand Down Expand Up @@ -46,7 +47,7 @@
"test:unit-test": "yarn jest",
"test:coverage": "yarn jest --config jest-coverage.config.mjs --rootDir .",
"test:watch": "yarn test:unit-test --watch",
"lint": "yarn eslint --ext .ts src -c .eslintrc.js",
"lint": "yarn eslint --ext .ts src -c .eslintrc.cjs",
"build": "rimraf dist && yarn tsc",
"watch": "yarn tsc -w",
"prepack": "yarn build -p tsconfig-publish.json",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

"outDir": "./dist",
"declaration": true,
"module": "commonjs",
"module": "ESNext",
"sourceMap": true
},
"include": ["src/**/*"]
Expand Down

0 comments on commit 87e42ad

Please sign in to comment.