Skip to content

Commit 729abcd

Browse files
feat: OPS-4906 ESM
1 parent f3e6160 commit 729abcd

File tree

4 files changed

+41
-16
lines changed

4 files changed

+41
-16
lines changed

jest.config.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const ES_PACKAGES_TO_TRANSFORM = [];
2+
3+
/** @type {import('jest').Config} */
4+
const config = {
5+
collectCoverageFrom: ['src/**/*.ts', '!src/**/types.ts'],
6+
reporters: ['default'],
7+
transform: {
8+
'^.+\\.(t|j)sx?$': '@swc/jest',
9+
},
10+
resolver: 'ts-jest-resolver',
11+
transformIgnorePatterns: [
12+
`node_modules/(?!(${ES_PACKAGES_TO_TRANSFORM.join('|')}))/node_modules/.+\\.js`,
13+
],
14+
};
15+
16+
export default config;

package.json

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@
1818
"email": "vlad@shelf.io",
1919
"url": "https://shelf.io"
2020
},
21-
"main": "lib",
21+
"sideEffects": false,
22+
"type": "module",
23+
"exports": "./lib/index.js",
24+
"module": "./lib/index.js",
2225
"types": "lib/index.d.ts",
2326
"files": [
2427
"lib"
2528
],
2629
"scripts": {
27-
"benchmark": "babel benchmark.ts | node",
28-
"build": "rm -rf lib/ && yarn build:types && babel src --out-dir lib --ignore '**/*.test.ts' --extensions '.ts'",
29-
"build:types": "tsc --emitDeclarationOnly --declaration --isolatedModules false --declarationDir lib",
30+
"benchmark": "tsx benchmark.ts",
31+
"build": "rm -rf lib/ && tsc",
3032
"coverage": "jest --coverage",
3133
"lint": "yarn lint:ci --fix",
3234
"lint:ci": "eslint . --quiet",
@@ -43,22 +45,20 @@
4345
"eslint --fix"
4446
]
4547
},
46-
"babel": {
47-
"extends": "@shelf/babel-config/backend"
48-
},
49-
"jest": {
50-
"testEnvironment": "node"
48+
"resolutions": {
49+
"strip-ansi": "6.0.1",
50+
"wrap-ansi": "7.0.0",
51+
"string-width": "4.2.3"
5152
},
5253
"dependencies": {
5354
"runes": "0.4.3",
54-
"string-length": "4.0.2"
55+
"string-length": "6.0.0"
5556
},
5657
"devDependencies": {
57-
"@babel/cli": "7.26.4",
58-
"@babel/core": "7.26.0",
59-
"@shelf/babel-config": "3.0.0",
6058
"@shelf/eslint-config": "4.4.0",
6159
"@shelf/tsconfig": "0.1.0",
60+
"@swc/core": "1.10.7",
61+
"@swc/jest": "0.2.37",
6262
"@types/benchmark": "2.1.5",
6363
"@types/jest": "29.5.14",
6464
"@types/node": "18",
@@ -70,6 +70,8 @@
7070
"jest": "29.7.0",
7171
"lint-staged": "15.3.0",
7272
"prettier": "3.4.2",
73+
"ts-jest-resolver": "2.0.1",
74+
"tsx": "4.19.2",
7375
"typescript": "5.7.3"
7476
},
7577
"engines": {

src/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fastChunkString from './index';
1+
import fastChunkString from './index.js';
22

33
const text = 'hello my dear world';
44

tsconfig.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
{
22
"extends": "@shelf/tsconfig/backend",
33
"compilerOptions": {
4-
"strict": true
4+
"strict": true,
5+
"module": "ESNext",
6+
"target": "ESNext",
7+
"moduleResolution": "bundler",
8+
"declaration": true,
9+
"resolveJsonModule": true,
10+
"declarationMap": true,
11+
"outDir": "lib"
512
},
6-
"exclude": ["node_modules"],
13+
"exclude": ["node_modules", "**/*.test.*", "**/mocks.ts"],
714
"include": ["src"]
815
}

0 commit comments

Comments
 (0)