Skip to content

Commit 42f54e8

Browse files
committed
Migrate package to ECMAScript modules
BREAKING CHANGE: parse-domain will now be released as native ECMAScript module. There's no CommonJS build anymore. If you're still using CommonJS, you need to import it asynchronously using `await import("parse-domain")`. If you're still using Node 12, you may need to update it to the latest 12.x version.
1 parent 371b07f commit 42f54e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+597
-4572
lines changed

.eslintrc.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

.eslintrc.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": [
3+
"peerigon/presets/prettier-typescript.js",
4+
// See https://github.com/peerigon/eslint-config-peerigon#peerigonstylesno-default-export
5+
"peerigon/styles/no-default-export",
6+
"peerigon/styles/no-null"
7+
],
8+
"env": {
9+
"node": true
10+
},
11+
"root": true
12+
}

.github/workflows/test-and-release.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ jobs:
2020
- name: 🛑 Cancel Previous Runs
2121
uses: styfle/cancel-workflow-action@a40b8845c0683271d9f53dfcb887a7e181d3918b # [email protected]
2222
- name: ⬇️ Checkout repo
23-
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # pin@v2
23+
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # pin@v2
2424
- name: ⎔ Setup node ${{ matrix.node-version }}
25-
uses: actions/setup-node@25316bbc1f10ac9d8798711f44914b1cf3c4e954 # pin@v2
25+
uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561 # pin@v2
2626
with:
2727
node-version: ${{ matrix.node-version }}
2828
cache: "npm"
2929
- name: 🗄 Cache node_modules
3030
id: cache-node_modules
31-
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # pin@v2
31+
uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed # pin@v2
3232
with:
3333
path: "**/node_modules"
3434
key: node_modules-${{ runner.os }}-node-${{ matrix.node-version }}-${{
3535
hashFiles('**/package-lock.json') }}
3636
- name: 🗄 Cache .eslintcache
37-
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # pin@v2
37+
uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed # pin@v2
3838
with:
3939
path: .eslintcache
4040
key: eslintcache-${{ runner.os }}-node-${{ matrix.node-version }}-${{
@@ -45,7 +45,8 @@ jobs:
4545
npm ci --ignore-scripts
4646
- name: 🧪 Test
4747
run: |
48-
npm run test
48+
npm run prepare:build
49+
npm test
4950
env:
5051
CI: true
5152
- name: ⬆️ Upload coverage report

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ coverage
2323
# node-waf configuration
2424
.lock-wscript
2525

26-
# Compiled binary addons (http://nodejs.org/api/addons.html)
27-
build/Release
2826

2927
# Dependency directory
3028
node_modules
@@ -36,7 +34,7 @@ node_modules
3634
.node_repl_history
3735

3836
# We don't check in compiled files. They are created upon npm publish and npm install.
39-
build-esm
40-
build-cjs
37+
build
38+
serialized-tries
4139

4240
.eslintcache

bin/update.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
#!/usr/bin/env node
22

3-
"use strict";
4-
5-
const { EOL } = require("os");
3+
import { EOL } from "os";
64

75
(async () => {
8-
process.argv.push(
9-
"--",
10-
"../../serialized-tries",
11-
"../../../build-esm/serialized-tries"
12-
);
6+
process.argv.push("--", "../../serialized-tries");
7+
8+
const updateTries = await import("../build/scripts/update-tries.js");
139

14-
await require("../build-cjs/src/scripts/update-tries.js").done;
10+
await updateTries.done;
1511

1612
process.stderr.write("Running smoke test... ");
1713

18-
require("../build-cjs/src/smoke-test.js").runSmokeTest();
14+
const smokeTest = await import("../build/smoke-test.js");
15+
16+
smokeTest.runSmokeTest();
1917

2018
process.stdout.write("ok" + EOL);
2119
})().catch((error) => {
2220
console.error(`parse-domain update failed: ${error}`);
23-
// eslint-disable-next-line no-process-exit, node/no-process-exit
2421
process.exit(1);
2522
});

jest.config.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
"use strict";
2-
3-
module.exports = {
1+
// eslint-disable-next-line import/no-default-export
2+
export default {
43
roots: ["<rootDir>/src"],
54
transform: {
65
"^.+\\.tsx?$": "ts-jest",
76
},
7+
extensionsToTreatAsEsm: [".ts"],
8+
moduleNameMapper: {
9+
"^(\\.{1,2}/.*)\\.js$": "$1",
10+
},
811
globals: {
912
"ts-jest": {
10-
diagnostics: false,
13+
useESM: true,
1114
},
1215
},
1316
collectCoverage: true,

0 commit comments

Comments
 (0)