aleph.js
aleph.js copied to clipboard
Unable to use UUID v4 from deno standard library in ssr definition
The following ssr
definition fails when building an aleph application
import { SSROptions } from "https://deno.land/x/[email protected]/types.d.ts";
import { v4 } from "https://deno.land/[email protected]/uuid/mod.ts";
type Props = {
uuid: string | undefined;
};
export const ssr: SSROptions<Props> = {
props: (request) => {
const uuid = request.params["uuid"];
return {
uuid: v4.validate(uuid) ? uuid : undefined,
};
},
};
The following error log is output.
> src/.aleph/production/pages/index.bundling.js:1:19: error: Could not read from file: /foobar/src/.aleph/production/-/deno.land/[email protected]/uuid/mod.bundling.js
1 │ import { v4 } from "../../../-/deno.land/[email protected]/uuid/mod.bundling.js";
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> src/.aleph/production/-/cdn.esm.sh/v53/deno_std_node_stream.bundling.js:367:4: error: Transforming async generator functions to the configured target environment ("es2015") is not supported yet
367 │ async *iterate() {
╵ ~~~~~
> src/.aleph/production/-/cdn.esm.sh/v53/deno_std_node_stream.bundling.js:4005:73: error: Transforming async generator functions to the configured target environment ("es2015") is not supported yet
4005 │ var AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(async function*() {
╵ ~~~~~
> src/.aleph/production/-/cdn.esm.sh/v53/deno_std_node_stream.bundling.js:6408:0: error: Transforming async generator functions to the configured target environment ("es2015") is not supported yet
6408 │ async function* fromReadable(val) {
╵ ~~~~~
> src/.aleph/production/-/cdn.esm.sh/v53/deno_std_node_stream.bundling.js:6414:12: error: Transforming for-await loops to the configured target environment ("es2015") is not supported yet
6414 │ for await (const chunk of iterable){
╵ ~~~~~
error: Uncaught (in promise) Error: Build failed with 5 errors:
src/.aleph/production/-/cdn.esm.sh/v53/deno_std_node_stream.bundling.js:367:4: error: Transforming async generator functions to the configured target environment ("es2015") is not supported yet
src/.aleph/production/-/cdn.esm.sh/v53/deno_std_node_stream.bundling.js:4005:73: error: Transforming async generator functions to the configured target environment ("es2015") is not supported yet
src/.aleph/production/-/cdn.esm.sh/v53/deno_std_node_stream.bundling.js:6408:0: error: Transforming async generator functions to the configured target environment ("es2015") is not supported yet
src/.aleph/production/-/cdn.esm.sh/v53/deno_std_node_stream.bundling.js:6414:12: error: Transforming for-await loops to the configured target environment ("es2015") is not supported yet
src/.aleph/production/pages/index.bundling.js:1:19: error: Could not read from file: /foobar/src/.aleph/production/-/deno.land/[email protected]/uuid/mod.bundling.js
let error = new Error(`${text}${summary}`);
^
at failureErrorWithLog (https://deno.land/x/[email protected]/mod.js:1439:15)
at https://deno.land/x/[email protected]/mod.js:1097:28
at runOnEndCallbacks (https://deno.land/x/[email protected]/mod.js:885:63)
at buildResponseToResult (https://deno.land/x/[email protected]/mod.js:1095:7)
at https://deno.land/x/[email protected]/mod.js:1204:14
at https://deno.land/x/[email protected]/mod.js:573:9
at handleIncomingPacket (https://deno.land/x/[email protected]/mod.js:670:9)
at readFromStdout (https://deno.land/x/[email protected]/mod.js:540:7)
at https://deno.land/x/[email protected]/mod.js:1709:11
make: *** [prod] Error 1
Maybe this is not an error specific to https://deno.land/[email protected]/uuid/mod.ts. 🤷 I'll keep debugging.
Possibly related to #411
I'm also seeing this error when trying to import date-fns
and react-qr-svg
.
Not sure what the deno.js file isn't respected? I have this deno.js file:
{
"compilerOptions": {
"target": "esnext",
"lib": ["dom", "dom.iterable", "dom.asynciterable", "deno.ns", "deno.unstable"]
}
}
@tatemz please try to update the default (es2015) build target to es2018 or higher since the esbuild can't transform the async generator expression, i will improve the error outputting
FYI https://github.com/alephjs/aleph.js/blob/ac6ca05e600f72aa741ee952ab2ce1df663ede18/types.d.ts#L182