@fulgurjs/federation 1.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,91 +0,0 @@
1
- # 草稿:vitejs/vite 上游 issue(P1 irregexp)——按指示仅存档于 docs/,不实际提交
2
-
3
- > 状态:草稿(2026-09-14)。证据链来自 `docs/待办问题与迁移方案.md` P1 节(2026-09-13 分步实验,
4
- > commit fed5)。若实际提交需先在干净仓库构造最小可复现(large-app 模板 + inline sourcemap 压出
5
- > 27MB 单行),下面 Reproduction 一节按此预期编写。
6
-
7
- ---
8
-
9
- ## Title
10
-
11
- `vite:build-import-analysis`: `Maximum call stack size exceeded` when a chunk contains a very long
12
- single-line `//# sourceMappingURL=data:` comment (V8 irregexp backtrack-stack exhaustion inside the
13
- build process)
14
-
15
- ## Describe the bug
16
-
17
- On a very large production build (real-world app, main entry chunk ≈ 38.8 MB containing a
18
- **single-line 27 MB** inline source map appended by rollup due to `sourcemap: 'inline'`), the build
19
- crashes with:
20
-
21
- ```
22
- RangeError: Maximum call stack size exceeded
23
- at String.replace (<anonymous>)
24
- at Object.generateBundle (node_modules/vite/dist/node/chunks/dep-*.js:…)
25
- ```
26
-
27
- The crash is inside `vite:build-import-analysis`'s `generateBundle`, where the plugin runs a
28
- `String.replace` with a regex over every chunk's code.
29
-
30
- Notably, the same regex over the same 38 MB file **succeeds offline** (a standalone Node script,
31
- even with `--stack-size=200`), but **consistently throws inside the build process**. Repeated
32
- experiments ruled out every other candidate:
33
-
34
- | Hypothesis | Experiment | Result |
35
- |---|---|---|
36
- | Regex shape (greedy/lazy) | both variants | both crash |
37
- | Rope/cons-string representation | `code.split('\n').join('\n')` flattening | still crashes |
38
- | JS call-stack exhaustion | probe shows ~63,529 frames of headroom at crash time | not the JS stack |
39
- | Content of the chunk | same file + same regex offline, `--stack-size=200` ladder | passes offline |
40
- | The regex engine itself | — | **V8 irregexp backtrack stack in the build's process state** |
41
-
42
- Conclusion from experiments: the only reliable bypass is to **avoid the regex engine entirely** for
43
- this replacement.
44
-
45
- ## Reproduction
46
-
47
- 1. `pnpm create vite large-app --template vue-ts`
48
- 2. Generate enough code so that `vite build` with `build.sourcemap: 'inline'` produces a main chunk
49
- of tens of MB (the inline `sourceMappingURL=data:` comment ends up as one giant single line —
50
- rollup appends it last, on a single line).
51
- 3. `vite build` → crash in `vite:build-import-analysis` (`String.replace` in `generateBundle`).
52
- 4. Same file + same regex in a standalone script → passes.
53
-
54
- (the crashing build had a 38.8 MB entry chunk / 27 MB single-line inline map; total 29,776 modules,
55
- 3m08s of transform before the bundle phase)
56
-
57
- ## Suggested fix
58
-
59
- `vite:build-import-analysis` rewrites imports in chunk code during `generateBundle`. The inline
60
- source-map comment is always a single line appended at the end of the chunk, so the plugin can
61
- pre-strip/protect it **without a regex**, e.g. split off lines starting with `//# sourceMappingURL=`
62
- before running its import-rewriting replace, then re-append. In our build this exact replacement
63
- (an unconditional no-regex line filter) fixed the crash while keeping output byte-identical:
64
-
65
- ```
66
- // before (crashes on 27MB single line)
67
- code = code.replace(RE, ...)
68
-
69
- // after (no regex over the giant line)
70
- const lines = code.split('\n')
71
- // ... rewrite only lines that are not the sourceMappingURL comment, re-append afterwards
72
- ```
73
-
74
- Alternatively, `vite:build-import-analysis` could skip chunks whose inline sourcemap line exceeds a
75
- size threshold and handle the comment separately.
76
-
77
- ## System Info
78
-
79
- - `vite`: 6.4.3 (build-import-analysis unchanged in this area since 5.x; verified present in 6.x line)
80
- - Operating System: macOS 15 (arm64), Node 20/24
81
- - Package manager: pnpm 11
82
-
83
- ## Any additional comments
84
-
85
- - The offline-vs-in-build discrepancy is the interesting part: identical input + identical regex +
86
- identical Node flags, only the enclosing process differs. That points at V8 irregexp's regexp
87
- stack (separate from the JS stack) being sensitive to the memory state of the build process —
88
- which makes this hard to reproduce in a small repo, and all the more worth fixing defensively by
89
- not running regexes over multi-MB single-line strings.
90
- - Related: any plugin hook that runs `String.replace`/`.match` over whole chunk sources is exposed
91
- to this; a defensive size guard in core would benefit ecosystem plugins too.