one 1.21.12 → 1.21.13
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.
- package/dist/cjs/Root.native.js.map +1 -1
- package/dist/cjs/cli/build.cjs +4 -0
- package/dist/cjs/cli/build.native.js +4 -0
- package/dist/cjs/cli/build.native.js.map +1 -1
- package/dist/cjs/cli.native.js.map +1 -1
- package/dist/cjs/clientLoaderResolver.native.js.map +1 -1
- package/dist/cjs/config.native.js.map +1 -1
- package/dist/cjs/constants.native.js.map +1 -1
- package/dist/cjs/constants.test.native.js.map +1 -1
- package/dist/cjs/createAPIRoute.native.js.map +1 -1
- package/dist/cjs/router/useInitializeOneRouter.cjs +3 -3
- package/dist/cjs/router/useInitializeOneRouter.native.js +3 -3
- package/dist/cjs/router/useInitializeOneRouter.native.js.map +1 -1
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.cjs +24 -14
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js +26 -14
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.test.cjs +16 -9
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.test.native.js +18 -9
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.test.native.js.map +1 -1
- package/dist/esm/cli/build.mjs +4 -0
- package/dist/esm/cli/build.mjs.map +1 -1
- package/dist/esm/cli/build.native.js +4 -0
- package/dist/esm/cli/build.native.js.map +1 -1
- package/dist/esm/router/useInitializeOneRouter.mjs +3 -3
- package/dist/esm/router/useInitializeOneRouter.mjs.map +1 -1
- package/dist/esm/router/useInitializeOneRouter.native.js +3 -3
- package/dist/esm/router/useInitializeOneRouter.native.js.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs +24 -14
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js +26 -14
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.mjs +16 -9
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.mjs.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.native.js +18 -9
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.native.js.map +1 -1
- package/package.json +13 -11
- package/src/cli/build.ts +9 -0
- package/src/router/useInitializeOneRouter.ts +8 -5
- package/src/vite/plugins/fileSystemRouterPlugin.test.ts +19 -9
- package/src/vite/plugins/fileSystemRouterPlugin.tsx +34 -42
- package/types/cli/build.d.ts.map +1 -1
- package/types/router/useInitializeOneRouter.d.ts.map +1 -1
- package/types/vite/plugins/fileSystemRouterPlugin.d.ts.map +1 -1
- package/vendor/react/package.json +2 -2
- package/vendor/react-dom/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["mkdirSync","mkdtempSync","rmSync","writeFileSync","EventEmitter","tmpdir","path","afterEach","beforeEach","describe","expect","it","vi","mock","actual","importActual","createServerModuleRunner","fn","
|
|
1
|
+
{"version":3,"names":["mkdirSync","mkdtempSync","rmSync","writeFileSync","EventEmitter","tmpdir","path","afterEach","beforeEach","describe","expect","it","vi","mock","actual","importActual","createServerModuleRunner","fn","import","previousVxrnVersion","globalThis","previousIsVxrnCli","process","env","IS_VXRN_CLI","previousViteEnvironment","VITE_ENVIRONMENT","previousVxrnPluginConfig","tempRoot","__vxrnPluginConfig__","recursive","force","restoreAllMocks","join","appDir","web","defaultRenderMode","createFileSystemRouterPlugin","plugin","router","root","watcherListener","server","environments","ssr","watcher","addListener","event","listener","on","configureServer","toBeDefined","warn","spyOn","console","mockImplementation","Error","Promise","resolve","resolves","toBeUndefined","toHaveBeenCalledWith","stringContaining","any","routeFile","virtualEntryId","renderCount","render","runner","id","default","mocked","mockReturnValue","middlewareHandlers","watcherListeners","Map","hot","send","middlewares","use","handler","push","add","set","get","loggingEnabled","installMiddlewares","routeMiddleware","at","handleRouteRequest","request","pathname","chunks","req","Object","assign","aborted","complete","originalUrl","url","headers","method","res","destroyed","writableFinished","setHeader","appendHeader","writeHead","write","chunk","end","emit","next","error","toHaveBeenCalled","toContain","toHaveBeenCalledTimes","versionBeforeChange","hotUpdate","call"],"sources":["../../../../src/vite/plugins/fileSystemRouterPlugin.test.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,SAAA,EAAWC,WAAA,EAAaC,MAAA,EAAQC,aAAA,QAAqB;AAC9D,SAASC,YAAA,QAAoB;AAC7B,SAASC,MAAA,QAAc;AACvB,OAAOC,IAAA,MAAU;AACjB,SAASC,SAAA,EAAWC,UAAA,EAAYC,QAAA,EAAUC,MAAA,EAAQC,EAAA,EAAIC,EAAA,QAAU;AAEhEA,EAAA,CAAGC,IAAA,CAAK,QAAQ,kBAAY;EAC1B,IAAAC,MAAM,SAASF,EAAM,CAAAG,YAAG,OAAoC;EAC5D,OAAO;IACL,GAAGD,MAAA;IACHE,wBAAA,EAA0BJ,EAAA,CAAGK,EAAA,CAAG,YAAO;MACrC;QACAC,MAAA,EAAAN,EAAA,CAAAK,EAAA;MACJ;IACD;EAUD;AACE;AACAR,QAAM,+BAA4B,EAAI;EACtC,IAAAU,mBAAM,GAAAC,UAA0B,gBAAY;EAC5C,IAAIC,iBAAA,GAAAC,OAAA,CAAAC,GAAA,CAAAC,WAAA;EACJ,IAAIC,uBAAA,GAAAH,OAAA,CAAAC,GAAA,CAAAG,gBAAA;EAEJ,IAAAC,wBAAiB;EACf,IAAAC,QAAA;EACFpB,UAAC;IAEDmB,wBAAgB,GAAAP,UAAA,CAAAS,oBAAA;EACd;EACEtB,SAAA,aAAiB;IACjB,IAAAqB,QAAA,EAAW;MACb1B,MAAA,CAAA0B,QAAA;QAEIE,SAAA;QACFC,KAAO;MACT;MACEH,QAAQ,QAAI;IACd;IACA,IAAIP,iBAAA,WAA4B;MAC9B,OAAOC,OAAA,CAAQC,GAAA,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AA,CAAAgF,SAAA,CAAAC,IAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "one",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.13",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"setup.mjs",
|
|
@@ -136,7 +136,9 @@
|
|
|
136
136
|
"module": "dist/esm",
|
|
137
137
|
"source": "src/index.ts",
|
|
138
138
|
"types": "./types/index.d.ts",
|
|
139
|
-
"bin":
|
|
139
|
+
"bin": {
|
|
140
|
+
"one": "run.mjs"
|
|
141
|
+
},
|
|
140
142
|
"files": [
|
|
141
143
|
"src",
|
|
142
144
|
"types",
|
|
@@ -181,18 +183,18 @@
|
|
|
181
183
|
"@cloudflare/vite-plugin": "^1.33.1",
|
|
182
184
|
"@swc/core": "^1.14.0",
|
|
183
185
|
"@ungap/structured-clone": "^1.2.0",
|
|
184
|
-
"@vxrn/color-scheme": "1.21.
|
|
185
|
-
"@vxrn/compiler": "1.21.
|
|
186
|
-
"@vxrn/resolve": "1.21.
|
|
187
|
-
"@vxrn/tslib-lite": "1.21.
|
|
188
|
-
"@vxrn/use-isomorphic-layout-effect": "1.21.
|
|
189
|
-
"@vxrn/vite-plugin-metro": "1.21.
|
|
186
|
+
"@vxrn/color-scheme": "1.21.13",
|
|
187
|
+
"@vxrn/compiler": "1.21.13",
|
|
188
|
+
"@vxrn/resolve": "1.21.13",
|
|
189
|
+
"@vxrn/tslib-lite": "1.21.13",
|
|
190
|
+
"@vxrn/use-isomorphic-layout-effect": "1.21.13",
|
|
191
|
+
"@vxrn/vite-plugin-metro": "1.21.13",
|
|
190
192
|
"babel-dead-code-elimination": "1.0.10",
|
|
191
193
|
"babel-plugin-module-resolver": "^5.0.2",
|
|
192
194
|
"babel-preset-expo": "~55.0.0",
|
|
193
195
|
"citty": "^0.1.6",
|
|
194
196
|
"core-js": "^3.38.1",
|
|
195
|
-
"create-vxrn": "1.21.
|
|
197
|
+
"create-vxrn": "1.21.13",
|
|
196
198
|
"escape-string-regexp": "^5.0.0",
|
|
197
199
|
"expo-linking": "~55.0.7",
|
|
198
200
|
"expo-modules-core": "~55.0.16",
|
|
@@ -212,7 +214,7 @@
|
|
|
212
214
|
"tsconfig-paths": "^4",
|
|
213
215
|
"use-latest-callback": "^0.2.3",
|
|
214
216
|
"vite": "^8.0.13",
|
|
215
|
-
"vxrn": "1.21.
|
|
217
|
+
"vxrn": "1.21.13",
|
|
216
218
|
"ws": "^8.21.0",
|
|
217
219
|
"xxhashjs": "^0.2.2"
|
|
218
220
|
},
|
|
@@ -308,7 +310,7 @@
|
|
|
308
310
|
},
|
|
309
311
|
"repository": {
|
|
310
312
|
"type": "git",
|
|
311
|
-
"url": "https://github.com/onejs/one.git",
|
|
313
|
+
"url": "git+https://github.com/onejs/one.git",
|
|
312
314
|
"directory": "packages/one"
|
|
313
315
|
}
|
|
314
316
|
}
|
package/src/cli/build.ts
CHANGED
|
@@ -680,6 +680,12 @@ export async function build(args: {
|
|
|
680
680
|
|
|
681
681
|
// caches for expensive operations
|
|
682
682
|
const collectImportsCache = new Map<string, string[]>()
|
|
683
|
+
// chunk graphs are routinely cyclic, and the cache above is only populated on
|
|
684
|
+
// the way out, so a cycle would recurse until the stack blew. tracking the
|
|
685
|
+
// keys still being expanded lets a re-entrant edge return nothing: the frame
|
|
686
|
+
// that is already expanding that key adds its own direct imports before it
|
|
687
|
+
// recurses, so the union it returns is still complete.
|
|
688
|
+
const collectImportsInFlight = new Set<string>()
|
|
683
689
|
const cssFileContentsCache = new Map<string, string>()
|
|
684
690
|
|
|
685
691
|
// css files with .inline.css extension — should be inlined as <style>
|
|
@@ -855,6 +861,8 @@ export async function build(args: {
|
|
|
855
861
|
const cacheKey = `${entry.file || imports.join(',')}:${type}`
|
|
856
862
|
const cached = collectImportsCache.get(cacheKey)
|
|
857
863
|
if (cached) return cached
|
|
864
|
+
if (collectImportsInFlight.has(cacheKey)) return []
|
|
865
|
+
collectImportsInFlight.add(cacheKey)
|
|
858
866
|
|
|
859
867
|
const result = [
|
|
860
868
|
...new Set(
|
|
@@ -875,6 +883,7 @@ export async function build(args: {
|
|
|
875
883
|
)
|
|
876
884
|
),
|
|
877
885
|
]
|
|
886
|
+
collectImportsInFlight.delete(cacheKey)
|
|
878
887
|
collectImportsCache.set(cacheKey, result)
|
|
879
888
|
return result
|
|
880
889
|
}
|
|
@@ -11,8 +11,11 @@ import { getSSRInitialState, ensureBaseLinkingConfig } from './linkingConfig'
|
|
|
11
11
|
let initVersion = 0
|
|
12
12
|
let lastInitVersion = -1
|
|
13
13
|
|
|
14
|
-
//
|
|
15
|
-
|
|
14
|
+
// the context the SSR route tree was built from. tracking the context itself
|
|
15
|
+
// rather than a "did we initialize" flag means a new context (dev, after a route
|
|
16
|
+
// module changes) rebuilds the tree, while a stable context (production) still
|
|
17
|
+
// initializes exactly once.
|
|
18
|
+
let ssrRouteTreeContext: One.RouteContext | null = null
|
|
16
19
|
|
|
17
20
|
export function useInitializeOneRouter(
|
|
18
21
|
context: One.RouteContext,
|
|
@@ -23,10 +26,10 @@ export function useInitializeOneRouter(
|
|
|
23
26
|
|
|
24
27
|
// SSR: initialize route tree once, then compute per-request state via cache
|
|
25
28
|
if (typeof window === 'undefined') {
|
|
26
|
-
if (
|
|
27
|
-
//
|
|
29
|
+
if (ssrRouteTreeContext !== context) {
|
|
30
|
+
// full initialization to set up route tree, root component, etc.
|
|
28
31
|
initialize(context, navigationRef, initialLocation, linking)
|
|
29
|
-
|
|
32
|
+
ssrRouteTreeContext = context
|
|
30
33
|
// also ensure linking config base is cached
|
|
31
34
|
ensureBaseLinkingConfig(routerStore.routeNode, linking)
|
|
32
35
|
}
|
|
@@ -9,7 +9,6 @@ vi.mock('vite', async () => {
|
|
|
9
9
|
return {
|
|
10
10
|
...actual,
|
|
11
11
|
createServerModuleRunner: vi.fn(() => ({
|
|
12
|
-
clearCache: vi.fn(),
|
|
13
12
|
import: vi.fn(),
|
|
14
13
|
})),
|
|
15
14
|
}
|
|
@@ -24,6 +23,7 @@ type MiddlewareHandler = (
|
|
|
24
23
|
type WatcherListener = (...args: string[]) => void | Promise<void>
|
|
25
24
|
|
|
26
25
|
describe('createFileSystemRouterPlugin', () => {
|
|
26
|
+
const previousVxrnVersion = globalThis['__vxrnVersion']
|
|
27
27
|
const previousIsVxrnCli = process.env.IS_VXRN_CLI
|
|
28
28
|
const previousViteEnvironment = process.env.VITE_ENVIRONMENT
|
|
29
29
|
let previousVxrnPluginConfig: unknown
|
|
@@ -55,6 +55,7 @@ describe('createFileSystemRouterPlugin', () => {
|
|
|
55
55
|
} else {
|
|
56
56
|
;(globalThis as any).__vxrnPluginConfig__ = previousVxrnPluginConfig
|
|
57
57
|
}
|
|
58
|
+
globalThis['__vxrnVersion'] = previousVxrnVersion
|
|
58
59
|
vi.restoreAllMocks()
|
|
59
60
|
})
|
|
60
61
|
|
|
@@ -135,7 +136,6 @@ describe('createFileSystemRouterPlugin', () => {
|
|
|
135
136
|
let renderCount = 0
|
|
136
137
|
const render = vi.fn(async () => `<html><body>${++renderCount}</body></html>`)
|
|
137
138
|
const runner = {
|
|
138
|
-
clearCache: vi.fn(),
|
|
139
139
|
import: vi.fn(async (id: string) => {
|
|
140
140
|
if (id === virtualEntryId) {
|
|
141
141
|
return { default: { render } }
|
|
@@ -234,15 +234,25 @@ describe('createFileSystemRouterPlugin', () => {
|
|
|
234
234
|
await expect(request('/')).resolves.toContain('<body>1</body>')
|
|
235
235
|
expect(render).toHaveBeenCalledTimes(1)
|
|
236
236
|
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
237
|
+
const versionBeforeChange = globalThis['__vxrnVersion']
|
|
238
|
+
// vite calls hotUpdate on the ssr environment after invalidating the graph;
|
|
239
|
+
// that is what tells the next render its route tree is built out of pre-edit
|
|
240
|
+
// modules
|
|
241
|
+
;(plugin as any).hotUpdate.call(
|
|
242
|
+
{
|
|
243
|
+
environment: {
|
|
244
|
+
name: 'ssr',
|
|
245
|
+
moduleGraph: { getModulesByFile: () => new Set([{ id: routeFile }]) },
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
{ file: routeFile }
|
|
249
|
+
)
|
|
243
250
|
|
|
244
251
|
await expect(request('/')).resolves.toContain('<body>2</body>')
|
|
245
252
|
expect(render).toHaveBeenCalledTimes(2)
|
|
246
|
-
|
|
253
|
+
|
|
254
|
+
// the render also has to invalidate the route context the tree is built
|
|
255
|
+
// from, otherwise it renders fresh html out of pre-edit route modules
|
|
256
|
+
expect(globalThis['__vxrnVersion']).toBe((versionBeforeChange || 0) + 1)
|
|
247
257
|
})
|
|
248
258
|
})
|
|
@@ -50,12 +50,11 @@ export function createFileSystemRouterPlugin(options: One.PluginOptions): Plugin
|
|
|
50
50
|
let runner: ModuleRunner
|
|
51
51
|
let server: ViteDevServer
|
|
52
52
|
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
let needsCacheClear = true
|
|
53
|
+
// set by hotUpdate below when the ssr environment sees a file change, consumed
|
|
54
|
+
// by the next page render. only refresh on an actual change, never per
|
|
55
|
+
// request: a per-request refresh rebuilds the route tree and re-renders every
|
|
56
|
+
// ssg page for nothing.
|
|
57
|
+
let needsRouteRefresh = false
|
|
59
58
|
|
|
60
59
|
// Track file dependencies from loaders for hot reload
|
|
61
60
|
// Maps file path -> set of route paths that depend on it
|
|
@@ -124,7 +123,7 @@ export function createFileSystemRouterPlugin(options: One.PluginOptions): Plugin
|
|
|
124
123
|
{
|
|
125
124
|
async handlePage({ route, url, loaderProps }) {
|
|
126
125
|
const ssgCacheKey = route.type === 'ssg' ? getSsgHtmlCacheKey(route, url) : null
|
|
127
|
-
if (ssgCacheKey && !
|
|
126
|
+
if (ssgCacheKey && !needsRouteRefresh) {
|
|
128
127
|
const cachedHtml = ssgHtmlCache.get(ssgCacheKey)
|
|
129
128
|
if (cachedHtml) {
|
|
130
129
|
return cachedHtml
|
|
@@ -166,7 +165,7 @@ export function createFileSystemRouterPlugin(options: One.PluginOptions): Plugin
|
|
|
166
165
|
await renderPromise
|
|
167
166
|
}
|
|
168
167
|
|
|
169
|
-
if (ssgCacheKey && !
|
|
168
|
+
if (ssgCacheKey && !needsRouteRefresh) {
|
|
170
169
|
const cachedHtml = ssgHtmlCache.get(ssgCacheKey)
|
|
171
170
|
if (cachedHtml) {
|
|
172
171
|
return cachedHtml
|
|
@@ -183,10 +182,17 @@ export function createFileSystemRouterPlugin(options: One.PluginOptions): Plugin
|
|
|
183
182
|
// so we must branch on route.file, not the joined path.
|
|
184
183
|
const isGeneratedNotFound = route.file === ''
|
|
185
184
|
const routeFile = isGeneratedNotFound ? '' : path.join(routerRoot, route.file)
|
|
186
|
-
if (
|
|
187
|
-
runner
|
|
185
|
+
if (needsRouteRefresh) {
|
|
186
|
+
// the module runner keeps itself fresh: every import re-checks the
|
|
187
|
+
// server, which has already invalidated the changed file and its
|
|
188
|
+
// importers, so only that chain re-evaluates. what it can't know
|
|
189
|
+
// about is our own route cache — the route context in
|
|
190
|
+
// useViteRoutes holds resolved route modules, and the SSR route
|
|
191
|
+
// tree is built from that context. bumping the version both watch
|
|
192
|
+
// rebuilds them from the fresh modules on this render.
|
|
193
|
+
globalThis['__vxrnVersion'] = (globalThis['__vxrnVersion'] || 0) + 1
|
|
188
194
|
ssgHtmlCache.clear()
|
|
189
|
-
|
|
195
|
+
needsRouteRefresh = false
|
|
190
196
|
}
|
|
191
197
|
|
|
192
198
|
globalThis['__vxrnresetState']?.()
|
|
@@ -587,7 +593,7 @@ export function createFileSystemRouterPlugin(options: One.PluginOptions): Plugin
|
|
|
587
593
|
try {
|
|
588
594
|
handleRequest = createRequestHandler()
|
|
589
595
|
ssgHtmlCache.clear()
|
|
590
|
-
|
|
596
|
+
needsRouteRefresh = true
|
|
591
597
|
} catch (error) {
|
|
592
598
|
console.warn(`[one] Failed to rebuild routes after ${changedPath} changed.`, error)
|
|
593
599
|
}
|
|
@@ -598,6 +604,22 @@ export function createFileSystemRouterPlugin(options: One.PluginOptions): Plugin
|
|
|
598
604
|
enforce: 'post',
|
|
599
605
|
apply: 'serve',
|
|
600
606
|
|
|
607
|
+
// the route tree we rendered from is built out of whatever route modules
|
|
608
|
+
// were resolved at the time, so any ssr-side change makes it stale. this
|
|
609
|
+
// runs inside vite's update sequence, after the graph has been invalidated,
|
|
610
|
+
// so by the time the next render reads the flag the fresh modules are
|
|
611
|
+
// already there to rebuild from.
|
|
612
|
+
//
|
|
613
|
+
// ask the graph rather than reading the `modules` argument: vite calls
|
|
614
|
+
// hotUpdate for every watcher event including files it knows nothing about,
|
|
615
|
+
// and an earlier plugin may have replaced `modules` (route-module-hmr-fix
|
|
616
|
+
// returns [] for ssr app files to suppress the full reload).
|
|
617
|
+
hotUpdate({ file }) {
|
|
618
|
+
if (this.environment.name !== 'ssr') return
|
|
619
|
+
if (!this.environment.moduleGraph.getModulesByFile(file)?.size) return
|
|
620
|
+
needsRouteRefresh = true
|
|
621
|
+
},
|
|
622
|
+
|
|
601
623
|
async config() {
|
|
602
624
|
const setting = options.optimization?.autoEntriesScanning ?? 'flat'
|
|
603
625
|
const routerRoot = normalizePath(getRouterRootFromOneOptions(options))
|
|
@@ -658,36 +680,6 @@ export function createFileSystemRouterPlugin(options: One.PluginOptions): Plugin
|
|
|
658
680
|
|
|
659
681
|
const appDir = path.resolve(process.cwd(), getRouterRootFromOneOptions(options))
|
|
660
682
|
|
|
661
|
-
// any watched file change means the SSR runner may be serving stale module
|
|
662
|
-
// code — mark the cache dirty so the next render re-evaluates once (set
|
|
663
|
-
// immediately/undebounced so it can't race ahead of a render).
|
|
664
|
-
//
|
|
665
|
-
// but only for files the SSR runner has ACTUALLY evaluated. the watcher
|
|
666
|
-
// fires for EVERY file event under the project root — including build-tool
|
|
667
|
-
// scratch files (e.g. *.bun-build temp artifacts), freshly created
|
|
668
|
-
// unrelated files, and other tooling's churn. in a busy monorepo that
|
|
669
|
-
// churn is near-constant, and marking the cache dirty on it forces a full
|
|
670
|
-
// re-evaluation of the SSR module tree on the very next render (a new
|
|
671
|
-
// AsyncFunction per module) — exactly the unbounded heap leak the
|
|
672
|
-
// needsCacheClear comment above exists to prevent (→ 5-8GB RSS / OOM).
|
|
673
|
-
//
|
|
674
|
-
// `runner.evaluatedModules` is the precise set clearCache() would re-evaluate,
|
|
675
|
-
// so a change outside it can never make the cache stale. it correctly
|
|
676
|
-
// includes both route files (loaded via runner.import) and shared source
|
|
677
|
-
// modules — unlike server.environments.ssr.moduleGraph, which misses
|
|
678
|
-
// runner-imported route files. (route-file adds/removes are still handled
|
|
679
|
-
// separately below via recreateRequestHandler, so a brand-new route is
|
|
680
|
-
// never missed.)
|
|
681
|
-
server.watcher.on('all', (_event, file) => {
|
|
682
|
-
if (file && runner?.evaluatedModules) {
|
|
683
|
-
const mods =
|
|
684
|
-
runner.evaluatedModules.getModulesByFile(file) ||
|
|
685
|
-
runner.evaluatedModules.getModulesByFile(normalizePath(file))
|
|
686
|
-
if (!mods || mods.size === 0) return
|
|
687
|
-
}
|
|
688
|
-
needsCacheClear = true
|
|
689
|
-
})
|
|
690
|
-
|
|
691
683
|
// on change ./app stuff lets reload this to pick up any route changes
|
|
692
684
|
const fileWatcherChangeListener = debounce((type: string, changedPath: string) => {
|
|
693
685
|
if (
|
package/types/cli/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/cli/build.ts"],"names":[],"mappings":"AAmXA,wBAAsB,KAAK,CAAC,IAAI,EAAE;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,SAAS,CAAA;IACpC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/cli/build.ts"],"names":[],"mappings":"AAmXA,wBAAsB,KAAK,CAAC,IAAI,EAAE;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,SAAS,CAAA;IACpC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,iBAmyCA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInitializeOneRouter.d.ts","sourceRoot":"","sources":["../../src/router/useInitializeOneRouter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,KAAK,WAAW,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"useInitializeOneRouter.d.ts","sourceRoot":"","sources":["../../src/router/useInitializeOneRouter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,KAAK,WAAW,MAAM,UAAU,CAAA;AAevC,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,GAAG,CAAC,YAAY,EACzB,eAAe,EAAE,GAAG,GAAG,SAAS,EAChC,OAAO,CAAC,EAAE,gBAAgB,sBAsC3B;AAGD,wBAAgB,mBAAmB,SAElC;AAKD,wBAAgB,UAAU,SAGzB"}
|
|
@@ -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;AAe1D,OAAO,KAAK,EAAE,GAAG,EAAa,MAAM,kBAAkB,CAAA;AA0BtD,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,GAAG,CAAC,aAAa,GAAG,MAAM,
|
|
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;AAe1D,OAAO,KAAK,EAAE,GAAG,EAAa,MAAM,kBAAkB,CAAA;AA0BtD,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,GAAG,CAAC,aAAa,GAAG,MAAM,CAm1B/E"}
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
33
|
-
"url": "https://github.com/facebook/react.git",
|
|
33
|
+
"url": "git+https://github.com/facebook/react.git",
|
|
34
34
|
"directory": "packages/react"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
@@ -44,4 +44,4 @@
|
|
|
44
44
|
"loose-envify"
|
|
45
45
|
]
|
|
46
46
|
}
|
|
47
|
-
}
|
|
47
|
+
}
|