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

[adapter-cloudflare-workers] Not able to upload/publish built site to Workers #4884

Closed
jaymakes11 opened this issue May 12, 2022 · 2 comments

Comments

@jaymakes11
Copy link

jaymakes11 commented May 12, 2022

Describe the bug

When running wrangler publish on my compiled Sveltekit site, Wrangler throws the following error:

Error: Something went wrong with the request to Cloudflare...
Uncaught SyntaxError: Cannot use import statement outside a module
  at line 1
 [API code: 10021]

Reproduction

I'm using the latest v1 version of Wrangler (1.19.12). I was not able to get Wrangler 2.x (which is now generally available) to work with the Cloudflare Workers adapter (which is a separate issue, created #4885 for this).

Relevant portions of my wrangler.toml:

type = "javascript"

[site]
bucket = "./dist/assets"
entry-point = "./dist/worker"

[build.upload]
format = "modules"
main = "./worker.mjs"

Logs

🌀  Running 
✨  Build completed successfully!
🌀  Using namespace for Workers Site "__my-production-workers_sites_assets"
✨  Success
🌀  Uploading site files
Error: Something went wrong with the request to Cloudflare...
Uncaught SyntaxError: Cannot use import statement outside a module
  at line 1
 [API code: 10021]

System Info

System:
  OS: macOS 12.3.1
  CPU: (10) arm64 Apple M1 Max
  Memory: 5.04 GB / 64.00 GB
  Shell: 5.8 - /bin/zsh
Binaries:
  Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node
  Yarn: 1.22.17 - ~/.nvm/versions/node/v16.14.0/bin/yarn
  npm: 8.5.4 - ~/.nvm/versions/node/v16.14.0/bin/npm
Browsers:
  Brave Browser: 101.1.38.111
  Chrome: 101.0.4951.64
  Firefox: 100.0
  Safari: 15.4
npmPackages:
  @sveltejs/adapter-cloudflare-workers: ^1.0.0-next.39 => 1.0.0-next.39 
  @sveltejs/kit: 1.0.0-next.328 => 1.0.0-next.328 
  svelte: ^3.47.0 => 3.47.0

Severity

blocking all usage of SvelteKit

Additional Information

Without this I'm unable to deploy my site to production. I was initially using the static adapter but switched over after reading #4818 and also after having issues with getting error pages to render on 404s and such (due to not knowing how to properly handle things in my Workers' index file). So I now have a site that I'm unable to update until this is addressed.

@jaymakes11 jaymakes11 changed the title [adapter-cloudflare-workers] Built site not able to be uploaded to Workers [adapter-cloudflare-workers] Not able to upload built site to Workers May 12, 2022
@jaymakes11 jaymakes11 changed the title [adapter-cloudflare-workers] Not able to upload built site to Workers [adapter-cloudflare-workers] Not able to upload/publish built site to Workers May 12, 2022
@Rich-Harris
Copy link
Member

I think the answer here is to drop support for Wrangler 1 and all its idiosyncracies, and just use Wrangler 2 instead. Opened #4887 for that

@Rich-Harris
Copy link
Member

#4887 was merged, and requires the use of Wrangler 2 which should have no problem with ESM syntax, so I'll close this (but feel free to open a new issue with a reproduction if not)

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