Skip to content

Enable esm again #19

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 3 commits into from
Sep 22, 2024
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
7 changes: 5 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
# python-version: '3.12'
cache: 'pip'
- uses: pre-commit/[email protected]

Expand All @@ -23,7 +24,7 @@ jobs:

strategy:
matrix:
node-version: [18.x, 20.x]
node-version: [20.x, 22.x]

steps:
- uses: actions/checkout@v4
Expand All @@ -38,3 +39,5 @@ jobs:
- run: npm run format
- run: npm run build:debug
- run: npm run build:prod
- run: npm run check:esmloads
- run: npm run check:cjsloads
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# Created by git when using merge tools for conflicts
*.BACKUP.*
*.BASE.*
!tsconfig.base*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
Expand Down Expand Up @@ -395,3 +396,4 @@ $RECYCLE.BIN/
*.lnk

# End of https://www.gitignore.io/api/git,node,linux,macos,python,pycharm,windows,visualstudiocode
build*/
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*
!dist/**
!src/**
!package*json
!README*
!tsconfig*
tsconfig.eslint.json
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repos: #The order matters, we want prospector to run after all the sorting was d
- id: check-json
# JSON that are not json
# (?x) means verbose (we can add spaces for better readibility, but they are ignored)
exclude: (?x) ^(tsconfig(\.\w+)? | \.vscode/.*) \.json$
exclude: (?x) /?(tsconfig(\.\w+)? | \.vscode/.*) \.json$
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
Expand All @@ -19,10 +19,10 @@ repos: #The order matters, we want prospector to run after all the sorting was d
# File normalization
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-prettier
rev: 'v3.1.0'
hooks:
- id: prettier
additional_dependencies:
- [email protected]
- [email protected]
# - repo: https://github.com/pre-commit/mirrors-prettier
# rev: 'v3.1.0'
# hooks:
# - id: prettier
# additional_dependencies:
# - [email protected]
# - [email protected]
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
},
"editor.formatOnSaveMode": "modificationsIfAvailable",
"[javascript,typescript,jsonc,json]": {
"editor.indentSize": "tabSize",
"editor.tabSize": 2,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSaveMode": "modificationsIfAvailable",
},
"eslint.experimental.useFlatConfig": true,
"eslint.useFlatConfig": true,
"jest.jestCommandLine": "npm test -- ",
"jest.runMode": {
"type": "on-demand",
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default [
project: [
'./tsconfig.eslint.json',
'./tsconfig.json',
'./tsconfig.prod.json',
'./tsconfig.node.json',
],
},
},
Expand Down
47 changes: 37 additions & 10 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,44 @@
import type { JestConfigWithTsJest } from 'ts-jest';
import {
createDefaultEsmPreset,
pathsToModuleNameMapper,
type JestConfigWithTsJest,
} from 'ts-jest';

import { compilerOptions } from './tsconfig.aliases.json';
import packageJson from './package.json';

const pathAliases = {
...compilerOptions.paths,
// Jest wants to know the folder to do the transformation, not the `src/index.js`. 🤷
[packageJson.name]: ['src'],
};

// See here for more info https://kulshekhar.github.io/ts-jest/docs/getting-started/presets/#advanced
const preset = createDefaultEsmPreset({
tsconfig: './tests/tsconfig.json',
});

const config: JestConfigWithTsJest = {
preset: 'ts-jest',
testRegex: [
'/tests/.*tests?.[jt]sx?',
'/__tests__/.*tests?.[jt]sx?',
'.*.(spec|test).[jt]sx?',
],
...preset,
roots: ['<rootDir>'],
modulePaths: [compilerOptions.baseUrl],
moduleNameMapper: pathsToModuleNameMapper(pathAliases, {
useESM: true,
}),
modulePathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/build/'],
testRegex: ['/tests/.*tests?.[mc]?[jt]sx?$', '.*.(spec|test).[mc]?[jt]sx?$'],
// I dono't think we need to run the spec multiple times.. the functional test on tests/ maybe.
// We can change this if we consider it useful to run the spec tests when the code is transpiled to javascript
testPathIgnorePatterns: ['node_modules', 'build/'],
// We can change this back if we consider it useful to run the spec tests when the code is transpiled to javascript
testPathIgnorePatterns: [
'node_modules',
'<rootDir>/build[^/]*/',
'<rootDir>/dist/',
],
testEnvironment: 'node',
collectCoverageFrom: ['src/**/*.{js,ts,jsx,tsx}'],
collectCoverageFrom: [
'src/**/*.{js,ts,jsx,tsx}',
'!src/**/*.{spec,test}.{js,ts,jsx,tsx}',
],
verbose: true,
// Important to use the AfterEnv to have the jest timeout and all the other settings inside that file to be correctly understood
// See the difference between setupFiles and setupFilesAfterEnv to see the difference.
Expand Down
Loading
Loading