-
Notifications
You must be signed in to change notification settings - Fork 12k
Type error between Angular CLI and Browserslist when extending a browserslist config #30183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I doubt this issue is caused by the Angular CLI, as it we just call the Browserslist API without much additional handling. Could you try running |
Hi @alan-agius4 , I don't have a But I still ran
|
I’m unable to replicate the issue. However, running I suggest to setup a runnable reproduction. You can read here why this is needed. A good way to make a minimal repro is to create a new app via This might be related to your directory structure so its really important to get an accurate repro to diagnose this. |
@alan-agius4 My library and the consuming app are separate repositories and the library is JS only while the consuming app is using Angular so it wouldn't be an apples to apples comparison recreating the library in Angular since it's TS. That being said, I did try to create an app to show this: https://github.com/maharielrosario/repro-app It's currently throwing |
The error is expected in this setup because the installed library is referencing the source code directly rather than the compiled output. Additionally, the library is built using ESM, which doesn't appear to be supported by Browserslist: https://github.com/browserslist/browserslist/blob/479f79c275c649edb59703a851c4bd2821a82653/node.js#L231 |
@alan-agius4 Browserslist author is here. Also, @maharielrosario was able to load ESM shared config by Browserslist CLI. We have problems only when we are using Angular CLI. This is why we expect that Angular CLI is breaking some Node.js |
Hi @ai, I missed that in version 20.19, Here's the output from running
It seems the core issue is that Browserslist code doesn't handle ESM default exports correctly—when requiring an ESM, the {
queries: [Module: null prototype] {
__esModule: true,
default: [ 'defaults' ]
}
} |
Thanks for the advice! Here is a fix browserslist/browserslist@4ab61c9 |
Browserslist 4.24.5 fixed ESM config support |
Command
build
Is this a regression?
The previous version in which this bug was not present was
No response
Description
I have a fresh Angular 19 application and I am trying to extend a browserslist configuration from a TS library that I changed to JS while debugging this issue. When I run the Angular build, it throws a type error.
Originally, I opened a ticket with the browserslist team so you can see browserslist/browserslist#891 for further context. I was getting errors with browserslist as they are using CommonJS requires in their code and my library and app were ESM. After removing browserslist-useragent-regexp, simplifying my library to JS, and still getting errors, they asked me to reach out to Angular as they were thinking Angular had an over complicated environment.
Minimal Reproduction
Create a shareable config following browserslist's instructions here: https://github.com/browserslist/browserslist?tab=readme-ov-file#shareable-configs
Here is my particular example with text changed as it's for a client I'm working with:
Snippet of application's package.json:
Here is the library's code for this config:
index.js
snippet of package.json
Exception or Error
Your Environment
Anything else relevant?
No response
The text was updated successfully, but these errors were encountered: