@checkdigit/typescript-config 8.1.0-PR.68-90e4 → 8.1.0-PR.68-5d97
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +9 -9
- package/bin/builder.mjs +8 -6
- package/dist-mjs/builder.mjs +2 -4
- package/dist-mjs/compile.mjs +9 -5
- package/package.json +1 -1
- package/src/builder.ts +1 -3
- package/src/compile.ts +13 -8
- package/tsconfig.json +2 -1
package/README.md
CHANGED
@@ -4,11 +4,11 @@
|
|
4
4
|
|
5
5
|
Copyright (c) 2022–2024 [Check Digit, LLC](https://checkdigit.com)
|
6
6
|
|
7
|
-
|
7
|
+
## Introduction
|
8
8
|
|
9
9
|
This module contains the standard Check Digit Typescript configuration, along with our standard build tool `builder`.
|
10
10
|
|
11
|
-
|
11
|
+
## Typescript Configuration
|
12
12
|
|
13
13
|
- currently requires Node 20.17 or above.
|
14
14
|
- emits `esnext`, with the default libraries, to avoid down-leveling. It is intended that application spec tests pick
|
@@ -17,7 +17,7 @@ This module contains the standard Check Digit Typescript configuration, along wi
|
|
17
17
|
- uses the `module` type of `esnext`.
|
18
18
|
- all compiler options set for maximum strictness.
|
19
19
|
|
20
|
-
|
20
|
+
## Builder
|
21
21
|
|
22
22
|
`builder` is a command line tool that generates ESM modules from the Typescript source.
|
23
23
|
It is intended to be used when publishing a package to NPM, or to bundle a package for deployment.
|
@@ -26,7 +26,7 @@ It uses `tsc` for generating types, and `esbuild` for generating code.
|
|
26
26
|
**Note:** 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 Node.js, but will cause issues in a browser environment.
|
28
28
|
|
29
|
-
|
29
|
+
### Options
|
30
30
|
|
31
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
|
@@ -39,9 +39,9 @@ dynamic `require`s by CommonJS submodules. This is not a problem for Node.js, bu
|
|
39
39
|
- `--minify` whether to minify the output.
|
40
40
|
- `--sourceMap` whether to include inline sourcemap.
|
41
41
|
|
42
|
-
|
42
|
+
### Examples
|
43
43
|
|
44
|
-
```
|
44
|
+
```shell
|
45
45
|
# build ESM .mjs files from Typescript source
|
46
46
|
npx builder --type=module --outDir=build-esm
|
47
47
|
|
@@ -49,7 +49,7 @@ npx builder --type=module --outDir=build-esm
|
|
49
49
|
npx builder --type=module --outDir=build-esm-bundle --entryPoint=index.ts --outFile=index.mjs
|
50
50
|
```
|
51
51
|
|
52
|
-
|
52
|
+
## Tests
|
53
53
|
|
54
54
|
This module includes a number of integration-style tests, to ensure that a specific version of Typescript will interoperate
|
55
55
|
with `builder`, in addition to libraries and frameworks used by Check Digit:
|
@@ -81,7 +81,7 @@ Bear in mind, any update of Typescript can potentially break your build. But hop
|
|
81
81
|
|
82
82
|
### Installation
|
83
83
|
|
84
|
-
```
|
84
|
+
```shell
|
85
85
|
npm add -D @checkdigit/typescript-config
|
86
86
|
```
|
87
87
|
|
@@ -92,7 +92,7 @@ Make sure your project's `tsconfig.json` extends `@checkdigit/typescript-config`
|
|
92
92
|
|
93
93
|
### Example `tsconfig.json`
|
94
94
|
|
95
|
-
```
|
95
|
+
```json
|
96
96
|
{
|
97
97
|
"extends": "@checkdigit/typescript-config"
|
98
98
|
}
|
package/bin/builder.mjs
CHANGED
@@ -85,6 +85,9 @@ function resolveTypescriptPaths() {
|
|
85
85
|
}
|
86
86
|
let newPath = resolved.path;
|
87
87
|
newPath += isDirectory ? `/index.mjs` : `.mjs`;
|
88
|
+
if (newPath.endsWith(".ts.mjs")) {
|
89
|
+
newPath = `${newPath.slice(0, -".ts.mjs".length)}.mjs`;
|
90
|
+
}
|
88
91
|
return { path: newPath, external: true };
|
89
92
|
});
|
90
93
|
};
|
@@ -138,6 +141,7 @@ async function compile_default({
|
|
138
141
|
useUnknownInCatchVariables: true,
|
139
142
|
exactOptionalPropertyTypes: true,
|
140
143
|
isolatedDeclarations: false,
|
144
|
+
allowImportingTsExtensions: true,
|
141
145
|
noEmit: type2 !== "types",
|
142
146
|
emitDeclarationOnly: type2 === "types",
|
143
147
|
rootDir: inDir2,
|
@@ -176,15 +180,15 @@ async function compile_default({
|
|
176
180
|
absWorkingDir: workingDirectory,
|
177
181
|
platform: "node",
|
178
182
|
format: "esm",
|
179
|
-
treeShaking:
|
183
|
+
treeShaking: true,
|
180
184
|
write: false,
|
181
185
|
metafile: outFile2 !== void 0,
|
182
186
|
sourcesContent: false,
|
183
187
|
logLevel: "error",
|
184
|
-
banner:
|
188
|
+
banner: outFile2 === void 0 ? {} : {
|
185
189
|
js: commonJsCompatabilityBanner
|
186
|
-
}
|
187
|
-
sourcemap: sourceMap2 ? "inline" : false,
|
190
|
+
},
|
191
|
+
sourcemap: sourceMap2 === true ? "inline" : false,
|
188
192
|
...outFile2 === void 0 ? {
|
189
193
|
// individual files
|
190
194
|
outdir: outDir2,
|
@@ -231,8 +235,6 @@ var {
|
|
231
235
|
}
|
232
236
|
});
|
233
237
|
assert3.ok(type === "module" || type === "types", "type must be types or module");
|
234
|
-
assert3.ok(inDir !== void 0, "inDir is required");
|
235
|
-
assert3.ok(outDir !== void 0, "outDir is required");
|
236
238
|
var compileResult = await compile_default({
|
237
239
|
type,
|
238
240
|
inDir: path2.join(process.cwd(), inDir),
|
package/dist-mjs/builder.mjs
CHANGED
@@ -3,7 +3,7 @@ import { strict as assert } from "node:assert";
|
|
3
3
|
import { promises as fs } from "node:fs";
|
4
4
|
import path from "node:path";
|
5
5
|
import { parseArgs } from "node:util";
|
6
|
-
import {
|
6
|
+
import { analyze, compile } from "./index.mjs";
|
7
7
|
var {
|
8
8
|
values: { type, inDir, outDir, entryPoint, outFile, external, minify, sourceMap }
|
9
9
|
} = parseArgs({
|
@@ -19,8 +19,6 @@ var {
|
|
19
19
|
}
|
20
20
|
});
|
21
21
|
assert.ok(type === "module" || type === "types", "type must be types or module");
|
22
|
-
assert.ok(inDir !== void 0, "inDir is required");
|
23
|
-
assert.ok(outDir !== void 0, "outDir is required");
|
24
22
|
var compileResult = await compile({
|
25
23
|
type,
|
26
24
|
inDir: path.join(process.cwd(), inDir),
|
@@ -44,4 +42,4 @@ if (compileResult.metafile !== void 0) {
|
|
44
42
|
`${outFile}: src ${analysis.sourceBytes}, node_modules ${analysis.moduleBytes}, total ${analysis.totalBytes}`
|
45
43
|
);
|
46
44
|
}
|
47
|
-
//# sourceMappingURL=data:application/json;base64,
|
45
|
+
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL2J1aWxkZXIudHMiXSwKICAibWFwcGluZ3MiOiAiO0FBRUEsU0FBUyxVQUFVLGNBQWM7QUFDakMsU0FBUyxZQUFZLFVBQVU7QUFDL0IsT0FBTyxVQUFVO0FBQ2pCLFNBQVMsaUJBQWlCO0FBRTFCLFNBQVMsU0FBUyxlQUFlO0FBRWpDLElBQU07QUFBQSxFQUNKLFFBQVEsRUFBRSxNQUFNLE9BQU8sUUFBUSxZQUFZLFNBQVMsVUFBVSxRQUFRLFVBQVU7QUFDbEYsSUFBSSxVQUFVO0FBQUEsRUFDWixTQUFTO0FBQUEsSUFDUCxNQUFNLEVBQUUsTUFBTSxVQUFVLE9BQU8sS0FBSyxTQUFTLFNBQVM7QUFBQSxJQUN0RCxPQUFPLEVBQUUsTUFBTSxVQUFVLE9BQU8sS0FBSyxTQUFTLE1BQU07QUFBQSxJQUNwRCxRQUFRLEVBQUUsTUFBTSxVQUFVLE9BQU8sS0FBSyxTQUFTLFFBQVE7QUFBQSxJQUN2RCxZQUFZLEVBQUUsTUFBTSxVQUFVLE9BQU8sS0FBSyxTQUFTLE9BQVU7QUFBQSxJQUM3RCxTQUFTLEVBQUUsTUFBTSxVQUFVLE9BQU8sS0FBSyxTQUFTLE9BQVU7QUFBQSxJQUMxRCxVQUFVLEVBQUUsTUFBTSxVQUFVLE9BQU8sS0FBSyxVQUFVLE1BQU0sU0FBUyxDQUFDLEVBQUU7QUFBQSxJQUNwRSxRQU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XMiOiBbXQp9Cg==
|
package/dist-mjs/compile.mjs
CHANGED
@@ -51,6 +51,9 @@ function resolveTypescriptPaths() {
|
|
51
51
|
}
|
52
52
|
let newPath = resolved.path;
|
53
53
|
newPath += isDirectory ? `/index.mjs` : `.mjs`;
|
54
|
+
if (newPath.endsWith(".ts.mjs")) {
|
55
|
+
newPath = `${newPath.slice(0, -".ts.mjs".length)}.mjs`;
|
56
|
+
}
|
54
57
|
return { path: newPath, external: true };
|
55
58
|
});
|
56
59
|
};
|
@@ -104,6 +107,7 @@ async function compile_default({
|
|
104
107
|
useUnknownInCatchVariables: true,
|
105
108
|
exactOptionalPropertyTypes: true,
|
106
109
|
isolatedDeclarations: false,
|
110
|
+
allowImportingTsExtensions: true,
|
107
111
|
noEmit: type !== "types",
|
108
112
|
emitDeclarationOnly: type === "types",
|
109
113
|
rootDir: inDir,
|
@@ -142,15 +146,15 @@ async function compile_default({
|
|
142
146
|
absWorkingDir: workingDirectory,
|
143
147
|
platform: "node",
|
144
148
|
format: "esm",
|
145
|
-
treeShaking:
|
149
|
+
treeShaking: true,
|
146
150
|
write: false,
|
147
151
|
metafile: outFile !== void 0,
|
148
152
|
sourcesContent: false,
|
149
153
|
logLevel: "error",
|
150
|
-
banner:
|
154
|
+
banner: outFile === void 0 ? {} : {
|
151
155
|
js: commonJsCompatabilityBanner
|
152
|
-
}
|
153
|
-
sourcemap: sourceMap ? "inline" : false,
|
156
|
+
},
|
157
|
+
sourcemap: sourceMap === true ? "inline" : false,
|
154
158
|
...outFile === void 0 ? {
|
155
159
|
// individual files
|
156
160
|
outdir: outDir,
|
@@ -183,4 +187,4 @@ async function compile_default({
|
|
183
187
|
export {
|
184
188
|
compile_default as default
|
185
189
|
};
|
186
|
-
//# sourceMappingURL=data:application/json;base64,
|
190
|
+
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL2NvbXBpbGUudHMiXSwKICAibWFwcGluZ3MiO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UMsRUFBRTtBQUFBLEVBQzlEO0FBRUEsU0FBTztBQUNUOyIsCiAgIm5hbWVzIjogW10KfQo=
|
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"name":"@checkdigit/typescript-config","version":"8.1.0-PR.68-
|
1
|
+
{"name":"@checkdigit/typescript-config","version":"8.1.0-PR.68-5d97","description":"Check Digit standard Typescript configuration","homepage":"https://github.com/checkdigit/typescript-config#readme","bugs":{"url":"https://github.com/checkdigit/typescript-config/issues"},"repository":{"type":"git","url":"git+https://github.com/checkdigit/typescript-config.git"},"license":"MIT","author":"Check Digit, LLC","type":"module","exports":{".":{"types":"./dist-types/index.d.ts","import":"./dist-mjs/index.mjs","default":"./tsconfig.json"}},"bin":{"builder":"./bin/builder.mjs"},"files":["bin","tsconfig.json","src","dist-types","dist-mjs","!src/**/test/**","!src/**/*.test.ts","!src/**/*.spec.ts","!dist-types/**/test/**","!dist-types/**/*.test.d.ts","!dist-types/**/*.spec.d.ts","!dist-mjs/**/test/**","!dist-mjs/**/*.test.mjs","!dist-mjs/**/*.spec.mjs","SECURITY.md"],"scripts":{"build":"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","build:builder":"esbuild src/builder.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:dist-mjs":"rimraf dist-mjs && npx builder --type=module --sourceMap --outDir=dist-mjs && node dist-mjs/index.mjs","build:dist-types":"rimraf dist-types && npx builder --type=types --outDir=dist-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.ts --outFile=test/index.mjs","build:mjs-bundle-minify":"rimraf build-mjs-bundle-minify && bin/builder.mjs --type=module --minify --outDir=build-mjs-bundle-minify --entryPoint=test/index.ts --outFile=test/index.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.ts --outFile=test/index.mjs --minify","build:types":"rimraf build-types && bin/builder.mjs --type=types --outDir=build-types","ci:compile":"tsc --noEmit","ci:lint":"npm run lint","ci:style":"npm run prettier","ci:test":"npm run build && npm run test:jest-mjs && npm run test:mjs && npm run test:mjs-bundle && npm run test:mjs-bundle-no-external","lint":"eslint --max-warnings 0 .","lint:fix":"eslint . --fix","prepare":"","prepublishOnly":"npm run build:builder && npm run build:dist-types && npm run build:dist-mjs","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","test:jest-mjs":"NODE_OPTIONS=\"--disable-warning ExperimentalWarning --experimental-vm-modules\" jest --coverage=false","test:mjs":"node --test build-mjs/test/index.mjs","test:mjs-bundle":"node --test build-mjs-bundle/test/index.mjs","test:mjs-bundle-minify":"node --test build-mjs-bundle-minify/test/index.mjs","test:mjs-bundle-no-external":"node --test build-mjs-bundle-no-external/test/index.mjs"},"prettier":"@checkdigit/prettier-config","jest":{"collectCoverageFrom":["<rootDir>/src/**"],"extensionsToTreatAsEsm":[".ts"],"moduleFileExtensions":["js","mjs","cjs","ts","json","node"],"testMatch":["<rootDir>/src/**/*.spec.ts"],"transform":{"^.+\\.ts$":["ts-jest",{"isolatedModules":true,"diagnostics":false,"useESM":true}]}},"devDependencies":{"@checkdigit/prettier-config":"^5.5.1","@eslint/js":"^9.15.0","@eslint/json":"^0.7.0","@eslint/markdown":"^6.2.1","@jest/globals":"^29.7.0","@types/uuid":"^10.0.0","@typescript-eslint/parser":"^8.15.0","eslint":"^9.15.0","eslint-config-prettier":"^9.1.0","eslint-plugin-jest":"^28.9.0","eslint-plugin-yml":"^1.15.0","jest":"^29.7.0","rimraf":"^6.0.1","ts-jest":"^29.2.5","typescript-eslint":"^8.15.0","uuid":"^11.0.3"},"peerDependencies":{"@types/node":">=20.18","esbuild":"0.24.0","typescript":"5.7.1-rc"},"engines":{"node":">=20.18"},"overrides":{"typescript":"5.7.1-rc"}}
|
package/src/builder.ts
CHANGED
@@ -5,7 +5,7 @@ import { promises as fs } from 'node:fs';
|
|
5
5
|
import path from 'node:path';
|
6
6
|
import { parseArgs } from 'node:util';
|
7
7
|
|
8
|
-
import {
|
8
|
+
import { analyze, compile } from './index';
|
9
9
|
|
10
10
|
const {
|
11
11
|
values: { type, inDir, outDir, entryPoint, outFile, external, minify, sourceMap },
|
@@ -23,8 +23,6 @@ const {
|
|
23
23
|
});
|
24
24
|
|
25
25
|
assert.ok(type === 'module' || type === 'types', 'type must be types or module');
|
26
|
-
assert.ok(inDir !== undefined, 'inDir is required');
|
27
|
-
assert.ok(outDir !== undefined, 'outDir is required');
|
28
26
|
|
29
27
|
const compileResult = await compile({
|
30
28
|
type,
|
package/src/compile.ts
CHANGED
@@ -5,7 +5,7 @@ import { promises as fs } from 'node:fs';
|
|
5
5
|
import path from 'node:path';
|
6
6
|
|
7
7
|
import typescript from 'typescript';
|
8
|
-
import { type PluginBuild
|
8
|
+
import { build, type PluginBuild } from 'esbuild';
|
9
9
|
|
10
10
|
const commonJsCompatabilityBanner = `import { createRequire as __createRequire } from "node:module";
|
11
11
|
import { fileURLToPath as __fileURLToPath } from "node:url";
|
@@ -173,12 +173,16 @@ function resolveTypescriptPaths() {
|
|
173
173
|
}
|
174
174
|
let newPath = resolved.path;
|
175
175
|
newPath += isDirectory ? `/index.mjs` : `.mjs`;
|
176
|
+
// we need to trim the .ts out, now that "allowImportingTsExtensions": true
|
177
|
+
if (newPath.endsWith('.ts.mjs')) {
|
178
|
+
newPath = `${newPath.slice(0, -'.ts.mjs'.length)}.mjs`;
|
179
|
+
}
|
176
180
|
return { path: newPath, external: true };
|
177
181
|
});
|
178
182
|
};
|
179
183
|
}
|
180
184
|
|
181
|
-
// eslint-disable-next-line max-lines-per-function
|
185
|
+
// eslint-disable-next-line max-lines-per-function
|
182
186
|
export default async function ({
|
183
187
|
type,
|
184
188
|
entryPoint,
|
@@ -235,6 +239,7 @@ export default async function ({
|
|
235
239
|
useUnknownInCatchVariables: true,
|
236
240
|
exactOptionalPropertyTypes: true,
|
237
241
|
isolatedDeclarations: false,
|
242
|
+
allowImportingTsExtensions: true,
|
238
243
|
noEmit: type !== 'types',
|
239
244
|
emitDeclarationOnly: type === 'types',
|
240
245
|
rootDir: inDir,
|
@@ -279,18 +284,18 @@ export default async function ({
|
|
279
284
|
absWorkingDir: workingDirectory,
|
280
285
|
platform: 'node',
|
281
286
|
format: 'esm',
|
282
|
-
treeShaking:
|
287
|
+
treeShaking: true,
|
283
288
|
write: false,
|
284
289
|
metafile: outFile !== undefined,
|
285
290
|
sourcesContent: false,
|
286
291
|
logLevel: 'error',
|
287
292
|
banner:
|
288
|
-
|
289
|
-
? {
|
293
|
+
outFile === undefined
|
294
|
+
? {}
|
295
|
+
: {
|
290
296
|
js: commonJsCompatabilityBanner,
|
291
|
-
}
|
292
|
-
|
293
|
-
sourcemap: sourceMap ? 'inline' : false,
|
297
|
+
},
|
298
|
+
sourcemap: sourceMap === true ? 'inline' : false,
|
294
299
|
...(outFile === undefined
|
295
300
|
? {
|
296
301
|
// individual files
|