@checkdigit/typescript-config 7.0.0-PR.54-457d → 7.0.0-PR.54-665c
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE.txt +1 -1
- package/README.md +10 -16
- package/bin/builder.mjs +4 -4
- package/package.json +1 -1
package/LICENSE.txt
CHANGED
package/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[![MIT License](https://img.shields.io/github/license/checkdigit/typescript-config)](https://github.com/checkdigit/typescript-config/blob/master/LICENSE.txt)
|
4
4
|
|
5
|
-
Copyright (c) 2022
|
5
|
+
Copyright (c) 2022–2024 [Check Digit, LLC](https://checkdigit.com)
|
6
6
|
|
7
7
|
### Introduction
|
8
8
|
|
@@ -12,23 +12,23 @@ This module contains the standard Check Digit Typescript configuration, along wi
|
|
12
12
|
|
13
13
|
- currently requires Node 20.11 or above.
|
14
14
|
- emits `esnext`, with the default libraries, to avoid down-leveling. It is intended that application spec tests pick
|
15
|
-
up any issues with using newer features unavailable in a particular environment. Browsers and NodeJS are fast
|
15
|
+
up any issues with using newer features unavailable in a particular environment. Browsers and NodeJS are fast-moving
|
16
16
|
targets, and can add language features at any time.
|
17
|
-
- uses the `module` type of `
|
17
|
+
- uses the `module` type of `esnext`.
|
18
18
|
- all compiler options set for maximum strictness.
|
19
19
|
|
20
20
|
### Builder
|
21
21
|
|
22
|
-
`builder` is a command line tool that generates either CommonJS or ESM modules, from Typescript source.
|
23
|
-
to be used when publishing a package to NPM, or to bundle a package for deployment.
|
24
|
-
types, and `esbuild` for generating code.
|
22
|
+
`builder` is a command line tool that generates either CommonJS or ESM modules, from the Typescript source.
|
23
|
+
It is intended to be used when publishing a package to NPM, or to bundle a package for deployment.
|
24
|
+
It uses `tsc` for generating types, and `esbuild` for generating code.
|
25
25
|
|
26
26
|
**Note:** if building an ESM bundle, the `require` function will be defined as a global variable, to allow
|
27
27
|
dynamic `require`s by CommonJS submodules. This is not a problem for NodeJS, but will cause issues in a browser environment.
|
28
28
|
|
29
29
|
#### Options
|
30
30
|
|
31
|
-
- `--type` the type of output to generate. Defaults to `module` (ESM). Valid values are `
|
31
|
+
- `--type` the type of output to generate. Defaults to `module` (ESM). Valid values are `module` or `types`.
|
32
32
|
- `--entryPoint` the entry point for the bundle, relative to the inDir. if not provided, the files in the inDir will
|
33
33
|
be processed as individual unbundled files.
|
34
34
|
- `--inDir` the input source code directory.
|
@@ -42,12 +42,6 @@ dynamic `require`s by CommonJS submodules. This is not a problem for NodeJS, but
|
|
42
42
|
#### Examples
|
43
43
|
|
44
44
|
```
|
45
|
-
# build commonjs .cjs files from Typescript source
|
46
|
-
npx builder --type=commonjs --outDir=build-cjs
|
47
|
-
|
48
|
-
# build single-file commonjs .cjs bundle from Typescript source
|
49
|
-
npx builder --type=commonjs --entryPoint=index.ts --outDir=build-cjs-bundle --outFile=index.cjs
|
50
|
-
|
51
45
|
# build ESM .mjs files from Typescript source
|
52
46
|
npx builder --type=module --outDir=build-esm
|
53
47
|
|
@@ -75,10 +69,10 @@ the new version of Typescript, and/or without emitting warnings during these tes
|
|
75
69
|
|
76
70
|
Strict semver is a little complicated, as Typescript itself does not adhere to semver. So our "best effort" policy is:
|
77
71
|
|
78
|
-
- Each update to the minimum Node target (e.g
|
72
|
+
- Each update to the minimum Node target (e.g., Node 18 to Node 20), or a change to a major compiler output option
|
79
73
|
(e.g. `module`, `target` or `moduleResolution`) will result in a new major version of this module.
|
80
|
-
We coordinate this with whatever the latest LTS version of Node is currently supported by Amazon Lambda,
|
81
|
-
and Azure Functions.
|
74
|
+
We coordinate this with whatever the latest LTS version of Node is currently supported by Amazon Lambda,
|
75
|
+
Google Cloud Functions, and Azure Functions.
|
82
76
|
- Each new "major" version of Typescript (e.g. `4.2.x` to `4.3.x`) will result in a new minor version of this module.
|
83
77
|
- A new minor update of Typescript (e.g. `4.3.1` to `4.3.2`) _may_ result in a patch, in
|
84
78
|
a situation where a specific need or issue requires setting a new minimum version of Typescript.
|
package/bin/builder.mjs
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
// src/builder/index.
|
2
|
+
// src/builder/index.ts
|
3
3
|
import { strict as assert3 } from "node:assert";
|
4
4
|
import { promises as fs2 } from "node:fs";
|
5
5
|
import path2 from "node:path";
|
6
6
|
import { parseArgs } from "node:util";
|
7
7
|
|
8
|
-
// src/builder/builder.
|
8
|
+
// src/builder/builder.ts
|
9
9
|
import { strict as assert } from "node:assert";
|
10
10
|
import { promises as fs } from "node:fs";
|
11
11
|
import path from "node:path";
|
@@ -184,7 +184,7 @@ async function builder_default({
|
|
184
184
|
return buildResult2;
|
185
185
|
}
|
186
186
|
|
187
|
-
// src/builder/analyze.
|
187
|
+
// src/builder/analyze.ts
|
188
188
|
import { strict as assert2 } from "node:assert";
|
189
189
|
function analyze(metafile) {
|
190
190
|
const source = new Set(Object.keys(metafile.inputs).filter((key) => !key.startsWith("node_modules")));
|
@@ -211,7 +211,7 @@ function analyze(metafile) {
|
|
211
211
|
};
|
212
212
|
}
|
213
213
|
|
214
|
-
// src/builder/index.
|
214
|
+
// src/builder/index.ts
|
215
215
|
var {
|
216
216
|
values: { type, inDir, outDir, entryPoint, outFile, external, minify, sourceMap }
|
217
217
|
} = parseArgs({
|
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"name":"@checkdigit/typescript-config","version":"7.0.0-PR.54-
|
1
|
+
{"name":"@checkdigit/typescript-config","version":"7.0.0-PR.54-665c","description":"Check Digit standard Typescript configuration","prettier":"@checkdigit/prettier-config","engines":{"node":">=20.11"},"type":"module","bin":{"builder":"./bin/builder.mjs"},"peerDependencies":{"@types/node":">=20.11","esbuild":"0.20.0","typescript":"5.4.0-beta"},"repository":{"type":"git","url":"git+https://github.com/checkdigit/typescript-config.git"},"author":"Check Digit, LLC","license":"MIT","bugs":{"url":"https://github.com/checkdigit/typescript-config/issues"},"homepage":"https://github.com/checkdigit/typescript-config#readme","scripts":{"prepublishOnly":"npm run build-builder","lint:fix":"eslint --ignore-path .gitignore . --fix","lint":"eslint --max-warnings 0 --ignore-path .gitignore .","prettier":"prettier --ignore-path .gitignore --list-different .","prettier:fix":"prettier --ignore-path .gitignore --write .","test":"npm run ci:compile && npm run ci:test && npm run ci:lint && npm run ci:style","build-builder":"esbuild src/builder/index.ts --bundle --platform=node --format=esm --external:typescript --external:esbuild --outfile=build-builder/builder.mjs && mkdir -p bin && { echo '#!/usr/bin/env node'; cat build-builder/builder.mjs; } > bin/builder.mjs && chmod +x bin/builder.mjs","build-types":"rimraf build-types && bin/builder.mjs --type=types --outDir=build-types","build-mjs":"rimraf build-mjs && bin/builder.mjs --type=module --outDir=build-mjs","build-mjs-bundle":"rimraf build-mjs-bundle && bin/builder.mjs --type=module --outDir=build-mjs-bundle --entryPoint=test/index.test.ts --outFile=test/index.test.mjs","build-mjs-bundle-minify":"rimraf build-mjs-bundle-minify && bin/builder.mjs --type=module --minify --outDir=build-mjs-bundle-minify --entryPoint=test/index.test.ts --outFile=test/index.test.mjs","build-mjs-bundle-no-external":"rimraf build-mjs-bundle-no-external && bin/builder.mjs --type=module --external=./node_modules/* --outDir=build-mjs-bundle-no-external --entryPoint=test/index.test.ts --outFile=test/index.test.mjs --minify","test-jest-mjs":"NODE_OPTIONS=\"--disable-warning ExperimentalWarning --experimental-vm-modules\" jest --coverage=false","test-mjs":"node --test build-mjs/test/index.test.mjs","test-mjs-bundle":"node --test build-mjs-bundle/test/index.test.mjs","test-mjs-bundle-minify":"node --test build-mjs-bundle-minify/test/index.test.mjs","test-mjs-bundle-no-external":"node --test build-mjs-bundle-no-external/test/index.test.mjs","ci:test":"npm run test-jest-mjs && npm run test-mjs && npm run test-mjs-bundle && npm run test-mjs-bundle-no-external","ci:compile":"tsc --noEmit && npm run build-builder && npm run build-types && npm run build-mjs && npm run build-mjs-bundle && npm run build-mjs-bundle-minify && npm run build-mjs-bundle-no-external","ci:lint":"npm run lint","ci:style":"npm run prettier"},"devDependencies":{"@apidevtools/json-schema-ref-parser":"^11.1.0","@checkdigit/prettier-config":"^5.2.0","@types/debug":"^4.1.12","@types/jest":"^29.5.11","@types/uuid":"^9.0.8","@typescript-eslint/eslint-plugin":"^6.20.0","@typescript-eslint/parser":"^6.20.0","debug":"^4.3.4","eslint":"^8.56.0","eslint-config-prettier":"^9.1.0","jest":"^29.7.0","node-fetch":"^3.3.2","rimraf":"^5.0.5","ts-jest":"^29.1.2","uuid":"^9.0.1"},"eslintConfig":{"parser":"@typescript-eslint/parser","plugins":["@typescript-eslint"],"parserOptions":{"project":"./tsconfig.json"},"extends":["eslint:all","plugin:@typescript-eslint/recommended","plugin:@typescript-eslint/recommended-requiring-type-checking","plugin:@typescript-eslint/strict","prettier"],"rules":{"@typescript-eslint/non-nullable-type-assertion-style":"error","capitalized-comments":"off","one-var":"off","sort-keys":"off","sort-imports":"off","max-lines":["error",{"max":500,"skipBlankLines":true,"skipComments":true}],"func-style":["error","declaration",{"allowArrowFunctions":true}],"no-magic-numbers":["error",{"ignore":[0,1,2]}],"no-undefined":"off","no-ternary":"off"},"overrides":[{"files":["*.spec.ts","*.test.ts"],"rules":{"@typescript-eslint/non-nullable-type-assertion-style":"off","@typescript-eslint/ban-types":"off","@typescript-eslint/require-await":"off","@typescript-eslint/consistent-type-definitions":"off","@typescript-eslint/ban-ts-comment":"off","@typescript-eslint/no-unnecessary-condition":"off","@typescript-eslint/consistent-indexed-object-style":"off","@typescript-eslint/no-unused-vars":"off","@typescript-eslint/no-unsafe-member-access":"off","line-comment-position":"off","no-fallthrough":"off","no-inline-comments":"off","no-param-reassign":"off","id-length":"off","no-magic-numbers":"off","func-names":"off","no-duplicate-imports":"off","symbol-description":"off","no-invalid-this":"off","max-lines-per-function":"off","max-lines":"off","max-statements":"off","no-await-in-loop":"off"}}]},"jest":{"moduleFileExtensions":["js","mjs","cjs","ts","json","node"],"extensionsToTreatAsEsm":[".ts"],"transform":{"^.+\\.ts$":["ts-jest",{"isolatedModules":true,"diagnostics":false,"useESM":true}]},"collectCoverageFrom":["<rootDir>/src/**"],"testMatch":["<rootDir>/src/**/*.spec.ts"]},"files":["bin","tsconfig.json","SECURITY.md"],"overrides":{"typescript":"5.4.0-beta"}}
|