deno_emit
deno_emit copied to clipboard
Error: Unable to output during bundling.
Bundler Code:
const url = new URL("./src/main/main.ts", import.meta.url);
const emited = await bundle(url.href);
await Deno.writeTextFile("./public/main.js", emited.code);
Code for Bundling:
console.log("Test?")
Versions 0.0.1 and 0.0.2 output bundles. Version 0.1.0 outputs the following error:
error: Uncaught (in promise) Error: load_transformed failed
const ret = new Error(getStringFromWasm0(arg0, arg1));
^
at __wbg_new_3047bf4b4f02b802 (https://deno.land/x/[email protected]/lib/emit.generated.js:331:19)
at js_sys::Error::new::hd040cb16e3d44f50 (https://deno.land/x/[email protected]/lib/emit_bg.wasm:1:8603350)
at <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h915169c188c0204d (https://deno.land/x/[email protected]/lib/emit_bg.wasm:1:1828345)
at wasm_bindgen_futures::task::singlethread::Task::run::h78ba7121ec820537 (https://deno.land/x/[email protected]/lib/emit_bg.wasm:1:8123409)
at wasm_bindgen_futures::queue::Queue::new::{{closure}}::h495bec1f71203164 (https://deno.land/x/[email protected]/lib/emit_bg.wasm:1:7394644)
at <dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::h54e735cb1ca738f9 (https://deno.land/x/[email protected]/lib/emit_bg.wasm:1:8585860)
at __wbg_adapter_16 (https://deno.land/x/[email protected]/lib/emit.generated.js:209:6)
at real (https://deno.land/x/[email protected]/lib/emit.generated.js:193:14)
Version 0.3.0 outputs the following error:
error: Uncaught (in promise) Error: Unable to output during bundling.
const ret = new Error(getStringFromWasm0(arg0, arg1));
^
at __wbg_new_651776e932b7e9c7 (https://deno.land/x/[email protected]/lib/emit.generated.js:329:19)
at <anonymous> (https://deno.land/x/[email protected]/lib/emit_bg.wasm:1:7194705)
at <anonymous> (https://deno.land/x/[email protected]/lib/emit_bg.wasm:1:1673383)
at <anonymous> (https://deno.land/x/[email protected]/lib/emit_bg.wasm:1:6371297)
at <anonymous> (https://deno.land/x/[email protected]/lib/emit_bg.wasm:1:7147137)
at __wbg_adapter_16 (https://deno.land/x/[email protected]/lib/emit.generated.js:205:6)
at real (https://deno.land/x/[email protected]/lib/emit.generated.js:189:14)
I'm not sure what's going on here?
Update: [email protected] and [email protected] works
The same problem here:
import { bundle } from "https://deno.land/x/[email protected]/mod.ts";
const result = await bundle(
"https://deno.land/[email protected]/collections/binary_heap.ts",
);
console.log(result);
Output:
error: Uncaught (in promise) Error: Unable to output during bundling.
const ret = new Error(getStringFromWasm0(arg0, arg1));
^
at __wbg_new_651776e932b7e9c7 (https://deno.land/x/[email protected]/lib/emit.generated.js:329:19)
at <anonymous> (https://deno.land/x/[email protected]/lib/emit_bg.wasm:1:7227815)
at <anonymous> (https://deno.land/x/[email protected]/lib/emit_bg.wasm:1:1618850)
at <anonymous> (https://deno.land/x/[email protected]/lib/emit_bg.wasm:1:6402505)
at <anonymous> (https://deno.land/x/[email protected]/lib/emit_bg.wasm:1:7180681)
at __wbg_adapter_16 (https://deno.land/x/[email protected]/lib/emit.generated.js:205:6)
at real (https://deno.land/x/[email protected]/lib/emit.generated.js:189:14)
Deno: v1.24.3
Deno 1.25.0 & emit 0.8.0
error: Uncaught (in worker "") (in promise) Error: Unable to output during bundling.
const ret = new Error(getStringFromWasm0(arg0, arg1));
^
at __wbg_new_651776e932b7e9c7 (https://deno.land/x/[email protected]/lib/emit.generated.js:329:19)
at <anonymous> (https://deno.land/x/[email protected]/lib/emit_bg.wasm:1:7252695)
at <anonymous> (https://deno.land/x/[email protected]/lib/emit_bg.wasm:1:1623573)
at <anonymous> (https://deno.land/x/[email protected]/lib/emit_bg.wasm:1:6423357)
at <anonymous> (https://deno.land/x/[email protected]/lib/emit_bg.wasm:1:7205220)
at __wbg_adapter_16 (https://deno.land/x/[email protected]/lib/emit.generated.js:205:6)
at real (https://deno.land/x/[email protected]/lib/emit.generated.js:189:14)
error: Uncaught (in promise) Error: Unhandled error in child worker.
at Worker.#pollControl (deno:runtime/js/11_workers.js:153:21)
Seems to be caused by running emit inside of a worker as it works outside of one
this occurs because bundle
needs a loader for local and remote files. if you don't provide one, it will use the default one provided by deno_cache
-- which requires permissions to write to the file system. to fix this, you need to define your own load
function. i ripped the one out of eszip
because i used it in another project and it serves its purpose.
import { serve } from "https://deno.land/std/http/server.ts";
import { bundle } from "https://deno.land/x/emit/mod.ts";
import { load } from "https://deno.land/x/eszip/loader.ts";
serve(async () => {
const url = new URL("https://deno.land/[email protected]/examples/chat/server.ts");
const { code } = await bundle(url, { load });
return new Response(code, {
status: 200,
headers: {
"content-type": "application/javascript",
},
});
});
https://dash.deno.com/playground/emit-in-deploy https://emit-in-deploy.deno.dev
this occurs because
bundle
needs a loader for local and remote files. if you don't provide one, it will use the default one provided bydeno_cache
-- which requires permissions to write to the file system. to fix this, you need to define your ownload
function. i ripped the one out ofeszip
because i used it in another project and it serves its purpose.import { serve } from "https://deno.land/std/http/server.ts"; import { bundle } from "https://deno.land/x/emit/mod.ts"; import { load } from "https://deno.land/x/eszip/loader.ts"; serve(async () => { const url = new URL("https://deno.land/[email protected]/examples/chat/server.ts"); const { code } = await bundle(url, { load }); return new Response(code, { status: 200, headers: { "content-type": "application/javascript", }, }); });
https://dash.deno.com/playground/emit-in-deploy https://emit-in-deploy.deno.dev
It's possible this fixes the error for OP but this doesn't fix it for workers (Same error, reference This comment)
@Blocksnmore What do you mean by "for workers"? Can you provide a reproducible example?
@Blocksnmore What do you mean by "for workers"? Can you provide a reproducible example?
I'm unable to reproduce this error on the latest version of emit so I'm assuming that it's either an error that's been fixed or was an issue with my original code which I can't find.
Thank you!