fix(editor): keep manifold-3d out of consumer bundler graphs - #735
Open
Aymericr wants to merge 1 commit into
Open
fix(editor): keep manifold-3d out of consumer bundler graphs#735Aymericr wants to merge 1 commit into
Aymericr wants to merge 1 commit into
Conversation
manifold-3d's emscripten glue awaits import('node:module') behind a Node
check; the branch never executes in a browser, but webpack refuses to
build any graph that can reach it. export-manager.tsx statically imports
the manifold worker wrapper and ExportManager renders unconditionally
from the editor root, so every external webpack consumer of
@pascal-app/editor failed at build time (#715).
The worker chunk is still built by the consumer's bundler, but it no
longer contains a traceable manifold-3d specifier. The glue is loaded at
runtime through an import() no bundler follows: bare specifier first
(bun tests, dev servers, bundlers that inlined it anyway), then a
version-pinned jsDelivr copy for bundled browser builds — emscripten
locates manifold.wasm relative to the glue's own URL, so the CDN path
self-resolves. configureManifoldRuntime(options) lets offline or
CSP-restricted hosts point both URLs at self-hosted assets.
A failed load no longer poisons later attempts: the cached module
promise resets on rejection.
Fixes #715
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
Empirical check of the pattern with webpack 5.110.2, isolated repro (worker created via
Still waiting on @smokie40 to validate the branch against their real Next/webpack integration before merging (per #715). |
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.
What does this PR do?
Fixes #715. External webpack consumers of
@pascal-app/editorfail at build time becausemanifold-3d's emscripten glue awaitsimport('node:module')behind a Node-only check — the branch never executes in a browser, but webpack refuses to build a graph that can reach it.export-manager.tsxstatically imports the manifold worker wrapper andExportManagerrenders unconditionally from the editor root, so the poison was in every consumer's graph whether or not they used print export.The fix keeps the worker chunk bundler-built but removes every traceable
manifold-3dspecifier from it:print-shell-compiler-manifold-core.tskeeps only a type import frommanifold-3d; the runtime factory loads through animport()no bundler follows (webpackIgnore+@vite-ignore), trying the bare specifier first (bun tests, dev servers, bundlers that inlined it anyway) and falling back to a version-pinned jsDelivr copy for bundled browser builds. Emscripten locatesmanifold.wasmrelative to the glue's own URL, so the CDN path self-resolves the wasm.configureManifoldRuntime({ moduleUrl, wasmUrl })(exported from the package entry) lets offline or CSP-restricted hosts point both URLs at self-hosted assets before the first print export.compileManifoldMeshData's second parameter went fromwasmUrl?: stringtoruntime?: ManifoldRuntimeOptions; no caller passed it).How to test
bun test packages/editor/src/lib/print-golden-house.test.ts packages/editor/src/lib/print-shell-compiler-baseline.test.ts— the in-process runner now reaches manifold through the bare-specifier branch of the untraced import.@pascal-app/editor— the build no longer errors onnode:module; the worker chunk contains nomanifold-3dmodule.Screenshots / screen recording
N/A — non-visual packaging/loading change.
Checklist
bun devbun checkto verify)mainbranchNote
Medium Risk
Print export now depends on runtime dynamic loading (CDN fallback or host-configured URLs); misconfiguration or network blocks could break Manifold compilation without affecting unrelated editor features.
Overview
Fixes #715 by stopping webpack/Next apps that import
@pascal-app/editorfrom failing onmanifold-3d’s unreachablenode:moduleimport in the emscripten glue.print-shell-compiler-manifold-core.tsnow uses a type-onlymanifold-3dimport and loads the runtime factory via a dynamicimport()annotated withwebpackIgnore/@vite-ignore, so consumer bundlers no longer tracemanifold-3d. Resolution tries the baremanifold-3dspecifier first, then a version-pinned jsDelivr glue URL; WASM follows the glue URL unless overridden. Failed loads clear the cached module promise so a later export can retry.Hosts with CSP or offline constraints can call the new public
configureManifoldRuntime({ moduleUrl, wasmUrl })(re-exported from the package entry) before the first print export. The worker request carries those options;compileManifoldMeshDatatakes optionalManifoldRuntimeOptionsinstead of a lonewasmUrl.Reviewed by Cursor Bugbot for commit 58edd0c. Bugbot is set up for automated code reviews on this repo. Configure here.