alephjs / aleph.js

The Full-stack Framework in Deno.
https://aleph.deno.dev/
MIT License
5.26k stars 168 forks source link

Build fails if `es2021` is specified as `build.target` in aleph.config.ts #411

Closed calmery closed 3 years ago

calmery commented 3 years ago
// aleph.config.ts
export default (): Config => ({
  build: {
    target: "es2021",
  },
});
$ aleph --version
aleph.js 0.3.0-beta.19
deno 1.14.2
v8 9.4.146.16
typescript 4.4.2

$ aleph build
INFO Download https://deno.land/x/aleph@v0.3.0-beta.19/bundler/polyfills/es2022/mod.ts
WARN Download https://deno.land/x/aleph@v0.3.0-beta.19/bundler/polyfills/es2022/mod.ts failed, retrying...
WARN Download https://deno.land/x/aleph@v0.3.0-beta.19/bundler/polyfills/es2022/mod.ts failed, retrying...
 > error: [plugin: deno-resolve-loader] Not Found

error: Uncaught (in promise) Error: Build failed with 1 error:
error: Not Found
  let error = new Error(`${text}${summary}`);
              ^
    at failureErrorWithLog (https://deno.land/x/esbuild@v0.13.2/mod.js:1439:15)
    at https://deno.land/x/esbuild@v0.13.2/mod.js:1097:28
    at runOnEndCallbacks (https://deno.land/x/esbuild@v0.13.2/mod.js:885:63)
    at buildResponseToResult (https://deno.land/x/esbuild@v0.13.2/mod.js:1095:7)
    at https://deno.land/x/esbuild@v0.13.2/mod.js:1204:14
    at https://deno.land/x/esbuild@v0.13.2/mod.js:573:9
    at handleIncomingPacket (https://deno.land/x/esbuild@v0.13.2/mod.js:670:9)
    at readFromStdout (https://deno.land/x/esbuild@v0.13.2/mod.js:540:7)
    at https://deno.land/x/esbuild@v0.13.2/mod.js:1709:11

This code seems to be the problem.

https://github.com/alephjs/aleph.js/blob/b2811446c13f38ba86c2d9b18ecaf7b6b63735ec/bundler/mod.ts#L234

It works if you modify it as follows

const version = parseInt(build.target.slice(2))
const polyfillTarget = 'es' + (version < 2021 ? version + 1 : version) // buildTarget + 1

But it's not smart...

ije commented 3 years ago

oh 😅 you figured out!!

calmery commented 3 years ago

Thanks for fixing it :)