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

"HeadlessChrome" in User-Agent forces downgrade to es2015 #509

Closed
mootari opened this issue Jan 27, 2023 · 2 comments
Closed

"HeadlessChrome" in User-Agent forces downgrade to es2015 #509

mootari opened this issue Jan 27, 2023 · 2 comments
Labels
browser Not working in Browser

Comments

@mootari
Copy link

mootari commented Jan 27, 2023

Whenever the User-Agent header contains "HeadlessChrome", the build target "es2015" will be selected, regardless of the specified version:

$ curl -s -H "User-Agent: HeadlessChrome/80" https://esm.sh/react@18.2.0
/* esm.sh - react@18.2.0 */
export * from "https://esm.sh/stable/react@18.2.0/es2015/react.js";
export { default } from "https://esm.sh/stable/react@18.2.0/es2015/react.js";
$ curl -s -H "User-Agent: HeadlessChrome/109" https://esm.sh/react@18.2.0
/* esm.sh - react@18.2.0 */
export * from "https://esm.sh/stable/react@18.2.0/es2015/react.js";
export { default } from "https://esm.sh/stable/react@18.2.0/es2015/react.js";
$ curl -s -H "User-Agent: Chrome/80" https://esm.sh/react@18.2.0
/* esm.sh - react@18.2.0 */
export * from "https://esm.sh/stable/react@18.2.0/es2021/react.js";
export { default } from "https://esm.sh/stable/react@18.2.0/es2021/react.js";
$ curl -s -H "User-Agent: Chrome/109" https://esm.sh/react@18.2.0
/* esm.sh - react@18.2.0 */
export * from "https://esm.sh/stable/react@18.2.0/es2022/react.js";
export { default } from "https://esm.sh/stable/react@18.2.0/es2022/react.js";
$ curl -s -H "User-Agent: HeadlessSomething/109" https://esm.sh/react@18.2.0
/* esm.sh - react@18.2.0 */
export * from "https://esm.sh/stable/react@18.2.0/esnext/react.js";
export { default } from "https://esm.sh/stable/react@18.2.0/esnext/react.js";

Please note that react is an arbitrary example. The issue was first encountered with @observablehq/stdlib, where the target causes the build to fail:

$ curl -s -H "User-Agent: HeadlessChrome/109" https://esm.sh/@observablehq/stdlib@5.3.2
/* esm.sh - error */
throw new Error("[esm.sh] " + "esbuild: Transforming async generator functions to the configured target environment (\"es2015\") is not supported yet");
export default null;
@mootari mootari added the browser Not working in Browser label Jan 27, 2023
@ije ije closed this as completed in 5c98a48 Jan 28, 2023
@ije
Copy link
Member

ije commented Jan 28, 2023

Screenshot 2023-01-28 at 11 56 57

fixed, thanks

@mootari
Copy link
Author

mootari commented Jan 28, 2023

Thank you!

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

No branches or pull requests

2 participants