@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/README.md
CHANGED
|
@@ -371,7 +371,7 @@ Production adapters enforce the app-router import policy when bundling loaders,
|
|
|
371
371
|
|
|
372
372
|
For Lambda deployments, build with `mreact-router build --target=aws-lambda` or `buildApp({ targets: ["aws-lambda"] })`. The target writes Node-compatible server/client output, `.mreact/server/import-policy.json`, and `.mreact/aws-lambda/mreact-handler.mjs` while skipping `.mreact/cloudflare` route modules, so loaders and server helpers may import Node-only dependencies such as database drivers without being bundled for the Workers runtime.
|
|
373
373
|
|
|
374
|
-
Package Lambda deployments with `mreact-router package aws-lambda --from .mreact --out .lambda` instead of pointing deployment tooling at the full project checkout. AWS Lambda enforces a 250 MB unzipped deployment package limit, and the runtime only needs `.mreact/`, `mreact-handler.mjs`, `package.json` / lockfiles, and production `node_modules`; `src/`, tests, dev dependencies, build caches, and Vite/Vitest/Playwright tooling are not required. `mreact-router build --target=aws-lambda` keeps compiled server route artifacts in `.mreact/server/server-modules/*.json` instead of embedding them in one large server manifest, writes compiled module bodies as hashed `.mjs` files, and keeps request/control artifacts separate from render artifacts so loader redirects do not read page render bundles. `createAwsLambdaRequestHandler()` treats `outDir` as read-only and materializes generated runtime files under `/tmp/mreact-router/<hash>/runtime` by default, with a `node_modules` symlink back to the deployed package root. Direct `createAwsLambdaRequestHandler()` and `createAwsLambdaStreamingRequestHandler()` handlers start only middleware and shared runtime preload in the background by default, so all-route preload work does not compete with the first user request. If a request arrives before preload finishes, middleware is resolved first, middleware responses or redirects return without loading the matched page artifact, and continuing requests load only the matched route's artifact closure. Static middleware `config.matcher` and `config.id` values are checked before importing the middleware module, so unmatched health checks and route-local middleware skips avoid evaluating heavyweight middleware dependencies. Route request artifacts omit page render exports, and built loader and route metadata artifacts are split, so loader redirects do not evaluate page-only or metadata-only dependencies before render or metadata is needed. Loader redirects settle before page component server transforms and render imports for non-stream routes, stream routes without a loading boundary, and stream loading routes whose loader source contains router control-flow helpers such as `redirect()` or `notFound()`. Prefer `await createPreloadedAwsLambdaRequestHandler()` in Node 24 ESM Lambda handlers when first-request latency matters: it waits for the full preload during Lambda initialization by default, increasing `Init Duration` but making the first handler invocation much closer to warm steady-state. Pass `runtimeDir` only when you need to control that writable cache location. With pnpm, run `pnpm --dir .lambda install --prod --frozen-lockfile --ignore-scripts --config.node-linker=hoisted`. pnpm's default isolated linker is symlink-heavy, so verify the artifact's symlink count with `find .lambda -type l | wc -l` and measure actual file bytes in addition to `du -sh .lambda` before upload. Packages listed in the generated import policy
|
|
374
|
+
Package Lambda deployments with `mreact-router package aws-lambda --from .mreact --out .lambda` instead of pointing deployment tooling at the full project checkout. AWS Lambda enforces a 250 MB unzipped deployment package limit, and the runtime only needs `.mreact/`, `mreact-handler.mjs`, `package.json` / lockfiles, and production `node_modules`; `src/`, tests, dev dependencies, build caches, and Vite/Vitest/Playwright tooling are not required. `mreact-router build --target=aws-lambda` keeps compiled server route artifacts in `.mreact/server/server-modules/*.json` instead of embedding them in one large server manifest, writes compiled module bodies as hashed `.mjs` files, and keeps request/control artifacts separate from render artifacts so loader redirects do not read page render bundles. AWS Lambda request/control artifacts bundle the generated import-policy packages they use for loaders, middleware, route handlers, and metadata, reducing first-hit package resolution on sparse Lambda traffic while leaving render-only, server action, custom handler, and adapter dependencies in production `node_modules`. `createAwsLambdaRequestHandler()` treats `outDir` as read-only and materializes generated runtime files under `/tmp/mreact-router/<hash>/runtime` by default, with a `node_modules` symlink back to the deployed package root. Direct `createAwsLambdaRequestHandler()` and `createAwsLambdaStreamingRequestHandler()` handlers start only middleware and shared runtime preload in the background by default, so all-route preload work does not compete with the first user request. If a request arrives before preload finishes, middleware is resolved first, middleware responses or redirects return without loading the matched page artifact, and continuing requests load only the matched route's artifact closure. Static middleware `config.matcher` and `config.id` values are checked before importing the middleware module, so unmatched health checks and route-local middleware skips avoid evaluating heavyweight middleware dependencies. Route request artifacts omit page render exports, and built loader and route metadata artifacts are split, so loader redirects do not evaluate page-only or metadata-only dependencies before render or metadata is needed. Loader redirects settle before page component server transforms and render imports for non-stream routes, stream routes without a loading boundary, and stream loading routes whose loader source contains router control-flow helpers such as `redirect()` or `notFound()`. Prefer `await createPreloadedAwsLambdaRequestHandler()` in Node 24 ESM Lambda handlers when first-request latency matters: it waits for the full preload during Lambda initialization by default, increasing `Init Duration` but making the first handler invocation much closer to warm steady-state. Pass `runtimeDir` only when you need to control that writable cache location. With pnpm, run `pnpm --dir .lambda install --prod --frozen-lockfile --ignore-scripts --config.node-linker=hoisted`. pnpm's default isolated linker is symlink-heavy, so verify the artifact's symlink count with `find .lambda -type l | wc -l` and measure actual file bytes in addition to `du -sh .lambda` before upload. Packages listed in the generated import policy may still be needed by render-only modules, inferred server actions, custom handlers, or adapter code, so keep them installed in that production artifact.
|
|
375
375
|
|
|
376
376
|
When a deployment needs custom adapter options such as `serverActions.authorize`, `onResponse`, `errorHandler`, or `allowedHosts`, create an app handler and package it with `mreact-router package aws-lambda --from .mreact --out .lambda --handler src/lambda.ts`. The package command bundles that handler into `.lambda/mreact-handler.mjs`, resolves app-local TypeScript imports with Vite-style extensionless paths, and keeps package imports external so production `node_modules` remains the runtime dependency boundary. If the handler imports the same app server modules that routes also import, those modules are compiled into the handler bundle separately from the mreact route artifacts; use `getServerRuntimeState()` for state that must be shared through the router runtime instead of relying on module singletons.
|
|
377
377
|
|
package/dist/build.d.ts
CHANGED
|
@@ -147,6 +147,7 @@ export declare function __bundleRouteRequestModuleBatchForTests(options: {
|
|
|
147
147
|
cacheDir?: string | undefined;
|
|
148
148
|
define?: UserConfig["define"] | undefined;
|
|
149
149
|
entries: readonly RouteRequestModuleBatchEntry[];
|
|
150
|
+
externalizeAllowedPackages?: boolean | undefined;
|
|
150
151
|
importPolicy?: AppRouterImportPolicy | undefined;
|
|
151
152
|
vitePlugins?: readonly PluginOption[] | undefined;
|
|
152
153
|
}): Promise<Record<string, string>>;
|
package/dist/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAsDA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAGL,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAG1B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD,OAAO,EAAqC,KAAK,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAiCnG,OAAO,KAAK,EAAU,YAAY,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAa7D,MAAM,WAAW,eAAgB,SAAQ,uBAAuB;IAC9D,eAAe,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACvE,kBAAkB,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACzE,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,SAAS,oBAAoB,EAAE,GAAG,SAAS,CAAC;IACtD,UAAU,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ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AAE,GAAG,SAAS,CAAC;CACnD,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAYlC;AAkJD,UAAU,4BAA4B;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,QAAQ,GAAG,UAAU,CAAC;CAC9B;AAwuDD,wBAAsB,+CAA+C,CAAC,OAAO,EAAE;IAC7E,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,SAAS;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACzD,WAAW,CAAC,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,CAAC;CACnD,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAYlC;AA0mCD;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,yBAAyB,CAAC,CA4CpC;AA6DD;;;;GAIG;AACH,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,qCAAqC,GAC7C,OAAO,CAAC,+BAA+B,CAAC,CAsD1C"}
|
package/dist/build.js
CHANGED
|
@@ -156,7 +156,7 @@ export async function buildApp(options) {
|
|
|
156
156
|
? await buildPublicAssetManifest(project, clientDir)
|
|
157
157
|
: await timeBuildPhase(timingSink, progressSink, "publicAssets", () => buildPublicAssetManifest(project, clientDir));
|
|
158
158
|
const clientRouteInferenceCache = createClientRouteInferenceCache();
|
|
159
|
-
const [serverActionManifest,
|
|
159
|
+
const [serverActionManifest, generatedImportPolicy] = await Promise.all([
|
|
160
160
|
shouldTrackBuildPhases === false
|
|
161
161
|
? collectBuildServerActionManifest({
|
|
162
162
|
files,
|
|
@@ -170,33 +170,6 @@ export async function buildApp(options) {
|
|
|
170
170
|
routes,
|
|
171
171
|
routesDir: project.routesDir,
|
|
172
172
|
})),
|
|
173
|
-
shouldTrackBuildPhases === false
|
|
174
|
-
? buildServerModuleArtifacts({
|
|
175
|
-
bundleCache: new Map(),
|
|
176
|
-
clientRouteInferenceCache: serverClientRouteInferenceCache,
|
|
177
|
-
define: viteDefine,
|
|
178
|
-
files,
|
|
179
|
-
prebundleServerComponents: buildTargets.includes("node") || shouldBuildAwsLambda,
|
|
180
|
-
project,
|
|
181
|
-
projectRoot: project.projectRoot,
|
|
182
|
-
routes,
|
|
183
|
-
sourceAnalysis,
|
|
184
|
-
serverTransformCache,
|
|
185
|
-
vitePlugins,
|
|
186
|
-
})
|
|
187
|
-
: timeBuildPhase(timingSink, progressSink, "serverModules", () => buildServerModuleArtifacts({
|
|
188
|
-
bundleCache: new Map(),
|
|
189
|
-
clientRouteInferenceCache: serverClientRouteInferenceCache,
|
|
190
|
-
define: viteDefine,
|
|
191
|
-
files,
|
|
192
|
-
prebundleServerComponents: buildTargets.includes("node") || shouldBuildAwsLambda,
|
|
193
|
-
project,
|
|
194
|
-
projectRoot: project.projectRoot,
|
|
195
|
-
routes,
|
|
196
|
-
sourceAnalysis,
|
|
197
|
-
serverTransformCache,
|
|
198
|
-
vitePlugins,
|
|
199
|
-
})),
|
|
200
173
|
shouldTrackBuildPhases === false
|
|
201
174
|
? buildGeneratedImportPolicy({
|
|
202
175
|
files,
|
|
@@ -211,6 +184,40 @@ export async function buildApp(options) {
|
|
|
211
184
|
routesDir: project.routesDir,
|
|
212
185
|
})),
|
|
213
186
|
]);
|
|
187
|
+
const actionRenderBundleExcludedFiles = new Set([...serverActionManifest.routeReferences.entries()]
|
|
188
|
+
.filter(([, references]) => references.length > 0)
|
|
189
|
+
.map(([file]) => file));
|
|
190
|
+
const serverModules = await (shouldTrackBuildPhases === false
|
|
191
|
+
? buildServerModuleArtifacts({
|
|
192
|
+
actionRenderBundleExcludedFiles,
|
|
193
|
+
bundleRequestRuntimePackages: shouldBuildAwsLambda,
|
|
194
|
+
bundleCache: new Map(),
|
|
195
|
+
clientRouteInferenceCache: serverClientRouteInferenceCache,
|
|
196
|
+
define: viteDefine,
|
|
197
|
+
files,
|
|
198
|
+
prebundleServerComponents: buildTargets.includes("node") || shouldBuildAwsLambda,
|
|
199
|
+
project,
|
|
200
|
+
projectRoot: project.projectRoot,
|
|
201
|
+
routes,
|
|
202
|
+
sourceAnalysis,
|
|
203
|
+
serverTransformCache,
|
|
204
|
+
vitePlugins,
|
|
205
|
+
})
|
|
206
|
+
: timeBuildPhase(timingSink, progressSink, "serverModules", () => buildServerModuleArtifacts({
|
|
207
|
+
actionRenderBundleExcludedFiles,
|
|
208
|
+
bundleRequestRuntimePackages: shouldBuildAwsLambda,
|
|
209
|
+
bundleCache: new Map(),
|
|
210
|
+
clientRouteInferenceCache: serverClientRouteInferenceCache,
|
|
211
|
+
define: viteDefine,
|
|
212
|
+
files,
|
|
213
|
+
prebundleServerComponents: buildTargets.includes("node") || shouldBuildAwsLambda,
|
|
214
|
+
project,
|
|
215
|
+
projectRoot: project.projectRoot,
|
|
216
|
+
routes,
|
|
217
|
+
sourceAnalysis,
|
|
218
|
+
serverTransformCache,
|
|
219
|
+
vitePlugins,
|
|
220
|
+
})));
|
|
214
221
|
const serverRoutes = routes.map((route) => ({
|
|
215
222
|
...route,
|
|
216
223
|
file: relative(project.projectRoot, route.file),
|
|
@@ -1314,6 +1321,7 @@ async function buildServerModuleArtifacts(options) {
|
|
|
1314
1321
|
bundleCache: options.bundleCache,
|
|
1315
1322
|
cacheDir: options.cacheDir,
|
|
1316
1323
|
entries: requestBatchEntries,
|
|
1324
|
+
externalizeAllowedPackages: !options.bundleRequestRuntimePackages,
|
|
1317
1325
|
importPolicy: requestModuleImportPolicy,
|
|
1318
1326
|
define: options.define,
|
|
1319
1327
|
vitePlugins: options.vitePlugins,
|
|
@@ -1335,6 +1343,7 @@ async function buildServerModuleArtifacts(options) {
|
|
|
1335
1343
|
cacheDir: options.cacheDir,
|
|
1336
1344
|
code: stripRouteLoaderOnlyExports(source, absoluteFile),
|
|
1337
1345
|
filename: absoluteFile,
|
|
1346
|
+
externalizeAllowedPackages: !options.bundleRequestRuntimePackages,
|
|
1338
1347
|
importPolicy: requestModuleImportPolicy,
|
|
1339
1348
|
define: options.define,
|
|
1340
1349
|
vitePlugins: options.vitePlugins,
|
|
@@ -1352,6 +1361,7 @@ async function buildServerModuleArtifacts(options) {
|
|
|
1352
1361
|
cacheDir: options.cacheDir,
|
|
1353
1362
|
code: stripRouteMetadataOnlyExports(source, absoluteFile),
|
|
1354
1363
|
filename: absoluteFile,
|
|
1364
|
+
externalizeAllowedPackages: !options.bundleRequestRuntimePackages,
|
|
1355
1365
|
importPolicy: requestModuleImportPolicy,
|
|
1356
1366
|
label: "Metadata",
|
|
1357
1367
|
define: options.define,
|
|
@@ -1371,6 +1381,7 @@ async function buildServerModuleArtifacts(options) {
|
|
|
1371
1381
|
bundleCache: options.bundleCache,
|
|
1372
1382
|
cacheDir: options.cacheDir,
|
|
1373
1383
|
filename: absoluteFile,
|
|
1384
|
+
externalizeAllowedPackages: !options.bundleRequestRuntimePackages,
|
|
1374
1385
|
importPolicy: requestModuleImportPolicy,
|
|
1375
1386
|
define: options.define,
|
|
1376
1387
|
routeKind: route?.kind,
|
|
@@ -1455,23 +1466,24 @@ async function buildServerModuleArtifacts(options) {
|
|
|
1455
1466
|
// cannot drop deferred Link content before the boundary resolves.
|
|
1456
1467
|
return undefined;
|
|
1457
1468
|
}
|
|
1469
|
+
const shouldWriteRenderBundle = options.prebundleServerComponents &&
|
|
1470
|
+
options.actionRenderBundleExcludedFiles?.has(file) !== true;
|
|
1471
|
+
const bundleCode = shouldWriteRenderBundle
|
|
1472
|
+
? await buildServerComponentBundleArtifactCode({
|
|
1473
|
+
clientRouteInferenceCache: options.clientRouteInferenceCache,
|
|
1474
|
+
code: output.code,
|
|
1475
|
+
externalizeCompatVendor,
|
|
1476
|
+
filename: absoluteFile,
|
|
1477
|
+
define: options.define,
|
|
1478
|
+
root: options.projectRoot,
|
|
1479
|
+
serverOutput,
|
|
1480
|
+
vitePlugins: options.vitePlugins,
|
|
1481
|
+
})
|
|
1482
|
+
: undefined;
|
|
1458
1483
|
return [
|
|
1459
1484
|
serverOutput,
|
|
1460
1485
|
{
|
|
1461
|
-
...(
|
|
1462
|
-
? {
|
|
1463
|
-
bundleCode: await buildServerComponentBundleArtifactCode({
|
|
1464
|
-
clientRouteInferenceCache: options.clientRouteInferenceCache,
|
|
1465
|
-
code: output.code,
|
|
1466
|
-
externalizeCompatVendor,
|
|
1467
|
-
filename: absoluteFile,
|
|
1468
|
-
define: options.define,
|
|
1469
|
-
root: options.projectRoot,
|
|
1470
|
-
serverOutput,
|
|
1471
|
-
vitePlugins: options.vitePlugins,
|
|
1472
|
-
}),
|
|
1473
|
-
}
|
|
1474
|
-
: {}),
|
|
1486
|
+
...(bundleCode === undefined ? {} : { bundleCode }),
|
|
1475
1487
|
code: output.code,
|
|
1476
1488
|
metadata: output.metadata,
|
|
1477
1489
|
sourceHash: hashText(code),
|
|
@@ -1602,6 +1614,7 @@ async function buildRequestModuleArtifactCode(options) {
|
|
|
1602
1614
|
code: options.source,
|
|
1603
1615
|
define: options.define,
|
|
1604
1616
|
file: options.filename,
|
|
1617
|
+
externalizeAllowedPackages: options.externalizeAllowedPackages,
|
|
1605
1618
|
importPolicy: options.importPolicy,
|
|
1606
1619
|
vitePlugins: options.vitePlugins,
|
|
1607
1620
|
});
|
|
@@ -1624,6 +1637,7 @@ async function buildRequestModuleArtifactCode(options) {
|
|
|
1624
1637
|
cacheDir: options.cacheDir,
|
|
1625
1638
|
code: stripRouteRequestOnlyExports(options.source, options.filename),
|
|
1626
1639
|
define: options.define,
|
|
1640
|
+
externalizeAllowedPackages: options.externalizeAllowedPackages,
|
|
1627
1641
|
filename: options.filename,
|
|
1628
1642
|
importPolicy: options.importPolicy,
|
|
1629
1643
|
vitePlugins: options.vitePlugins,
|
|
@@ -1653,6 +1667,7 @@ async function bundleRouteRequestModuleBatchCode(options) {
|
|
|
1653
1667
|
cacheDir: options.cacheDir,
|
|
1654
1668
|
code: entry.code,
|
|
1655
1669
|
define: options.define,
|
|
1670
|
+
externalizeAllowedPackages: options.externalizeAllowedPackages,
|
|
1656
1671
|
filename: entry.filename,
|
|
1657
1672
|
importPolicy: options.importPolicy,
|
|
1658
1673
|
label: entry.label,
|
|
@@ -1682,6 +1697,7 @@ async function bundleRouteRequestModuleBatchCode(options) {
|
|
|
1682
1697
|
appDir: options.appDir,
|
|
1683
1698
|
importPolicy: options.importPolicy,
|
|
1684
1699
|
label: "Request artifact",
|
|
1700
|
+
externalizeAllowedPackages: options.externalizeAllowedPackages,
|
|
1685
1701
|
}),
|
|
1686
1702
|
],
|
|
1687
1703
|
root: options.importPolicy?.projectRoot ?? dirname(options.entries[0]?.filename ?? options.appDir),
|
|
@@ -1696,6 +1712,7 @@ async function bundleRouteRequestModuleBatchCode(options) {
|
|
|
1696
1712
|
cacheDir: options.cacheDir,
|
|
1697
1713
|
code: entry.code,
|
|
1698
1714
|
define: options.define,
|
|
1715
|
+
externalizeAllowedPackages: options.externalizeAllowedPackages,
|
|
1699
1716
|
filename: entry.filename,
|
|
1700
1717
|
importPolicy: options.importPolicy,
|
|
1701
1718
|
label: entry.label,
|
|
@@ -1720,6 +1737,7 @@ export async function __bundleRouteRequestModuleBatchForTests(options) {
|
|
|
1720
1737
|
cacheDir: options.cacheDir,
|
|
1721
1738
|
define: options.define,
|
|
1722
1739
|
entries: options.entries,
|
|
1740
|
+
externalizeAllowedPackages: options.externalizeAllowedPackages,
|
|
1723
1741
|
importPolicy: options.importPolicy,
|
|
1724
1742
|
vitePlugins: options.vitePlugins,
|
|
1725
1743
|
}));
|
|
@@ -1739,6 +1757,7 @@ async function bundleRouteRequestModuleCode(options) {
|
|
|
1739
1757
|
fileImportMetaUrlPlugin(),
|
|
1740
1758
|
createAppRouterImportPolicyPlugin({
|
|
1741
1759
|
appDir: options.appDir,
|
|
1760
|
+
externalizeAllowedPackages: options.externalizeAllowedPackages,
|
|
1742
1761
|
importPolicy: options.importPolicy,
|
|
1743
1762
|
label: options.label,
|
|
1744
1763
|
}),
|
|
@@ -1766,6 +1785,7 @@ function routeRequestBundleCacheKey(options) {
|
|
|
1766
1785
|
? undefined
|
|
1767
1786
|
: resolve(options.importPolicy.projectRoot),
|
|
1768
1787
|
},
|
|
1788
|
+
externalizeAllowedPackages: options.externalizeAllowedPackages,
|
|
1769
1789
|
label: options.label,
|
|
1770
1790
|
platform: "node",
|
|
1771
1791
|
target: "es2022",
|