chore: update to esbuild-deno-loader@0.10.2 and esbuild@0.20.2 (#2366)
This commit is contained in:
+1
-1
@@ -6,5 +6,5 @@ export {
|
|||||||
toFileUrl,
|
toFileUrl,
|
||||||
} from "https://deno.land/std@0.216.0/path/mod.ts";
|
} from "https://deno.land/std@0.216.0/path/mod.ts";
|
||||||
export { escape as regexpEscape } from "https://deno.land/std@0.216.0/regexp/escape.ts";
|
export { escape as regexpEscape } from "https://deno.land/std@0.216.0/regexp/escape.ts";
|
||||||
export { denoPlugins } from "https://deno.land/x/esbuild_deno_loader@0.9.0/mod.ts";
|
export { denoPlugins } from "jsr:@luca/esbuild-deno-loader@0.10.3";
|
||||||
export { assertEquals } from "https://deno.land/std@0.216.0/assert/mod.ts";
|
export { assertEquals } from "https://deno.land/std@0.216.0/assert/mod.ts";
|
||||||
|
|||||||
+27
-21
@@ -2,7 +2,7 @@ import {
|
|||||||
type BuildOptions,
|
type BuildOptions,
|
||||||
type OnLoadOptions,
|
type OnLoadOptions,
|
||||||
type Plugin,
|
type Plugin,
|
||||||
} from "https://deno.land/x/esbuild@v0.19.11/mod.js";
|
} from "https://deno.land/x/esbuild@v0.20.2/mod.js";
|
||||||
import { denoPlugins, fromFileUrl, regexpEscape, relative } from "./deps.ts";
|
import { denoPlugins, fromFileUrl, regexpEscape, relative } from "./deps.ts";
|
||||||
import { Builder, BuildSnapshot } from "./mod.ts";
|
import { Builder, BuildSnapshot } from "./mod.ts";
|
||||||
|
|
||||||
@@ -23,6 +23,30 @@ export interface EsbuildBuilderOptions {
|
|||||||
basePath?: string;
|
basePath?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let esbuild: typeof import("https://deno.land/x/esbuild@v0.20.2/mod.js");
|
||||||
|
|
||||||
|
export async function initializeEsbuild() {
|
||||||
|
esbuild =
|
||||||
|
// deno-lint-ignore no-deprecated-deno-api
|
||||||
|
Deno.run === undefined ||
|
||||||
|
Deno.env.get("FRESH_ESBUILD_LOADER") === "portable"
|
||||||
|
? await import("https://deno.land/x/esbuild@v0.20.2/wasm.js")
|
||||||
|
: await import("https://deno.land/x/esbuild@v0.20.2/mod.js");
|
||||||
|
const esbuildWasmURL =
|
||||||
|
new URL("./esbuild_v0.20.2.wasm", import.meta.url).href;
|
||||||
|
|
||||||
|
// deno-lint-ignore no-deprecated-deno-api
|
||||||
|
if (Deno.run === undefined) {
|
||||||
|
await esbuild.initialize({
|
||||||
|
wasmURL: esbuildWasmURL,
|
||||||
|
worker: false,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await esbuild.initialize({});
|
||||||
|
}
|
||||||
|
return esbuild;
|
||||||
|
}
|
||||||
|
|
||||||
export class EsbuildBuilder implements Builder {
|
export class EsbuildBuilder implements Builder {
|
||||||
#options: EsbuildBuilderOptions;
|
#options: EsbuildBuilderOptions;
|
||||||
|
|
||||||
@@ -34,25 +58,7 @@ export class EsbuildBuilder implements Builder {
|
|||||||
const opts = this.#options;
|
const opts = this.#options;
|
||||||
|
|
||||||
// Lazily initialize esbuild
|
// Lazily initialize esbuild
|
||||||
// @deno-types="https://deno.land/x/esbuild@v0.19.4/mod.d.ts"
|
const esbuild = await initializeEsbuild();
|
||||||
const esbuild =
|
|
||||||
// deno-lint-ignore no-deprecated-deno-api
|
|
||||||
Deno.run === undefined ||
|
|
||||||
Deno.env.get("FRESH_ESBUILD_LOADER") === "portable"
|
|
||||||
? await import("https://deno.land/x/esbuild@v0.19.11/wasm.js")
|
|
||||||
: await import("https://deno.land/x/esbuild@v0.19.11/mod.js");
|
|
||||||
const esbuildWasmURL =
|
|
||||||
new URL("./esbuild_v0.19.11.wasm", import.meta.url).href;
|
|
||||||
|
|
||||||
// deno-lint-ignore no-deprecated-deno-api
|
|
||||||
if (Deno.run === undefined) {
|
|
||||||
await esbuild.initialize({
|
|
||||||
wasmURL: esbuildWasmURL,
|
|
||||||
worker: false,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await esbuild.initialize({});
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const absWorkingDir = opts.absoluteWorkingDir;
|
const absWorkingDir = opts.absoluteWorkingDir;
|
||||||
@@ -129,7 +135,7 @@ export class EsbuildBuilder implements Builder {
|
|||||||
|
|
||||||
return new EsbuildSnapshot(files, dependencies);
|
return new EsbuildSnapshot(files, dependencies);
|
||||||
} finally {
|
} finally {
|
||||||
esbuild.stop();
|
await esbuild.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user