@checkdigit/typescript-config 3.4.0-PR.36-36e6 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1 +1,197 @@
1
- {"name":"@checkdigit/typescript-config","version":"3.4.0-PR.36-36e6","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-types":"rimraf build-types && npx builder --type=types --outDir=build-types","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 --minify --sourceMap","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 --minify","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-types && 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.8","@types/jest":"^29.5.1","@types/uuid":"^9.0.1","@typescript-eslint/eslint-plugin":"^5.59.7","@typescript-eslint/parser":"^5.59.7","debug":"^4.3.4","eslint":"^8.41.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/"]}
1
+ {
2
+ "name": "@checkdigit/typescript-config",
3
+ "version": "3.5.0",
4
+ "description": "Check Digit standard Typescript configuration",
5
+ "prettier": "@checkdigit/prettier-config",
6
+ "engines": {
7
+ "node": ">=16"
8
+ },
9
+ "bin": {
10
+ "builder": "./bin/builder.mjs"
11
+ },
12
+ "peerDependencies": {
13
+ "@types/node": ">=16",
14
+ "esbuild": "0.17.19",
15
+ "typescript": ">=5.0.4 <5.1"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/checkdigit/typescript-config.git"
20
+ },
21
+ "author": "Check Digit, LLC",
22
+ "license": "MIT",
23
+ "bugs": {
24
+ "url": "https://github.com/checkdigit/typescript-config/issues"
25
+ },
26
+ "homepage": "https://github.com/checkdigit/typescript-config#readme",
27
+ "scripts": {
28
+ "preversion": "npm test",
29
+ "postversion": "git push && git push --tags",
30
+ "prepare": "npm run build-builder",
31
+ "lint:fix": "eslint -f unix --ext .ts,.mts src --fix",
32
+ "lint": "eslint -f unix --ext .ts,.mts src",
33
+ "prettier": "prettier --ignore-path .gitignore --list-different .",
34
+ "prettier:fix": "prettier --ignore-path .gitignore --write .",
35
+ "test": "npm run ci:compile && npm run ci:test && npm run ci:lint && npm run ci:style",
36
+ "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",
37
+ "build-types": "rimraf build-types && npx builder --type=types --outDir=build-types",
38
+ "build-cjs": "rimraf build-cjs && npx builder --type=commonjs --outDir=build-cjs",
39
+ "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 --minify --sourceMap",
40
+ "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",
41
+ "build-esm": "rimraf build-esm && npx builder --type=module --outDir=build-esm",
42
+ "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",
43
+ "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 --minify",
44
+ "test-jest-esm": "NODE_OPTIONS=\"--experimental-vm-modules\" jest --coverage=false src/*.mts src/*/*.mts src/*/*/*.mts",
45
+ "test-jest-cjs": "jest --coverage=false src/*.ts src/*/*.ts src/*/*/*.ts",
46
+ "test-cjs": "node --test build-cjs/test/index.test.cjs",
47
+ "test-cjs-bundle": "node --test build-cjs-bundle/test/index.test.cjs",
48
+ "test-cjs-bundle-no-external": "node --test build-cjs-bundle-no-external/test/index.test.cjs",
49
+ "test-esm": "node --test build-esm/test/index.test.mjs",
50
+ "test-esm-bundle": "echo \"node --test build-esm-bundle/test/index.test.mjs\"",
51
+ "test-esm-bundle-no-external": "node --test build-esm-bundle-no-external/test/index.test.mjs",
52
+ "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",
53
+ "ci:compile": "npm run build-builder && npm run build-types && 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",
54
+ "ci:lint": "npm run lint",
55
+ "ci:style": "npm run prettier"
56
+ },
57
+ "devDependencies": {
58
+ "@checkdigit/prettier-config": "^3.4.0",
59
+ "@types/debug": "^4.1.8",
60
+ "@types/jest": "^29.5.1",
61
+ "@types/uuid": "^9.0.1",
62
+ "@typescript-eslint/eslint-plugin": "^5.59.7",
63
+ "@typescript-eslint/parser": "^5.59.7",
64
+ "debug": "^4.3.4",
65
+ "eslint": "^8.41.0",
66
+ "eslint-config-prettier": "^8.8.0",
67
+ "get-port": "^6.1.2",
68
+ "got": "^11.8.6",
69
+ "jest": "^29.5.0",
70
+ "rimraf": "^5.0.1",
71
+ "ts-jest": "^29.1.0",
72
+ "uuid": "^9.0.0"
73
+ },
74
+ "eslintConfig": {
75
+ "parser": "@typescript-eslint/parser",
76
+ "plugins": [
77
+ "@typescript-eslint"
78
+ ],
79
+ "parserOptions": {
80
+ "project": "./tsconfig.json"
81
+ },
82
+ "extends": [
83
+ "eslint:all",
84
+ "plugin:@typescript-eslint/recommended",
85
+ "plugin:@typescript-eslint/recommended-requiring-type-checking",
86
+ "plugin:@typescript-eslint/strict",
87
+ "prettier"
88
+ ],
89
+ "rules": {
90
+ "@typescript-eslint/non-nullable-type-assertion-style": "error",
91
+ "capitalized-comments": "off",
92
+ "one-var": "off",
93
+ "sort-keys": "off",
94
+ "sort-imports": "off",
95
+ "func-style": [
96
+ "error",
97
+ "declaration",
98
+ {
99
+ "allowArrowFunctions": true
100
+ }
101
+ ],
102
+ "no-magic-numbers": [
103
+ "error",
104
+ {
105
+ "ignore": [
106
+ 0,
107
+ 1,
108
+ 2
109
+ ]
110
+ }
111
+ ],
112
+ "no-undefined": "off",
113
+ "no-ternary": "off"
114
+ },
115
+ "overrides": [
116
+ {
117
+ "files": [
118
+ "*.spec.mts",
119
+ "*.test.mts",
120
+ "*.spec.ts",
121
+ "*.test.ts"
122
+ ],
123
+ "rules": {
124
+ "@typescript-eslint/non-nullable-type-assertion-style": "off",
125
+ "@typescript-eslint/ban-types": "off",
126
+ "@typescript-eslint/require-await": "off",
127
+ "@typescript-eslint/consistent-type-definitions": "off",
128
+ "@typescript-eslint/ban-ts-comment": "off",
129
+ "@typescript-eslint/no-unnecessary-condition": "off",
130
+ "@typescript-eslint/consistent-indexed-object-style": "off",
131
+ "@typescript-eslint/no-unused-vars": "off",
132
+ "@typescript-eslint/no-unsafe-member-access": "off",
133
+ "line-comment-position": "off",
134
+ "no-inline-comments": "off",
135
+ "no-param-reassign": "off",
136
+ "id-length": "off",
137
+ "no-magic-numbers": "off",
138
+ "func-names": "off",
139
+ "no-duplicate-imports": "off",
140
+ "symbol-description": "off",
141
+ "no-invalid-this": "off",
142
+ "max-lines-per-function": "off",
143
+ "max-lines": "off",
144
+ "max-statements": "off",
145
+ "no-await-in-loop": "off"
146
+ }
147
+ }
148
+ ]
149
+ },
150
+ "jest": {
151
+ "moduleFileExtensions": [
152
+ "js",
153
+ "mjs",
154
+ "cjs",
155
+ "ts",
156
+ "mts",
157
+ "json",
158
+ "node"
159
+ ],
160
+ "extensionsToTreatAsEsm": [
161
+ ".mts"
162
+ ],
163
+ "transform": {
164
+ "^.+\\.mts$": [
165
+ "ts-jest",
166
+ {
167
+ "isolatedModules": true,
168
+ "diagnostics": false,
169
+ "useESM": true
170
+ }
171
+ ],
172
+ "^.+\\.ts$": [
173
+ "ts-jest",
174
+ {
175
+ "isolatedModules": true,
176
+ "diagnostics": false,
177
+ "useESM": false
178
+ }
179
+ ]
180
+ },
181
+ "collectCoverageFrom": [
182
+ "<rootDir>/src/**",
183
+ "!<rootDir>/src/**/*.spec.mts",
184
+ "!<rootDir>/src/**/*.test.mts",
185
+ "!<rootDir>/src/**/*.spec.ts",
186
+ "!<rootDir>/src/**/*.test.ts"
187
+ ],
188
+ "testMatch": [
189
+ "<rootDir>/src/**/*.spec.ts",
190
+ "<rootDir>/src/**/*.spec.mts"
191
+ ]
192
+ },
193
+ "files": [
194
+ "tsconfig.json",
195
+ "SECURITY.md"
196
+ ]
197
+ }
@@ -1,236 +0,0 @@
1
- // builder/builder.mts
2
-
3
- import { strict as assert } from 'node:assert';
4
- import { promises as fs } from 'node:fs';
5
- import path from 'node:path';
6
- import typescript from 'typescript';
7
-
8
- import { PluginBuild, build } from 'esbuild';
9
-
10
- export interface BuilderOptions {
11
- /**
12
- * whether to produce Typescript types, ESM or CommonJS code
13
- */
14
- type: 'module' | 'commonjs' | 'types';
15
-
16
- /**
17
- * the entry point for the bundle, relative to the inDir. if not provided, the files in the inDir will be processed
18
- * as individual unbundled files
19
- */
20
- entryPoint?: string | undefined;
21
-
22
- /**
23
- * source code
24
- */
25
- inDir: string;
26
-
27
- /**
28
- * build directory
29
- */
30
- outDir: string;
31
-
32
- /**
33
- * build file, relative to the outDir
34
- */
35
- outFile?: string | undefined;
36
-
37
- /**
38
- * external modules to exclude from the bundle
39
- */
40
- external?: string[] | undefined;
41
-
42
- /**
43
- * whether to minify output
44
- */
45
- minify?: boolean | undefined;
46
-
47
- /**
48
- * whether to include sourcemap
49
- */
50
- sourceMap?: boolean | undefined;
51
- }
52
-
53
- /**
54
- * Recursively obtains all files in a directory
55
- * @param {string} directory
56
- * @returns {Promise<string[]>}
57
- */
58
- async function getFiles(directory: string): Promise<string[]> {
59
- const entries = await fs.readdir(directory, { withFileTypes: true });
60
- const files = await Promise.all(
61
- entries.map((entry) => {
62
- const result = path.resolve(directory, entry.name);
63
- return entry.isDirectory() ? getFiles(result) : result;
64
- })
65
- );
66
- return files.flat();
67
- }
68
-
69
- function excludeSourceMaps(filter: RegExp) {
70
- return (pluginBuild: PluginBuild) => {
71
- // ignore source maps for any Javascript file that matches filter
72
- pluginBuild.onLoad({ filter }, async (args) => {
73
- if (args.path.endsWith('.js') || args.path.endsWith('.mjs') || args.path.endsWith('.cjs')) {
74
- return {
75
- contents: `${await fs.readFile(
76
- args.path,
77
- 'utf8'
78
- )}\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==`,
79
- loader: 'default',
80
- };
81
- }
82
- return undefined;
83
- });
84
- };
85
- }
86
-
87
- function resolveTypescriptPaths(type: 'module' | 'commonjs') {
88
- const extension = type === 'module' ? 'mjs' : 'cjs';
89
- return (pluginBuild: PluginBuild) => {
90
- // rewrite paths based on standard node resolution
91
- pluginBuild.onResolve({ filter: /.*/u }, async (resolved) => {
92
- if (resolved.kind === 'entry-point' || !resolved.path.startsWith('.') || resolved.path.endsWith('.js')) {
93
- return { external: resolved.kind !== 'entry-point' };
94
- }
95
- let isDirectory = false;
96
- try {
97
- const stats = await fs.lstat(path.join(resolved.resolveDir, resolved.path));
98
- isDirectory = stats.isDirectory();
99
- } catch {
100
- // do nothing
101
- }
102
- let newPath = resolved.path;
103
- newPath += isDirectory ? `/index.${extension}` : `.${extension}`;
104
- return { path: newPath, external: true };
105
- });
106
- };
107
- }
108
-
109
- // eslint-disable-next-line func-names,max-lines-per-function,max-statements
110
- export default async function ({
111
- type,
112
- entryPoint,
113
- inDir,
114
- outDir,
115
- outFile,
116
- external = [],
117
- minify = false,
118
- sourceMap,
119
- }: BuilderOptions): Promise<string[]> {
120
- const messages: string[] = [];
121
-
122
- assert.ok(
123
- (entryPoint === undefined && outFile === undefined) || (entryPoint !== undefined && outFile !== undefined),
124
- 'entryPoint and outFile must both be provided'
125
- );
126
-
127
- const allSourceFiles = await getFiles(inDir);
128
- const productionSourceFiles =
129
- entryPoint === undefined ? allSourceFiles.filter((file) => file.endsWith('.ts')) : [path.join(inDir, entryPoint)];
130
-
131
- /**
132
- * Emit declarations using typescript compiler, if type is 'types'. Otherwise, just compile to ensure the build is good.
133
- */
134
- const program = typescript.createProgram(productionSourceFiles, {
135
- module: typescript.ModuleKind.ESNext,
136
- moduleResolution: typescript.ModuleResolutionKind.Bundler,
137
- target: typescript.ScriptTarget.ESNext,
138
- declaration: true,
139
- noEmit: type !== 'types',
140
- noEmitOnError: true,
141
- emitDeclarationOnly: type === 'types',
142
- rootDir: inDir,
143
- outDir,
144
- noLib: false,
145
- skipLibCheck: true,
146
- strict: true,
147
- preserveConstEnums: true,
148
- noImplicitReturns: true,
149
- noUnusedLocals: true,
150
- noUnusedParameters: true,
151
- alwaysStrict: true,
152
- verbatimModuleSyntax: false,
153
- noFallthroughCasesInSwitch: true,
154
- forceConsistentCasingInFileNames: true,
155
- emitDecoratorMetadata: true,
156
- experimentalDecorators: true,
157
- resolveJsonModule: true,
158
- esModuleInterop: true,
159
- noUncheckedIndexedAccess: true,
160
- noPropertyAccessFromIndexSignature: true,
161
- allowUnusedLabels: false,
162
- allowUnreachableCode: false,
163
- noImplicitOverride: true,
164
- useUnknownInCatchVariables: true,
165
- exactOptionalPropertyTypes: true,
166
- });
167
- const emitResult = program.emit();
168
- const allDiagnostics = typescript.sortAndDeduplicateDiagnostics([
169
- ...typescript.getPreEmitDiagnostics(program),
170
- ...emitResult.diagnostics,
171
- ]);
172
- for (const diagnostic of allDiagnostics) {
173
- if (diagnostic.file) {
174
- assert.ok(diagnostic.start !== undefined);
175
- const { line, character } = typescript.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
176
- const message = typescript.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
177
- messages.push(`tsc: ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
178
- } else {
179
- // eslint-disable-next-line no-console
180
- messages.push(`tsc: ${typescript.flattenDiagnosticMessageText(diagnostic.messageText, '\n')}`);
181
- }
182
- }
183
-
184
- if (messages.length > 0) {
185
- throw new Error(`tsc failed ${JSON.stringify(messages)}`);
186
- }
187
-
188
- if (type === 'types') {
189
- return [];
190
- }
191
-
192
- /**
193
- * Emit ESM javascript using esbuild
194
- */
195
- const buildResult = await build({
196
- entryPoints: productionSourceFiles,
197
- bundle: true,
198
- minify,
199
- platform: 'node',
200
- format: type === 'module' ? 'esm' : 'cjs',
201
- sourcesContent: false,
202
- sourcemap: sourceMap ? 'inline' : false,
203
- ...(outFile === undefined
204
- ? {
205
- // individual files
206
- outdir: outDir,
207
- outExtension: { '.js': type === 'module' ? '.mjs' : '.cjs' },
208
- plugins: [
209
- {
210
- name: 'resolve-typescript-paths',
211
- setup: resolveTypescriptPaths(type),
212
- },
213
- ],
214
- }
215
- : {
216
- // bundling
217
- outfile: path.join(outDir, outFile),
218
- legalComments: 'none',
219
- external,
220
- plugins: [
221
- {
222
- name: 'exclude-source-maps',
223
- setup: excludeSourceMaps(/node_modules/u),
224
- },
225
- ],
226
- }),
227
- });
228
-
229
- messages.push(...buildResult.errors.map((error) => `esbuild error: ${error.text}`));
230
- messages.push(...buildResult.warnings.map((warning) => `esbuild warning: ${warning.text}`));
231
- if (messages.length > 0) {
232
- throw new Error(`esbuild failed ${JSON.stringify(messages)}`);
233
- }
234
-
235
- return messages;
236
- }
@@ -1,44 +0,0 @@
1
- // builder/index.mts
2
-
3
- import { strict as assert } from 'node:assert';
4
- import path from 'node:path';
5
- import { parseArgs } from 'node:util';
6
-
7
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
8
- // @ts-expect-error
9
- import builder from './builder.mts';
10
-
11
- const {
12
- values: { type, inDir, outDir, entryPoint, outFile, external, minify, sourceMap },
13
- } = parseArgs({
14
- options: {
15
- type: { type: 'string', short: 't', default: 'module' },
16
- inDir: { type: 'string', short: 'i', default: 'src' },
17
- outDir: { type: 'string', short: 'o', default: 'build' },
18
- entryPoint: { type: 'string', short: 'e', default: undefined },
19
- outFile: { type: 'string', short: 'f', default: undefined },
20
- external: { type: 'string', short: 'x', multiple: true, default: [] },
21
- minify: { type: 'boolean', short: 'm', default: false },
22
- sourceMap: { type: 'boolean', short: 's', default: false },
23
- },
24
- });
25
-
26
- assert.ok(type === 'module' || type === 'commonjs' || type === 'types', 'type must be types, module or commonjs');
27
- assert.ok(inDir !== undefined, 'inDir is required');
28
- assert.ok(outDir !== undefined, 'outDir is required');
29
-
30
- const messages = await builder({
31
- type,
32
- inDir: path.join(process.cwd(), inDir),
33
- outDir: path.join(process.cwd(), outDir),
34
- entryPoint,
35
- outFile,
36
- external,
37
- minify,
38
- sourceMap,
39
- });
40
- if (messages.length > 0) {
41
- // eslint-disable-next-line no-console
42
- console.warn(JSON.stringify(messages, undefined, 2));
43
- process.exit(1);
44
- }
@@ -1,3 +0,0 @@
1
- // module-directory/index.ts
2
-
3
- export default () => 'module-directory-index';