diff --git a/jest.config.cjs b/jest.config.cjs new file mode 100644 index 00000000..7268e883 --- /dev/null +++ b/jest.config.cjs @@ -0,0 +1,19 @@ +/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ +module.exports = { + moduleNameMapper: { + '^(\\.{1,2}/.*)\\.js$': '$1', + }, + transform: { + // '^.+\\.[tj]sx?$' to process js/ts with `ts-jest` + // '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest` + '^.+\\.m?[tj]sx?$': [ + 'ts-jest', + { + useESM: true, + }, + ], + }, + testEnvironment: 'node', + moduleDirectories: ['node_modules', 'src'], + modulePathIgnorePatterns: ["tests/testutils.test.ts"], +}; \ No newline at end of file diff --git a/jest.config.js b/jest.config.js deleted file mode 100644 index f8be42bb..00000000 --- a/jest.config.js +++ /dev/null @@ -1,6 +0,0 @@ -/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ -module.exports = { - preset: 'ts-jest', - testEnvironment: 'node', - modulePathIgnorePatterns: ["tests/testutils.test.ts"], -}; \ No newline at end of file diff --git a/tsconfig.esm.json b/tsconfig.esm.json new file mode 100644 index 00000000..c1340ea2 --- /dev/null +++ b/tsconfig.esm.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ + "outDir": "build/esm", /* Redirect output structure to the directory. */ + "target": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ + } +} \ No newline at end of file