Просмотр исходного кода

core-js null-load + analysis plugin fix

Yuki Takei 1 месяц назад
Родитель
Сommit
5f1fa90d1c

+ 1 - 0
.kiro/specs/reduce-modules-loaded/analysis-ledger.md

@@ -29,6 +29,7 @@ Measured via `ChunkModuleStatsPlugin` in `next.config.utils.js`. The `initial` c
 | + validator → isMongoId regex in LinkEditModal | 8.6 | **1,572** | 4,608 (-112) | 6,180 (-112) | 8,895 (-112) | 2026-02-20 |
 | + validator → isMongoId regex in LinkEditModal | 8.6 | **1,572** | 4,608 (-112) | 6,180 (-112) | 8,895 (-112) | 2026-02-20 |
 | + react-hotkeys → tinykeys migration | 8.7 | **1,573** (+1) | 4,516 (-92) | 6,089 (-91) | 8,802 (-93) | 2026-02-24 |
 | + react-hotkeys → tinykeys migration | 8.7 | **1,573** (+1) | 4,516 (-92) | 6,089 (-91) | 8,802 (-93) | 2026-02-24 |
 | + markdown pipeline → next/dynamic({ ssr: true }) | 8.8 | **1,073** (-500) | 5,016 (+500) | 6,089 (0) | 8,803 (+1) | 2026-02-24 |
 | + markdown pipeline → next/dynamic({ ssr: true }) | 8.8 | **1,073** (-500) | 5,016 (+500) | 6,089 (0) | 8,803 (+1) | 2026-02-24 |
+| + core-js null-load + analysis plugin fix | 8.9 | **894** (-179) | 5,011 (-5) | 5,905 (-184) | 8,619 (-184) | 2026-02-24 |
 
 
 > **Note**: Originally reported baseline was 51.5s, but automated measurement on the same machine consistently shows ~31s. The 51.5s figure may reflect cold cache, different system load, or an earlier codebase state.
 > **Note**: Originally reported baseline was 51.5s, but automated measurement on the same machine consistently shows ~31s. The 51.5s figure may reflect cold cache, different system load, or an earlier codebase state.
 
 

+ 7 - 0
.kiro/specs/reduce-modules-loaded/tasks.md

@@ -219,6 +219,13 @@ The following loop repeats until the user declares completion:
   - Result: initial: 1,073 (-500, -31.8%) / async-only: 5,016 (+500) / total: 6,089 (unchanged) / compiled: 8,803 (+1)
   - Result: initial: 1,073 (-500, -31.8%) / async-only: 5,016 (+500) / total: 6,089 (unchanged) / compiled: 8,803 (+1)
   - _Requirements: 7.2, 6.1_
   - _Requirements: 7.2, 6.1_
 
 
+- [x] 8.9 Loop iteration 7: core-js null-load + ChunkModuleStatsPlugin analysis fix
+  - Added null-loader rule for `core-js` on client side — polyfills baked into next-i18next/react-stickynode dist files; all APIs natively supported by target browsers (Chrome 64+, Safari 12+)
+  - Null-loading eliminates 179 core-js transitive dependency modules; 37 entry-point modules remain as empty stubs
+  - Fixed `ChunkModuleStatsPlugin` to strip webpack loader prefixes (e.g., `source-map-loader!/path`) before package attribution — corrects 82 previously misattributed modules
+  - Result: initial: 894 (-179, -16.7%) / async-only: 5,011 (-5) / total: 5,905 (-184) / compiled: 8,619 (-184)
+  - _Requirements: 3.1, 3.2, 6.1_
+
 - [ ] 8.N Loop iteration N: (next iteration — measure, analyze, propose, implement)
 - [ ] 8.N Loop iteration N: (next iteration — measure, analyze, propose, implement)
 
 
 ## Phase 3: Next.js Version Upgrade Evaluation (Deferred)
 ## Phase 3: Next.js Version Upgrade Evaluation (Deferred)

+ 1 - 0
apps/app/next.config.js

@@ -130,6 +130,7 @@ module.exports = (phase) => {
             /i18next-fs-backend/, // server-only filesystem translation backend (leaks via next-i18next)
             /i18next-fs-backend/, // server-only filesystem translation backend (leaks via next-i18next)
             /\/bunyan\//, // server-only logging (client uses browser-bunyan via universal-bunyan)
             /\/bunyan\//, // server-only logging (client uses browser-bunyan via universal-bunyan)
             /bunyan-format/, // server-only log formatter (client uses @browser-bunyan/console-formatted-stream)
             /bunyan-format/, // server-only log formatter (client uses @browser-bunyan/console-formatted-stream)
+            /[\\/]core-js[\\/]/, // polyfills baked into next-i18next/react-stickynode dist; all APIs natively supported by target browsers (Chrome 64+, Safari 12+)
           ].map((packageRegExp) => {
           ].map((packageRegExp) => {
             return {
             return {
               test: packageRegExp,
               test: packageRegExp,

+ 5 - 1
apps/app/src/utils/next.config.utils.js

@@ -93,7 +93,11 @@ exports.createChunkModuleStatsPlugin = () => ({
         const analyzeModuleSet = (moduleIds, title, filename) => {
         const analyzeModuleSet = (moduleIds, title, filename) => {
           const packageCounts = {};
           const packageCounts = {};
           const appModules = [];
           const appModules = [];
-          for (const id of moduleIds) {
+          for (const rawId of moduleIds) {
+            // Strip webpack loader prefixes (e.g., "source-map-loader!/path/to/file" → "/path/to/file")
+            const id = rawId.includes('!')
+              ? rawId.slice(rawId.lastIndexOf('!') + 1)
+              : rawId;
             const nmIdx = id.lastIndexOf('node_modules/');
             const nmIdx = id.lastIndexOf('node_modules/');
             if (nmIdx !== -1) {
             if (nmIdx !== -1) {
               const rest = id.slice(nmIdx + 'node_modules/'.length);
               const rest = id.slice(nmIdx + 'node_modules/'.length);