-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix Cloudflare Workers adapter target #3827
Fix Cloudflare Workers adapter target #3827
Conversation
🦋 Changeset detectedLatest commit: 4867f2d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
When attempting to upload a SvelteKit app which contains modern ES features such as optional chaining or nullish coalescing, workers is unable to parse the built output. ``` Module parse failed: Unexpected token (13066:47) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders | if (typeof window !== "undefined") { | const windowAny = window; > const dataLayer = windowAny.dataLayer ?? []; | windowAny.dataLayer = dataLayer; | gtag = function() { Error: webpack returned an error. You may be able to resolve this issue by running npm install ``` I could not find any official documentation of what version of ES workers support, but ES2020 is the year that nullish coalescing was introduced, and setting it to ES2019 appears to fix the issue.
d6dfa69
to
4867f2d
Compare
Why is webpack being used to bundle stuff in cloudflare workers? The docs recommend to set |
I was taking a look at it this morning and @bluwy appears to be correct, this app was converted from a previous Cloudflare Workers app that we changed to SvelteKit. We kept parts of the workers config, including the Webpack build portion, which is no longer necessary. Removing it also fixed the issue. So I believe this could be reverted, sorry I was just typing/about to close! |
This reverts commit faefb47.
When attempting to upload a SvelteKit app which contains modern ES
features such as optional chaining or nullish coalescing, workers is
unable to parse the built output.
I could not find any official documentation of what version of ES
workers support, but ES2020 is the year that nullish coalescing was
introduced, and setting it to ES2019 appears to fix the issue.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Unsure how to test this
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpx changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0