Skip to content
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

esbuild keepNames use results in errors in older browsers #3477

Closed
jahorton opened this issue Nov 6, 2023 · 1 comment
Closed

esbuild keepNames use results in errors in older browsers #3477

jahorton opened this issue Nov 6, 2023 · 1 comment

Comments

@jahorton
Copy link

jahorton commented Nov 6, 2023

From part of esbuild's keepNames (https://esbuild.github.io/api/#keep-names) setup:

var ae=Object.defineProperty;var v=function(r,e){return ae(r,\"name\",{value:e,configurable:!0})};

When that block of code is executed on certain notable older browsers, the following error will be thrown:

TypeError: Cannot redefine property: name 

My team has run into this issue in our support of Android 5.0 / API 21 devices, which (if not updated) defaults to Chrome for Android 35.

This is fortunately rather easy to verify through Android Studio:

  1. Via "Tools" > "Device Manager"...
  2. The "Nexus S" and "Pixel 2 XL" simulation targets can be configured for use of API 21, which have images set to Chrome 35
  3. From there, remote-device inspection can then be used to inspect inside the simulated app's webview.
  4. Then, within the Chrome inspector window, via Console, enter the following lines commands in sequence:
var temp = function() { console.log("hello") };
console.log(temp.name); // outputs "" on API 21 / Android 5.0
Object.defineProperty(temp, 'name', {value: 'temp', configurable: true}); // will throw the error on API 21 / Android 5.0.

I cannot guarantee that API 21 is either the earliest or the last Android API to have this issue; it's simply the earliest one my team supports and is the version for which we encountered the issue.

I suppose this is a case in which keepNames should simply be off... and that's probably fair. Would be nice if there were an error clearly denoting that keepNames has failed in these cases, though - it took quite a bit of investigation to reach this conclusion.

@jahorton jahorton changed the title esbuild name minification results in errors in older browsers esbuild identifier minification results in errors in older browsers Nov 6, 2023
@jahorton jahorton changed the title esbuild identifier minification results in errors in older browsers esbuild keepNames use results in errors in older browsers Nov 6, 2023
@evanw
Copy link
Owner

evanw commented Nov 6, 2023

I think this corresponds to this configurable: true support matrix. I should be able to make esbuild generate an error if you attempt to configure it this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants