Skip to content
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

OPS-4906 ESM, upgrade string-length #293

Merged
merged 3 commits into from
Jan 15, 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
16 changes: 16 additions & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const ES_PACKAGES_TO_TRANSFORM = [];

/** @type {import('jest').Config} */
const config = {
collectCoverageFrom: ['src/**/*.ts', '!src/**/types.ts'],
reporters: ['default'],
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
resolver: 'ts-jest-resolver',
transformIgnorePatterns: [
`node_modules/(?!(${ES_PACKAGES_TO_TRANSFORM.join('|')}))/node_modules/.+\\.js`,
],
};

export default config;
29 changes: 15 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@
"email": "[email protected]",
"url": "https://shelf.io"
},
"main": "lib",
"sideEffects": false,
"type": "module",
"exports": "./lib/index.js",
"module": "./lib/index.js",
"types": "lib/index.d.ts",
"files": [
"lib"
],
"scripts": {
"benchmark": "babel benchmark.ts | node",
"build": "rm -rf lib/ && yarn build:types && babel src --out-dir lib --ignore '**/*.test.ts' --extensions '.ts'",
"build:types": "tsc --emitDeclarationOnly --declaration --isolatedModules false --declarationDir lib",
"benchmark": "tsx benchmark.ts",
"build": "rm -rf lib/ && tsc",
"coverage": "jest --coverage",
"lint": "yarn lint:ci --fix",
"lint:ci": "eslint . --quiet",
"prepack": "yarn build",
"test": "jest src",
"type-check": "tsc --noEmit",
"type-check:watch": "npm run type-check -- --watch"
Expand All @@ -43,22 +44,20 @@
"eslint --fix"
]
},
"babel": {
"extends": "@shelf/babel-config/backend"
},
"jest": {
"testEnvironment": "node"
"resolutions": {
"strip-ansi": "6.0.1",
"wrap-ansi": "7.0.0",
"string-width": "4.2.3"
},
"dependencies": {
"runes": "0.4.3",
"string-length": "4.0.2"
"string-length": "6.0.0"
},
"devDependencies": {
"@babel/cli": "7.26.4",
"@babel/core": "7.26.0",
"@shelf/babel-config": "3.0.0",
"@shelf/eslint-config": "4.4.0",
"@shelf/tsconfig": "0.1.0",
"@swc/core": "1.10.7",
"@swc/jest": "0.2.37",
"@types/benchmark": "2.1.5",
"@types/jest": "29.5.14",
"@types/node": "18",
Expand All @@ -70,6 +69,8 @@
"jest": "29.7.0",
"lint-staged": "15.3.0",
"prettier": "3.4.2",
"ts-jest-resolver": "2.0.1",
"tsx": "4.19.2",
"typescript": "5.7.3"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fastChunkString from './index';
import fastChunkString from './index.js';

const text = 'hello my dear world';

Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import runes from 'runes';
import stringLength from 'string-length';

export default function fastChunkString(
function fastChunkString(
str: string,
{
size,
Expand Down Expand Up @@ -49,4 +49,4 @@ function getChunksUnicode(str: string, size: number): string[] {

return chunks;
}
module.exports = fastChunkString;
export default fastChunkString;
11 changes: 9 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
{
"extends": "@shelf/tsconfig/backend",
"compilerOptions": {
"strict": true
"strict": true,
"module": "ESNext",
"target": "ESNext",
"moduleResolution": "bundler",
"declaration": true,
"resolveJsonModule": true,
"declarationMap": true,
"outDir": "lib"
},
"exclude": ["node_modules"],
"exclude": ["node_modules", "**/*.test.*", "**/mocks.ts"],
"include": ["src"]
}
Loading