Skip to content

Commit

Permalink
chore: upgrade deps add configs
Browse files Browse the repository at this point in the history
- Remove TypeScript config `noImplicitAny` and `noImplicitTHis`.
  They are both enabled under `strict` in TSC >=5.0

- Remove `noUnusedLocals`: this should be checked by a linter.

- Enable skipLibCheck (recommended by TSC)

- Remove stripInternal (no use)

- Add tsconfig and rome $schema for auto-completion in IDE

- Remove `npx` in scripts: it incurs a 30% slowdown.

- Specify `--target` for _ESbuild_.
  _ESbuild_ >= 0.18.0 no longer relies on `tsconfig`'s `target` option.
  • Loading branch information
Conaclos committed Jun 19, 2023
1 parent 4c5b501 commit 21dbee5
Show file tree
Hide file tree
Showing 10 changed files with 280 additions and 293 deletions.
510 changes: 255 additions & 255 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@
"test": "sh ./scripts/test.sh"
},
"devDependencies": {
"esbuild": "0.17.12",
"oletus": "3.3.0",
"rome": "12.0.0",
"typescript": "5.0.2",
"esbuild": "0.18.0",
"oletus": "4.0.0",
"rome": "12.1.3",
"typescript": "5.1.3",
"validate-commit-message": "3.2.0"
}
}
5 changes: 2 additions & 3 deletions rome.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
{
"$schema": "https://docs.rome.tools/schemas/12.1.3/schema.json",
"formatter": {
"indentStyle": "space",
"indentSize": 4,
"ignore": ["*.json", "./tsconfig-base.json"]
"ignore": ["*.json"]
},
"linter": {
"enabled": true,
"rules": {
"all": true
}
},
"javascript": {
"formatter": {
"quoteProperties": "preserve",
"semicolons": "asNeeded"
}
},
Expand Down
8 changes: 6 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#!/bin/sh
set -eu

# https://node.green/#ES2020
# https://kangax.github.io/compat-table/es2016plus
TARGET=es2020

# build ESM
esbuild src/*.ts src/*/*.ts --platform=neutral --outdir=dist --log-level=warning
esbuild src/*.ts src/*/*.ts --target=$TARGET --platform=neutral --outdir=dist --log-level=warning

# build .d.ts
tsc --build src

# build CommonJS (fallback)
esbuild src/index.ts --bundle --platform=node > dist/index.cjs
esbuild src/index.ts --bundle --target=$TARGET --platform=node > dist/index.cjs

cp -f dist/index.d.ts dist/index.d.cts
4 changes: 2 additions & 2 deletions src/env/dev.node.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
declare const process: { readonly env: Record<string, string | undefined> }
declare const process: { readonly env: { NODE_ENV: string | undefined } }

export const DEV: boolean = process.env["NODE_ENV"] === "development"
export const DEV: boolean = process.env.NODE_ENV === "development"
10 changes: 4 additions & 6 deletions src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
"extends": "../tsconfig-base.json",
"compilerOptions": {
"outDir": "../dist",
"noEmit": false,
"composite": true,
"emitDeclarationOnly": true,

"composite": true
},
"include": ["**/*.ts"]
"noEmit": false,
"outDir": "../dist"
}
}
5 changes: 0 additions & 5 deletions tests/codec/_util.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion tests/codec/_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ByteCursor, Config } from "@bare-ts/lib"

/**
*
* @param {...number[]} rest
* @param {...number} rest
* @returns {ByteCursor}
*/
export function fromBytes(...rest) {
Expand Down
8 changes: 1 addition & 7 deletions tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{
"extends": "../tsconfig-base.json",
"compilerOptions": {
"moduleResolution": "node",
"paths": { "@bare-ts/lib": ["../src/index.js"] }
},
"include": ["**/*.js", "**/*.ts"],
"references": [{ "path": "../src" }]
"extends": "../tsconfig-base.json"
}
13 changes: 5 additions & 8 deletions tsconfig-base.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
// https://node.green/#ES2020
// https://kangax.github.io/compat-table/es2016plus
"lib": ["ES2020"],
"moduleResolution": "node16",
"module": "ES2020",
"moduleResolution": "node16",
"target": "ES2020",

// Don't implicitly import @types/*
"types": [],

"noEmit": true,
"sourceMap": true,
"stripInternal": true,

"types": [],

"esModuleInterop": true,
"isolatedModules": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"verbatimModuleSyntax": true,

"allowUnreachableCode": false,
Expand Down

0 comments on commit 21dbee5

Please sign in to comment.