From 1828a8f78987bc15230a6e3feb7b29cefc4490d7 Mon Sep 17 00:00:00 2001 From: Felix Gnass Date: Tue, 24 May 2022 17:27:30 +0200 Subject: [PATCH 1/4] Fix exports map to support loading in Node esm --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index e822231..f91729c 100644 --- a/package.json +++ b/package.json @@ -4,20 +4,20 @@ "version": "4.0.1", "description": "Connect your components up to that address bar.", "main": "dist/preact-router.js", - "module": "dist/preact-router.module.js", - "jsnext:main": "dist/preact-router.module.js", + "module": "dist/preact-router.mjs", + "jsnext:main": "dist/preact-router.mjs", "umd:main": "dist/preact-router.umd.js", "unpkg": "dist/preact-router.umd.js", "exports": { ".": { - "module": "./dist/preact-router.module.js", - "import": "./dist/preact-router.module.js", + "module": "./dist/preact-router.mjs", + "import": "./dist/preact-router.mjs", "require": "./dist/preact-router.js" }, "./package.json": "./package.json", "./match": { - "module": "./match/index.module.js", - "import": "./match/index.module.js", + "module": "./match/index.mjs", + "import": "./match/index.mjs", "require": "./match/index.js" }, "./match/package.json": "./match/package.json" From 00cf17f2895361a9d3d57c83edaf2f28a87b1f4c Mon Sep 17 00:00:00 2001 From: Felix Gnass Date: Thu, 26 May 2022 14:35:26 +0200 Subject: [PATCH 2/4] Use .mjs only for module exports --- .gitignore | 1 + package.json | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 32ccb95..5cbd5b8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ node_modules /npm-debug.log .DS_Store /match/*.js +/match/*.mjs diff --git a/package.json b/package.json index f91729c..6d6f200 100644 --- a/package.json +++ b/package.json @@ -4,26 +4,26 @@ "version": "4.0.1", "description": "Connect your components up to that address bar.", "main": "dist/preact-router.js", - "module": "dist/preact-router.mjs", - "jsnext:main": "dist/preact-router.mjs", + "module": "dist/preact-router.module.js", + "jsnext:main": "dist/preact-router.module.js", "umd:main": "dist/preact-router.umd.js", "unpkg": "dist/preact-router.umd.js", "exports": { ".": { - "module": "./dist/preact-router.mjs", + "module": "./dist/preact-router.module.js", "import": "./dist/preact-router.mjs", "require": "./dist/preact-router.js" }, "./package.json": "./package.json", "./match": { - "module": "./match/index.mjs", + "module": "./match/index.module.js", "import": "./match/index.mjs", "require": "./match/index.js" }, "./match/package.json": "./match/package.json" }, "scripts": { - "build": "microbundle -f es --no-generateTypes && microbundle src/cjs.js -f cjs,umd --no-generateTypes && (cd match && npm run build)", + "build": "microbundle -f es --no-generateTypes && copyfiles dist/preact-router.module.js dist/preact-router.mjs && microbundle src/cjs.js -f cjs,umd --no-generateTypes && (cd match && npm run build && copyfiles index.module.js index.mjs)", "test": "npm-run-all lint build test:unit test:ts", "lint": "eslint src test", "fix": "npm run lint -- --fix", From 1ef5ad4d8445ff6748b4861fd5ffc8641da8d857 Mon Sep 17 00:00:00 2001 From: Ryan Christian <33403762+rschristian@users.noreply.github.com> Date: Fri, 27 May 2022 02:54:11 -0500 Subject: [PATCH 3/4] Apply suggestions from code review --- package.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 6d6f200..a953100 100644 --- a/package.json +++ b/package.json @@ -10,20 +10,21 @@ "unpkg": "dist/preact-router.umd.js", "exports": { ".": { - "module": "./dist/preact-router.module.js", + "module": "./dist/preact-router.mjs", "import": "./dist/preact-router.mjs", "require": "./dist/preact-router.js" }, "./package.json": "./package.json", "./match": { - "module": "./match/index.module.js", + "module": "./match/index.mjs", "import": "./match/index.mjs", "require": "./match/index.js" }, "./match/package.json": "./match/package.json" }, "scripts": { - "build": "microbundle -f es --no-generateTypes && copyfiles dist/preact-router.module.js dist/preact-router.mjs && microbundle src/cjs.js -f cjs,umd --no-generateTypes && (cd match && npm run build && copyfiles index.module.js index.mjs)", + "build": "microbundle -f es --no-generateTypes && microbundle src/cjs.js -f cjs,umd --no-generateTypes && (cd match && npm run build)", + "postbuild": "cp dist/preact-router.module.js dist/preact-router.mjs && cp match/index.module.js match/index.mjs", "test": "npm-run-all lint build test:unit test:ts", "lint": "eslint src test", "fix": "npm run lint -- --fix", From 433c4c38285bcc20bd8ec4a8193d2b02c79ac2df Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Fri, 27 May 2022 14:44:17 -0500 Subject: [PATCH 4/4] test: Ensures dist test uses CJS build of router --- test/dist.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/dist.test.js b/test/dist.test.js index 1c7d8eb..9c3e92f 100644 --- a/test/dist.test.js +++ b/test/dist.test.js @@ -2,7 +2,7 @@ import { h } from 'preact'; import { toBeCloneOf } from './utils/assert-clone-of'; // import '../test_helpers/assert-clone-of'; -const router = require('../dist/preact-router'); +const router = require('../dist/preact-router.js'); const { Router, Link, route } = router; describe('dist', () => {