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

[Wrangler] Build target ES2022 #2720

Merged
merged 13 commits into from
Feb 17, 2023
Merged

[Wrangler] Build target ES2022 #2720

merged 13 commits into from
Feb 17, 2023

Conversation

JacobMGEvans
Copy link
Contributor

@JacobMGEvans JacobMGEvans commented Feb 14, 2023

What this PR solves / how to test:
Upgrade the target for JavaScript to ES2022 which is supported in the Worker runtime. You can test that it works by either inspecting your Workers built code or the code being sent over the wire on Publish, if it preserves the ES2022 code then it is working, the only thing we don't support on the Workers runtime (hence 99%) is the ES2022 RegEx feature as seen in the compat table for the latest Chrome version.

Author has included the following, where applicable:

  • Tests
  • Changeset

Reviewer has performed the following, where applicable:

  • Checked for inclusion of relevant tests
  • Checked for inclusion of a relevant changeset
  • Checked for creation of associated docs updates
  • Manually pulled down the changes and spot-tested

Fixes #2716

@changeset-bot
Copy link

changeset-bot bot commented Feb 14, 2023

🦋 Changeset detected

Latest commit: d69b791

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@JacobMGEvans JacobMGEvans added the maintenance Maintenance task label Feb 14, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Feb 14, 2023

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/runs/4205465154/npm-package-wrangler-2720

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/prs/2720/npm-package-wrangler-2720

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/runs/4205465154/npm-package-wrangler-2720 dev path/to/script.js
Additional artifacts:
npm install https://prerelease-registry.devprod.cloudflare.dev/runs/4205465154/npm-package-cloudflare-pages-shared-2720

@penalosa
Copy link
Contributor

What about esnext?

@JacobMGEvans JacobMGEvans marked this pull request as ready for review February 14, 2023 20:25
@JacobMGEvans JacobMGEvans requested a review from a team as a code owner February 14, 2023 20:25
@IgorMinar
Copy link
Contributor

What about esnext?

I'd rather not.

esnext is an "unpinned" dependency, and unpinned dependencies of any kind are dangerous as they make it possible for something that used to work well to stop working in the future. This is why npm has a lock file and why semver is a thing.

Sticking to a versioned target requires future bump, but it will be an intentional choice that we control and make rather than a side effect of future esbuild update.

@JacobMGEvans
Copy link
Contributor Author

What about esnext?

I'd rather not.

esnext is an "unpinned" dependency, and unpinned dependencies of any kind are dangerous as they make it possible for something that used to work well to stop working in the future. This is why npm has a lock file and why semver is a thing.

Sticking to a versioned target requires future bump, but it will be an intentional choice that we control and make rather than a side effect of future esbuild update.

@penalosa Yeah so as much as I would like to, I think this is one of those things we have to manually try to stay on top of as Workerd updates to latest ECMA/V8. If we do something like esnext the compat table looks like this https://kangax.github.io/compat-table/esnext/ which is 5% compat with Chrome 111/112

@codecov
Copy link

codecov bot commented Feb 15, 2023

Codecov Report

Merging #2720 (d69b791) into main (0e10605) will decrease coverage by 5.87%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2720      +/-   ##
==========================================
- Coverage   74.03%   68.16%   -5.87%     
==========================================
  Files         166      166              
  Lines       10155    10155              
  Branches     2703     2703              
==========================================
- Hits         7518     6922     -596     
- Misses       2637     3233     +596     
Impacted Files Coverage Δ
packages/wrangler/src/bundle.ts 83.00% <ø> (-10.68%) ⬇️
packages/wrangler/src/entry.ts 68.29% <ø> (-30.09%) ⬇️
packages/wrangler/src/__tests__/helpers/mock-kv.ts 10.00% <0.00%> (-90.00%) ⬇️
...rangler/src/__tests__/helpers/mock-known-routes.ts 28.57% <0.00%> (-71.43%) ⬇️
...r/src/__tests__/helpers/mock-get-zone-from-host.ts 28.57% <0.00%> (-71.43%) ⬇️
packages/wrangler/src/sites.ts 26.81% <0.00%> (-67.40%) ⬇️
packages/wrangler/src/durable.ts 24.32% <0.00%> (-64.87%) ⬇️
packages/wrangler/src/publish/publish.ts 38.10% <0.00%> (-48.60%) ⬇️
packages/wrangler/src/bundle-reporter.ts 51.61% <0.00%> (-48.39%) ⬇️
packages/wrangler/src/create-worker-upload-form.ts 44.23% <0.00%> (-46.16%) ⬇️
... and 15 more

@penalosa
Copy link
Contributor

I didn't release v8 was so far behind esnext! That makes sense to pin to 2022.

packages/wrangler/src/__tests__/publish.test.ts Outdated Show resolved Hide resolved
packages/wrangler/src/__tests__/publish.test.ts Outdated Show resolved Hide resolved
@JacobMGEvans JacobMGEvans requested review from mrbbot and a team February 16, 2023 23:20
Copy link
Contributor

@mrbbot mrbbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Using top-level await to detect es2022 with an error is clever. 🙂

@JacobMGEvans JacobMGEvans merged commit de0cb57 into main Feb 17, 2023
@JacobMGEvans JacobMGEvans deleted the jacobmgevans/esbuild-es2022 branch February 17, 2023 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Maintenance task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 BUG: wrangler unnecessarily downlevels JS code to es2020
4 participants