@storm-software/esbuild 0.37.0 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/bin/esbuild.ts +297 -0
- package/{bin → dist/bin}/esbuild.cjs +0 -0
- package/package.json +4 -4
- package/dist/chunk-BYH4XDRH.cjs +0 -6
- package/dist/chunk-GZSSIGNC.cjs +0 -153
- package/dist/chunk-JZ25TPTY.cjs +0 -42
- package/dist/chunk-TWFEYLU4.cjs +0 -352
- package/dist/chunk-VGC3FXLU.cjs +0 -203
- package/dist/rollup.cjs +0 -6906
- /package/dist/{assets.cjs → src/assets.cjs} +0 -0
- /package/dist/{assets.d.cts → src/assets.d.cts} +0 -0
- /package/dist/{assets.d.ts → src/assets.d.ts} +0 -0
- /package/dist/{assets.js → src/assets.js} +0 -0
- /package/dist/{build.cjs → src/build.cjs} +0 -0
- /package/dist/{build.d.cts → src/build.d.cts} +0 -0
- /package/dist/{build.d.ts → src/build.d.ts} +0 -0
- /package/dist/{build.js → src/build.js} +0 -0
- /package/dist/{chunk-2LYIFO7K.js → src/chunk-2LYIFO7K.js} +0 -0
- /package/dist/{chunk-55UPQQ65.cjs → src/chunk-55UPQQ65.cjs} +0 -0
- /package/dist/{chunk-72UBXZRO.js → src/chunk-72UBXZRO.js} +0 -0
- /package/dist/{chunk-7KIT5JE6.js → src/chunk-7KIT5JE6.js} +0 -0
- /package/dist/{chunk-B3MHVZOK.cjs → src/chunk-B3MHVZOK.cjs} +0 -0
- /package/dist/{chunk-BK5GLVSJ.cjs → src/chunk-BK5GLVSJ.cjs} +0 -0
- /package/dist/{chunk-BWMW4ZUS.cjs → src/chunk-BWMW4ZUS.cjs} +0 -0
- /package/dist/{chunk-C25ALB4J.cjs → src/chunk-C25ALB4J.cjs} +0 -0
- /package/dist/{chunk-CEJM5IFH.js → src/chunk-CEJM5IFH.js} +0 -0
- /package/dist/{chunk-FHHEEOIV.js → src/chunk-FHHEEOIV.js} +0 -0
- /package/dist/{chunk-H7NSISN4.cjs → src/chunk-H7NSISN4.cjs} +0 -0
- /package/dist/{chunk-IULOZ7MO.cjs → src/chunk-IULOZ7MO.cjs} +0 -0
- /package/dist/{chunk-JCICRU7K.cjs → src/chunk-JCICRU7K.cjs} +0 -0
- /package/dist/{chunk-KV6GNLVF.js → src/chunk-KV6GNLVF.js} +0 -0
- /package/dist/{chunk-KXZCIMKJ.js → src/chunk-KXZCIMKJ.js} +0 -0
- /package/dist/{chunk-LBRDOW2V.cjs → src/chunk-LBRDOW2V.cjs} +0 -0
- /package/dist/{chunk-NACKZM5D.js → src/chunk-NACKZM5D.js} +0 -0
- /package/dist/{chunk-NLIYZM5H.cjs → src/chunk-NLIYZM5H.cjs} +0 -0
- /package/dist/{chunk-Q3WZPCLD.js → src/chunk-Q3WZPCLD.js} +0 -0
- /package/dist/{chunk-QOTJTLX7.js → src/chunk-QOTJTLX7.js} +0 -0
- /package/dist/{chunk-RBXXACL5.cjs → src/chunk-RBXXACL5.cjs} +0 -0
- /package/dist/{chunk-RNXNYWO3.js → src/chunk-RNXNYWO3.js} +0 -0
- /package/dist/{chunk-T4N45NGL.cjs → src/chunk-T4N45NGL.cjs} +0 -0
- /package/dist/{chunk-VLK67MTI.js → src/chunk-VLK67MTI.js} +0 -0
- /package/dist/{chunk-VNLMOUVN.js → src/chunk-VNLMOUVN.js} +0 -0
- /package/dist/{chunk-XHTD4QDZ.cjs → src/chunk-XHTD4QDZ.cjs} +0 -0
- /package/dist/{clean.cjs → src/clean.cjs} +0 -0
- /package/dist/{clean.d.cts → src/clean.d.cts} +0 -0
- /package/dist/{clean.d.ts → src/clean.d.ts} +0 -0
- /package/dist/{clean.js → src/clean.js} +0 -0
- /package/dist/{config.cjs → src/config.cjs} +0 -0
- /package/dist/{config.d.cts → src/config.d.cts} +0 -0
- /package/dist/{config.d.ts → src/config.d.ts} +0 -0
- /package/dist/{config.js → src/config.js} +0 -0
- /package/dist/{context.cjs → src/context.cjs} +0 -0
- /package/dist/{context.d.cts → src/context.d.cts} +0 -0
- /package/dist/{context.d.ts → src/context.d.ts} +0 -0
- /package/dist/{context.js → src/context.js} +0 -0
- /package/dist/{index.cjs → src/index.cjs} +0 -0
- /package/dist/{index.d.cts → src/index.d.cts} +0 -0
- /package/dist/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/{index.js → src/index.js} +0 -0
- /package/dist/{package-json.cjs → src/package-json.cjs} +0 -0
- /package/dist/{package-json.d.cts → src/package-json.d.cts} +0 -0
- /package/dist/{package-json.d.ts → src/package-json.d.ts} +0 -0
- /package/dist/{package-json.js → src/package-json.js} +0 -0
- /package/dist/{plugins → src/plugins}/deps-check.cjs +0 -0
- /package/dist/{plugins → src/plugins}/deps-check.d.cts +0 -0
- /package/dist/{plugins → src/plugins}/deps-check.d.ts +0 -0
- /package/dist/{plugins → src/plugins}/deps-check.js +0 -0
- /package/dist/{plugins → src/plugins}/resolve-paths.cjs +0 -0
- /package/dist/{plugins → src/plugins}/resolve-paths.d.cts +0 -0
- /package/dist/{plugins → src/plugins}/resolve-paths.d.ts +0 -0
- /package/dist/{plugins → src/plugins}/resolve-paths.js +0 -0
- /package/dist/{tsup.cjs → src/tsup.cjs} +0 -0
- /package/dist/{tsup.d.cts → src/tsup.d.cts} +0 -0
- /package/dist/{tsup.d.ts → src/tsup.d.ts} +0 -0
- /package/dist/{tsup.js → src/tsup.js} +0 -0
- /package/dist/{types.cjs → src/types.cjs} +0 -0
- /package/dist/{types.d.cts → src/types.d.cts} +0 -0
- /package/dist/{types.d.ts → src/types.d.ts} +0 -0
- /package/dist/{types.js → src/types.js} +0 -0
- /package/dist/{watch.cjs → src/watch.cjs} +0 -0
- /package/dist/{watch.d.cts → src/watch.d.cts} +0 -0
- /package/dist/{watch.d.ts → src/watch.d.ts} +0 -0
- /package/dist/{watch.js → src/watch.js} +0 -0
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
|
|
|
21
21
|
|
|
22
22
|
<h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
23
23
|
|
|
24
|
-
[](https://prettier.io/) [](http://nx.dev/) [](https://nextjs.org/) [](http://commitizen.github.io/cz-cli/)  [](https://fumadocs.vercel.app/) 
|
|
25
25
|
|
|
26
26
|
<!-- prettier-ignore-start -->
|
|
27
27
|
<!-- markdownlint-disable -->
|
|
@@ -40,6 +40,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
|
|
|
40
40
|
|
|
41
41
|
<!-- START doctoc -->
|
|
42
42
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
43
|
+
|
|
43
44
|
## Table of Contents
|
|
44
45
|
|
|
45
46
|
- [Storm ESBuild Package](#storm-esbuild-package)
|
package/bin/esbuild.ts
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import type { StormWorkspaceConfig } from "@storm-software/config";
|
|
4
|
+
import { getConfig } from "@storm-software/config-tools/get-config";
|
|
5
|
+
import {
|
|
6
|
+
getStopwatch,
|
|
7
|
+
writeFatal,
|
|
8
|
+
writeInfo,
|
|
9
|
+
writeSuccess
|
|
10
|
+
} from "@storm-software/config-tools/logger/console";
|
|
11
|
+
import { findWorkspaceRootSafe } from "@storm-software/config-tools/utilities/find-workspace-root";
|
|
12
|
+
import {
|
|
13
|
+
exitWithError,
|
|
14
|
+
exitWithSuccess,
|
|
15
|
+
handleProcess
|
|
16
|
+
} from "@storm-software/config-tools/utilities/process-handler";
|
|
17
|
+
import { Command, Option } from "commander";
|
|
18
|
+
import { Format } from "esbuild";
|
|
19
|
+
import { build } from "../src/build";
|
|
20
|
+
import { clean } from "../src/clean";
|
|
21
|
+
import { ESBuildCLIOptions } from "../src/types";
|
|
22
|
+
|
|
23
|
+
async function createProgram(config: StormWorkspaceConfig) {
|
|
24
|
+
try {
|
|
25
|
+
writeInfo("⚡ Running Storm ESBuild pipeline", config);
|
|
26
|
+
|
|
27
|
+
const root = findWorkspaceRootSafe();
|
|
28
|
+
process.env.STORM_WORKSPACE_ROOT ??= root;
|
|
29
|
+
process.env.NX_WORKSPACE_ROOT_PATH ??= root;
|
|
30
|
+
if (root) {
|
|
31
|
+
process.chdir(root);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const program = new Command("storm-esbuild");
|
|
35
|
+
program.version("1.0.0", "-v --version", "display CLI version");
|
|
36
|
+
|
|
37
|
+
program
|
|
38
|
+
.description("⚡ Run the Storm ESBuild pipeline")
|
|
39
|
+
.showHelpAfterError()
|
|
40
|
+
.showSuggestionAfterError();
|
|
41
|
+
|
|
42
|
+
const projectRootOption = new Option(
|
|
43
|
+
"-p --project-root <path>",
|
|
44
|
+
"The path to the root of the project to build. This path is defined relative to the workspace root."
|
|
45
|
+
).makeOptionMandatory(true);
|
|
46
|
+
|
|
47
|
+
const sourceRootOption = new Option(
|
|
48
|
+
"-s --source-root <path>",
|
|
49
|
+
"The path of the project's source folder to build"
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const nameOption = new Option(
|
|
53
|
+
"-n --name <value>",
|
|
54
|
+
"The name of the project to build"
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const outputPathOption = new Option(
|
|
58
|
+
"-o --output-path <path>",
|
|
59
|
+
"The path of the project's source folder to build"
|
|
60
|
+
).default("dist/{projectRoot}");
|
|
61
|
+
|
|
62
|
+
const platformOption = new Option(
|
|
63
|
+
"-p --platform <value>",
|
|
64
|
+
"The platform to build the distribution for"
|
|
65
|
+
)
|
|
66
|
+
.choices(["node", "neutral", "browser"])
|
|
67
|
+
.default("node");
|
|
68
|
+
|
|
69
|
+
const formatOption = new Option(
|
|
70
|
+
"-f, --format <value...>",
|
|
71
|
+
"The format to build the distribution in"
|
|
72
|
+
)
|
|
73
|
+
.choices(["esm", "cjs", "iife"])
|
|
74
|
+
.argParser<string[]>((value: string, previous: string[]) => {
|
|
75
|
+
if (previous === undefined) {
|
|
76
|
+
return [value];
|
|
77
|
+
} else if (!previous.includes(value)) {
|
|
78
|
+
previous.push(value);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return previous;
|
|
82
|
+
})
|
|
83
|
+
.default("esm");
|
|
84
|
+
|
|
85
|
+
const cleanOption = new Option(
|
|
86
|
+
"-c --clean",
|
|
87
|
+
"Should the output directory be cleaned before building"
|
|
88
|
+
).default(true);
|
|
89
|
+
|
|
90
|
+
const noCleanOption = new Option(
|
|
91
|
+
"--no-clean",
|
|
92
|
+
"Should the output directory be cleaned before building"
|
|
93
|
+
).default(false);
|
|
94
|
+
|
|
95
|
+
const bundleOption = new Option(
|
|
96
|
+
"-b --bundle",
|
|
97
|
+
"Should the output be bundled"
|
|
98
|
+
).default(true);
|
|
99
|
+
|
|
100
|
+
const noBundleOption = new Option(
|
|
101
|
+
"--no-bundle",
|
|
102
|
+
"Should the output be bundled"
|
|
103
|
+
).default(false);
|
|
104
|
+
|
|
105
|
+
const targetOption = new Option(
|
|
106
|
+
"-t --target <value>",
|
|
107
|
+
"The target to build the distribution for"
|
|
108
|
+
)
|
|
109
|
+
.choices([
|
|
110
|
+
"ESNext",
|
|
111
|
+
"ES2015",
|
|
112
|
+
"ES2016",
|
|
113
|
+
"ES2017",
|
|
114
|
+
"ES2018",
|
|
115
|
+
"ES2019",
|
|
116
|
+
"ES2020",
|
|
117
|
+
"ES2021",
|
|
118
|
+
"ES2022",
|
|
119
|
+
"ES2023"
|
|
120
|
+
])
|
|
121
|
+
.default("ESNext");
|
|
122
|
+
|
|
123
|
+
const watchOption = new Option(
|
|
124
|
+
"-w --watch",
|
|
125
|
+
"Should the build process watch for changes"
|
|
126
|
+
).default(false);
|
|
127
|
+
|
|
128
|
+
const modeOption = new Option(
|
|
129
|
+
"-m --mode",
|
|
130
|
+
"What mode should the build process run in"
|
|
131
|
+
).default("production");
|
|
132
|
+
|
|
133
|
+
const bannerOption = new Option(
|
|
134
|
+
"--banner <value>",
|
|
135
|
+
"The banner to prepend to the output"
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
const footerOption = new Option(
|
|
139
|
+
"--footer <value>",
|
|
140
|
+
"The footer to prepend to the output"
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
const splittingOption = new Option(
|
|
144
|
+
"--splitting",
|
|
145
|
+
"Should the output be split into multiple files"
|
|
146
|
+
).default(true);
|
|
147
|
+
|
|
148
|
+
const treeShakingOption = new Option(
|
|
149
|
+
"--treeshake",
|
|
150
|
+
"Should tree shaking be enabled"
|
|
151
|
+
).default(true);
|
|
152
|
+
|
|
153
|
+
const generatePackageJsonOption = new Option(
|
|
154
|
+
"--generate-package-json",
|
|
155
|
+
"Should a package.json be generated for the output"
|
|
156
|
+
).default(true);
|
|
157
|
+
|
|
158
|
+
// const emitOnAllOption = new Option(
|
|
159
|
+
// "--emit-on-all",
|
|
160
|
+
// "Should the output be emitted on all platforms"
|
|
161
|
+
// ).default(false);
|
|
162
|
+
|
|
163
|
+
const metafileOption = new Option(
|
|
164
|
+
"--metafile",
|
|
165
|
+
"Should a metafile be generated for the output"
|
|
166
|
+
).default(true);
|
|
167
|
+
|
|
168
|
+
const minifyOption = new Option(
|
|
169
|
+
"--minify",
|
|
170
|
+
"Should the output be minified"
|
|
171
|
+
).default(true);
|
|
172
|
+
|
|
173
|
+
const includeSrcOption = new Option(
|
|
174
|
+
"--include-src",
|
|
175
|
+
"Should the source files be included in the output"
|
|
176
|
+
).default(false);
|
|
177
|
+
|
|
178
|
+
const injectShimsOption = new Option(
|
|
179
|
+
"--shims",
|
|
180
|
+
"Should shims be injected into the output"
|
|
181
|
+
).default(true);
|
|
182
|
+
|
|
183
|
+
const dtsOption = new Option(
|
|
184
|
+
"--dts",
|
|
185
|
+
"Should typescript type declarations be emitted for the output"
|
|
186
|
+
).default(true);
|
|
187
|
+
|
|
188
|
+
program
|
|
189
|
+
.command("build", { isDefault: true })
|
|
190
|
+
.alias("bundle")
|
|
191
|
+
.description(
|
|
192
|
+
"Run a TypeScript build using ESBuild, API-Extractor, and TSC (for type generation)."
|
|
193
|
+
)
|
|
194
|
+
.addOption(nameOption)
|
|
195
|
+
.addOption(projectRootOption)
|
|
196
|
+
.addOption(sourceRootOption)
|
|
197
|
+
.addOption(outputPathOption)
|
|
198
|
+
.addOption(platformOption)
|
|
199
|
+
.addOption(formatOption)
|
|
200
|
+
.addOption(targetOption)
|
|
201
|
+
.addOption(bundleOption)
|
|
202
|
+
.addOption(noBundleOption)
|
|
203
|
+
.addOption(cleanOption)
|
|
204
|
+
.addOption(noCleanOption)
|
|
205
|
+
.addOption(watchOption)
|
|
206
|
+
.addOption(modeOption)
|
|
207
|
+
.addOption(bannerOption)
|
|
208
|
+
.addOption(footerOption)
|
|
209
|
+
.addOption(splittingOption)
|
|
210
|
+
.addOption(treeShakingOption)
|
|
211
|
+
.addOption(generatePackageJsonOption)
|
|
212
|
+
.addOption(metafileOption)
|
|
213
|
+
.addOption(minifyOption)
|
|
214
|
+
.addOption(includeSrcOption)
|
|
215
|
+
.addOption(injectShimsOption)
|
|
216
|
+
.addOption(dtsOption)
|
|
217
|
+
.action(buildAction(config));
|
|
218
|
+
|
|
219
|
+
program
|
|
220
|
+
.command("clean")
|
|
221
|
+
.alias("clear")
|
|
222
|
+
.description(
|
|
223
|
+
"Clean the output directory of the project. This command will remove the 'dist' folder."
|
|
224
|
+
)
|
|
225
|
+
.addOption(nameOption)
|
|
226
|
+
.action(cleanAction(config));
|
|
227
|
+
|
|
228
|
+
return program;
|
|
229
|
+
} catch (e) {
|
|
230
|
+
writeFatal(
|
|
231
|
+
`A fatal error occurred while running the program: ${e.message}`,
|
|
232
|
+
config
|
|
233
|
+
);
|
|
234
|
+
process.exit(1);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const buildAction =
|
|
239
|
+
(config: StormWorkspaceConfig) => async (options: ESBuildCLIOptions) => {
|
|
240
|
+
try {
|
|
241
|
+
await build({
|
|
242
|
+
...options,
|
|
243
|
+
format: options.format as Format
|
|
244
|
+
});
|
|
245
|
+
} catch (e) {
|
|
246
|
+
writeFatal(
|
|
247
|
+
`A fatal error occurred while cleaning the ESBuild output directory: ${e.message}`,
|
|
248
|
+
config
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
exitWithError(config);
|
|
252
|
+
process.exit(1);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
const cleanAction =
|
|
257
|
+
(config: StormWorkspaceConfig) =>
|
|
258
|
+
async (options: { output: string; name?: string }) => {
|
|
259
|
+
try {
|
|
260
|
+
await clean(options.name, options.output, config);
|
|
261
|
+
} catch (e) {
|
|
262
|
+
writeFatal(
|
|
263
|
+
`A fatal error occurred while cleaning the ESBuild output directory: ${e.message}`,
|
|
264
|
+
config
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
exitWithError(config);
|
|
268
|
+
process.exit(1);
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
void (async () => {
|
|
273
|
+
const config = await getConfig();
|
|
274
|
+
const stopwatch = getStopwatch("Storm ESBuild executable");
|
|
275
|
+
|
|
276
|
+
try {
|
|
277
|
+
handleProcess(config);
|
|
278
|
+
|
|
279
|
+
const program = await createProgram(config);
|
|
280
|
+
await program.parseAsync(process.argv);
|
|
281
|
+
|
|
282
|
+
writeSuccess(
|
|
283
|
+
`🎉 Storm ESBuild executable has completed successfully!`,
|
|
284
|
+
config
|
|
285
|
+
);
|
|
286
|
+
exitWithSuccess(config);
|
|
287
|
+
} catch (error) {
|
|
288
|
+
writeFatal(
|
|
289
|
+
`A fatal error occurred while running Storm ESBuild executable: \n\n${error.message}`,
|
|
290
|
+
config
|
|
291
|
+
);
|
|
292
|
+
exitWithError(config);
|
|
293
|
+
process.exit(1);
|
|
294
|
+
} finally {
|
|
295
|
+
stopwatch();
|
|
296
|
+
}
|
|
297
|
+
})();
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storm-software/esbuild",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing `esbuild` utilities for building Storm Software libraries and applications",
|
|
6
6
|
"repository": {
|
|
@@ -239,9 +239,9 @@
|
|
|
239
239
|
"dependencies": {
|
|
240
240
|
"@nx/devkit": "20.8.0",
|
|
241
241
|
"@nx/js": "20.8.0",
|
|
242
|
-
"@storm-software/build-tools": "0.
|
|
243
|
-
"@storm-software/config": "1.
|
|
244
|
-
"@storm-software/config-tools": "1.
|
|
242
|
+
"@storm-software/build-tools": "0.147.0",
|
|
243
|
+
"@storm-software/config": "1.116.0",
|
|
244
|
+
"@storm-software/config-tools": "1.166.0",
|
|
245
245
|
"chokidar": "^4.0.3",
|
|
246
246
|
"commander": "^12.1.0",
|
|
247
247
|
"defu": "6.1.4",
|
package/dist/chunk-BYH4XDRH.cjs
DELETED
package/dist/chunk-GZSSIGNC.cjs
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }
|
|
2
|
-
|
|
3
|
-
var _chunkBYH4XDRHjs = require('./chunk-BYH4XDRH.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkTWFEYLU4js = require('./chunk-TWFEYLU4.cjs');
|
|
7
|
-
|
|
8
|
-
// src/cli-main.ts
|
|
9
|
-
var _cac = require('cac');
|
|
10
|
-
|
|
11
|
-
// node_modules/.pnpm/flat@6.0.1/node_modules/flat/index.js
|
|
12
|
-
function isBuffer(obj) {
|
|
13
|
-
return obj && obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
|
|
14
|
-
}
|
|
15
|
-
function keyIdentity(key) {
|
|
16
|
-
return key;
|
|
17
|
-
}
|
|
18
|
-
function flatten(target, opts) {
|
|
19
|
-
opts = opts || {};
|
|
20
|
-
const delimiter = opts.delimiter || ".";
|
|
21
|
-
const maxDepth = opts.maxDepth;
|
|
22
|
-
const transformKey = opts.transformKey || keyIdentity;
|
|
23
|
-
const output = {};
|
|
24
|
-
function step(object, prev, currentDepth) {
|
|
25
|
-
currentDepth = currentDepth || 1;
|
|
26
|
-
Object.keys(object).forEach(function(key) {
|
|
27
|
-
const value = object[key];
|
|
28
|
-
const isarray = opts.safe && Array.isArray(value);
|
|
29
|
-
const type = Object.prototype.toString.call(value);
|
|
30
|
-
const isbuffer = isBuffer(value);
|
|
31
|
-
const isobject = type === "[object Object]" || type === "[object Array]";
|
|
32
|
-
const newKey = prev ? prev + delimiter + transformKey(key) : transformKey(key);
|
|
33
|
-
if (!isarray && !isbuffer && isobject && Object.keys(value).length && (!opts.maxDepth || currentDepth < maxDepth)) {
|
|
34
|
-
return step(value, newKey, currentDepth + 1);
|
|
35
|
-
}
|
|
36
|
-
output[newKey] = value;
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
step(target);
|
|
40
|
-
return output;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// src/cli-main.ts
|
|
44
|
-
function ensureArray(input) {
|
|
45
|
-
return Array.isArray(input) ? input : input.split(",");
|
|
46
|
-
}
|
|
47
|
-
async function main(options = {}) {
|
|
48
|
-
const cli = _cac.cac.call(void 0, "tsup");
|
|
49
|
-
cli.command("[...files]", "Bundle files", {
|
|
50
|
-
ignoreOptionDefaultValue: true
|
|
51
|
-
}).option("--entry.* <file>", "Use a key-value pair as entry files").option("-d, --out-dir <dir>", "Output directory", { default: "dist" }).option("--format <format>", 'Bundle format, "cjs", "iife", "esm"', {
|
|
52
|
-
default: "cjs"
|
|
53
|
-
}).option("--minify [terser]", "Minify bundle").option("--minify-whitespace", "Minify whitespace").option("--minify-identifiers", "Minify identifiers").option("--minify-syntax", "Minify syntax").option(
|
|
54
|
-
"--keep-names",
|
|
55
|
-
"Keep original function and class names in minified code"
|
|
56
|
-
).option("--target <target>", 'Bundle target, "es20XX" or "esnext"', {
|
|
57
|
-
default: "es2017"
|
|
58
|
-
}).option(
|
|
59
|
-
"--legacy-output",
|
|
60
|
-
"Output different formats to different folder instead of using different extensions"
|
|
61
|
-
).option("--dts [entry]", "Generate declaration file").option("--dts-resolve", "Resolve externals types used for d.ts files").option("--dts-only", "Emit declaration files only").option(
|
|
62
|
-
"--experimental-dts [entry]",
|
|
63
|
-
"Generate declaration file (experimental)"
|
|
64
|
-
).option(
|
|
65
|
-
"--sourcemap [inline]",
|
|
66
|
-
"Generate external sourcemap, or inline source: --sourcemap inline"
|
|
67
|
-
).option(
|
|
68
|
-
"--watch [path]",
|
|
69
|
-
'Watch mode, if path is not specified, it watches the current folder ".". Repeat "--watch" for more than one path'
|
|
70
|
-
).option("--ignore-watch <path>", "Ignore custom paths in watch mode").option(
|
|
71
|
-
"--onSuccess <command>",
|
|
72
|
-
"Execute command after successful build, specially useful for watch mode"
|
|
73
|
-
).option("--env.* <value>", "Define compile-time env variables").option(
|
|
74
|
-
"--inject <file>",
|
|
75
|
-
"Replace a global variable with an import from another file"
|
|
76
|
-
).option("--define.* <value>", "Define compile-time constants").option(
|
|
77
|
-
"--external <name>",
|
|
78
|
-
"Mark specific packages / package.json (dependencies and peerDependencies) as external"
|
|
79
|
-
).option("--global-name <name>", "Global variable name for iife format").option("--jsxFactory <jsxFactory>", "Name of JSX factory function", {
|
|
80
|
-
default: "React.createElement"
|
|
81
|
-
}).option("--jsxFragment <jsxFragment>", "Name of JSX fragment function", {
|
|
82
|
-
default: "React.Fragment"
|
|
83
|
-
}).option("--replaceNodeEnv", "Replace process.env.NODE_ENV").option("--no-splitting", "Disable code splitting").option("--clean", "Clean output directory").option(
|
|
84
|
-
"--silent",
|
|
85
|
-
'Suppress non-error logs (excluding "onSuccess" process output)'
|
|
86
|
-
).option("--pure <express>", "Mark specific expressions as pure").option("--metafile", "Emit esbuild metafile (a JSON file)").option("--platform <platform>", "Target platform", {
|
|
87
|
-
default: "node"
|
|
88
|
-
}).option("--loader <ext=loader>", "Specify the loader for a file extension").option("--tsconfig <filename>", "Use a custom tsconfig").option("--config <filename>", "Use a custom config file").option("--no-config", "Disable config file").option("--shims", "Enable cjs and esm shims").option("--inject-style", "Inject style tag to document head").option(
|
|
89
|
-
"--treeshake [strategy]",
|
|
90
|
-
'Using Rollup for treeshaking instead, "recommended" or "smallest" or "safest"'
|
|
91
|
-
).option("--publicDir [dir]", "Copy public directory to output directory").option(
|
|
92
|
-
"--killSignal <signal>",
|
|
93
|
-
'Signal to kill child process, "SIGTERM" or "SIGKILL"'
|
|
94
|
-
).option("--cjsInterop", "Enable cjs interop").action(async (files, flags) => {
|
|
95
|
-
const { build } = await Promise.resolve().then(() => _interopRequireWildcard(require("./index.js")));
|
|
96
|
-
Object.assign(options, {
|
|
97
|
-
...flags
|
|
98
|
-
});
|
|
99
|
-
if (!options.entry && files.length > 0) {
|
|
100
|
-
options.entry = files.map(_chunkTWFEYLU4js.slash);
|
|
101
|
-
}
|
|
102
|
-
if (flags.format) {
|
|
103
|
-
const format = ensureArray(flags.format);
|
|
104
|
-
options.format = format;
|
|
105
|
-
}
|
|
106
|
-
if (flags.external) {
|
|
107
|
-
const external = ensureArray(flags.external);
|
|
108
|
-
options.external = external;
|
|
109
|
-
}
|
|
110
|
-
if (flags.target) {
|
|
111
|
-
options.target = flags.target.includes(",") ? flags.target.split(",") : flags.target;
|
|
112
|
-
}
|
|
113
|
-
if (flags.dts || flags.dtsResolve || flags.dtsOnly) {
|
|
114
|
-
options.dts = {};
|
|
115
|
-
if (typeof flags.dts === "string") {
|
|
116
|
-
options.dts.entry = flags.dts;
|
|
117
|
-
}
|
|
118
|
-
if (flags.dtsResolve) {
|
|
119
|
-
options.dts.resolve = flags.dtsResolve;
|
|
120
|
-
}
|
|
121
|
-
if (flags.dtsOnly) {
|
|
122
|
-
options.dts.only = true;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
if (flags.inject) {
|
|
126
|
-
const inject = ensureArray(flags.inject);
|
|
127
|
-
options.inject = inject;
|
|
128
|
-
}
|
|
129
|
-
if (flags.define) {
|
|
130
|
-
const define = flatten(flags.define);
|
|
131
|
-
options.define = define;
|
|
132
|
-
}
|
|
133
|
-
if (flags.loader) {
|
|
134
|
-
const loader = ensureArray(flags.loader);
|
|
135
|
-
options.loader = loader.reduce((result, item) => {
|
|
136
|
-
const parts = item.split("=");
|
|
137
|
-
return {
|
|
138
|
-
...result,
|
|
139
|
-
[parts[0]]: parts[1]
|
|
140
|
-
};
|
|
141
|
-
}, {});
|
|
142
|
-
}
|
|
143
|
-
await build(options);
|
|
144
|
-
});
|
|
145
|
-
cli.help();
|
|
146
|
-
cli.version(_chunkBYH4XDRHjs.version);
|
|
147
|
-
cli.parse(process.argv, { run: false });
|
|
148
|
-
await cli.runMatchedCommand();
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
exports.main = main;
|
package/dist/chunk-JZ25TPTY.cjs
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/errors.ts
|
|
2
|
-
var _worker_threads = require('worker_threads');
|
|
3
|
-
var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
|
|
4
|
-
var PrettyError = class extends Error {
|
|
5
|
-
constructor(message) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.name = this.constructor.name;
|
|
8
|
-
if (typeof Error.captureStackTrace === "function") {
|
|
9
|
-
Error.captureStackTrace(this, this.constructor);
|
|
10
|
-
} else {
|
|
11
|
-
this.stack = new Error(message).stack;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
function handleError(error) {
|
|
16
|
-
if (error.loc) {
|
|
17
|
-
console.error(
|
|
18
|
-
_picocolors2.default.bold(
|
|
19
|
-
_picocolors2.default.red(
|
|
20
|
-
`Error parsing: ${error.loc.file}:${error.loc.line}:${error.loc.column}`
|
|
21
|
-
)
|
|
22
|
-
)
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
if (error.frame) {
|
|
26
|
-
console.error(_picocolors2.default.red(error.message));
|
|
27
|
-
console.error(_picocolors2.default.dim(error.frame));
|
|
28
|
-
} else if (error instanceof PrettyError) {
|
|
29
|
-
console.error(_picocolors2.default.red(error.message));
|
|
30
|
-
} else {
|
|
31
|
-
console.error(_picocolors2.default.red(error.stack));
|
|
32
|
-
}
|
|
33
|
-
process.exitCode = 1;
|
|
34
|
-
if (!_worker_threads.isMainThread && _worker_threads.parentPort) {
|
|
35
|
-
_worker_threads.parentPort.postMessage("error");
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
exports.PrettyError = PrettyError; exports.handleError = handleError;
|