Skip to content

fix(pptx): externalize fflate in the browser entry - #4

Merged
eric8810 merged 2 commits into
arcships:masterfrom
Taozizz:fix/pptx-browser-fflate
Jul 24, 2026
Merged

fix(pptx): externalize fflate in the browser entry#4
eric8810 merged 2 commits into
arcships:masterfrom
Taozizz:fix/pptx-browser-fflate

Conversation

@Taozizz

@Taozizz Taozizz commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Root cause

tsup.config.ts listed fflate in noExternal while tsup's default platform is node, so esbuild resolved fflate's exports map through the node condition and inlined the Node ESM build (esm/index.mjs) into dist/browser.js. Its module-scope, unguarded

import { createRequire } from "module";
var require2 = createRequire("/");

breaks every downstream browser bundler ("createRequire" is not exported by "__vite-browser-external" on Vite/Rollup; webpack fails resolving module), and crashes the Vite dev server at module evaluation.

Fix

Option 3 from the issue, matching docx-core and xlsx-core which are unaffected for exactly this reason:

  • drop fflate from noExternal;
  • declare fflate: ^0.8.2 as a regular dependency.

dist/browser.js now keeps a bare import { Unzip, UnzipInflate } from "fflate", which consumer bundlers resolve through fflate's own exports map — browser builds get esm/browser.js. Zero occurrences of createRequire/worker_threads remain in the published dist.

Gate hardening

The release gates missed this because nothing ever bundled dist/browser.js:

  • the external tgz consumer template now imports every package's secondary entries (@arcships/pptx-core/browser, @arcships/vue-pptx, @arcships/vue-xlsx/chart|map|webgl), so entry-level bundling regressions fail the gate's vite build;
  • the template mounts PptxViewer beside 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.mjs now packs workspace @arcships/office-interaction and overrides it, instead of resolving the unpublished 0.6.0 from the registry (the standalone gate could not run at all since the 0.6.0 candidate bump).

Verification

  • pnpm test:pptx: 21/21 tests pass; verify-pptx-consumer passes 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.
  • Downstream repro: a real Vite 5 + vue-tsc app consuming the packed tgzs builds clean with its module-alias workaround removed; the pptx vendor chunk contains no Node remnants.

Fixes #1

@eric8810
eric8810 merged commit 31346b8 into arcships:master Jul 24, 2026
1 check passed
@Taozizz
Taozizz deleted the fix/pptx-browser-fflate branch July 28, 2026 03:17
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

Successfully merging this pull request may close these issues.

fix: pptx-core browser entry inlines fflate's Node ESM build — import { createRequire } from "module" breaks browser bundlers

2 participants