Open Grovespaz opened 1 month ago
Thanks, that's helpful - I'll try to reproduce it.
I can't seem to produce it - both of those sets of tests pass.
What version of es-abstract
do you have installed, as well as this package? What package manager are you using? (yarn often installs incorrect dependency versions, eg)
It's very odd, after some experimentation it only seems to happen on production builds. I'm using npm and Nuxt3 (which uses Vite under the hood), this leads me to think that their build step transforms the code in such a way that it fails.
My full list of packages is such:
"array.prototype.toreversed": "^1.1.2",
"array.prototype.tosorted": "^1.1.4",
"sass": "1.75.0",
"sass-loader": "14.2.1",
"vue-scrollto": "^2.20.0"
"nuxt": "^3.11.2",
"nuxt-gtag": "^1.1.2"
Feel free to close if it's outside of your scope, of course.
what about npm ls es-abstract
?
├─┬ array.prototype.toreversed@1.1.2
│ └─┬ es-abstract@1.23.3
│ ├─┬ arraybuffer.prototype.slice@1.0.3
│ │ └── es-abstract@1.23.3 deduped
│ ├─┬ function.prototype.name@1.1.6
│ │ └── es-abstract@1.23.3 deduped
│ └─┬ string.prototype.trim@1.2.9
│ └── es-abstract@1.23.3 deduped
└─┬ array.prototype.tosorted@1.1.4
└── es-abstract@1.23.3 deduped
hmm, that should be right.
What bundler are you using? Can you confirm the literal function source that's being passed to SortCompare using the debugger?
I'm using vite (esbuild), which turns this:
npx esbuild --minify node_modules/array.prototype.tosorted/implementation.js
into this:
o = function (n, u) {
return CompareArrayElements(n, u, e);
},
causing it to fail the IsAbstractClosure
fn.name
check.
I don't think many minifiers respect (0,x)
semantics. terser happens to work here despite not respecting (0,x)
because it inlines the SortCompare
definition into the SortIndexedProperties
call site afterwards so the function coincidentally stays anonymous.
Eliding function names isn't universally safe behavior, especially when minifying, because it's introspectable, so that seems like a bug worth filing on esbuild.
When using this shim, an assertion seems to be thrown in
SortIndexedProperties
.It seems to do this in Chrome 90 and Safari 15. I've only imported this shim and imported the /auto variant. If I can provide any additional information, please let me know.