Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/tools/deno-esbuild-bundle.ts
3544 views
1
import * as esbuild from "npm:[email protected]";
2
// Import the Wasm build on platforms where running subprocesses is not
3
// permitted, such as Deno Deploy, or when running without `--allow-run`.
4
// import * as esbuild from "https://deno.land/x/[email protected]/wasm.js";
5
6
import { denoPlugins } from "jsr:@luca/esbuild-deno-loader@^0.11.1";
7
import { assert } from "https://deno.land/[email protected]/testing/asserts.ts";
8
9
const importMapURL = `file://${Deno.cwd()}/import_map.json`;
10
// console.log("importMapURL", importMapURL);
11
12
await esbuild.build({
13
plugins: [...denoPlugins({ importMapURL })
14
// I wish I could do it this way, but it doesn't work; either
15
// the plugin is called with an unresolved name before import map,
16
// or the plugin isn't called at all..
17
// , {
18
// "name": "quarto-build-remove-eslint-disable-next-line",
19
// setup(build: any) {
20
// build.onLoad({ filter: /DOMWorld\.js/ }, async (args: any) => {
21
// console.log("HERE!!?!?!");
22
// const contents = await Deno.readTextFile(args.path);
23
// assert(contents.indexOf("eslint-disable-next-line") !== -1);
24
// const newContents = contents.replace("eslint-disable-next-line", "");
25
// return {
26
// contents: newContents,
27
// loader: "js",
28
// };
29
// });
30
// }
31
// }
32
],
33
entryPoints: ["./quarto.ts"],
34
outfile: "../package/pkg-working/bin/quarto.js",
35
bundle: true,
36
format: "esm",
37
});
38
esbuild.stop();
39
// extremely gross to have to do it this way, but apparently esbuild
40
// plugins don't compose nicely (or at least the deno plugin doesn't)
41
42
let out = Deno.readTextFileSync("../package/pkg-working/bin/quarto.js");
43
out = out.replace("eslint-disable-next-line", "");
44
Deno.writeTextFileSync("../package/pkg-working/bin/quarto.js", out);
45