Skip to content

Commit ddda8ae

Browse files
Merge pull request #293 from shelfio/feature/OPS-4906-esm
OPS-4906 ESM, upgrade string-length
2 parents f3e6160 + d6b4e32 commit ddda8ae

File tree

5 files changed

+43
-19
lines changed

5 files changed

+43
-19
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 & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,20 @@
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",
33-
"prepack": "yarn build",
3435
"test": "jest src",
3536
"type-check": "tsc --noEmit",
3637
"type-check:watch": "npm run type-check -- --watch"
@@ -43,22 +44,20 @@
4344
"eslint --fix"
4445
]
4546
},
46-
"babel": {
47-
"extends": "@shelf/babel-config/backend"
48-
},
49-
"jest": {
50-
"testEnvironment": "node"
47+
"resolutions": {
48+
"strip-ansi": "6.0.1",
49+
"wrap-ansi": "7.0.0",
50+
"string-width": "4.2.3"
5151
},
5252
"dependencies": {
5353
"runes": "0.4.3",
54-
"string-length": "4.0.2"
54+
"string-length": "6.0.0"
5555
},
5656
"devDependencies": {
57-
"@babel/cli": "7.26.4",
58-
"@babel/core": "7.26.0",
59-
"@shelf/babel-config": "3.0.0",
6057
"@shelf/eslint-config": "4.4.0",
6158
"@shelf/tsconfig": "0.1.0",
59+
"@swc/core": "1.10.7",
60+
"@swc/jest": "0.2.37",
6261
"@types/benchmark": "2.1.5",
6362
"@types/jest": "29.5.14",
6463
"@types/node": "18",
@@ -70,6 +69,8 @@
7069
"jest": "29.7.0",
7170
"lint-staged": "15.3.0",
7271
"prettier": "3.4.2",
72+
"ts-jest-resolver": "2.0.1",
73+
"tsx": "4.19.2",
7374
"typescript": "5.7.3"
7475
},
7576
"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

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import runes from 'runes';
22
import stringLength from 'string-length';
33

4-
export default function fastChunkString(
4+
function fastChunkString(
55
str: string,
66
{
77
size,
@@ -49,4 +49,4 @@ function getChunksUnicode(str: string, size: number): string[] {
4949

5050
return chunks;
5151
}
52-
module.exports = fastChunkString;
52+
export default fastChunkString;

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)