Repository navigation
fix(deploy): emit additional modules and use Worker conditions in framework Worker bundles - #538
Closed
Pleasurecruise wants to merge 1 commit into
Closed
Pleasurecruise wants to merge 1 commit into
Pleasurecruise wants to merge 1 commit into
Conversation
…mework Worker bundles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #535.
prepareBundledBuildOutputre-bundles framework Worker output with a plain Vite lib build. Compared with@cloudflare/vite-plugin, that build has two gaps:.wasm,.bin,.txt,.htmland.sqlimports are bundled as JavaScript. A plugin now applies the Cloudflare Vite plugin's additional module rules: it resolves#subpath imports, keeps matches external, and emits each file inrenderChunkwith a chunk-relative path.copyBundlethen uploads them with their existing module types. The Cloudflare plugin does not export this logic, so it is reimplemented here.workerdandbrowserbuilds gets the browser one. For example,decode-named-character-reference(used by micromark) then callsdocument.createElementat module load, and the deployed Worker fails withReferenceError: document is not defined. The build now usesWORKER_CONDITIONS, moved fromwrapper.tsto its own module socf-build-output.tsstill imports Vite lazily.Both changes apply to every bundle built by
prepareBundledBuildOutput, including the static Worker.Test
#subpath import and a dynamic import becomewasm/text/datamodules and passcfdry-run; a dependency withworkerdandbrowserexports resolves to itsworkerdbuild. Each fails without its fix.vp test runforcf-build-output.test.ts,wrapper.test.ts,scheduled-dispatch.test.tsandsveltekit-worker-build.test.ts, andvp run --filter ./packages/void typecheckpass.@resvg/resvg-wasmand micromark: the deployed Worker serves SSR pages.