Skip to content

Commit

Permalink
Fix exports map to support loading in Node esm (#425)
Browse files Browse the repository at this point in the history
* Fix exports map to support loading in Node esm

* Use .mjs only for module exports

* Apply suggestions from code review

* test: Ensures dist test uses CJS build of router

Co-authored-by: Ryan Christian <33403762+rschristian@users.noreply.github.com>
Co-authored-by: Ryan Christian <rchristian@ryanchristian.dev>
  • Loading branch information
3 people committed May 27, 2022
1 parent c6915eb commit 1e0b9ad
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules
/npm-debug.log
.DS_Store
/match/*.js
/match/*.mjs
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@
"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"
},
"scripts": {
"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",
Expand Down
2 changes: 1 addition & 1 deletion test/dist.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 1e0b9ad

Please sign in to comment.