-
Notifications
You must be signed in to change notification settings - Fork 738
[Bug]: TinyMCE + Vite 8 (Rolldown) - Module Execution Order Bug #8812
Copy link
Copy link
Closed
Description
Reproduction link or steps
TinyMCE + Vite 8 (Rolldown) - Module Execution Order Bug
Issue Description
When multiple files independently import tinymce/tinymce, Rolldown incorrectly orders module execution in production builds. Side-effect imports (tinymce/models/dom) execute before the main tinymce module is initialized, causing ReferenceError: tinymce is not defined.
Reproduction Steps
-
Install dependencies:
npm install
-
Run development mode (WORKS):
npm run dev
- Open browser → No errors
- TinyMCE initializes correctly
-
Build for production (FAILS):
npm run preview
- Open browser console
- ERROR:
Uncaught ReferenceError: tinymce is not defined - Error occurs in bundled
models/dommodule
Root Cause
The bug is triggered by Shared Chunk Extraction in Rolldown:
- Multiple entry points (10 modules) import the same wrapper.
- Rolldown extracts TinyMCE into a shared chunk (e.g.,
assets/utils-[hash].js). - Inside this shared chunk, the module order is corrupted:
models/domis wrapped as an IIFE and executed immediately:})))();tinymce/tinymceis wrapped as a lazy CJS module and not yet executed.- Immediate execution fails because
tinymceglobal is missing.
Verification of Bug (Manual)
If for some reason the browser console doesn't show the error immediately, you can verify the bug by inspecting the generated code:
- Look in
dist/assets/for the large shared chunk (e.g.,utils-v9yuU6bo.js). - Search for the string
})))();. - You will find it at the end of the
models/dommodule region. - Note that the main
tinymcemodule nearby ends with}));(lazy) whilemodels/domends with})))();(immediate). This is the bug.
Workaround
Add to vite.config.ts:
export default {
build: {
rollupOptions: {
output: {
strictExecutionOrder: true, // Forces correct module order
},
},
},
};What is expected?
To work like vite 7
What is actually happening?
It fails
System Info
System:
OS: macOS 15.7.4
CPU: (8) x64 Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz
Memory: 1022.98 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.14.0 - /Users/doberkofler/.nvm/versions/node/v24.14.0/bin/node
npm: 11.11.1 - /Users/doberkofler/.nvm/versions/node/v24.14.0/bin/npm
pnpm: 10.32.1 - /usr/local/bin/pnpm
bun: 1.2.19 - /Users/doberkofler/.bun/bin/bun
Watchman: 2026.03.09.00 - /usr/local/bin/watchman
Browsers:
Chrome: 146.0.7680.153
Safari: 26.3.1Any additional comments?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackPriority
None yet
Effort
None yet