Angular 15: Webpack throws error if I require ES6 support in browserslist file

599 views Asked by At

My browserslist file is

> 0.5%
last 2 versions
Firefox ESR
not dead
not IE 9-11

and when running ng build it throws a warning saying that ES5 output is not supported by the Angular CLI

so i added the following line to browserslist as this answer suggested: supports es6-module

but then Webpack throws invalid version error (tp.0) Log:

[error] HookWebpackError: Transform failed with 1 error:
error: Invalid version: "tp.0"
    at makeWebpackError (C:\Users\manna\Desktop\AngularProjects\angular-config\node_modules\webpack\lib\HookWebpackError.js:48:9)
    at C:\Users\manna\Desktop\AngularProjects\angular-config\node_modules\webpack\lib\Compilation.js:3060:12
    at eval (eval at create (C:\Users\manna\Desktop\AngularProjects\angular-config\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:115:1)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
-- inner error --
Error: Transform failed with 1 error:
error: Invalid version: "tp.0"
    at failureErrorWithLog (C:\Users\manna\Desktop\AngularProjects\angular-config\node_modules\esbuild\lib\main.js:1604:15)
    at C:\Users\manna\Desktop\AngularProjects\angular-config\node_modules\esbuild\lib\main.js:837:29
    at responseCallbacks.<computed> (C:\Users\manna\Desktop\AngularProjects\angular-config\node_modules\esbuild\lib\main.js:701:9)
    at handleIncomingPacket (C:\Users\manna\Desktop\AngularProjects\angular-config\node_modules\esbuild\lib\main.js:756:9)
    at Socket.readFromStdout (C:\Users\manna\Desktop\AngularProjects\angular-config\node_modules\esbuild\lib\main.js:677:7)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Readable.push (node:internal/streams/readable:234:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)
1

There are 1 answers

1
Zze On

We experienced this exact same issue. However this was fixed in Angular 15.0.4 on 2022-12-14.

I am struggling to find the exact change that they made in the 15.0.4 release history, however this is the link to the doco update they made that accompanied the fix.

https://github.com/angular/angular/pull/47842/files

It was something about Safari support at the time being interpreted as an ES5 browser under the "last 2 versions" inclusion.