Skip to content

Commit f61fc53

Browse files
authored
Merge pull request #81 from coren-frankel/node-esm-config
Node ESM configuration w/ CJS & ESM build outputs
2 parents 7f53b76 + bccbbb1 commit f61fc53

12 files changed

+377
-47
lines changed
File renamed without changes.

jest.config.js renamed to jest.config.cjs

+17-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
// https://jestjs.io/docs/en/configuration.html
33

44
module.exports = {
5+
// ESM config
6+
transform: {
7+
'^.+\\.tsx?$': [
8+
'ts-jest',
9+
{
10+
useESM: true,
11+
},
12+
],
13+
},
14+
515
// All imported modules in your tests should be mocked automatically
616
// automock: false,
717

@@ -91,8 +101,10 @@ module.exports = {
91101
// An enum that specifies notification mode. Requires { notify: true }
92102
// notifyMode: "failure-change",
93103

94-
// A preset that is used as a base for Jest's configuration
95-
preset: 'ts-jest',
104+
// A preset that is used as a base for Jest's configuration;
105+
// https://kulshekhar.github.io/ts-jest/docs/guides/esm-support/#esm-presets
106+
// If you are using custom transform config, please remove preset from your Jest config to avoid issues that Jest doesn't transform files correctly.
107+
// preset: 'ts-jest',
96108

97109
// Run tests from one or more projects
98110
// projects: undefined,
@@ -170,9 +182,9 @@ module.exports = {
170182
// transform: undefined,
171183

172184
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
173-
// transformIgnorePatterns: [
174-
// "/node_modules/"
175-
// ],
185+
transformIgnorePatterns: [
186+
"/node_modules/"
187+
],
176188

177189
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
178190
// unmockedModulePathPatterns: undefined,

0 commit comments

Comments
 (0)