fix(pptx): externalize fflate in the browser entry - #4
Merged
Conversation
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.
Root cause
tsup.config.tslistedfflateinnoExternalwhile tsup's default platform isnode, so esbuild resolved fflate'sexportsmap through thenodecondition and inlined the Node ESM build (esm/index.mjs) intodist/browser.js. Its module-scope, unguardedbreaks every downstream browser bundler (
"createRequire" is not exported by "__vite-browser-external"on Vite/Rollup; webpack fails resolvingmodule), and crashes the Vite dev server at module evaluation.Fix
Option 3 from the issue, matching
docx-coreandxlsx-corewhich are unaffected for exactly this reason:fflatefromnoExternal;fflate: ^0.8.2as a regular dependency.dist/browser.jsnow keeps a bareimport { Unzip, UnzipInflate } from "fflate", which consumer bundlers resolve through fflate's own exports map — browser builds getesm/browser.js. Zero occurrences ofcreateRequire/worker_threadsremain in the published dist.Gate hardening
The release gates missed this because nothing ever bundled
dist/browser.js:@arcships/pptx-core/browser,@arcships/vue-pptx,@arcships/vue-xlsx/chart|map|webgl), so entry-level bundling regressions fail the gate'svite build;PptxViewerbeside the DOCX/XLSX/PDF viewers and wires its load state into the aggregate readiness check, so module-evaluation crashes fail the browser check too;verify-pptx-consumer.mjsnow packs workspace@arcships/office-interactionand overrides it, instead of resolving the unpublished0.6.0from the registry (the standalone gate could not run at all since the0.6.0candidate bump).Verification
pnpm test:pptx: 21/21 tests pass;verify-pptx-consumerpasses end to end (tgz → out-of-workspace install →tsc+vite build→ preview → Playwright click-animation check).pnpm test:consumer: 9 tgz contract checks + hardened external consumer gate (npm install,tsc,vue-tsc,vite build, Playwright blackbox) all pass.vue-tscapp consuming the packed tgzs builds clean with itsmodule-alias workaround removed; the pptx vendor chunk contains no Node remnants.Fixes #1