From fdcaf29a68e7e8c20b909216f086efe64e831cd9 Mon Sep 17 00:00:00 2001 From: Brian Takita Date: Mon, 19 Jul 2021 19:06:25 -0400 Subject: [PATCH 1/4] fix: esm: runtime issue with importing EventEmitter: using named import fixes https://github.com/Conduitry/cheap-watch/issues/9 --- package.json | 11 ++++++----- rollup.config.js | 8 ++++---- src/CheapWatch.ts | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index c8ec450..a6c5308 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,9 @@ "watch", "watcher" ], - "main": "dist/CheapWatch.cjs.js", - "module": "dist/CheapWatch.esm.js", + "type": "module", + "main": "dist/CheapWatch.cjs", + "module": "dist/CheapWatch.mjs", "types": "types/CheapWatch.d.ts", "files": [ "dist", @@ -30,10 +31,10 @@ }, "homepage": "https://conduitry.dev/cheap-watch", "devDependencies": { + "@types/node": "=8", "rollup": "^2", - "rollup-plugin-cheap-ts": "Conduitry/rollup-plugin-cheap-ts#semver:^1", - "typescript": "^3", - "@types/node": "=8" + "rollup-plugin-typescript2": "^0.30.0", + "typescript": "^3" }, "scripts": { "build": "rollup -c", diff --git a/rollup.config.js b/rollup.config.js index 95dcb98..bbea9d5 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,16 +1,16 @@ -import cheap_ts from 'rollup-plugin-cheap-ts'; +import typescript2 from 'rollup-plugin-typescript2'; export default { input: './src/CheapWatch', external: name => /^[a-z]/.test(name), - plugins: [cheap_ts()], + plugins: [typescript2()], output: [ { - file: './dist/CheapWatch.cjs.js', + file: './dist/CheapWatch.cjs', format: 'cjs', sourcemap: true, interop: false, }, - { file: './dist/CheapWatch.esm.js', format: 'esm', sourcemap: true }, + { file: './dist/CheapWatch.mjs', format: 'es', sourcemap: true }, ], }; diff --git a/src/CheapWatch.ts b/src/CheapWatch.ts index a61f3fa..0df3763 100644 --- a/src/CheapWatch.ts +++ b/src/CheapWatch.ts @@ -1,4 +1,4 @@ -import * as EventEmitter from 'events'; +import { EventEmitter } from 'events'; import * as fs from 'fs'; import { promisify } from 'util'; From b97d38c6babbde6f2ad0c8891c317a6082e1338c Mon Sep 17 00:00:00 2001 From: Brian Takita Date: Tue, 20 Jul 2021 07:53:31 -0400 Subject: [PATCH 2/4] fix: build --- package.json | 6 +++--- rollup.config.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index a6c5308..9996192 100644 --- a/package.json +++ b/package.json @@ -31,10 +31,10 @@ }, "homepage": "https://conduitry.dev/cheap-watch", "devDependencies": { - "@types/node": "=8", - "rollup": "^2", + "@types/node": "^16", + "rollup": "^2.53.2", "rollup-plugin-typescript2": "^0.30.0", - "typescript": "^3" + "typescript": "^4.3.5" }, "scripts": { "build": "rollup -c", diff --git a/rollup.config.js b/rollup.config.js index bbea9d5..045f708 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,7 +1,7 @@ import typescript2 from 'rollup-plugin-typescript2'; export default { - input: './src/CheapWatch', + input: './src/CheapWatch.ts', external: name => /^[a-z]/.test(name), plugins: [typescript2()], output: [ From 4555245465aa0b9caff43e2fc2741815d12b48a6 Mon Sep 17 00:00:00 2001 From: Brian Takita Date: Wed, 21 Jul 2021 13:46:21 -0400 Subject: [PATCH 3/4] fix: import from ESM --- package.json | 2 +- rollup.config.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 9996192..14a8ca5 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "homepage": "https://conduitry.dev/cheap-watch", "devDependencies": { "@types/node": "^16", - "rollup": "^2.53.2", + "rollup": "^2.53.3", "rollup-plugin-typescript2": "^0.30.0", "typescript": "^4.3.5" }, diff --git a/rollup.config.js b/rollup.config.js index 045f708..fc979b0 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -10,6 +10,7 @@ export default { format: 'cjs', sourcemap: true, interop: false, + exports: 'auto' }, { file: './dist/CheapWatch.mjs', format: 'es', sourcemap: true }, ], From f79b980a7c6dce62734217da5e1b9cf2cc757312 Mon Sep 17 00:00:00 2001 From: Brian Takita Date: Wed, 21 Jul 2021 21:24:28 -0400 Subject: [PATCH 4/4] @rollup/plugin-typescript instead of rollup-plugin-typescript2 --- package.json | 2 +- rollup.config.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 14a8ca5..afae969 100644 --- a/package.json +++ b/package.json @@ -31,9 +31,9 @@ }, "homepage": "https://conduitry.dev/cheap-watch", "devDependencies": { + "@rollup/plugin-typescript": "^8.2.3", "@types/node": "^16", "rollup": "^2.53.3", - "rollup-plugin-typescript2": "^0.30.0", "typescript": "^4.3.5" }, "scripts": { diff --git a/rollup.config.js b/rollup.config.js index fc979b0..14ef857 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,9 +1,9 @@ -import typescript2 from 'rollup-plugin-typescript2'; +import typescript from '@rollup/plugin-typescript'; export default { input: './src/CheapWatch.ts', external: name => /^[a-z]/.test(name), - plugins: [typescript2()], + plugins: [typescript()], output: [ { file: './dist/CheapWatch.cjs',