136
install.js
@@ -0,24 +1,8 @@ | ||
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __defProps = Object.defineProperties; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __spreadValues = (a, b) => { | ||
for (var prop in b || (b = {})) | ||
if (__hasOwnProp.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
if (__getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(b)) { | ||
if (__propIsEnum.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
} | ||
return a; | ||
}; | ||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
var __copyProps = (to, from, except, desc) => { | ||
@@ -32,3 +16,10 @@ if (from && typeof from === "object" || typeof from === "function") { | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
@@ -40,27 +31,30 @@ // lib/npm/node-platform.ts | ||
var ESBUILD_BINARY_PATH = process.env.ESBUILD_BINARY_PATH || ESBUILD_BINARY_PATH; | ||
var isValidBinaryPath = (x) => !!x && x !== "/usr/bin/esbuild"; | ||
var knownWindowsPackages = { | ||
"win32 arm64 LE": "esbuild-windows-arm64", | ||
"win32 ia32 LE": "esbuild-windows-32", | ||
"win32 x64 LE": "esbuild-windows-64" | ||
"win32 arm64 LE": "@esbuild/win32-arm64", | ||
"win32 ia32 LE": "@esbuild/win32-ia32", | ||
"win32 x64 LE": "@esbuild/win32-x64" | ||
}; | ||
var knownUnixlikePackages = { | ||
"android arm64 LE": "esbuild-android-arm64", | ||
"darwin arm64 LE": "esbuild-darwin-arm64", | ||
"darwin x64 LE": "esbuild-darwin-64", | ||
"freebsd arm64 LE": "esbuild-freebsd-arm64", | ||
"freebsd x64 LE": "esbuild-freebsd-64", | ||
"linux arm LE": "esbuild-linux-arm", | ||
"linux arm64 LE": "esbuild-linux-arm64", | ||
"linux ia32 LE": "esbuild-linux-32", | ||
"linux mips64el LE": "esbuild-linux-mips64le", | ||
"linux ppc64 LE": "esbuild-linux-ppc64le", | ||
"linux riscv64 LE": "esbuild-linux-riscv64", | ||
"linux s390x BE": "esbuild-linux-s390x", | ||
"linux x64 LE": "esbuild-linux-64", | ||
"netbsd x64 LE": "esbuild-netbsd-64", | ||
"openbsd x64 LE": "esbuild-openbsd-64", | ||
"sunos x64 LE": "esbuild-sunos-64" | ||
"android arm64 LE": "@esbuild/android-arm64", | ||
"darwin arm64 LE": "@esbuild/darwin-arm64", | ||
"darwin x64 LE": "@esbuild/darwin-x64", | ||
"freebsd arm64 LE": "@esbuild/freebsd-arm64", | ||
"freebsd x64 LE": "@esbuild/freebsd-x64", | ||
"linux arm LE": "@esbuild/linux-arm", | ||
"linux arm64 LE": "@esbuild/linux-arm64", | ||
"linux ia32 LE": "@esbuild/linux-ia32", | ||
"linux mips64el LE": "@esbuild/linux-mips64el", | ||
"linux ppc64 LE": "@esbuild/linux-ppc64", | ||
"linux riscv64 LE": "@esbuild/linux-riscv64", | ||
"linux s390x BE": "@esbuild/linux-s390x", | ||
"linux x64 LE": "@esbuild/linux-x64", | ||
"linux loong64 LE": "@esbuild/linux-loong64", | ||
"netbsd x64 LE": "@esbuild/netbsd-x64", | ||
"openbsd x64 LE": "@esbuild/openbsd-x64", | ||
"sunos x64 LE": "@esbuild/sunos-x64" | ||
}; | ||
var knownWebAssemblyFallbackPackages = { | ||
"android x64 LE": "esbuild-android-64" | ||
"android arm LE": "@esbuild/android-arm", | ||
"android x64 LE": "@esbuild/android-x64" | ||
}; | ||
@@ -89,3 +83,3 @@ function pkgAndSubpathForCurrentPlatform() { | ||
const esbuildLibDir = path.dirname(require.resolve("esbuild")); | ||
return path.join(esbuildLibDir, `downloaded-${pkg}-${path.basename(subpath)}`); | ||
return path.join(esbuildLibDir, `downloaded-${pkg.replace("/", "-")}-${path.basename(subpath)}`); | ||
} | ||
@@ -100,2 +94,3 @@ | ||
var child_process = require("child_process"); | ||
var versionFromPackageJSON = require(path2.join(__dirname, "package.json")).version; | ||
var toPath = path2.join(__dirname, "bin", "esbuild"); | ||
@@ -105,8 +100,40 @@ var isToPathJS = true; | ||
command.push("--version"); | ||
const stdout = child_process.execFileSync(command.shift(), command, { | ||
stdio: "pipe" | ||
}).toString().trim(); | ||
if (stdout !== "0.14.39") { | ||
throw new Error(`Expected ${JSON.stringify("0.14.39")} but got ${JSON.stringify(stdout)}`); | ||
let stdout; | ||
try { | ||
stdout = child_process.execFileSync(command.shift(), command, { | ||
// Without this, this install script strangely crashes with the error | ||
// "EACCES: permission denied, write" but only on Ubuntu Linux when node is | ||
// installed from the Snap Store. This is not a problem when you download | ||
// the official version of node. The problem appears to be that stderr | ||
// (i.e. file descriptor 2) isn't writable? | ||
// | ||
// More info: | ||
// - https://snapcraft.io/ (what the Snap Store is) | ||
// - https://nodejs.org/dist/ (download the official version of node) | ||
// - https://github.com/evanw/esbuild/issues/1711#issuecomment-1027554035 | ||
// | ||
stdio: "pipe" | ||
}).toString().trim(); | ||
} catch (err) { | ||
if (os2.platform() === "darwin" && /_SecTrustEvaluateWithError/.test(err + "")) { | ||
let os3 = "this version of macOS"; | ||
try { | ||
os3 = "macOS " + child_process.execFileSync("sw_vers", ["-productVersion"]).toString().trim(); | ||
} catch { | ||
} | ||
throw new Error(`The "esbuild" package cannot be installed because ${os3} is too outdated. | ||
The Go compiler (which esbuild relies on) no longer supports ${os3}, | ||
which means the "esbuild" binary executable can't be run. You can either: | ||
* Update your version of macOS to one that the Go compiler supports | ||
* Use the "esbuild-wasm" package instead of the "esbuild" package | ||
* Build esbuild yourself using an older version of the Go compiler | ||
`); | ||
} | ||
throw err; | ||
} | ||
if (stdout !== versionFromPackageJSON) { | ||
throw new Error(`Expected ${JSON.stringify(versionFromPackageJSON)} but got ${JSON.stringify(stdout)}`); | ||
} | ||
} | ||
@@ -155,3 +182,3 @@ function isYarn() { | ||
function installUsingNPM(pkg, subpath, binPath) { | ||
const env = __spreadProps(__spreadValues({}, process.env), { npm_config_global: void 0 }); | ||
const env = { ...process.env, npm_config_global: void 0 }; | ||
const esbuildLibDir = path2.dirname(require.resolve("esbuild")); | ||
@@ -162,3 +189,6 @@ const installDir = path2.join(esbuildLibDir, "npm-install"); | ||
fs2.writeFileSync(path2.join(installDir, "package.json"), "{}"); | ||
child_process.execSync(`npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${"0.14.39"}`, { cwd: installDir, stdio: "pipe", env }); | ||
child_process.execSync( | ||
`npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${versionFromPackageJSON}`, | ||
{ cwd: installDir, stdio: "pipe", env } | ||
); | ||
const installedBinPath = path2.join(installDir, "node_modules", pkg, subpath); | ||
@@ -212,3 +242,3 @@ fs2.renameSync(installedBinPath, binPath); | ||
async function downloadDirectlyFromNPM(pkg, subpath, binPath) { | ||
const url = `https://registry.npmjs.org/${pkg}/-/${pkg}-${"0.14.39"}.tgz`; | ||
const url = `https://registry.npmjs.org/${pkg}/-/${pkg.replace("@esbuild/", "")}-${versionFromPackageJSON}.tgz`; | ||
console.error(`[esbuild] Trying to download ${JSON.stringify(url)}`); | ||
@@ -224,5 +254,9 @@ try { | ||
async function checkAndPreparePackage() { | ||
if (ESBUILD_BINARY_PATH) { | ||
applyManualBinaryPathOverride(ESBUILD_BINARY_PATH); | ||
return; | ||
if (isValidBinaryPath(ESBUILD_BINARY_PATH)) { | ||
if (!fs2.existsSync(ESBUILD_BINARY_PATH)) { | ||
console.warn(`[esbuild] Ignoring bad configuration: ESBUILD_BINARY_PATH=${ESBUILD_BINARY_PATH}`); | ||
} else { | ||
applyManualBinaryPathOverride(ESBUILD_BINARY_PATH); | ||
return; | ||
} | ||
} | ||
@@ -258,3 +292,3 @@ const { pkg, subpath } = pkgAndSubpathForCurrentPlatform(); | ||
if (isToPathJS) { | ||
validateBinaryVersion("node", toPath); | ||
validateBinaryVersion(process.execPath, toPath); | ||
} else { | ||
@@ -261,0 +295,0 @@ validateBinaryVersion(toPath); |
@@ -1,153 +0,186 @@ | ||
export type Platform = 'browser' | 'node' | 'neutral'; | ||
export type Format = 'iife' | 'cjs' | 'esm'; | ||
export type Loader = 'js' | 'jsx' | 'ts' | 'tsx' | 'css' | 'json' | 'text' | 'base64' | 'file' | 'dataurl' | 'binary' | 'default'; | ||
export type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent'; | ||
export type Charset = 'ascii' | 'utf8'; | ||
export type Drop = 'console' | 'debugger'; | ||
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' | 'local-css' | 'text' | 'ts' | 'tsx' | ||
export type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent' | ||
export type Charset = 'ascii' | 'utf8' | ||
export type Drop = 'console' | 'debugger' | ||
interface CommonOptions { | ||
/** Documentation: https://esbuild.github.io/api/#sourcemap */ | ||
sourcemap?: boolean | 'linked' | 'inline' | 'external' | 'both'; | ||
sourcemap?: boolean | 'linked' | 'inline' | 'external' | 'both' | ||
/** Documentation: https://esbuild.github.io/api/#legal-comments */ | ||
legalComments?: 'none' | 'inline' | 'eof' | 'linked' | 'external'; | ||
legalComments?: 'none' | 'inline' | 'eof' | 'linked' | 'external' | ||
/** Documentation: https://esbuild.github.io/api/#source-root */ | ||
sourceRoot?: string; | ||
sourceRoot?: string | ||
/** Documentation: https://esbuild.github.io/api/#sources-content */ | ||
sourcesContent?: boolean; | ||
sourcesContent?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#format */ | ||
format?: Format; | ||
/** Documentation: https://esbuild.github.io/api/#globalName */ | ||
globalName?: string; | ||
format?: Format | ||
/** Documentation: https://esbuild.github.io/api/#global-name */ | ||
globalName?: string | ||
/** Documentation: https://esbuild.github.io/api/#target */ | ||
target?: string | string[]; | ||
target?: string | string[] | ||
/** Documentation: https://esbuild.github.io/api/#supported */ | ||
supported?: Record<string, boolean> | ||
/** Documentation: https://esbuild.github.io/api/#platform */ | ||
platform?: Platform | ||
/** Documentation: https://esbuild.github.io/api/#mangle-props */ | ||
mangleProps?: RegExp; | ||
mangleProps?: RegExp | ||
/** Documentation: https://esbuild.github.io/api/#mangle-props */ | ||
reserveProps?: RegExp; | ||
reserveProps?: RegExp | ||
/** Documentation: https://esbuild.github.io/api/#mangle-props */ | ||
mangleQuoted?: boolean; | ||
mangleQuoted?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#mangle-props */ | ||
mangleCache?: Record<string, string | false>; | ||
mangleCache?: Record<string, string | false> | ||
/** Documentation: https://esbuild.github.io/api/#drop */ | ||
drop?: Drop[]; | ||
drop?: Drop[] | ||
/** Documentation: https://esbuild.github.io/api/#drop-labels */ | ||
dropLabels?: string[] | ||
/** Documentation: https://esbuild.github.io/api/#minify */ | ||
minify?: boolean; | ||
minify?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#minify */ | ||
minifyWhitespace?: boolean; | ||
minifyWhitespace?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#minify */ | ||
minifyIdentifiers?: boolean; | ||
minifyIdentifiers?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#minify */ | ||
minifySyntax?: boolean; | ||
minifySyntax?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#line-limit */ | ||
lineLimit?: number | ||
/** Documentation: https://esbuild.github.io/api/#charset */ | ||
charset?: Charset; | ||
charset?: Charset | ||
/** Documentation: https://esbuild.github.io/api/#tree-shaking */ | ||
treeShaking?: boolean; | ||
treeShaking?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#ignore-annotations */ | ||
ignoreAnnotations?: boolean; | ||
ignoreAnnotations?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#jsx */ | ||
jsx?: 'transform' | 'preserve'; | ||
jsx?: 'transform' | 'preserve' | 'automatic' | ||
/** Documentation: https://esbuild.github.io/api/#jsx-factory */ | ||
jsxFactory?: string; | ||
jsxFactory?: string | ||
/** Documentation: https://esbuild.github.io/api/#jsx-fragment */ | ||
jsxFragment?: string; | ||
jsxFragment?: string | ||
/** Documentation: https://esbuild.github.io/api/#jsx-import-source */ | ||
jsxImportSource?: string | ||
/** Documentation: https://esbuild.github.io/api/#jsx-development */ | ||
jsxDev?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#jsx-side-effects */ | ||
jsxSideEffects?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#define */ | ||
define?: { [key: string]: string }; | ||
define?: { [key: string]: string } | ||
/** Documentation: https://esbuild.github.io/api/#pure */ | ||
pure?: string[]; | ||
pure?: string[] | ||
/** Documentation: https://esbuild.github.io/api/#keep-names */ | ||
keepNames?: boolean; | ||
keepNames?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#color */ | ||
color?: boolean; | ||
color?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#log-level */ | ||
logLevel?: LogLevel; | ||
logLevel?: LogLevel | ||
/** Documentation: https://esbuild.github.io/api/#log-limit */ | ||
logLimit?: number; | ||
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 { | ||
/** Documentation: https://esbuild.github.io/api/#bundle */ | ||
bundle?: boolean; | ||
bundle?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#splitting */ | ||
splitting?: boolean; | ||
splitting?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#preserve-symlinks */ | ||
preserveSymlinks?: boolean; | ||
preserveSymlinks?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#outfile */ | ||
outfile?: string; | ||
outfile?: string | ||
/** Documentation: https://esbuild.github.io/api/#metafile */ | ||
metafile?: boolean; | ||
metafile?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#outdir */ | ||
outdir?: string; | ||
outdir?: string | ||
/** Documentation: https://esbuild.github.io/api/#outbase */ | ||
outbase?: string; | ||
/** Documentation: https://esbuild.github.io/api/#platform */ | ||
platform?: Platform; | ||
outbase?: string | ||
/** Documentation: https://esbuild.github.io/api/#external */ | ||
external?: string[]; | ||
external?: string[] | ||
/** Documentation: https://esbuild.github.io/api/#packages */ | ||
packages?: 'external' | ||
/** Documentation: https://esbuild.github.io/api/#alias */ | ||
alias?: Record<string, string> | ||
/** Documentation: https://esbuild.github.io/api/#loader */ | ||
loader?: { [ext: string]: Loader }; | ||
loader?: { [ext: string]: Loader } | ||
/** Documentation: https://esbuild.github.io/api/#resolve-extensions */ | ||
resolveExtensions?: string[]; | ||
/** Documentation: https://esbuild.github.io/api/#mainFields */ | ||
mainFields?: string[]; | ||
resolveExtensions?: string[] | ||
/** Documentation: https://esbuild.github.io/api/#main-fields */ | ||
mainFields?: string[] | ||
/** Documentation: https://esbuild.github.io/api/#conditions */ | ||
conditions?: string[]; | ||
conditions?: string[] | ||
/** Documentation: https://esbuild.github.io/api/#write */ | ||
write?: boolean; | ||
write?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#allow-overwrite */ | ||
allowOverwrite?: boolean; | ||
allowOverwrite?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#tsconfig */ | ||
tsconfig?: string; | ||
tsconfig?: string | ||
/** Documentation: https://esbuild.github.io/api/#out-extension */ | ||
outExtension?: { [ext: string]: string }; | ||
outExtension?: { [ext: string]: string } | ||
/** Documentation: https://esbuild.github.io/api/#public-path */ | ||
publicPath?: string; | ||
publicPath?: string | ||
/** Documentation: https://esbuild.github.io/api/#entry-names */ | ||
entryNames?: string; | ||
entryNames?: string | ||
/** Documentation: https://esbuild.github.io/api/#chunk-names */ | ||
chunkNames?: string; | ||
chunkNames?: string | ||
/** Documentation: https://esbuild.github.io/api/#asset-names */ | ||
assetNames?: string; | ||
assetNames?: string | ||
/** Documentation: https://esbuild.github.io/api/#inject */ | ||
inject?: string[]; | ||
inject?: string[] | ||
/** Documentation: https://esbuild.github.io/api/#banner */ | ||
banner?: { [type: string]: string }; | ||
banner?: { [type: string]: string } | ||
/** Documentation: https://esbuild.github.io/api/#footer */ | ||
footer?: { [type: string]: string }; | ||
/** Documentation: https://esbuild.github.io/api/#incremental */ | ||
incremental?: boolean; | ||
footer?: { [type: string]: string } | ||
/** Documentation: https://esbuild.github.io/api/#entry-points */ | ||
entryPoints?: string[] | Record<string, string>; | ||
entryPoints?: string[] | Record<string, string> | { in: string, out: string }[] | ||
/** Documentation: https://esbuild.github.io/api/#stdin */ | ||
stdin?: StdinOptions; | ||
stdin?: StdinOptions | ||
/** Documentation: https://esbuild.github.io/plugins/ */ | ||
plugins?: Plugin[]; | ||
plugins?: Plugin[] | ||
/** Documentation: https://esbuild.github.io/api/#working-directory */ | ||
absWorkingDir?: string; | ||
absWorkingDir?: string | ||
/** Documentation: https://esbuild.github.io/api/#node-paths */ | ||
nodePaths?: string[]; // The "NODE_PATH" variable from Node.js | ||
/** Documentation: https://esbuild.github.io/api/#watch */ | ||
watch?: boolean | WatchMode; | ||
} | ||
export interface WatchMode { | ||
onRebuild?: (error: BuildFailure | null, result: BuildResult | null) => void; | ||
} | ||
export interface StdinOptions { | ||
contents: string; | ||
resolveDir?: string; | ||
sourcefile?: string; | ||
loader?: Loader; | ||
contents: string | Uint8Array | ||
resolveDir?: string | ||
sourcefile?: string | ||
loader?: Loader | ||
} | ||
export interface Message { | ||
pluginName: string; | ||
text: string; | ||
location: Location | null; | ||
notes: Note[]; | ||
id: string | ||
pluginName: string | ||
text: string | ||
location: Location | null | ||
notes: Note[] | ||
@@ -158,58 +191,45 @@ /** | ||
*/ | ||
detail: any; | ||
detail: any | ||
} | ||
export interface Note { | ||
text: string; | ||
location: Location | null; | ||
text: string | ||
location: Location | null | ||
} | ||
export interface Location { | ||
file: string; | ||
namespace: string; | ||
file: string | ||
namespace: string | ||
/** 1-based */ | ||
line: number; | ||
line: number | ||
/** 0-based, in bytes */ | ||
column: number; | ||
column: number | ||
/** in bytes */ | ||
length: number; | ||
lineText: string; | ||
suggestion: string; | ||
length: number | ||
lineText: string | ||
suggestion: string | ||
} | ||
export interface OutputFile { | ||
path: string; | ||
/** "text" as bytes */ | ||
contents: Uint8Array; | ||
/** "contents" as text */ | ||
text: string; | ||
path: string | ||
contents: Uint8Array | ||
hash: string | ||
/** "contents" as text (changes automatically with "contents") */ | ||
readonly text: string | ||
} | ||
export interface BuildInvalidate { | ||
(): Promise<BuildIncremental>; | ||
dispose(): void; | ||
} | ||
export interface BuildIncremental extends BuildResult { | ||
rebuild: BuildInvalidate; | ||
} | ||
export interface BuildResult { | ||
errors: Message[]; | ||
warnings: Message[]; | ||
export interface BuildResult<ProvidedOptions extends BuildOptions = BuildOptions> { | ||
errors: Message[] | ||
warnings: Message[] | ||
/** Only when "write: false" */ | ||
outputFiles?: OutputFile[]; | ||
/** Only when "incremental: true" */ | ||
rebuild?: BuildInvalidate; | ||
/** Only when "watch: true" */ | ||
stop?: () => void; | ||
outputFiles: OutputFile[] | (ProvidedOptions['write'] extends false ? never : undefined) | ||
/** Only when "metafile: true" */ | ||
metafile?: Metafile; | ||
metafile: Metafile | (ProvidedOptions['metafile'] extends true ? never : undefined) | ||
/** Only when "mangleCache" is present */ | ||
mangleCache?: Record<string, string | false>; | ||
mangleCache: Record<string, string | false> | (ProvidedOptions['mangleCache'] extends Object ? never : undefined) | ||
} | ||
export interface BuildFailure extends Error { | ||
errors: Message[]; | ||
warnings: Message[]; | ||
errors: Message[] | ||
warnings: Message[] | ||
} | ||
@@ -219,15 +239,18 @@ | ||
export interface ServeOptions { | ||
port?: number; | ||
host?: string; | ||
servedir?: string; | ||
onRequest?: (args: ServeOnRequestArgs) => void; | ||
port?: number | ||
host?: string | ||
servedir?: string | ||
keyfile?: string | ||
certfile?: string | ||
fallback?: string | ||
onRequest?: (args: ServeOnRequestArgs) => void | ||
} | ||
export interface ServeOnRequestArgs { | ||
remoteAddress: string; | ||
method: string; | ||
path: string; | ||
status: number; | ||
remoteAddress: string | ||
method: string | ||
path: string | ||
status: number | ||
/** The time to generate the response, not to send it */ | ||
timeInMS: number; | ||
timeInMS: number | ||
} | ||
@@ -237,59 +260,66 @@ | ||
export interface ServeResult { | ||
port: number; | ||
host: string; | ||
wait: Promise<void>; | ||
stop: () => void; | ||
port: number | ||
host: string | ||
} | ||
export interface TransformOptions extends CommonOptions { | ||
tsconfigRaw?: string | { | ||
compilerOptions?: { | ||
jsxFactory?: string, | ||
jsxFragmentFactory?: string, | ||
useDefineForClassFields?: boolean, | ||
importsNotUsedAsValues?: 'remove' | 'preserve' | 'error', | ||
preserveValueImports?: boolean, | ||
}, | ||
}; | ||
sourcefile?: string; | ||
loader?: Loader; | ||
banner?: string; | ||
footer?: string; | ||
/** 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 { | ||
code: string; | ||
map: string; | ||
warnings: Message[]; | ||
export interface TransformResult<ProvidedOptions extends TransformOptions = TransformOptions> { | ||
code: string | ||
map: string | ||
warnings: Message[] | ||
/** Only when "mangleCache" is present */ | ||
mangleCache?: Record<string, string | false>; | ||
mangleCache: Record<string, string | false> | (ProvidedOptions['mangleCache'] extends Object ? never : undefined) | ||
/** Only when "legalComments" is "external" */ | ||
legalComments: string | (ProvidedOptions['legalComments'] extends 'external' ? never : undefined) | ||
} | ||
export interface TransformFailure extends Error { | ||
errors: Message[]; | ||
warnings: Message[]; | ||
errors: Message[] | ||
warnings: Message[] | ||
} | ||
export interface Plugin { | ||
name: string; | ||
setup: (build: PluginBuild) => (void | Promise<void>); | ||
name: string | ||
setup: (build: PluginBuild) => (void | Promise<void>) | ||
} | ||
export interface PluginBuild { | ||
initialOptions: BuildOptions; | ||
resolve(path: string, options?: ResolveOptions): Promise<ResolveResult>; | ||
/** Documentation: https://esbuild.github.io/plugins/#build-options */ | ||
initialOptions: BuildOptions | ||
/** Documentation: https://esbuild.github.io/plugins/#resolve */ | ||
resolve(path: string, options?: ResolveOptions): Promise<ResolveResult> | ||
/** Documentation: https://esbuild.github.io/plugins/#on-start */ | ||
onStart(callback: () => | ||
(OnStartResult | null | void | Promise<OnStartResult | null | void>)): void; | ||
(OnStartResult | null | void | Promise<OnStartResult | null | void>)): void | ||
/** Documentation: https://esbuild.github.io/plugins/#on-end */ | ||
onEnd(callback: (result: BuildResult) => | ||
(void | Promise<void>)): void; | ||
(OnEndResult | null | void | Promise<OnEndResult | null | void>)): void | ||
/** Documentation: https://esbuild.github.io/plugins/#on-resolve */ | ||
onResolve(options: OnResolveOptions, callback: (args: OnResolveArgs) => | ||
(OnResolveResult | null | undefined | Promise<OnResolveResult | null | undefined>)): void; | ||
(OnResolveResult | null | undefined | Promise<OnResolveResult | null | undefined>)): void | ||
/** Documentation: https://esbuild.github.io/plugins/#on-load */ | ||
onLoad(options: OnLoadOptions, callback: (args: OnLoadArgs) => | ||
(OnLoadResult | null | undefined | Promise<OnLoadResult | null | undefined>)): void; | ||
(OnLoadResult | null | undefined | Promise<OnLoadResult | null | undefined>)): void | ||
/** Documentation: https://esbuild.github.io/plugins/#on-dispose */ | ||
onDispose(callback: () => void): void | ||
// This is a full copy of the esbuild library in case you need it | ||
esbuild: { | ||
serve: typeof serve, | ||
context: typeof context, | ||
build: typeof build, | ||
@@ -305,43 +335,52 @@ buildSync: typeof buildSync, | ||
version: typeof version, | ||
}; | ||
} | ||
} | ||
/** Documentation: https://esbuild.github.io/plugins/#resolve-options */ | ||
export interface ResolveOptions { | ||
pluginName?: string; | ||
importer?: string; | ||
namespace?: string; | ||
resolveDir?: string; | ||
kind?: ImportKind; | ||
pluginData?: any; | ||
pluginName?: string | ||
importer?: string | ||
namespace?: string | ||
resolveDir?: string | ||
kind?: ImportKind | ||
pluginData?: any | ||
} | ||
/** Documentation: https://esbuild.github.io/plugins/#resolve-results */ | ||
export interface ResolveResult { | ||
errors: Message[]; | ||
warnings: Message[]; | ||
errors: Message[] | ||
warnings: Message[] | ||
path: string; | ||
external: boolean; | ||
sideEffects: boolean; | ||
namespace: string; | ||
suffix: string; | ||
pluginData: any; | ||
path: string | ||
external: boolean | ||
sideEffects: boolean | ||
namespace: string | ||
suffix: string | ||
pluginData: any | ||
} | ||
export interface OnStartResult { | ||
errors?: PartialMessage[]; | ||
warnings?: PartialMessage[]; | ||
errors?: PartialMessage[] | ||
warnings?: PartialMessage[] | ||
} | ||
export interface OnEndResult { | ||
errors?: PartialMessage[] | ||
warnings?: PartialMessage[] | ||
} | ||
/** Documentation: https://esbuild.github.io/plugins/#on-resolve-options */ | ||
export interface OnResolveOptions { | ||
filter: RegExp; | ||
namespace?: string; | ||
filter: RegExp | ||
namespace?: string | ||
} | ||
/** Documentation: https://esbuild.github.io/plugins/#on-resolve-arguments */ | ||
export interface OnResolveArgs { | ||
path: string; | ||
importer: string; | ||
namespace: string; | ||
resolveDir: string; | ||
kind: ImportKind; | ||
pluginData: any; | ||
path: string | ||
importer: string | ||
namespace: string | ||
resolveDir: string | ||
kind: ImportKind | ||
pluginData: any | ||
} | ||
@@ -360,61 +399,68 @@ | ||
| 'import-rule' | ||
| 'composes-from' | ||
| 'url-token' | ||
/** Documentation: https://esbuild.github.io/plugins/#on-resolve-results */ | ||
export interface OnResolveResult { | ||
pluginName?: string; | ||
pluginName?: string | ||
errors?: PartialMessage[]; | ||
warnings?: PartialMessage[]; | ||
errors?: PartialMessage[] | ||
warnings?: PartialMessage[] | ||
path?: string; | ||
external?: boolean; | ||
sideEffects?: boolean; | ||
namespace?: string; | ||
suffix?: string; | ||
pluginData?: any; | ||
path?: string | ||
external?: boolean | ||
sideEffects?: boolean | ||
namespace?: string | ||
suffix?: string | ||
pluginData?: any | ||
watchFiles?: string[]; | ||
watchDirs?: string[]; | ||
watchFiles?: string[] | ||
watchDirs?: string[] | ||
} | ||
/** Documentation: https://esbuild.github.io/plugins/#on-load-options */ | ||
export interface OnLoadOptions { | ||
filter: RegExp; | ||
namespace?: string; | ||
filter: RegExp | ||
namespace?: string | ||
} | ||
/** Documentation: https://esbuild.github.io/plugins/#on-load-arguments */ | ||
export interface OnLoadArgs { | ||
path: string; | ||
namespace: string; | ||
suffix: string; | ||
pluginData: any; | ||
path: string | ||
namespace: string | ||
suffix: string | ||
pluginData: any | ||
} | ||
/** Documentation: https://esbuild.github.io/plugins/#on-load-results */ | ||
export interface OnLoadResult { | ||
pluginName?: string; | ||
pluginName?: string | ||
errors?: PartialMessage[]; | ||
warnings?: PartialMessage[]; | ||
errors?: PartialMessage[] | ||
warnings?: PartialMessage[] | ||
contents?: string | Uint8Array; | ||
resolveDir?: string; | ||
loader?: Loader; | ||
pluginData?: any; | ||
contents?: string | Uint8Array | ||
resolveDir?: string | ||
loader?: Loader | ||
pluginData?: any | ||
watchFiles?: string[]; | ||
watchDirs?: string[]; | ||
watchFiles?: string[] | ||
watchDirs?: string[] | ||
} | ||
export interface PartialMessage { | ||
pluginName?: string; | ||
text?: string; | ||
location?: Partial<Location> | null; | ||
notes?: PartialNote[]; | ||
detail?: any; | ||
id?: string | ||
pluginName?: string | ||
text?: string | ||
location?: Partial<Location> | null | ||
notes?: PartialNote[] | ||
detail?: any | ||
} | ||
export interface PartialNote { | ||
text?: string; | ||
location?: Partial<Location> | null; | ||
text?: string | ||
location?: Partial<Location> | null | ||
} | ||
/** Documentation: https://esbuild.github.io/api/#metafile */ | ||
export interface Metafile { | ||
@@ -427,3 +473,6 @@ inputs: { | ||
kind: ImportKind | ||
external?: boolean | ||
original?: string | ||
}[] | ||
format?: 'cjs' | 'esm' | ||
} | ||
@@ -441,6 +490,8 @@ } | ||
path: string | ||
kind: ImportKind | ||
kind: ImportKind | 'file-loader' | ||
external?: boolean | ||
}[] | ||
exports: string[] | ||
entryPoint?: string | ||
cssBundle?: string | ||
} | ||
@@ -451,12 +502,34 @@ } | ||
export interface FormatMessagesOptions { | ||
kind: 'error' | 'warning'; | ||
color?: boolean; | ||
terminalWidth?: number; | ||
kind: 'error' | 'warning' | ||
color?: boolean | ||
terminalWidth?: number | ||
} | ||
export interface AnalyzeMetafileOptions { | ||
color?: boolean; | ||
verbose?: boolean; | ||
color?: boolean | ||
verbose?: boolean | ||
} | ||
export interface WatchOptions { | ||
} | ||
export interface BuildContext<ProvidedOptions extends BuildOptions = BuildOptions> { | ||
/** Documentation: https://esbuild.github.io/api/#rebuild */ | ||
rebuild(): Promise<BuildResult<ProvidedOptions>> | ||
/** Documentation: https://esbuild.github.io/api/#watch */ | ||
watch(options?: WatchOptions): Promise<void> | ||
/** Documentation: https://esbuild.github.io/api/#serve */ | ||
serve(options?: ServeOptions): Promise<ServeResult> | ||
cancel(): Promise<void> | ||
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 } | ||
/** | ||
@@ -470,13 +543,9 @@ * This function invokes the "esbuild" command-line tool for you. It returns a | ||
* | ||
* Documentation: https://esbuild.github.io/api/#build-api | ||
* Documentation: https://esbuild.github.io/api/#build | ||
*/ | ||
export declare function build(options: BuildOptions & { write: false }): Promise<BuildResult & { outputFiles: OutputFile[] }>; | ||
export declare function build(options: BuildOptions & { incremental: true, metafile: true }): Promise<BuildIncremental & { metafile: Metafile }>; | ||
export declare function build(options: BuildOptions & { incremental: true }): Promise<BuildIncremental>; | ||
export declare function build(options: BuildOptions & { metafile: true }): Promise<BuildResult & { metafile: Metafile }>; | ||
export declare function build(options: BuildOptions): Promise<BuildResult>; | ||
export declare function build<T extends BuildOptions>(options: SameShape<BuildOptions, T>): Promise<BuildResult<T>> | ||
/** | ||
* This function is similar to "build" but it serves the resulting files over | ||
* HTTP on a localhost address with the specified port. | ||
* This is the advanced long-running form of "build" that supports additional | ||
* features such as watch mode and a local development server. | ||
* | ||
@@ -486,5 +555,5 @@ * - Works in node: yes | ||
* | ||
* Documentation: https://esbuild.github.io/api/#serve | ||
* Documentation: https://esbuild.github.io/api/#build | ||
*/ | ||
export declare function serve(serveOptions: ServeOptions, buildOptions: BuildOptions): Promise<ServeResult>; | ||
export declare function context<T extends BuildOptions>(options: SameShape<BuildOptions, T>): Promise<BuildContext<T>> | ||
@@ -500,5 +569,5 @@ /** | ||
* | ||
* Documentation: https://esbuild.github.io/api/#transform-api | ||
* Documentation: https://esbuild.github.io/api/#transform | ||
*/ | ||
export declare function transform(input: string, options?: TransformOptions): Promise<TransformResult>; | ||
export declare function transform<T extends TransformOptions>(input: string | Uint8Array, options?: SameShape<TransformOptions, T>): Promise<TransformResult<T>> | ||
@@ -513,3 +582,3 @@ /** | ||
*/ | ||
export declare function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]>; | ||
export declare function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]> | ||
@@ -526,3 +595,3 @@ /** | ||
*/ | ||
export declare function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise<string>; | ||
export declare function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise<string> | ||
@@ -535,6 +604,5 @@ /** | ||
* | ||
* Documentation: https://esbuild.github.io/api/#build-api | ||
* Documentation: https://esbuild.github.io/api/#build | ||
*/ | ||
export declare function buildSync(options: BuildOptions & { write: false }): BuildResult & { outputFiles: OutputFile[] }; | ||
export declare function buildSync(options: BuildOptions): BuildResult; | ||
export declare function buildSync<T extends BuildOptions>(options: SameShape<BuildOptions, T>): BuildResult<T> | ||
@@ -547,5 +615,5 @@ /** | ||
* | ||
* Documentation: https://esbuild.github.io/api/#transform-api | ||
* Documentation: https://esbuild.github.io/api/#transform | ||
*/ | ||
export declare function transformSync(input: string, options?: TransformOptions): TransformResult; | ||
export declare function transformSync<T extends TransformOptions>(input: string | Uint8Array, options?: SameShape<TransformOptions, T>): TransformResult<T> | ||
@@ -558,3 +626,3 @@ /** | ||
*/ | ||
export declare function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[]; | ||
export declare function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[] | ||
@@ -569,3 +637,3 @@ /** | ||
*/ | ||
export declare function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string; | ||
export declare function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string | ||
@@ -580,5 +648,5 @@ /** | ||
* | ||
* Documentation: https://esbuild.github.io/api/#running-in-the-browser | ||
* Documentation: https://esbuild.github.io/api/#browser | ||
*/ | ||
export declare function initialize(options: InitializeOptions): Promise<void>; | ||
export declare function initialize(options: InitializeOptions): Promise<void> | ||
@@ -590,3 +658,3 @@ export interface InitializeOptions { | ||
*/ | ||
wasmURL?: string | ||
wasmURL?: string | URL | ||
@@ -611,2 +679,2 @@ /** | ||
export let version: string; | ||
export let version: string |
{ | ||
"name": "esbuild", | ||
"version": "0.14.39", | ||
"version": "0.19.4", | ||
"description": "An extremely fast JavaScript and CSS bundler and minifier.", | ||
@@ -18,24 +18,26 @@ "repository": "https://github.com/evanw/esbuild", | ||
"optionalDependencies": { | ||
"esbuild-android-64": "0.14.39", | ||
"esbuild-android-arm64": "0.14.39", | ||
"esbuild-darwin-64": "0.14.39", | ||
"esbuild-darwin-arm64": "0.14.39", | ||
"esbuild-freebsd-64": "0.14.39", | ||
"esbuild-freebsd-arm64": "0.14.39", | ||
"esbuild-linux-32": "0.14.39", | ||
"esbuild-linux-64": "0.14.39", | ||
"esbuild-linux-arm": "0.14.39", | ||
"esbuild-linux-arm64": "0.14.39", | ||
"esbuild-linux-mips64le": "0.14.39", | ||
"esbuild-linux-ppc64le": "0.14.39", | ||
"esbuild-linux-riscv64": "0.14.39", | ||
"esbuild-linux-s390x": "0.14.39", | ||
"esbuild-netbsd-64": "0.14.39", | ||
"esbuild-openbsd-64": "0.14.39", | ||
"esbuild-sunos-64": "0.14.39", | ||
"esbuild-windows-32": "0.14.39", | ||
"esbuild-windows-64": "0.14.39", | ||
"esbuild-windows-arm64": "0.14.39" | ||
"@esbuild/android-arm": "0.19.4", | ||
"@esbuild/android-arm64": "0.19.4", | ||
"@esbuild/android-x64": "0.19.4", | ||
"@esbuild/darwin-arm64": "0.19.4", | ||
"@esbuild/darwin-x64": "0.19.4", | ||
"@esbuild/freebsd-arm64": "0.19.4", | ||
"@esbuild/freebsd-x64": "0.19.4", | ||
"@esbuild/linux-arm": "0.19.4", | ||
"@esbuild/linux-arm64": "0.19.4", | ||
"@esbuild/linux-ia32": "0.19.4", | ||
"@esbuild/linux-loong64": "0.19.4", | ||
"@esbuild/linux-mips64el": "0.19.4", | ||
"@esbuild/linux-ppc64": "0.19.4", | ||
"@esbuild/linux-riscv64": "0.19.4", | ||
"@esbuild/linux-s390x": "0.19.4", | ||
"@esbuild/linux-x64": "0.19.4", | ||
"@esbuild/netbsd-x64": "0.19.4", | ||
"@esbuild/openbsd-x64": "0.19.4", | ||
"@esbuild/sunos-x64": "0.19.4", | ||
"@esbuild/win32-arm64": "0.19.4", | ||
"@esbuild/win32-ia32": "0.19.4", | ||
"@esbuild/win32-x64": "0.19.4" | ||
}, | ||
"license": "MIT" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
131520
11.99%7
16.67%3258
6.51%22
10%15
7.14%