Repository navigation
Description
Describe the bug 📝
Two separate bundling bugs introduced with the WebGPU work in the 3.5.0 line. Both block
Next.js builds entirely (Turbopack and webpack). Companion issue for
@thatopen/fragments: ThatOpen/engine_fragment#350
Reproduction ▶️
No response
Steps to reproduce 🔢
Environment
@thatopen/components |
3.6.0 (also 3.5.0) |
@thatopen/components-front |
3.6.0 (also 3.5.0) |
@thatopen/fragments |
3.6.0 |
three |
0.184.0 |
| Next.js | 16.4.4 (latest stable), 16.5.0-canary.37, and 15.5.28 — all affected |
| Node / pnpm | 22.x / 10.28 |
Reproduction: a Next.js app router project with the versions above and one client component
doing import * as OBF from "@thatopen/components-front", then next build. No model needs
to be loaded — both failures are at link time.
Bug 1 — WebGPU-only three symbols read as static members of the three namespace
@thatopen/components and @thatopen/components-front 3.5.0+ read symbols that exist only in
three/webgpu off the default three namespace. ESM makes a missing named export statically
detectable, so the bundler rejects the module graph before the runtime guards can run.
Export PointsNodeMaterial doesn't exist in target module
./node_modules/@thatopen/components-front/dist/index.js
'Node' is not exported from 'three' (imported as 'o').
'NodeUpdateType' is not exported from 'three' (imported as 'o').
'StorageTexture' is not exported from 'three' (imported as 'o').
'BlendMode' is not exported from 'three' (imported as 'o').
'RenderPipeline' is not exported from 'three' (imported as 'o').
./node_modules/@thatopen/components-front/dist/composition-*.js
Symbols involved in these two packages: TSL, NodeMaterial, WebGPURenderer,
MeshBasicNodeMaterial, PointsNodeMaterial, StorageTexture, RenderPipeline,
NodeUpdateType, BlendMode, Node, PassNode, OutputStructNode.
All verified absent from [email protected]'s default entry and present in
build/three.webgpu.js.
Worth noting the two bundlers disagree on how many surface: Turbopack reports
PointsNodeMaterial and tree-shakes the composition-* chunks; webpack links them and
reports five more. So fixing only the Turbopack-reported symbols still leaves webpack broken.
Aliasing three → three/webgpu is not a workaround: that build does not export
WebGLRenderer, and it would flip the stack's typeof THREE.WebGPURenderer === "function"
detection to true while the app still renders with WebGL.
Version bisect
Measured under both bundlers (Turbopack and webpack), no workarounds applied:
| Stack | Turbopack | webpack |
|---|---|---|
| components 3.4.9 / components-front 3.4.5 / fragments 3.4.8 | ✅ compiles clean | ✅ compiles clean |
| components 3.5.0 / components-front 3.5.0 / fragments 3.5.1 | ❌ fails | ❌ fails |
| components 3.6.0 / components-front 3.6.0 / fragments 3.6.0 | ❌ fails | ❌ fails |
On Next.js 15.x, where next build uses webpack by default, the failure is the same — so this
is not limited to Turbopack users.
THREE.{TSL,NodeMaterial,WebGPURenderer} first appear in @thatopen/components/dist at
3.5.0 (none in 3.4.9).
Suggested fix
Same as the fragments issue: resolve the webgpu namespace via await import("three/webgpu")
inside the webgpu branch rather than naming those symbols on the three namespace, or isolate
the WebGPU code behind a subpath export so WebGL consumers never link it. The
webgpu/webgl-addons-stub.mjs file already shipped in this package shows the inverse case is
handled by documented bundler aliases — WebGL consumers need the equivalent.
Bug 2 — potree-core is declared an optional peer dep but emitted as an unconditional import specifier
package.json declares:
"peerDependenciesMeta": { "potree-core": { "optional": true } }but dist/index.js contains a plain dynamic import with a literal specifier:
const { Potree: l } = await import("potree-core");Bundlers resolve dynamic-import specifiers at build time, so the optional flag cannot be
honored — an app that never touches point clouds still fails to build:
Module not found: Can't resolve 'potree-core'
./node_modules/@thatopen/components-front/dist/index.js (6661:209)
optional: true only silences the package manager's peer warning; it has no effect on module
resolution. So today potree-core is effectively a hard dependency for anyone who bundles,
which contradicts both the manifest and the intent.
This appeared in 3.5.0 — potree-core does not occur in [email protected]'s dist.
Suggested fix
Either move PointCloudLoader behind its own subpath export
(@thatopen/components-front/potree) so the specifier is never in a WebGL consumer's graph,
or guard the specifier so it is not statically analyzable, or document the required bundler
alias/stub for apps that do not use point clouds.
Current workaround
A stub module aliased in place of potree-core:
// potree-core-stub.mjs
const refuse = (name) => class {
constructor() { throw new Error(`${name}: potree-core is not installed.`); }
};
export const Potree = refuse("Potree");
export const PointCloudOctree = refuse("PointCloudOctree");
export default { Potree, PointCloudOctree };// next.config.mjs
turbopack: { resolveAlias: { "potree-core": "./potree-core-stub.mjs" } }(Installing potree-core works too, but ships an unused dependency.)
System Info 💻
Next.js - Turbopack + WebpackUsed Package Manager 📦
npm
Error Trace/Logs 📃
No response
Validations ✅
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a repository issue and not a framework-specific issue. For example, if it's a THREE.js related bug, it should likely be reported to mrdoob/threejs instead.
- Check that this is a concrete bug. For Q&A join our Community.
- The provided reproduction is a minimal reproducible example of the bug.
Activity