@checkdigit/typescript-config 3.3.0-PR.30-c398 → 3.3.0-PR.30-d5d5
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +37 -3
- package/package.json +1 -1
package/README.md
CHANGED
@@ -6,7 +6,9 @@ Copyright (c) 2022-2023 [Check Digit, LLC](https://checkdigit.com)
|
|
6
6
|
|
7
7
|
### Introduction
|
8
8
|
|
9
|
-
This module contains the standard Check Digit Typescript configuration
|
9
|
+
This module contains the standard Check Digit Typescript configuration, along with our standard build tool `builder`.
|
10
|
+
|
11
|
+
### Typescript Configuration
|
10
12
|
|
11
13
|
- currently requires Node 16 or above.
|
12
14
|
- emits `esnext`, with the default libraries, to avoid down-leveling. It is intended that application spec tests pick
|
@@ -15,17 +17,49 @@ This module contains the standard Check Digit Typescript configuration.
|
|
15
17
|
- uses the `module` type of `commonjs`.
|
16
18
|
- all compiler options set for maximum strictness.
|
17
19
|
|
20
|
+
### Builder
|
21
|
+
|
22
|
+
`builder` is a command line tool that generates either commonjs or esm modules, from Typescript source. It is intended
|
23
|
+
to be used when publishing a package to NPM, or to bundle a package for deployment. It uses `tsc` for generating
|
24
|
+
types, and `esbuild` for generating code.
|
25
|
+
|
26
|
+
#### Options
|
27
|
+
|
28
|
+
- `--type` the type of module to generate. Defaults to `module` (ESM). Valid values are `commonjs` and `module`.
|
29
|
+
- `--entryPoint` the entry point for the bundle, relative to the inDir. if not provided, the files in the inDir will
|
30
|
+
be processed as individual unbundled files.
|
31
|
+
- `--inDir` the input source code directory.
|
32
|
+
- `--outDir` the output directory.
|
33
|
+
- `--outFile` the output file, relative to `--outDir`. This is provided for single-file bundles, along with `--entryPoint`.
|
34
|
+
- `--external` external modules to exclude from the bundle. Built-in `node` modules are automatically excluded.
|
35
|
+
A wildcard `*` can be used to exclude multiple external modules.
|
36
|
+
|
37
|
+
#### Examples
|
38
|
+
|
39
|
+
```
|
40
|
+
# build commonjs .cjs files from Typescript source
|
41
|
+
npx builder --type=commonjs --outDir=build-cjs
|
42
|
+
|
43
|
+
# build single-file commonjs .cjs bundle from Typescript source
|
44
|
+
npx builder --type=commonjs --entryPoint=index.ts --outDir=build-cjs-bundle --outFile=index.cjs
|
45
|
+
|
46
|
+
# build ESM .mjs files from Typescript source
|
47
|
+
npx builder --type=module --outDir=build-esm
|
48
|
+
|
49
|
+
# build single-file ESM .mjs bundle from Typescript source
|
50
|
+
npx builder --type=module --outDir=build-esm-bundle --entryPoint=index.ts --outFile=index.mjs
|
51
|
+
```
|
52
|
+
|
18
53
|
### Tests
|
19
54
|
|
20
55
|
This module includes a number of integration-style tests, to ensure that a specific version of Typescript will interoperate
|
21
|
-
with
|
56
|
+
with `builder`, in addition to libraries and frameworks used by Check Digit:
|
22
57
|
|
23
58
|
- Jest and `ts-jest`
|
24
59
|
- ESLint and `@typescript-eslint/eslint-plugin`
|
25
60
|
- Built-in `node:test` runner
|
26
61
|
- prettier
|
27
62
|
- tsc
|
28
|
-
- swc
|
29
63
|
- esbuild
|
30
64
|
|
31
65
|
We do this to ensure that Typescript upgrades do not break these dependencies. New major versions of Typescript are not immediately
|
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"name":"@checkdigit/typescript-config","version":"3.3.0-PR.30-
|
1
|
+
{"name":"@checkdigit/typescript-config","version":"3.3.0-PR.30-d5d5","description":"Check Digit standard Typescript configuration","prettier":"@checkdigit/prettier-config","engines":{"node":">=16"},"bin":{"builder":"./bin/builder.mjs"},"peerDependencies":{"@types/node":">=16","esbuild":"0.17.19","typescript":">=5.0.4 <5.1"},"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":{"preversion":"npm test","postversion":"git push && git push --tags","prepare":"npm run build-builder","lint:fix":"eslint -f unix --ext .ts,.mts src --fix","lint":"eslint -f unix --ext .ts,.mts src","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.mts --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-cjs":"rimraf build-cjs && npx builder --type=commonjs --outDir=build-cjs","build-cjs-bundle":"rimraf build-cjs-bundle && npx builder --type=commonjs --entryPoint=test/index.test.ts --outDir=build-cjs-bundle --outFile=test/index.test.cjs","build-cjs-bundle-no-external":"rimraf build-cjs-bundle-no-external && npx builder --type=commonjs --external=./node_modules/* --entryPoint=test/index.test.ts --outDir=build-cjs-bundle-no-external --outFile=test/index.test.cjs","build-esm":"rimraf build-esm && npx builder --type=module --outDir=build-esm","build-esm-bundle":"rimraf build-esm-bundle && npx builder --type=module --outDir=build-esm-bundle --entryPoint=test/index.test.ts --outFile=test/index.test.mjs","build-esm-bundle-no-external":"rimraf build-esm-bundle-no-external && npx builder --type=module --external=./node_modules/* --outDir=build-esm-bundle-no-external --entryPoint=test/index.test.ts --outFile=test/index.test.mjs","test-jest-esm":"NODE_OPTIONS=\"--experimental-vm-modules\" jest --coverage=false src/*.mts src/*/*.mts src/*/*/*.mts","test-jest-cjs":"jest --coverage=false src/*.ts src/*/*.ts src/*/*/*.ts","test-cjs":"node --test build-cjs/test/index.test.cjs","test-cjs-bundle":"node --test build-cjs-bundle/test/index.test.cjs","test-cjs-bundle-no-external":"node --test build-cjs-bundle-no-external/test/index.test.cjs","test-esm":"node --test build-esm/test/index.test.mjs","test-esm-bundle":"echo \"node --test build-esm-bundle/test/index.test.mjs\"","test-esm-bundle-no-external":"node --test build-esm-bundle-no-external/test/index.test.mjs","ci:test":"npm run test-jest-cjs && npm run test-jest-esm && npm run test-cjs && npm run test-cjs-bundle && npm run test-cjs-bundle-no-external && npm run test-esm && npm run test-esm-bundle && npm run test-esm-bundle-no-external","ci:compile":"npm run build-builder && npm run build-cjs && npm run build-cjs-bundle && npm run build-cjs-bundle-no-external && npm run build-esm && npm run build-esm-bundle && npm run build-esm-bundle-no-external","ci:lint":"npm run lint","ci:style":"npm run prettier"},"devDependencies":{"@checkdigit/prettier-config":"^3.4.0","@types/debug":"^4.1.7","@types/jest":"^29.5.1","@types/uuid":"^9.0.1","@typescript-eslint/eslint-plugin":"^5.59.6","@typescript-eslint/parser":"^5.59.6","debug":"^4.3.4","eslint":"^8.40.0","eslint-config-prettier":"^8.8.0","get-port":"^6.1.2","got":"^11.8.6","jest":"^29.5.0","rimraf":"^5.0.1","ts-jest":"^29.1.0","uuid":"^9.0.0"},"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","func-style":["error","declaration",{"allowArrowFunctions":true}],"no-magic-numbers":["error",{"ignore":[0,1,2]}],"no-undefined":"off","no-ternary":"off"},"overrides":[{"files":["*.spec.mts","*.test.mts","*.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-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","mts","json","node"],"extensionsToTreatAsEsm":[".mts"],"transform":{"^.+\\.mts$":["ts-jest",{"isolatedModules":true,"diagnostics":false,"useESM":true}],"^.+\\.ts$":["ts-jest",{"isolatedModules":true,"diagnostics":false,"useESM":false}]},"collectCoverageFrom":["<rootDir>/src/**","!<rootDir>/src/**/*.spec.mts","!<rootDir>/src/**/*.test.mts","!<rootDir>/src/**/*.spec.ts","!<rootDir>/src/**/*.test.ts"],"testMatch":["<rootDir>/src/**/*.spec.ts","<rootDir>/src/**/*.spec.mts"]},"files":["tsconfig.json","SECURITY.md","/src/"]}
|