Skip to content

Commit 07b8ef2

Browse files
authored
Merge pull request #4 from MatrixAI/feature-conversion-to-esm
Conversion to ESM
2 parents c4dc04a + 305487b commit 07b8ef2

26 files changed

+5223
-5063
lines changed

.eslintrc

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

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,6 @@ dist
130130
# editor
131131
.vscode/
132132
.idea/
133+
134+
# prettier for local editor-based linting
135+
.prettierrc

.npmrc

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

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
shell = { ci ? false }:
1515
with pkgs;
1616
pkgs.mkShell {
17-
nativeBuildInputs = [ nodejs_20 shellcheck gitAndTools.gh ];
17+
nativeBuildInputs = [ nodejs_20 gitAndTools.gh ];
1818
PKG_IGNORE_TAG = 1;
1919
shellHook = ''
2020
echo "Entering $(npm pkg get name)"

jest.config.js renamed to jest.config.mjs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
const path = require('path');
2-
const { pathsToModuleNameMapper } = require('ts-jest');
3-
const { compilerOptions } = require('./tsconfig');
1+
import path from 'node:path';
2+
import url from 'node:url';
3+
import tsconfigJSON from './tsconfig.json' assert { type: "json" };
44

5-
const moduleNameMapper = pathsToModuleNameMapper(compilerOptions.paths, {
6-
prefix: '<rootDir>/src/',
7-
});
5+
const projectPath = path.dirname(url.fileURLToPath(import.meta.url));
86

97
// Global variables that are shared across the jest worker pool
108
// These variables must be static and serializable
119
const globals = {
1210
// Absolute directory to the project root
13-
projectDir: __dirname,
11+
projectDir: projectPath,
1412
// Absolute directory to the test root
15-
testDir: path.join(__dirname, 'tests'),
13+
testDir: path.join(projectPath, 'tests'),
1614
// Default asynchronous test timeout
1715
defaultTimeout: 20000,
1816
// Timeouts rely on setTimeout which takes 32 bit numbers
@@ -24,7 +22,7 @@ const globals = {
2422
// They can however receive the process environment
2523
// Use `process.env` to set variables
2624

27-
module.exports = {
25+
const config = {
2826
testEnvironment: 'node',
2927
verbose: true,
3028
collectCoverage: false,
@@ -40,10 +38,10 @@ module.exports = {
4038
parser: {
4139
syntax: "typescript",
4240
tsx: true,
43-
decorators: compilerOptions.experimentalDecorators,
41+
decorators: tsconfigJSON.compilerOptions.experimentalDecorators,
4442
dynamicImport: true,
4543
},
46-
target: compilerOptions.target.toLowerCase(),
44+
target: tsconfigJSON.compilerOptions.target.toLowerCase(),
4745
keepClassNames: true,
4846
},
4947
}
@@ -77,5 +75,10 @@ module.exports = {
7775
'jest-extended/all',
7876
'<rootDir>/tests/setupAfterEnv.ts'
7977
],
80-
moduleNameMapper: moduleNameMapper,
78+
moduleNameMapper: {
79+
"^(\\.{1,2}/.*)\\.js$": "$1",
80+
},
81+
extensionsToTreatAsEsm: ['.ts', '.tsx', '.mts'],
8182
};
83+
84+
export default config;

0 commit comments

Comments
 (0)