Skip to content

Commit 1e7071a

Browse files
committed
feat: refactor build to add ESM export
1 parent 62c6142 commit 1e7071a

18 files changed

+16001
-8215
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
npm-debug.log
22
node_modules
33
coverage.html
4-
lib
4+
dist
5+
.tshy

benchmark/benchmark.ts

+3
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ function benchmark(name: string, tests: {[key: string]: () => void}) {
156156
console.log(`${indent}${secondIndent}#${i + 1}: ${benchmarkText}`);
157157
}
158158
});
159+
suite.on('error', function (event: {target: Benchmark}) {
160+
console.error(event.target.error);
161+
});
159162
suite.run();
160163
console.log();
161164
}

benchmark/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"type": "commonjs"}

eslint.config.mjs

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default tseslint.config(
1919
"no-duplicate-imports": ["error", {"includeExports": true}],
2020
"arrow-body-style": ["error", "as-needed"],
2121
"no-restricted-globals": ["error", "name", "toString", "pending"],
22+
"import/no-unresolved": "off",
2223
"import/order": ["error", {
2324
"groups": ["builtin", "external", "internal", "sibling"],
2425
"pathGroupsExcludedImportTypes": ["parent", "sibling", "index"],
@@ -27,6 +28,7 @@ export default tseslint.config(
2728
"caseInsensitive": true
2829
}
2930
}]
30-
}
31+
},
32+
ignores: ["dist"]
3133
}
3234
);

jest.config.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { createDefaultEsmPreset, createDefaultPreset } from 'ts-jest'
2+
3+
export default {
4+
...(process.env.TEST_DIST === 'esm' ?
5+
createDefaultEsmPreset({tsconfig: 'tsconfig.esm.json', diagnostics: { ignoreCodes: ['TS151001'] }}) :
6+
createDefaultPreset()),
7+
...(!process.env.TEST_DIST ? {
8+
moduleNameMapper: {
9+
'^(.+)\\.js$': '$1',
10+
}
11+
} : {}),
12+
testPathIgnorePatterns: ["/node_modules/", "/dist/", "/test-apps/"],
13+
}

0 commit comments

Comments
 (0)