one 1.24.2 → 1.24.4

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.
Files changed (27) hide show
  1. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.cjs +9 -0
  2. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js +9 -0
  3. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
  4. package/dist/cjs/vite/plugins/virtualEntryPlugin.cjs +3 -3
  5. package/dist/cjs/vite/plugins/virtualEntryPlugin.native.js +4 -4
  6. package/dist/cjs/vite/plugins/virtualEntryPlugin.native.js.map +1 -1
  7. package/dist/cjs/vite/plugins/virtualEntryPlugin.test.cjs +32 -2
  8. package/dist/cjs/vite/plugins/virtualEntryPlugin.test.native.js +38 -2
  9. package/dist/cjs/vite/plugins/virtualEntryPlugin.test.native.js.map +1 -1
  10. package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs +9 -0
  11. package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs.map +1 -1
  12. package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js +9 -0
  13. package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
  14. package/dist/esm/vite/plugins/virtualEntryPlugin.mjs +3 -3
  15. package/dist/esm/vite/plugins/virtualEntryPlugin.mjs.map +1 -1
  16. package/dist/esm/vite/plugins/virtualEntryPlugin.native.js +4 -4
  17. package/dist/esm/vite/plugins/virtualEntryPlugin.native.js.map +1 -1
  18. package/dist/esm/vite/plugins/virtualEntryPlugin.test.mjs +32 -2
  19. package/dist/esm/vite/plugins/virtualEntryPlugin.test.mjs.map +1 -1
  20. package/dist/esm/vite/plugins/virtualEntryPlugin.test.native.js +38 -2
  21. package/dist/esm/vite/plugins/virtualEntryPlugin.test.native.js.map +1 -1
  22. package/package.json +9 -9
  23. package/src/vite/plugins/fileSystemRouterPlugin.tsx +10 -0
  24. package/src/vite/plugins/virtualEntryPlugin.test.ts +51 -2
  25. package/src/vite/plugins/virtualEntryPlugin.ts +27 -16
  26. package/types/vite/plugins/fileSystemRouterPlugin.d.ts.map +1 -1
  27. package/types/vite/plugins/virtualEntryPlugin.d.ts.map +1 -1
@@ -228,24 +228,35 @@ export function createVirtualEntry(options: {
228
228
  ? `linking: ${JSON.stringify(options.router.linking)},`
229
229
  : ''
230
230
 
231
- // vite 8.1 bundledDev: the client is a single bundle, so the react-refresh
232
- // preamble normally provided by /@one/dev.js (which imports /@vite/client
233
- // a module that doesn't exist in bundled mode) never installs $RefreshReg$,
234
- // and every compiler-wrapped route module then throws "preamble was not
235
- // loaded". install it here instead this runs at entry-body time, before
236
- // the lazily-globbed route modules evaluate. ('one' and /@react-refresh are
237
- // node_modules / the runtime, so neither is refresh-wrapped.)
238
- // `isBundled` is true for EVERY environment during build, so it alone can't
239
- // gate this a prod build would emit an import of /@react-refresh, which
240
- // only exists while serving. dev mode is what makes the preamble necessary.
241
- const isBundledClient =
242
- this.environment.mode === 'dev' &&
243
- this.environment.name === 'client' &&
244
- !!(this.environment.config as any)?.isBundled
245
- const refreshPreambleImport = isBundledClient
231
+ // the react-refresh preamble has to be installed before the first
232
+ // compiler-wrapped module evaluates, or that module throws "React refresh
233
+ // preamble was not loaded" and client init aborts. /@one/dev.js installs
234
+ // it, but it cannot be relied on to win: it is a DEFERRED module script,
235
+ // so it waits for the document to finish parsing, while the client entry
236
+ // is async and runs the moment it arrives. that race is decided by
237
+ // document size. a SPA shell is a few hundred bytes and dev.js wins; a
238
+ // prerendered +ssg/ssr page is hundreds of KB and the entry regularly
239
+ // wins, throws on the first route module, and leaves the page unhydrated
240
+ // and unthemed on the very same server. bundled dev has no working
241
+ // /@one/dev.js at all, since it imports /@vite/client, which does not
242
+ // exist there.
243
+ // so install it from the entry, whose body is the one point guaranteed to
244
+ // run before the lazily-globbed route modules in every dev client. the
245
+ // !$RefreshReg$ guard makes this a no-op when dev.js already won, and
246
+ // dev.js keeps its own install because injectIntoGlobalHook wants to run
247
+ // before react evaluates. ('one' and /@react-refresh are node_modules /
248
+ // the runtime, so neither is refresh-wrapped, and on the client the setup
249
+ // file is imported lazily rather than statically.)
250
+ // this must stay gated to a dev CLIENT. `isBundled` is true for EVERY
251
+ // environment during build, so it cannot gate this on its own, and a prod
252
+ // build emitting an import of /@react-refresh would reference a module
253
+ // that only exists while serving.
254
+ const isDevClient =
255
+ this.environment.mode === 'dev' && this.environment.name === 'client'
256
+ const refreshPreambleImport = isDevClient
246
257
  ? `import { injectIntoGlobalHook as __oneInjectRefresh } from '/@react-refresh'`
247
258
  : ''
248
- const refreshPreambleSetup = isBundledClient
259
+ const refreshPreambleSetup = isDevClient
249
260
  ? `if (typeof window !== 'undefined' && !window.$RefreshReg$) {
250
261
  __oneInjectRefresh(window)
251
262
  window.$RefreshReg$ = () => {}
@@ -1 +1 @@
1
- {"version":3,"file":"fileSystemRouterPlugin.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/fileSystemRouterPlugin.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAW,MAAM,EAAiB,MAAM,MAAM,CAAA;AAY1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAIxD,OAAO,KAAK,EAAE,GAAG,EAAa,MAAM,kBAAkB,CAAA;AA0BtD,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,GAAG,CAAC,aAAa,EAC1B,UAAU,EAAE,UAAU,GACrB,MAAM,CAw2BR"}
1
+ {"version":3,"file":"fileSystemRouterPlugin.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/fileSystemRouterPlugin.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAW,MAAM,EAAiB,MAAM,MAAM,CAAA;AAY1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAIxD,OAAO,KAAK,EAAE,GAAG,EAAa,MAAM,kBAAkB,CAAA;AA0BtD,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,GAAG,CAAC,aAAa,EAC1B,UAAU,EAAE,UAAU,GACrB,MAAM,CAk3BR"}
@@ -1 +1 @@
1
- {"version":3,"file":"virtualEntryPlugin.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/virtualEntryPlugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AASlC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAsGnC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAC1C,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;IACpC,KAAK,EAAE,GAAG,CAAC,KAAK,CAAA;IAChB,SAAS,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC,WAAW,CAAC,CAAA;IAC1C,UAAU,EAAE,UAAU,CAAA;CACvB,GAAG,MAAM,CAoMT"}
1
+ {"version":3,"file":"virtualEntryPlugin.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/virtualEntryPlugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AASlC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAsGnC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAC1C,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;IACpC,KAAK,EAAE,GAAG,CAAC,KAAK,CAAA;IAChB,SAAS,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC,WAAW,CAAC,CAAA;IAC1C,UAAU,EAAE,UAAU,CAAA;CACvB,GAAG,MAAM,CA+MT"}