2024-06-03 16:12:38 -04:00
|
|
|
import * as ESBuild from "https://deno.land/x/esbuild@v0.19.2/wasm.js";
|
|
|
|
import * as Mapper from "https://esm.sh/esbuild-plugin-importmaps@1.0.0";
|
|
|
|
await ESBuild.initialize({ worker: false } as ESBuild.InitializeOptions);
|
2024-06-03 14:51:40 -04:00
|
|
|
const options = {
|
2024-06-03 16:12:38 -04:00
|
|
|
plugins: [Mapper.importmapPlugin({
|
|
|
|
"imports": {
|
|
|
|
"react": "https://esm.sh/preact@10.22.0/compat",
|
|
|
|
"react/": "https://esm.sh/preact@10.22.0/compat/",
|
|
|
|
"other": "./other.tsx",
|
|
|
|
"entry": "./app.tsx"
|
|
|
|
}
|
|
|
|
})],
|
|
|
|
entryPoints: ["entry"],
|
2024-06-03 11:39:19 -04:00
|
|
|
bundle: true,
|
2024-06-03 16:12:38 -04:00
|
|
|
minify: false,
|
2024-06-03 11:39:19 -04:00
|
|
|
format: "esm",
|
2024-06-03 16:12:38 -04:00
|
|
|
jsx: "automatic",
|
|
|
|
jsxImportSource: "react"
|
|
|
|
} as ESBuild.BuildOptions;
|
2024-06-03 14:51:40 -04:00
|
|
|
|
|
|
|
const result = await ESBuild.build(options);
|
2024-06-03 16:12:38 -04:00
|
|
|
const decode = new TextDecoder("utf-8")
|
|
|
|
await Deno.writeTextFile("./dump.js", decode.decode(result.outputFiles?.[0].contents));
|
2024-06-03 14:51:40 -04:00
|
|
|
ESBuild.stop();
|