Remove node_modules, use bundled code instead

This commit is contained in:
Ashcon Partovi 2023-09-11 09:20:47 -07:00
parent b5e3caf47a
commit 5254461333
269 changed files with 71107 additions and 37583 deletions

88
node_modules/esbuild/lib/main.d.ts generated vendored
View file

@ -1,6 +1,6 @@
export type Platform = 'browser' | 'node' | 'neutral'
export type Format = 'iife' | 'cjs' | 'esm'
export type Loader = 'base64' | 'binary' | 'copy' | 'css' | 'dataurl' | 'default' | 'empty' | 'file' | 'js' | 'json' | 'jsx' | 'text' | 'ts' | 'tsx'
export type Loader = 'base64' | 'binary' | 'copy' | 'css' | 'dataurl' | 'default' | 'empty' | 'file' | 'js' | 'json' | 'jsx' | 'local-css' | 'text' | 'ts' | 'tsx'
export type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent'
export type Charset = 'ascii' | 'utf8'
export type Drop = 'console' | 'debugger'
@ -36,6 +36,8 @@ interface CommonOptions {
mangleCache?: Record<string, string | false>
/** Documentation: https://esbuild.github.io/api/#drop */
drop?: Drop[]
/** Documentation: https://esbuild.github.io/api/#drop-labels */
dropLabels?: string[]
/** Documentation: https://esbuild.github.io/api/#minify */
minify?: boolean
/** Documentation: https://esbuild.github.io/api/#minify */
@ -44,6 +46,8 @@ interface CommonOptions {
minifyIdentifiers?: boolean
/** Documentation: https://esbuild.github.io/api/#minify */
minifySyntax?: boolean
/** Documentation: https://esbuild.github.io/api/#line-limit */
lineLimit?: number
/** Documentation: https://esbuild.github.io/api/#charset */
charset?: Charset
/** Documentation: https://esbuild.github.io/api/#tree-shaking */
@ -79,6 +83,28 @@ interface CommonOptions {
logLimit?: number
/** Documentation: https://esbuild.github.io/api/#log-override */
logOverride?: Record<string, LogLevel>
/** Documentation: https://esbuild.github.io/api/#tsconfig-raw */
tsconfigRaw?: string | TsconfigRaw
}
export interface TsconfigRaw {
compilerOptions?: {
alwaysStrict?: boolean
baseUrl?: string
experimentalDecorators?: boolean
importsNotUsedAsValues?: 'remove' | 'preserve' | 'error'
jsx?: 'preserve' | 'react-native' | 'react' | 'react-jsx' | 'react-jsxdev'
jsxFactory?: string
jsxFragmentFactory?: string
jsxImportSource?: string
paths?: Record<string, string[]>
preserveValueImports?: boolean
strict?: boolean
target?: string
useDefineForClassFields?: boolean
verbatimModuleSyntax?: boolean
}
}
export interface BuildOptions extends CommonOptions {
@ -185,21 +211,21 @@ export interface Location {
export interface OutputFile {
path: string
/** "text" as bytes */
contents: Uint8Array
hash: string
/** "contents" as text (changes automatically with "contents") */
readonly text: string
}
export interface BuildResult<SpecificOptions extends BuildOptions = BuildOptions> {
export interface BuildResult<ProvidedOptions extends BuildOptions = BuildOptions> {
errors: Message[]
warnings: Message[]
/** Only when "write: false" */
outputFiles: OutputFile[] | (SpecificOptions['write'] extends false ? never : undefined)
outputFiles: OutputFile[] | (ProvidedOptions['write'] extends false ? never : undefined)
/** Only when "metafile: true" */
metafile: Metafile | (SpecificOptions['metafile'] extends true ? never : undefined)
metafile: Metafile | (ProvidedOptions['metafile'] extends true ? never : undefined)
/** Only when "mangleCache" is present */
mangleCache: Record<string, string | false> | (SpecificOptions['mangleCache'] extends Object ? never : undefined)
mangleCache: Record<string, string | false> | (ProvidedOptions['mangleCache'] extends Object ? never : undefined)
}
export interface BuildFailure extends Error {
@ -214,6 +240,7 @@ export interface ServeOptions {
servedir?: string
keyfile?: string
certfile?: string
fallback?: string
onRequest?: (args: ServeOnRequestArgs) => void
}
@ -233,34 +260,24 @@ export interface ServeResult {
}
export interface TransformOptions extends CommonOptions {
tsconfigRaw?: string | {
compilerOptions?: {
alwaysStrict?: boolean,
importsNotUsedAsValues?: 'remove' | 'preserve' | 'error',
jsx?: 'react' | 'react-jsx' | 'react-jsxdev' | 'preserve',
jsxFactory?: string,
jsxFragmentFactory?: string,
jsxImportSource?: string,
preserveValueImports?: boolean,
target?: string,
useDefineForClassFields?: boolean,
},
}
/** Documentation: https://esbuild.github.io/api/#sourcefile */
sourcefile?: string
/** Documentation: https://esbuild.github.io/api/#loader */
loader?: Loader
/** Documentation: https://esbuild.github.io/api/#banner */
banner?: string
/** Documentation: https://esbuild.github.io/api/#footer */
footer?: string
}
export interface TransformResult<SpecificOptions extends TransformOptions = TransformOptions> {
export interface TransformResult<ProvidedOptions extends TransformOptions = TransformOptions> {
code: string
map: string
warnings: Message[]
/** Only when "mangleCache" is present */
mangleCache: Record<string, string | false> | (SpecificOptions['mangleCache'] extends Object ? never : undefined)
mangleCache: Record<string, string | false> | (ProvidedOptions['mangleCache'] extends Object ? never : undefined)
/** Only when "legalComments" is "external" */
legalComments: string | (SpecificOptions['legalComments'] extends 'external' ? never : undefined)
legalComments: string | (ProvidedOptions['legalComments'] extends 'external' ? never : undefined)
}
export interface TransformFailure extends Error {
@ -375,6 +392,7 @@ export type ImportKind =
// CSS
| 'import-rule'
| 'composes-from'
| 'url-token'
/** Documentation: https://esbuild.github.io/plugins/#on-resolve-results */
@ -487,9 +505,9 @@ export interface AnalyzeMetafileOptions {
export interface WatchOptions {
}
export interface BuildContext<SpecificOptions extends BuildOptions = BuildOptions> {
export interface BuildContext<ProvidedOptions extends BuildOptions = BuildOptions> {
/** Documentation: https://esbuild.github.io/api/#rebuild */
rebuild(): Promise<BuildResult<SpecificOptions>>
rebuild(): Promise<BuildResult<ProvidedOptions>>
/** Documentation: https://esbuild.github.io/api/#watch */
watch(options?: WatchOptions): Promise<void>
@ -501,6 +519,11 @@ export interface BuildContext<SpecificOptions extends BuildOptions = BuildOption
dispose(): Promise<void>
}
// This is a TypeScript type-level function which replaces any keys in "In"
// that aren't in "Out" with "never". We use this to reject properties with
// typos in object literals. See: https://stackoverflow.com/questions/49580725
type SameShape<Out, In extends Out> = In & { [Key in Exclude<keyof In, keyof Out>]: never }
/**
* This function invokes the "esbuild" command-line tool for you. It returns a
* promise that either resolves with a "BuildResult" object or rejects with a
@ -511,8 +534,7 @@ export interface BuildContext<SpecificOptions extends BuildOptions = BuildOption
*
* Documentation: https://esbuild.github.io/api/#build
*/
export declare function build<SpecificOptions extends BuildOptions>(options: SpecificOptions): Promise<BuildResult<SpecificOptions>>
export declare function build(options: BuildOptions): Promise<BuildResult>
export declare function build<T extends BuildOptions>(options: SameShape<BuildOptions, T>): Promise<BuildResult<T>>
/**
* This is the advanced long-running form of "build" that supports additional
@ -523,8 +545,7 @@ export declare function build(options: BuildOptions): Promise<BuildResult>
*
* Documentation: https://esbuild.github.io/api/#build
*/
export declare function context<T extends BuildOptions>(options: T): Promise<BuildContext<T>>
export declare function context(options: BuildOptions): Promise<BuildContext>
export declare function context<T extends BuildOptions>(options: SameShape<BuildOptions, T>): Promise<BuildContext<T>>
/**
* This function transforms a single JavaScript file. It can be used to minify
@ -537,8 +558,7 @@ export declare function context(options: BuildOptions): Promise<BuildContext>
*
* Documentation: https://esbuild.github.io/api/#transform
*/
export declare function transform<SpecificOptions extends TransformOptions>(input: string | Uint8Array, options?: SpecificOptions): Promise<TransformResult<SpecificOptions>>
export declare function transform(input: string | Uint8Array, options?: TransformOptions): Promise<TransformResult>
export declare function transform<T extends TransformOptions>(input: string | Uint8Array, options?: SameShape<TransformOptions, T>): Promise<TransformResult<T>>
/**
* Converts log messages to formatted message strings suitable for printing in
@ -570,8 +590,7 @@ export declare function analyzeMetafile(metafile: Metafile | string, options?: A
*
* Documentation: https://esbuild.github.io/api/#build
*/
export declare function buildSync<SpecificOptions extends BuildOptions>(options: SpecificOptions): BuildResult<SpecificOptions>
export declare function buildSync(options: BuildOptions): BuildResult
export declare function buildSync<T extends BuildOptions>(options: SameShape<BuildOptions, T>): BuildResult<T>
/**
* A synchronous version of "transform".
@ -581,8 +600,7 @@ export declare function buildSync(options: BuildOptions): BuildResult
*
* Documentation: https://esbuild.github.io/api/#transform
*/
export declare function transformSync<SpecificOptions extends TransformOptions>(input: string, options?: SpecificOptions): TransformResult<SpecificOptions>
export declare function transformSync(input: string | Uint8Array, options?: TransformOptions): TransformResult
export declare function transformSync<T extends TransformOptions>(input: string | Uint8Array, options?: SameShape<TransformOptions, T>): TransformResult<T>
/**
* A synchronous version of "formatMessages".

58
node_modules/esbuild/lib/main.js generated vendored
View file

@ -314,7 +314,9 @@ function pushCommonFlags(flags, options, keys) {
let minifySyntax = getFlag(options, keys, "minifySyntax", mustBeBoolean);
let minifyWhitespace = getFlag(options, keys, "minifyWhitespace", mustBeBoolean);
let minifyIdentifiers = getFlag(options, keys, "minifyIdentifiers", mustBeBoolean);
let lineLimit = getFlag(options, keys, "lineLimit", mustBeInteger);
let drop = getFlag(options, keys, "drop", mustBeArray);
let dropLabels = getFlag(options, keys, "dropLabels", mustBeArray);
let charset = getFlag(options, keys, "charset", mustBeString);
let treeShaking = getFlag(options, keys, "treeShaking", mustBeBoolean);
let ignoreAnnotations = getFlag(options, keys, "ignoreAnnotations", mustBeBoolean);
@ -330,6 +332,7 @@ function pushCommonFlags(flags, options, keys) {
let pure = getFlag(options, keys, "pure", mustBeArray);
let keepNames = getFlag(options, keys, "keepNames", mustBeBoolean);
let platform = getFlag(options, keys, "platform", mustBeString);
let tsconfigRaw = getFlag(options, keys, "tsconfigRaw", mustBeStringOrObject);
if (legalComments)
flags.push(`--legal-comments=${legalComments}`);
if (sourceRoot !== void 0)
@ -348,6 +351,8 @@ function pushCommonFlags(flags, options, keys) {
flags.push(`--global-name=${globalName}`);
if (platform)
flags.push(`--platform=${platform}`);
if (tsconfigRaw)
flags.push(`--tsconfig-raw=${typeof tsconfigRaw === "string" ? tsconfigRaw : JSON.stringify(tsconfigRaw)}`);
if (minify)
flags.push("--minify");
if (minifySyntax)
@ -356,6 +361,8 @@ function pushCommonFlags(flags, options, keys) {
flags.push("--minify-whitespace");
if (minifyIdentifiers)
flags.push("--minify-identifiers");
if (lineLimit)
flags.push(`--line-limit=${lineLimit}`);
if (charset)
flags.push(`--charset=${charset}`);
if (treeShaking !== void 0)
@ -365,6 +372,8 @@ function pushCommonFlags(flags, options, keys) {
if (drop)
for (let what of drop)
flags.push(`--drop:${validateStringValue(what, "drop")}`);
if (dropLabels)
flags.push(`--drop-labels=${Array.from(dropLabels).map((what) => validateStringValue(what, "dropLabels")).join(",")}`);
if (mangleProps)
flags.push(`--mangle-props=${mangleProps.source}`);
if (reserveProps)
@ -622,7 +631,6 @@ function flagsForTransformOptions(callName, options, isTTY2, logLevelDefault) {
pushLogFlags(flags, options, keys, isTTY2, logLevelDefault);
pushCommonFlags(flags, options, keys);
let sourcemap = getFlag(options, keys, "sourcemap", mustBeStringOrBoolean);
let tsconfigRaw = getFlag(options, keys, "tsconfigRaw", mustBeStringOrObject);
let sourcefile = getFlag(options, keys, "sourcefile", mustBeString);
let loader = getFlag(options, keys, "loader", mustBeString);
let banner = getFlag(options, keys, "banner", mustBeString);
@ -631,8 +639,6 @@ function flagsForTransformOptions(callName, options, isTTY2, logLevelDefault) {
checkForInvalidFlags(options, keys, `in ${callName}() call`);
if (sourcemap)
flags.push(`--sourcemap=${sourcemap === true ? "external" : sourcemap}`);
if (tsconfigRaw)
flags.push(`--tsconfig-raw=${typeof tsconfigRaw === "string" ? tsconfigRaw : JSON.stringify(tsconfigRaw)}`);
if (sourcefile)
flags.push(`--sourcefile=${sourcefile}`);
if (loader)
@ -727,7 +733,11 @@ function createChannel(streamIn) {
}
throw new Error(`Invalid command: ` + request.command);
} catch (e) {
sendResponse(id, { errors: [extractErrorMessageV8(e, streamIn, null, void 0, "")] });
const errors = [extractErrorMessageV8(e, streamIn, null, void 0, "")];
try {
sendResponse(id, { errors });
} catch {
}
}
};
let isFirstPacket = true;
@ -735,8 +745,8 @@ function createChannel(streamIn) {
if (isFirstPacket) {
isFirstPacket = false;
let binaryVersion = String.fromCharCode(...bytes);
if (binaryVersion !== "0.17.10") {
throw new Error(`Cannot start service: Host version "${"0.17.10"}" does not match binary version ${quote(binaryVersion)}`);
if (binaryVersion !== "0.19.2") {
throw new Error(`Cannot start service: Host version "${"0.19.2"}" does not match binary version ${quote(binaryVersion)}`);
}
return;
}
@ -1134,6 +1144,7 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
const servedir = getFlag(options2, keys, "servedir", mustBeString);
const keyfile = getFlag(options2, keys, "keyfile", mustBeString);
const certfile = getFlag(options2, keys, "certfile", mustBeString);
const fallback = getFlag(options2, keys, "fallback", mustBeString);
const onRequest = getFlag(options2, keys, "onRequest", mustBeFunction);
checkForInvalidFlags(options2, keys, `in serve() call`);
const request2 = {
@ -1151,6 +1162,8 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
request2.keyfile = keyfile;
if (certfile !== void 0)
request2.certfile = certfile;
if (fallback !== void 0)
request2.fallback = fallback;
sendRequest(refs, request2, (error2, response2) => {
if (error2)
return reject(new Error(error2));
@ -1622,7 +1635,7 @@ function parseStackLinesV8(streamIn, lines, ident) {
}
function failureErrorWithLog(text, errors, warnings) {
let limit = 5;
let summary = errors.length < 1 ? "" : ` with ${errors.length} error${errors.length < 2 ? "" : "s"}:` + errors.slice(0, limit + 1).map((e, i) => {
text += errors.length < 1 ? "" : ` with ${errors.length} error${errors.length < 2 ? "" : "s"}:` + errors.slice(0, limit + 1).map((e, i) => {
if (i === limit)
return "\n...";
if (!e.location)
@ -1633,9 +1646,19 @@ error: ${e.text}`;
return `
${file}:${line}:${column}: ERROR: ${pluginText}${e.text}`;
}).join("");
let error = new Error(`${text}${summary}`);
error.errors = errors;
error.warnings = warnings;
let error = new Error(text);
for (const [key, value] of [["errors", errors], ["warnings", warnings]]) {
Object.defineProperty(error, key, {
configurable: true,
enumerable: true,
get: () => value,
set: (value2) => Object.defineProperty(error, key, {
configurable: true,
enumerable: true,
value: value2
})
});
}
return error;
}
function replaceDetailsInMessages(messages, stash) {
@ -1713,11 +1736,12 @@ function sanitizeStringArray(values, property) {
}
return result;
}
function convertOutputFiles({ path: path3, contents }) {
function convertOutputFiles({ path: path3, contents, hash }) {
let text = null;
return {
path: path3,
contents,
hash,
get text() {
const binary = this.contents;
if (text === null || binary !== contents) {
@ -1905,7 +1929,7 @@ for your current platform.`);
"node_modules",
".cache",
"esbuild",
`pnpapi-${pkg.replace("/", "-")}-${"0.17.10"}-${path.basename(subpath)}`
`pnpapi-${pkg.replace("/", "-")}-${"0.19.2"}-${path.basename(subpath)}`
);
if (!fs.existsSync(binTargetPath)) {
fs.mkdirSync(path.dirname(binTargetPath), { recursive: true });
@ -1940,7 +1964,7 @@ if (process.env.ESBUILD_WORKER_THREADS !== "0") {
}
}
var _a;
var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.17.10";
var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.19.2";
var esbuildCommandAndArgs = () => {
if ((!ESBUILD_BINARY_PATH || false) && (path2.basename(__filename) !== "main.js" || path2.basename(__dirname) !== "lib")) {
throw new Error(
@ -2007,7 +2031,7 @@ var fsAsync = {
}
}
};
var version = "0.17.10";
var version = "0.19.2";
var build = (options) => ensureServiceIsRunning().build(options);
var context = (buildOptions) => ensureServiceIsRunning().context(buildOptions);
var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
@ -2117,7 +2141,7 @@ var ensureServiceIsRunning = () => {
if (longLivedService)
return longLivedService;
let [command, args] = esbuildCommandAndArgs();
let child = child_process.spawn(command, args.concat(`--service=${"0.17.10"}`, "--ping"), {
let child = child_process.spawn(command, args.concat(`--service=${"0.19.2"}`, "--ping"), {
windowsHide: true,
stdio: ["pipe", "pipe", "inherit"],
cwd: defaultWD
@ -2217,7 +2241,7 @@ var runServiceSync = (callback) => {
esbuild: node_exports
});
callback(service);
let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.17.10"}`), {
let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.19.2"}`), {
cwd: defaultWD,
windowsHide: true,
input: stdin,
@ -2237,7 +2261,7 @@ var workerThreadService = null;
var startWorkerThreadService = (worker_threads2) => {
let { port1: mainPort, port2: workerPort } = new worker_threads2.MessageChannel();
let worker = new worker_threads2.Worker(__filename, {
workerData: { workerPort, defaultWD, esbuildVersion: "0.17.10" },
workerData: { workerPort, defaultWD, esbuildVersion: "0.19.2" },
transferList: [workerPort],
// From node's documentation: https://nodejs.org/api/worker_threads.html
//