Commit 50bef56
committed
perf: let the bundler filter the build plugins
All three build plugins used the legacy `transformInclude` callback. That forces
unplugin's JS wrapper and stops the bundler applying the filter natively, so every
module in the graph called into the plugin.
- moved the id tests into `transform.filter.id`, and the `defineOgImage` substring test
into `transform.filter.code`
- dropped `isJS`. Its regex `/\.(?:[cm]?j|t)sx?$/` matches `mj` or `t`, never `mt`, so a
`.mts` or `.cts` module never reached the handler. `defineOgImage` in a `.mts` file was
silently left in the client bundle under `zeroRuntime`
- the remaining `isVue` call is not redundant: `/\.vue/` admits `?vue&type=style` and
`?nuxt_component`, which only `isVue` rejects
- `stripLiteral` parses the whole module and ran before the cheap composable test.
Reordered
- anchored every extension pattern to end-or-query, since ids carry a query in dev
- `components.islands.mjs` was a no-op branch inside the handler. It is a filter exclude
- `addBuildPlugin(..., { build: true })` filtered nothing. Kit skips a plugin on
`build: false`, and `nuxt.options.build` is always truthy1 parent f8308f5 commit 50bef56
11 files changed
Lines changed: 893 additions & 706 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
| |||
64 | 67 | | |
65 | 68 | | |
66 | 69 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
75 | 82 | | |
76 | 83 | | |
77 | 84 | | |
78 | 85 | | |
79 | | - | |
| 86 | + | |
| 87 | + | |
80 | 88 | | |
81 | 89 | | |
82 | | - | |
83 | 90 | | |
84 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
85 | 94 | | |
86 | 95 | | |
87 | 96 | | |
88 | 97 | | |
89 | | - | |
| 98 | + | |
90 | 99 | | |
91 | 100 | | |
92 | 101 | | |
0 commit comments