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

feat(cloudflare): Add support for txt and bin cloudflare specific module types #251

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adrianlyjak
Copy link
Contributor

@adrianlyjak adrianlyjak commented Apr 25, 2024

A follow on feature to #249

Changes

  • In addition to the existing wasm imports, this adds support for loading .bin and .txt files within cloudflare pages functions
  • renamed wasm related code and config options to module-loader to clarify that this supports multiple formats
    • renamed wasmModuleImports to cloudflareModules, retaining the previous so that this is non-breaking.
  • supports plain .wasm imports instead of only .wasm?module imports to be consistent with cloudflare pages
  • Modified the behavior to default to allowing wasmModuleImports by default. Initially we'd decided to keep this opt-in so as to keep the hacky branching from breaking the build: feat(@astrojs/cloudflare): Add support for wasm module imports astro#8542 (comment). There's no more branching, so now the vite plugin here is doing close to nothing except for string comparisons if there's no matching import, so it seems safe to me now. (You'd effectively be opting in by importing the right file format)
  • long term structure for the implemenation is such that it in the future it can easily be extended to support custom file extensions
    • either based on wrangler.toml rules (if cloudflare pages gets support for that, right now it seems to be workers only)
    • or perhaps the plugin could rewrite the extensions to one of the supported data types (CompiledWasm -> .wasm, Data -> .bin, or Text -> .txt)

Testing

  • Added additional test cases for each format to the wasm (now module-loader) test suite

Docs

I changed the name from wasmModuleImports to cloudflareModules in the cloudflare config. The old parameter is still available, but marked as deprecated. Any opinions around terminology here? Most everything I come up with ends up sounding generic, IMO, its hard to name this feature, so I was just going off terminology that cloudflare uses https://developers.cloudflare.com/pages/functions/module-support/.

What's the process for updating documentation? Should I make an associated merge request in the docs repo? https://github.com/withastro/docs/blob/main/src/content/docs/en/guides/integrations-guide/cloudflare.mdx

Copy link

changeset-bot bot commented Apr 25, 2024

🦋 Changeset detected

Latest commit: 64fac3f

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

This PR includes changesets to release 9 packages
Name Type
@astrojs/cloudflare Minor
@test/astro-cloudflare-astro-dev-platform Patch
@test/astro-cloudflare-external-image-service Patch
@test/astro-cloudflare-wasm Patch
@test/astro-cloudflare-no-output Patch
@test/astro-cloudflare-prerender-optimizations Patch
@test/astro-cloudflare-routes-json Patch
@test/astro-cloudflare-with-solid-js Patch
@test/astro-cloudflare-wrangler-preview-platform 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

@adrianlyjak adrianlyjak force-pushed the feat-cloudflare-bundling branch 3 times, most recently from e52355b to a0a031e Compare April 25, 2024 23:50
@adrianlyjak adrianlyjak marked this pull request as ready for review April 26, 2024 00:05
@adrianlyjak
Copy link
Contributor Author

@alexanderniebuhr
Copy link
Member

@adrianlyjak yeah a docs pr to the docs repo is needed :)

Copy link
Member

@alexanderniebuhr alexanderniebuhr left a comment

Choose a reason for hiding this comment

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

@adrianlyjak Thanks for the contribution, very happy to have it ❤️
As already said, this needs a companion docs PR in the docs repo. (fyi @sarah11918)

I personally like that you took the step to still support the old flag, so we can ship this as a minor.

adrianlyjak added a commit to adrianlyjak/withastro-docs that referenced this pull request May 7, 2024
adrianlyjak added a commit to adrianlyjak/withastro-docs that referenced this pull request May 7, 2024
adrianlyjak added a commit to adrianlyjak/withastro-docs that referenced this pull request May 7, 2024
@adrianlyjak adrianlyjak changed the title feat(cloudflare): Add support for more "bundling" formats feat(cloudflare): Add support for txt and bin cloudflare specific module types May 7, 2024
adrianlyjak added a commit to adrianlyjak/withastro-docs that referenced this pull request May 7, 2024
@adrianlyjak
Copy link
Contributor Author

@alexanderniebuhr @sarah11918 initial merge request for doc updates is here withastro/docs#8211. Let me know if you have any feedback!

@alexanderniebuhr
Copy link
Member

Thanks for the update. Will review both PR's ;)

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

Successfully merging this pull request may close these issues.

None yet

2 participants