Commit f4f5f91
authored
fix(frontend): drop playcanvas manualChunk + raise Docker build heap + add fork-friendly prepare hook (#184)
* fix(frontend): drop playcanvas manualChunk + raise Docker build heap
The Vite config split `node_modules/playcanvas` into its own chunk for
caching and parallel-fetch reasons. That split surfaced a cross-chunk
module-evaluation race: a minified class identifier inside the
playcanvas chunk was undefined at the moment an engine-chunk module
called `new` on it, manifesting as "q is not a constructor" at runtime.
The race depends on Rollup version, native-binary platform, and Node
major — so the same source compiled on Mac and inside `node:20-alpine`
can disagree on whether the dashboard loads.
Letting Rollup co-locate playcanvas with the engine code that imports
it keeps the class definition and its instantiation inside the same
module record, removing the race entirely. The engine chunk is still
lazy-loaded by the dashboard route so non-dashboard pages remain
unaffected, and dashboard users were already loading both chunks so
bytes-over-the-wire to that route are unchanged.
Bundle shape after the change (verified inside `node:20-alpine`):
dist/assets/engine-*.js ~3.1 MB (PlayCanvas now inlined here)
dist/assets/mermaid-*.js ~4.4 MB (unchanged)
dist/assets/rapier-*.js ~233 kB (unchanged)
dist/assets/colyseus-*.js ~154 kB (unchanged)
no dist/assets/playcanvas-*.js — split removed
The larger engine chunk pushes Rollup's rendering pass close to Node's
default ~1.7 GB old-space heap, so bump the Docker build to 4 GB via
`NODE_OPTIONS`. Local Mac builds with `npm run build` were unaffected
because npm scripts inherit a more generous default; pinning it at the
Dockerfile level keeps the production build deterministic across hosts
with different system memory.
Signed-off-by: Arun Rajkumar <mickyarunr@gmail.com>
* chore(frontend): add no-op prepare hook for downstream fork conflict avoidance
Add a `prepare` script that registers `npm-merge-driver` for
package-lock.json conflicts. Upstream itself has no merge conflicts to
reconcile, so the registered driver is a no-op here; the value is that
downstream forks of this repo can rely on the same line being present
in their package.json without having to add it themselves — which
would otherwise produce a one-line drift in the `scripts` block and a
guaranteed `package.json` merge conflict on every fork sync that
touches an adjacent script.
The script only runs when invoked from inside a git working tree
(`test -d ../.git`) so the Docker build (which copies only the
frontend tree, not .git) is unaffected. `npx --yes` lets the package
resolve on first use without a separate install step.
Background: a downstream Docker deploy was bitten this week by a
chain of upstream-merge -> lockfile conflict -> "regenerate the
lockfile" -> silent transitive drift, which ultimately broke
production. This hook is the upstream half of the fix that prevents
the same shape of pain on any fork tracking this repo.
Signed-off-by: Arun Rajkumar <mickyarunr@gmail.com>
---------
Signed-off-by: Arun Rajkumar <mickyarunr@gmail.com>1 parent 84ca5a6 commit f4f5f91
3 files changed
Lines changed: 23 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
19 | 28 | | |
20 | 29 | | |
21 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
42 | 50 | | |
43 | | - | |
44 | 51 | | |
45 | 52 | | |
46 | 53 | | |
| |||
0 commit comments