@reckona/mreact-router 0.0.157 → 0.0.158
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/README.md +1 -1
- package/dist/build.d.ts +1 -0
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +62 -42
- package/dist/build.js.map +1 -1
- package/dist/import-policy.d.ts +1 -0
- package/dist/import-policy.d.ts.map +1 -1
- package/dist/import-policy.js +6 -4
- package/dist/import-policy.js.map +1 -1
- package/dist/render.d.ts +1 -0
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +1 -0
- package/dist/render.js.map +1 -1
- package/package.json +11 -11
- package/src/build.ts +66 -32
- package/src/import-policy.ts +7 -4
- package/src/render.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reckona/mreact-router",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.158",
|
|
4
4
|
"description": "File-system app router, SSR, actions, and deployment adapters for mreact.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jsx",
|
|
@@ -105,20 +105,20 @@
|
|
|
105
105
|
},
|
|
106
106
|
"dependencies": {
|
|
107
107
|
"typescript": "^6.0.3",
|
|
108
|
-
"@reckona/mreact
|
|
109
|
-
"@reckona/mreact-
|
|
110
|
-
"@reckona/mreact-
|
|
111
|
-
"@reckona/mreact-
|
|
112
|
-
"@reckona/mreact-
|
|
113
|
-
"@reckona/mreact": "0.0.
|
|
114
|
-
"@reckona/mreact-reactive-dom": "0.0.
|
|
115
|
-
"@reckona/mreact-server": "0.0.
|
|
116
|
-
"@reckona/mreact-shared": "0.0.
|
|
108
|
+
"@reckona/mreact": "0.0.158",
|
|
109
|
+
"@reckona/mreact-compiler": "0.0.158",
|
|
110
|
+
"@reckona/mreact-compat": "0.0.158",
|
|
111
|
+
"@reckona/mreact-query": "0.0.158",
|
|
112
|
+
"@reckona/mreact-devtools": "0.0.158",
|
|
113
|
+
"@reckona/mreact-reactive-core": "0.0.158",
|
|
114
|
+
"@reckona/mreact-reactive-dom": "0.0.158",
|
|
115
|
+
"@reckona/mreact-server": "0.0.158",
|
|
116
|
+
"@reckona/mreact-shared": "0.0.158"
|
|
117
117
|
},
|
|
118
118
|
"peerDependencies": {
|
|
119
119
|
"vite": ">=8 <9"
|
|
120
120
|
},
|
|
121
121
|
"optionalDependencies": {
|
|
122
|
-
"@reckona/mreact-router-native": "0.0.
|
|
122
|
+
"@reckona/mreact-router-native": "0.0.158"
|
|
123
123
|
}
|
|
124
124
|
}
|
package/src/build.ts
CHANGED
|
@@ -448,7 +448,7 @@ export async function buildApp(options: BuildAppOptions): Promise<BuildAppResult
|
|
|
448
448
|
);
|
|
449
449
|
|
|
450
450
|
const clientRouteInferenceCache = createClientRouteInferenceCache();
|
|
451
|
-
const [serverActionManifest,
|
|
451
|
+
const [serverActionManifest, generatedImportPolicy] = await Promise.all([
|
|
452
452
|
shouldTrackBuildPhases === false
|
|
453
453
|
? collectBuildServerActionManifest({
|
|
454
454
|
files,
|
|
@@ -464,8 +464,32 @@ export async function buildApp(options: BuildAppOptions): Promise<BuildAppResult
|
|
|
464
464
|
routesDir: project.routesDir,
|
|
465
465
|
}),
|
|
466
466
|
),
|
|
467
|
+
shouldTrackBuildPhases === false
|
|
468
|
+
? buildGeneratedImportPolicy({
|
|
469
|
+
files,
|
|
470
|
+
projectRoot: project.projectRoot,
|
|
471
|
+
routes,
|
|
472
|
+
routesDir: project.routesDir,
|
|
473
|
+
})
|
|
474
|
+
: timeBuildPhase(timingSink, progressSink, "importPolicy", () =>
|
|
475
|
+
buildGeneratedImportPolicy({
|
|
476
|
+
files,
|
|
477
|
+
projectRoot: project.projectRoot,
|
|
478
|
+
routes,
|
|
479
|
+
routesDir: project.routesDir,
|
|
480
|
+
}),
|
|
481
|
+
),
|
|
482
|
+
]);
|
|
483
|
+
const actionRenderBundleExcludedFiles = new Set(
|
|
484
|
+
[...serverActionManifest.routeReferences.entries()]
|
|
485
|
+
.filter(([, references]) => references.length > 0)
|
|
486
|
+
.map(([file]) => file),
|
|
487
|
+
);
|
|
488
|
+
const serverModules = await (
|
|
467
489
|
shouldTrackBuildPhases === false
|
|
468
490
|
? buildServerModuleArtifacts({
|
|
491
|
+
actionRenderBundleExcludedFiles,
|
|
492
|
+
bundleRequestRuntimePackages: shouldBuildAwsLambda,
|
|
469
493
|
bundleCache: new Map(),
|
|
470
494
|
clientRouteInferenceCache: serverClientRouteInferenceCache,
|
|
471
495
|
define: viteDefine,
|
|
@@ -480,6 +504,8 @@ export async function buildApp(options: BuildAppOptions): Promise<BuildAppResult
|
|
|
480
504
|
})
|
|
481
505
|
: timeBuildPhase(timingSink, progressSink, "serverModules", () =>
|
|
482
506
|
buildServerModuleArtifacts({
|
|
507
|
+
actionRenderBundleExcludedFiles,
|
|
508
|
+
bundleRequestRuntimePackages: shouldBuildAwsLambda,
|
|
483
509
|
bundleCache: new Map(),
|
|
484
510
|
clientRouteInferenceCache: serverClientRouteInferenceCache,
|
|
485
511
|
define: viteDefine,
|
|
@@ -492,23 +518,8 @@ export async function buildApp(options: BuildAppOptions): Promise<BuildAppResult
|
|
|
492
518
|
serverTransformCache,
|
|
493
519
|
vitePlugins,
|
|
494
520
|
}),
|
|
495
|
-
)
|
|
496
|
-
|
|
497
|
-
? buildGeneratedImportPolicy({
|
|
498
|
-
files,
|
|
499
|
-
projectRoot: project.projectRoot,
|
|
500
|
-
routes,
|
|
501
|
-
routesDir: project.routesDir,
|
|
502
|
-
})
|
|
503
|
-
: timeBuildPhase(timingSink, progressSink, "importPolicy", () =>
|
|
504
|
-
buildGeneratedImportPolicy({
|
|
505
|
-
files,
|
|
506
|
-
projectRoot: project.projectRoot,
|
|
507
|
-
routes,
|
|
508
|
-
routesDir: project.routesDir,
|
|
509
|
-
}),
|
|
510
|
-
),
|
|
511
|
-
]);
|
|
521
|
+
)
|
|
522
|
+
);
|
|
512
523
|
const serverRoutes = routes.map((route) => ({
|
|
513
524
|
...route,
|
|
514
525
|
file: relative(project.projectRoot, route.file),
|
|
@@ -1993,6 +2004,8 @@ function routePathFromParams(route: AppRoute, params: StaticParams): string {
|
|
|
1993
2004
|
}
|
|
1994
2005
|
|
|
1995
2006
|
async function buildServerModuleArtifacts(options: {
|
|
2007
|
+
actionRenderBundleExcludedFiles?: ReadonlySet<string> | undefined;
|
|
2008
|
+
bundleRequestRuntimePackages: boolean;
|
|
1996
2009
|
bundleCache: Map<string, Promise<RouterBundleOutput>>;
|
|
1997
2010
|
cacheDir?: string | undefined;
|
|
1998
2011
|
clientRouteInferenceCache: ClientRouteInferenceCache;
|
|
@@ -2091,6 +2104,7 @@ async function buildServerModuleArtifacts(options: {
|
|
|
2091
2104
|
bundleCache: options.bundleCache,
|
|
2092
2105
|
cacheDir: options.cacheDir,
|
|
2093
2106
|
entries: requestBatchEntries,
|
|
2107
|
+
externalizeAllowedPackages: !options.bundleRequestRuntimePackages,
|
|
2094
2108
|
importPolicy: requestModuleImportPolicy,
|
|
2095
2109
|
define: options.define,
|
|
2096
2110
|
vitePlugins: options.vitePlugins,
|
|
@@ -2119,6 +2133,7 @@ async function buildServerModuleArtifacts(options: {
|
|
|
2119
2133
|
cacheDir: options.cacheDir,
|
|
2120
2134
|
code: stripRouteLoaderOnlyExports(source, absoluteFile),
|
|
2121
2135
|
filename: absoluteFile,
|
|
2136
|
+
externalizeAllowedPackages: !options.bundleRequestRuntimePackages,
|
|
2122
2137
|
importPolicy: requestModuleImportPolicy,
|
|
2123
2138
|
define: options.define,
|
|
2124
2139
|
vitePlugins: options.vitePlugins,
|
|
@@ -2138,6 +2153,7 @@ async function buildServerModuleArtifacts(options: {
|
|
|
2138
2153
|
cacheDir: options.cacheDir,
|
|
2139
2154
|
code: stripRouteMetadataOnlyExports(source, absoluteFile),
|
|
2140
2155
|
filename: absoluteFile,
|
|
2156
|
+
externalizeAllowedPackages: !options.bundleRequestRuntimePackages,
|
|
2141
2157
|
importPolicy: requestModuleImportPolicy,
|
|
2142
2158
|
label: "Metadata",
|
|
2143
2159
|
define: options.define,
|
|
@@ -2161,6 +2177,7 @@ async function buildServerModuleArtifacts(options: {
|
|
|
2161
2177
|
bundleCache: options.bundleCache,
|
|
2162
2178
|
cacheDir: options.cacheDir,
|
|
2163
2179
|
filename: absoluteFile,
|
|
2180
|
+
externalizeAllowedPackages: !options.bundleRequestRuntimePackages,
|
|
2164
2181
|
importPolicy: requestModuleImportPolicy,
|
|
2165
2182
|
define: options.define,
|
|
2166
2183
|
routeKind: route?.kind,
|
|
@@ -2273,23 +2290,26 @@ async function buildServerModuleArtifacts(options: {
|
|
|
2273
2290
|
return undefined;
|
|
2274
2291
|
}
|
|
2275
2292
|
|
|
2293
|
+
const shouldWriteRenderBundle =
|
|
2294
|
+
options.prebundleServerComponents &&
|
|
2295
|
+
options.actionRenderBundleExcludedFiles?.has(file) !== true;
|
|
2296
|
+
const bundleCode = shouldWriteRenderBundle
|
|
2297
|
+
? await buildServerComponentBundleArtifactCode({
|
|
2298
|
+
clientRouteInferenceCache: options.clientRouteInferenceCache,
|
|
2299
|
+
code: output.code,
|
|
2300
|
+
externalizeCompatVendor,
|
|
2301
|
+
filename: absoluteFile,
|
|
2302
|
+
define: options.define,
|
|
2303
|
+
root: options.projectRoot,
|
|
2304
|
+
serverOutput,
|
|
2305
|
+
vitePlugins: options.vitePlugins,
|
|
2306
|
+
})
|
|
2307
|
+
: undefined;
|
|
2308
|
+
|
|
2276
2309
|
return [
|
|
2277
2310
|
serverOutput,
|
|
2278
2311
|
{
|
|
2279
|
-
...(
|
|
2280
|
-
? {
|
|
2281
|
-
bundleCode: await buildServerComponentBundleArtifactCode({
|
|
2282
|
-
clientRouteInferenceCache: options.clientRouteInferenceCache,
|
|
2283
|
-
code: output.code,
|
|
2284
|
-
externalizeCompatVendor,
|
|
2285
|
-
filename: absoluteFile,
|
|
2286
|
-
define: options.define,
|
|
2287
|
-
root: options.projectRoot,
|
|
2288
|
-
serverOutput,
|
|
2289
|
-
vitePlugins: options.vitePlugins,
|
|
2290
|
-
}),
|
|
2291
|
-
}
|
|
2292
|
-
: {}),
|
|
2312
|
+
...(bundleCode === undefined ? {} : { bundleCode }),
|
|
2293
2313
|
code: output.code,
|
|
2294
2314
|
metadata: output.metadata,
|
|
2295
2315
|
sourceHash: hashText(code),
|
|
@@ -2476,6 +2496,7 @@ async function buildRequestModuleArtifactCode(options: {
|
|
|
2476
2496
|
bundleCache: Map<string, Promise<RouterBundleOutput>>;
|
|
2477
2497
|
cacheDir?: string | undefined;
|
|
2478
2498
|
define?: UserConfig["define"] | undefined;
|
|
2499
|
+
externalizeAllowedPackages: boolean;
|
|
2479
2500
|
filename: string;
|
|
2480
2501
|
importPolicy: AppRouterImportPolicy;
|
|
2481
2502
|
routeKind?: AppRoute["kind"] | undefined;
|
|
@@ -2488,6 +2509,7 @@ async function buildRequestModuleArtifactCode(options: {
|
|
|
2488
2509
|
code: options.source,
|
|
2489
2510
|
define: options.define,
|
|
2490
2511
|
file: options.filename,
|
|
2512
|
+
externalizeAllowedPackages: options.externalizeAllowedPackages,
|
|
2491
2513
|
importPolicy: options.importPolicy,
|
|
2492
2514
|
vitePlugins: options.vitePlugins,
|
|
2493
2515
|
});
|
|
@@ -2512,6 +2534,7 @@ async function buildRequestModuleArtifactCode(options: {
|
|
|
2512
2534
|
cacheDir: options.cacheDir,
|
|
2513
2535
|
code: stripRouteRequestOnlyExports(options.source, options.filename),
|
|
2514
2536
|
define: options.define,
|
|
2537
|
+
externalizeAllowedPackages: options.externalizeAllowedPackages,
|
|
2515
2538
|
filename: options.filename,
|
|
2516
2539
|
importPolicy: options.importPolicy,
|
|
2517
2540
|
vitePlugins: options.vitePlugins,
|
|
@@ -2524,6 +2547,7 @@ async function bundleRouteLoaderModuleCode(options: {
|
|
|
2524
2547
|
cacheDir?: string | undefined;
|
|
2525
2548
|
code: string;
|
|
2526
2549
|
define?: UserConfig["define"] | undefined;
|
|
2550
|
+
externalizeAllowedPackages?: boolean | undefined;
|
|
2527
2551
|
filename: string;
|
|
2528
2552
|
importPolicy?: AppRouterImportPolicy | undefined;
|
|
2529
2553
|
vitePlugins?: readonly PluginOption[] | undefined;
|
|
@@ -2540,6 +2564,7 @@ async function bundleRouteRequestModuleBatchCode(options: {
|
|
|
2540
2564
|
cacheDir?: string | undefined;
|
|
2541
2565
|
define?: UserConfig["define"] | undefined;
|
|
2542
2566
|
entries: readonly RouteRequestModuleBatchEntry[];
|
|
2567
|
+
externalizeAllowedPackages?: boolean | undefined;
|
|
2543
2568
|
importPolicy?: AppRouterImportPolicy | undefined;
|
|
2544
2569
|
vitePlugins?: readonly PluginOption[] | undefined;
|
|
2545
2570
|
}): Promise<Map<string, string>> {
|
|
@@ -2562,6 +2587,7 @@ async function bundleRouteRequestModuleBatchCode(options: {
|
|
|
2562
2587
|
cacheDir: options.cacheDir,
|
|
2563
2588
|
code: entry.code,
|
|
2564
2589
|
define: options.define,
|
|
2590
|
+
externalizeAllowedPackages: options.externalizeAllowedPackages,
|
|
2565
2591
|
filename: entry.filename,
|
|
2566
2592
|
importPolicy: options.importPolicy,
|
|
2567
2593
|
label: entry.label,
|
|
@@ -2594,6 +2620,7 @@ async function bundleRouteRequestModuleBatchCode(options: {
|
|
|
2594
2620
|
appDir: options.appDir,
|
|
2595
2621
|
importPolicy: options.importPolicy,
|
|
2596
2622
|
label: "Request artifact",
|
|
2623
|
+
externalizeAllowedPackages: options.externalizeAllowedPackages,
|
|
2597
2624
|
}),
|
|
2598
2625
|
],
|
|
2599
2626
|
root:
|
|
@@ -2613,6 +2640,7 @@ async function bundleRouteRequestModuleBatchCode(options: {
|
|
|
2613
2640
|
cacheDir: options.cacheDir,
|
|
2614
2641
|
code: entry.code,
|
|
2615
2642
|
define: options.define,
|
|
2643
|
+
externalizeAllowedPackages: options.externalizeAllowedPackages,
|
|
2616
2644
|
filename: entry.filename,
|
|
2617
2645
|
importPolicy: options.importPolicy,
|
|
2618
2646
|
label: entry.label,
|
|
@@ -2643,6 +2671,7 @@ export async function __bundleRouteRequestModuleBatchForTests(options: {
|
|
|
2643
2671
|
cacheDir?: string | undefined;
|
|
2644
2672
|
define?: UserConfig["define"] | undefined;
|
|
2645
2673
|
entries: readonly RouteRequestModuleBatchEntry[];
|
|
2674
|
+
externalizeAllowedPackages?: boolean | undefined;
|
|
2646
2675
|
importPolicy?: AppRouterImportPolicy | undefined;
|
|
2647
2676
|
vitePlugins?: readonly PluginOption[] | undefined;
|
|
2648
2677
|
}): Promise<Record<string, string>> {
|
|
@@ -2652,6 +2681,7 @@ export async function __bundleRouteRequestModuleBatchForTests(options: {
|
|
|
2652
2681
|
cacheDir: options.cacheDir,
|
|
2653
2682
|
define: options.define,
|
|
2654
2683
|
entries: options.entries,
|
|
2684
|
+
externalizeAllowedPackages: options.externalizeAllowedPackages,
|
|
2655
2685
|
importPolicy: options.importPolicy,
|
|
2656
2686
|
vitePlugins: options.vitePlugins,
|
|
2657
2687
|
}),
|
|
@@ -2664,6 +2694,7 @@ async function bundleRouteRequestModuleCode(options: {
|
|
|
2664
2694
|
cacheDir?: string | undefined;
|
|
2665
2695
|
code: string;
|
|
2666
2696
|
define?: UserConfig["define"] | undefined;
|
|
2697
|
+
externalizeAllowedPackages?: boolean | undefined;
|
|
2667
2698
|
filename: string;
|
|
2668
2699
|
importPolicy?: AppRouterImportPolicy | undefined;
|
|
2669
2700
|
label: "Loader" | "Metadata";
|
|
@@ -2683,6 +2714,7 @@ async function bundleRouteRequestModuleCode(options: {
|
|
|
2683
2714
|
fileImportMetaUrlPlugin(),
|
|
2684
2715
|
createAppRouterImportPolicyPlugin({
|
|
2685
2716
|
appDir: options.appDir,
|
|
2717
|
+
externalizeAllowedPackages: options.externalizeAllowedPackages,
|
|
2686
2718
|
importPolicy: options.importPolicy,
|
|
2687
2719
|
label: options.label,
|
|
2688
2720
|
}),
|
|
@@ -2701,6 +2733,7 @@ function routeRequestBundleCacheKey(options: {
|
|
|
2701
2733
|
appDir: string;
|
|
2702
2734
|
code: string;
|
|
2703
2735
|
define?: UserConfig["define"] | undefined;
|
|
2736
|
+
externalizeAllowedPackages?: boolean | undefined;
|
|
2704
2737
|
filename: string;
|
|
2705
2738
|
importPolicy?: AppRouterImportPolicy | undefined;
|
|
2706
2739
|
label: "Loader" | "Metadata";
|
|
@@ -2723,6 +2756,7 @@ function routeRequestBundleCacheKey(options: {
|
|
|
2723
2756
|
? undefined
|
|
2724
2757
|
: resolve(options.importPolicy.projectRoot),
|
|
2725
2758
|
},
|
|
2759
|
+
externalizeAllowedPackages: options.externalizeAllowedPackages,
|
|
2726
2760
|
label: options.label,
|
|
2727
2761
|
platform: "node",
|
|
2728
2762
|
target: "es2022",
|
package/src/import-policy.ts
CHANGED
|
@@ -21,6 +21,7 @@ export interface AppRouterImportPolicy {
|
|
|
21
21
|
export interface AppRouterImportPolicyPluginOptions {
|
|
22
22
|
allowedSourceDirs?: readonly string[] | undefined;
|
|
23
23
|
appDir: string;
|
|
24
|
+
externalizeAllowedPackages?: boolean | undefined;
|
|
24
25
|
importPolicy?: AppRouterImportPolicy | undefined;
|
|
25
26
|
label: string;
|
|
26
27
|
projectRoot?: string | undefined;
|
|
@@ -110,10 +111,12 @@ export function createAppRouterImportPolicyPlugin(options: AppRouterImportPolicy
|
|
|
110
111
|
return undefined;
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
return
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
return options.externalizeAllowedPackages === false
|
|
115
|
+
? undefined
|
|
116
|
+
: {
|
|
117
|
+
external: true,
|
|
118
|
+
path: pathToFileURL(resolvedPackage).href,
|
|
119
|
+
};
|
|
117
120
|
});
|
|
118
121
|
},
|
|
119
122
|
};
|
package/src/render.ts
CHANGED
|
@@ -2525,6 +2525,7 @@ export async function bundleMiddlewareModuleCode(options: {
|
|
|
2525
2525
|
appDir: string;
|
|
2526
2526
|
code: string;
|
|
2527
2527
|
define?: UserConfig["define"] | undefined;
|
|
2528
|
+
externalizeAllowedPackages?: boolean | undefined;
|
|
2528
2529
|
file: string;
|
|
2529
2530
|
importPolicy?: AppRouterImportPolicy | undefined;
|
|
2530
2531
|
vitePlugins?: readonly PluginOption[] | undefined;
|
|
@@ -2539,6 +2540,7 @@ export async function bundleMiddlewareModuleCode(options: {
|
|
|
2539
2540
|
fileImportMetaUrlPlugin(),
|
|
2540
2541
|
createAppRouterImportPolicyPlugin({
|
|
2541
2542
|
appDir: options.appDir,
|
|
2543
|
+
externalizeAllowedPackages: options.externalizeAllowedPackages,
|
|
2542
2544
|
importPolicy: options.importPolicy,
|
|
2543
2545
|
label: "Middleware",
|
|
2544
2546
|
}),
|