Skip to content

Migration to ESM #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@
"jest": true
},
"parser": "@typescript-eslint/parser",
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"prettier"
],
"plugins": [
"import"
],
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": [
"import"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"rules": {
"linebreak-style": ["error", "unix"],
"no-empty": 1,
Expand Down Expand Up @@ -182,3 +181,4 @@
]
}
}

2 changes: 0 additions & 2 deletions .npmrc

This file was deleted.

60 changes: 11 additions & 49 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ npm run prebuild
# build the dist and native objects
npm run build
# run the repl (this allows you to import from ./src)
npm run ts-node
npm run tsx
# run the tests
npm run test
# lint the source code
Expand Down
27 changes: 15 additions & 12 deletions jest.config.js → jest.config.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
const path = require('path');
const { pathsToModuleNameMapper } = require('ts-jest');
const { compilerOptions } = require('./tsconfig');
import path from 'node:path';
import url from 'node:url';
import tsconfigJSON from './tsconfig.json' assert { type: "json" };

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

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

module.exports = {
const config = {
testEnvironment: 'node',
verbose: true,
collectCoverage: false,
Expand All @@ -40,10 +38,10 @@ module.exports = {
parser: {
syntax: "typescript",
tsx: true,
decorators: compilerOptions.experimentalDecorators,
decorators: tsconfigJSON.compilerOptions.experimentalDecorators,
dynamicImport: true,
},
target: compilerOptions.target.toLowerCase(),
target: tsconfigJSON.compilerOptions.target.toLowerCase(),
keepClassNames: true,
},
}
Expand Down Expand Up @@ -77,5 +75,10 @@ module.exports = {
'jest-extended/all',
'<rootDir>/tests/setupAfterEnv.ts'
],
moduleNameMapper: moduleNameMapper,
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
extensionsToTreatAsEsm: ['.ts', '.tsx', '.mts'],
};

export default config;
Loading