Skip to content

Commit

Permalink
Merge pull request #127 from shelfio/feature/migration-to-esm
Browse files Browse the repository at this point in the history
Migrate package to ESM format
  • Loading branch information
batovpasha authored Aug 2, 2023
2 parents 4f030e6 + d57f9de commit 2e8a48f
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 15 deletions.
8 changes: 5 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ orbs:
parameters:
node_version:
type: string
default: '16.15.0'
default: '16.17.0'

commands:
install_deps:
Expand All @@ -15,7 +15,9 @@ commands:
pkg-manager: yarn
cache-version: v1-all
app-dir: ~/repo
override-ci-command: yarn install --pure-lockfile --ignore-scripts --no-progress
override-ci-command: >
npx --yes retry-cli -n 5 -t 3000 --
yarn install --pure-lockfile --ignore-scripts --no-progress
jobs:
build:
Expand All @@ -26,6 +28,6 @@ jobs:
steps:
- checkout
- install_deps
- run: yarn test --maxWorkers=4
- run: yarn type-check
- run: yarn lint:ci
- run: yarn coverage --maxWorkers=4
18 changes: 18 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type {Config} from 'jest';

const config: Config = {
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
resetMocks: true,
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
};

export default config;
18 changes: 8 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@
"email": "[email protected]",
"url": "https://shelf.io"
},
"main": "lib",
"sideEffects": false,
"type": "module",
"exports": "./lib/index.js",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
"lib"
],
"scripts": {
"benchmark:memory": "yarn build && cd benchmark/memory && ./test.sh",
"benchmark:speed": "yarn build && cd benchmark/speed && babel test.ts | node",
"build": "rm -rf lib/ && yarn build:types && yarn build:code",
"build:code": "babel src --out-dir lib --ignore '**/*.test.ts' --extensions '.ts' && find ./lib -name '*.test.d.ts' -delete",
"build:types": "tsc --emitDeclarationOnly --declaration --isolatedModules false --declarationDir lib",
"build": "rm -rf lib/ && tsc",
"coverage": "yarn test --coverage",
"lint": "yarn lint:ci --fix",
"lint:ci": "eslint . --ext .js,.ts,.json",
Expand All @@ -35,17 +36,13 @@
"eslint --fix"
]
},
"babel": {
"extends": "@shelf/babel-config/backend"
},
"prettier": "@shelf/prettier-config",
"devDependencies": {
"@babel/cli": "7.22.5",
"@babel/core": "7.22.5",
"@shelf/babel-config": "1.2.0",
"@shelf/eslint-config": "2.27.1",
"@shelf/prettier-config": "1.0.0",
"@shelf/tsconfig": "0.0.11",
"@swc/core": "1.3.73",
"@swc/jest": "0.2.27",
"@types/jest": "29.4.0",
"@types/node": "14",
"benny": "3.7.1",
Expand All @@ -56,6 +53,7 @@
"lint-staged": "13.2.2",
"normalize-space-x": "4.1.2",
"prettier": "2.8.8",
"ts-node": "10.9.1",
"typescript": "5.1.3"
},
"engines": {
Expand Down
6 changes: 6 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ describe('#normalizeSpaces', () => {
expect(result).toEqual('a b');
});

it('should normalize text without spaces at the start and at the end correctly', () => {
const result = normalizeSpaces(`a${ALL_WHITESPACE_CHARS_2018}b`);

expect(result).toEqual('a b');
});

it('should normalize text with character that consists of surrogate pairs correctly', () => {
const result = normalizeSpaces(' hello \n\n\n interesting \n \n \tworld 😀 ');

Expand Down
10 changes: 8 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{
"extends": "@shelf/tsconfig/backend",
"compilerOptions": {
"strict": true
"strict": true,
"module": "ESNext",
"target": "ESNext",
"moduleResolution": "node",
"declaration": true,
"resolveJsonModule": false,
"outDir": "lib"
},
"exclude": ["node_modules"],
"exclude": ["node_modules", "**/*.test.*", "**/*.mock.ts"],
"include": ["src"]
}

0 comments on commit 2e8a48f

Please sign in to comment.