remote-components 0.4.4 → 0.4.5

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 (46) hide show
  1. package/dist/{chunk-76W64VJG.cjs → chunk-7OD5S534.cjs} +6 -6
  2. package/dist/{chunk-QNPKWDSY.js → chunk-MJ2KYXGR.js} +2 -2
  3. package/dist/{chunk-2VLOQRNR.js → chunk-NZM2SI6U.js} +2 -2
  4. package/dist/{chunk-3XXIKTRR.js → chunk-O4A6CJGI.js} +3 -3
  5. package/dist/{chunk-CELPDJVY.cjs → chunk-PNASFKWA.cjs} +7 -7
  6. package/dist/{chunk-7X64ZGV5.js → chunk-PT3R275L.js} +41 -25
  7. package/dist/chunk-PT3R275L.js.map +1 -0
  8. package/dist/{chunk-5GPOQVC3.cjs → chunk-TWO3XB6H.cjs} +10 -10
  9. package/dist/{chunk-7ZQ7SWZM.cjs → chunk-W5FSHVWU.cjs} +41 -25
  10. package/dist/chunk-W5FSHVWU.cjs.map +1 -0
  11. package/dist/config/nextjs.cjs +37 -9
  12. package/dist/config/nextjs.cjs.map +1 -1
  13. package/dist/config/nextjs.d.ts +14 -1
  14. package/dist/config/nextjs.js +31 -3
  15. package/dist/config/nextjs.js.map +1 -1
  16. package/dist/host/html.cjs +13 -13
  17. package/dist/host/html.js +5 -5
  18. package/dist/host/nextjs/app/client-only.cjs +6 -6
  19. package/dist/host/nextjs/app/client-only.js +4 -4
  20. package/dist/host/react.cjs +5 -5
  21. package/dist/host/react.js +4 -4
  22. package/dist/internal/runtime/turbopack/chunk-loader.cjs +39 -23
  23. package/dist/internal/runtime/turbopack/chunk-loader.cjs.map +1 -1
  24. package/dist/internal/runtime/turbopack/chunk-loader.js +39 -23
  25. package/dist/internal/runtime/turbopack/chunk-loader.js.map +1 -1
  26. package/dist/internal/runtime/turbopack/patterns.cjs +1 -1
  27. package/dist/internal/runtime/turbopack/patterns.cjs.map +1 -1
  28. package/dist/internal/runtime/turbopack/patterns.js +1 -1
  29. package/dist/internal/runtime/turbopack/patterns.js.map +1 -1
  30. package/dist/{turbopack-ABJOQO3J.js → turbopack-55EJDSUT.js} +3 -3
  31. package/dist/{turbopack-L7JU77FH.cjs → turbopack-Q6KJAEOX.cjs} +8 -8
  32. package/dist/{webpack-V4ZH7KA2.js → webpack-AQ34DAJZ.js} +2 -2
  33. package/dist/{webpack-2QRFGZIF.cjs → webpack-FWUNUWLF.cjs} +5 -5
  34. package/package.json +1 -1
  35. package/dist/chunk-7X64ZGV5.js.map +0 -1
  36. package/dist/chunk-7ZQ7SWZM.cjs.map +0 -1
  37. /package/dist/{chunk-76W64VJG.cjs.map → chunk-7OD5S534.cjs.map} +0 -0
  38. /package/dist/{chunk-QNPKWDSY.js.map → chunk-MJ2KYXGR.js.map} +0 -0
  39. /package/dist/{chunk-2VLOQRNR.js.map → chunk-NZM2SI6U.js.map} +0 -0
  40. /package/dist/{chunk-3XXIKTRR.js.map → chunk-O4A6CJGI.js.map} +0 -0
  41. /package/dist/{chunk-CELPDJVY.cjs.map → chunk-PNASFKWA.cjs.map} +0 -0
  42. /package/dist/{chunk-5GPOQVC3.cjs.map → chunk-TWO3XB6H.cjs.map} +0 -0
  43. /package/dist/{turbopack-ABJOQO3J.js.map → turbopack-55EJDSUT.js.map} +0 -0
  44. /package/dist/{turbopack-L7JU77FH.cjs.map → turbopack-Q6KJAEOX.cjs.map} +0 -0
  45. /package/dist/{webpack-V4ZH7KA2.js.map → webpack-AQ34DAJZ.js.map} +0 -0
  46. /package/dist/{webpack-2QRFGZIF.cjs.map → webpack-FWUNUWLF.cjs.map} +0 -0
@@ -21,10 +21,10 @@ import "../chunk-ENYGL5CO.js";
21
21
 
22
22
  // src/config/nextjs/index.ts
23
23
  import { existsSync, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
24
+ import { createRequire } from "node:module";
24
25
  import { basename, dirname, join as join2, relative } from "node:path";
25
26
  import enhancedResolve from "enhanced-resolve";
26
27
  import { findUpSync as findUpSync2 } from "find-up";
27
- import { configSchema } from "next/dist/server/config-schema.js";
28
28
  import TsConfigPathsWebpackPlugin from "tsconfig-paths-webpack-plugin";
29
29
 
30
30
  // src/utils/project-id.ts
@@ -109,6 +109,18 @@ function getNextMajorVersion() {
109
109
  function hasPagesDirectory() {
110
110
  return existsSync(join2(process.cwd(), "pages")) || existsSync(join2(process.cwd(), "src/pages"));
111
111
  }
112
+ function isChunkLoadingGlobalSupported(schema) {
113
+ return schema.safeParse({ turbopack: { chunkLoadingGlobal: "__test__" } }).success;
114
+ }
115
+ function loadAppConfigSchema() {
116
+ try {
117
+ const appRequire = createRequire(join2(process.cwd(), "package.json"));
118
+ const mod = appRequire("next/dist/server/config-schema.js");
119
+ return mod.configSchema;
120
+ } catch {
121
+ return void 0;
122
+ }
123
+ }
112
124
  function readProjectPackageJson() {
113
125
  const defaults = { name: basename(process.cwd()), type: "module" };
114
126
  try {
@@ -311,7 +323,8 @@ ${requirements}
311
323
  }
312
324
  }
313
325
  if (process.env.TURBOPACK) {
314
- if (!configSchema.safeParse({
326
+ const appConfigSchema = loadAppConfigSchema();
327
+ if (!appConfigSchema?.safeParse({
315
328
  turbopack: {
316
329
  resolveAlias: {
317
330
  ...alias
@@ -329,12 +342,26 @@ ${requirements}
329
342
  );
330
343
  process.exit(1);
331
344
  }
345
+ const chunkLoadingGlobalSupported = appConfigSchema !== void 0 && isChunkLoadingGlobalSupported(appConfigSchema);
346
+ const chunkLoadingGlobalValue = `TURBOPACK_remote_chunk_loading_global_${projectId}`;
347
+ if (chunkLoadingGlobalSupported) {
348
+ logDebug(
349
+ "Config",
350
+ `Turbopack chunkLoadingGlobal set to "${chunkLoadingGlobalValue}" \u2014 chunks will use a build-time scoped global (no runtime TURBOPACK rename needed).`
351
+ );
352
+ } else {
353
+ logDebug(
354
+ "Config",
355
+ "Turbopack chunkLoadingGlobal not supported by this Next.js version \u2014 falling back to runtime TURBOPACK global rename."
356
+ );
357
+ }
332
358
  nextConfig.turbopack = {
333
359
  ...nextConfig.turbopack,
334
360
  resolveAlias: {
335
361
  ...nextConfig.turbopack?.resolveAlias,
336
362
  ...alias
337
- }
363
+ },
364
+ ...chunkLoadingGlobalSupported ? { chunkLoadingGlobal: chunkLoadingGlobalValue } : {}
338
365
  };
339
366
  nextConfig.compiler = {
340
367
  ...nextConfig.compiler,
@@ -353,6 +380,7 @@ ${requirements}
353
380
  });
354
381
  }
355
382
  export {
383
+ isChunkLoadingGlobalSupported,
356
384
  withRemoteComponentsConfig
357
385
  };
358
386
  //# sourceMappingURL=nextjs.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/config/nextjs/index.ts","../../src/utils/project-id.ts","../../src/utils/project-id-env.ts","../../src/config/webpack/nextjs.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { basename, dirname, join, relative } from 'node:path';\nimport enhancedResolve from 'enhanced-resolve';\nimport { findUpSync } from 'find-up';\nimport type { NextConfig } from 'next';\nimport { configSchema } from 'next/dist/server/config-schema.js';\nimport TsConfigPathsWebpackPlugin from 'tsconfig-paths-webpack-plugin';\nimport { SHARED_MODULE_MANIFEST_PROTOCOL } from '#internal/host/shared/shared-broker';\nimport {\n CORE_REACT_SHARED_KEYS,\n VENDOR_SHARED,\n} from '#internal/host/shared/shared-module-resolver';\nimport { logDebug, logError, logWarn } from '#internal/utils/logger';\nimport { resolveProjectId } from '#internal/utils/project-id';\nimport { transform as webpackTransform } from '../webpack/nextjs';\n\nfunction getNextMajorVersion(): number | undefined {\n try {\n const nextPkgPath = findUpSync('node_modules/next/package.json', {\n cwd: process.cwd(),\n });\n if (!nextPkgPath) return undefined;\n const { version } = JSON.parse(readFileSync(nextPkgPath, 'utf8')) as {\n version: string;\n };\n const major = version.split('.')[0];\n return major ? Number.parseInt(major, 10) : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction hasPagesDirectory(): boolean {\n return (\n existsSync(join(process.cwd(), 'pages')) ||\n existsSync(join(process.cwd(), 'src/pages'))\n );\n}\n\ninterface ZodSchema {\n safeParse: (data: unknown) => { success: boolean };\n}\n\nfunction readProjectPackageJson(): { name: string; type: string } {\n const defaults = { name: basename(process.cwd()), type: 'module' };\n try {\n const packageJsonPath = findUpSync('package.json', {\n cwd: process.cwd(),\n });\n if (packageJsonPath) {\n return {\n ...defaults,\n ...(JSON.parse(readFileSync(packageJsonPath, 'utf8')) as {\n name: string;\n type: string;\n }),\n };\n }\n } catch {\n // noop\n }\n return defaults;\n}\n\ninterface WithRemoteComponentsOptions {\n /**\n * An array of package names that should be shared between the host and remote components.\n * This is useful for ensuring that both the host and remote components use the same version\n * of shared libraries.\n *\n * Essential packages are included by default: `react`, `react-dom`, `next/navigation`, `next/link`, `next/form`, `next/image` (loader only), and `next/script`.\n */\n shared?: string[];\n}\n\n/**\n * This function configures Next.js to support Remote Components.\n * You need to also use the `withMicrofrontends` function to extend your Next.js configuration.\n *\n * @param nextConfig - The Next.js configuration object.\n * @param options - Optional configuration for remote components.\n * @returns The modified Next.js configuration object with remote components support.\n *\n * @example\n *\n * ```js\n * import { withMicrofrontends } from '@vercel/microfrontends/next/config';\n * import { withRemoteComponentsConfig } from 'remote-components/config/nextjs';\n *\n * const nextConfig = {\n * // your Next.js configuration\n * };\n *\n * export default withRemoteComponentsConfig(\n * withMicrofrontends(nextConfig),\n * {\n * shared: ['some-package', 'another-package'],\n * },\n * );\n * ```\n */\nexport function withRemoteComponentsConfig(\n nextConfig: NextConfig,\n options?: WithRemoteComponentsOptions,\n) {\n const virtualRemoteComponentAppSharedRemote = join(\n process.cwd(),\n '.remote-components/shared/app-remote.tsx',\n );\n const virtualRemoteComponentPagesSharedRemote = join(\n process.cwd(),\n '.remote-components/shared/pages-remote.tsx',\n );\n const virtualRemoteComponentAppSharedHost = join(\n process.cwd(),\n '.remote-components/shared/app-host.tsx',\n );\n const virtualRemoteComponentPagesSharedHost = join(\n process.cwd(),\n '.remote-components/shared/pages-host.tsx',\n );\n\n const appShared = new Set([\n ...CORE_REACT_SHARED_KEYS,\n 'next/navigation',\n 'next/dist/client/components/navigation',\n 'next/link',\n 'next/dist/client/app-dir/link',\n 'next/form',\n 'next/dist/client/app-dir/form',\n 'next/dist/shared/lib/image-loader',\n 'next/script',\n 'next/dist/client/script',\n 'next/dist/build/polyfills/process',\n ...(options?.shared ?? []),\n ]);\n const pagesShared = new Set([\n ...CORE_REACT_SHARED_KEYS,\n 'next/router',\n 'next/link',\n 'next/dist/shared/lib/image-loader',\n 'next/script',\n 'next/form',\n ...(options?.shared ?? []),\n ]);\n\n const vendorShared = { ...VENDOR_SHARED };\n\n // resolve using enhanced-resolve\n // named import does not work with enhanced-resolve when using cjs\n // eslint-disable-next-line import/no-named-as-default-member\n const resolve = enhancedResolve.create.sync({\n conditionNames: ['browser', 'import', 'module', 'require'],\n ...(existsSync(join(process.cwd(), 'tsconfig.json'))\n ? {\n extensions: ['.js', '.jsx', '.ts', '.tsx'],\n plugins: [\n new TsConfigPathsWebpackPlugin({\n configFile: join(process.cwd(), 'tsconfig.json'),\n }) as unknown as enhancedResolve.Plugin,\n ],\n }\n : {}),\n });\n\n const packageJson = readProjectPackageJson();\n\n const generateSharedModule = ({\n sharedEntries,\n sharedManifest,\n }: {\n sharedEntries: string[];\n sharedManifest?: string;\n }) => {\n const shared = sharedEntries.join('\\n');\n\n if (packageJson.type !== 'module') {\n const exports = [`shared: {\\n${shared}\\n}`];\n if (sharedManifest) {\n exports.push(`sharedManifest: ${sharedManifest}`);\n }\n return `'use client';\\nmodule.exports = {\\n${exports.join(',\\n')}\\n};\\n`;\n }\n\n return `'use client';\\nexport const shared = {\\n${shared}\\n};\\n${\n sharedManifest ? `export const sharedManifest = ${sharedManifest};\\n` : ''\n }`;\n };\n\n const resolveSharedPath = (moduleName: string): string | undefined => {\n try {\n const resolved = resolve(process.cwd(), moduleName);\n if (resolved) {\n return relative(process.cwd(), resolved).replace(\n /^(?<relative>\\.\\.\\/)+/,\n '',\n );\n }\n } catch {\n // if module resolution using enhanced-resolve fails, fallback to require.resolve called in the shared/remote file\n }\n };\n\n const sharedKeyExpression = (moduleName: string): string => {\n const path = resolveSharedPath(moduleName);\n return (\n vendorShared[moduleName] ??\n (path ? `'${path}'` : `require.resolve('${moduleName}')`)\n );\n };\n\n const generateSharedRemote = (sharedRemote: Set<string>) => {\n const sharedEntries = Array.from(sharedRemote).reduce<string[]>(\n (acc, curr) => {\n const id = sharedKeyExpression(curr);\n // @legacy(remote-components<=0.4.x): keep emitting the historical\n // shared map until hosts on 0.4.x are outside the compatibility window.\n acc.push(`[${id}]: '${curr}',`);\n acc.push(\n `['__remote_shared_module_${curr}']: () => import('${curr}'),`,\n );\n return acc;\n },\n [],\n );\n const requirements = Array.from(sharedRemote)\n .map(\n (curr) =>\n `{ id: ${sharedKeyExpression(curr)}, specifier: '${curr}', required: true, singleton: true }`,\n )\n .join(',\\n');\n return generateSharedModule({\n sharedEntries,\n sharedManifest: `{ protocol: '${SHARED_MODULE_MANIFEST_PROTOCOL}', requirements: [\\n${requirements}\\n] }`,\n });\n };\n const generateSharedHost = (sharedHost: Set<string>) =>\n generateSharedModule({\n sharedEntries: Array.from(sharedHost).reduce<string[]>((acc, curr) => {\n acc.push(`['${curr}']: () => import('${curr}'),`);\n return acc;\n }, []),\n });\n\n const appSharedRemote = generateSharedRemote(appShared);\n const pagesSharedRemote = generateSharedRemote(pagesShared);\n\n const appSharedHost = generateSharedHost(appShared);\n const pagesSharedHost = generateSharedHost(pagesShared);\n\n const emitSharedFiles = () => {\n mkdirSync(dirname(virtualRemoteComponentAppSharedRemote), {\n recursive: true,\n });\n\n writeFileSync(\n virtualRemoteComponentAppSharedRemote,\n appSharedRemote,\n 'utf-8',\n );\n writeFileSync(\n virtualRemoteComponentPagesSharedRemote,\n pagesSharedRemote,\n 'utf-8',\n );\n writeFileSync(virtualRemoteComponentAppSharedHost, appSharedHost, 'utf-8');\n writeFileSync(\n virtualRemoteComponentPagesSharedHost,\n pagesSharedHost,\n 'utf-8',\n );\n };\n\n nextConfig.transpilePackages = [\n ...(nextConfig.transpilePackages ?? []),\n 'remote-components',\n ];\n\n nextConfig.env = {\n ...nextConfig.env,\n REMOTE_COMPONENTS_CONFIGURED: '1',\n };\n\n const alias = {\n '#remote-components/remote/defaults/app': `./${relative(\n process.cwd(),\n virtualRemoteComponentAppSharedRemote,\n )}`,\n '#remote-components/remote/defaults/pages': `./${relative(\n process.cwd(),\n virtualRemoteComponentPagesSharedRemote,\n )}`,\n '#remote-components/host/defaults/app': `./${relative(\n process.cwd(),\n virtualRemoteComponentAppSharedHost,\n )}`,\n '#remote-components/host/defaults/pages': `./${relative(\n process.cwd(),\n virtualRemoteComponentPagesSharedHost,\n )}`,\n };\n\n const projectId = resolveProjectId(packageJson.name);\n process.env.REMOTE_COMPONENTS_PROJECT_ID = projectId;\n\n if (hasPagesDirectory()) {\n // Log instead of throwing for the version check because\n // withRemoteComponentsConfig is shared by both hosts and remotes.\n // Only Pages Router hosts are broken on Next.js < 16 — remotes\n // work fine and must not have their builds blocked.\n const nextMajor = getNextMajorVersion();\n if (nextMajor !== undefined && nextMajor < 16) {\n const log =\n process.env.NODE_ENV !== 'production' ||\n process.env.VERCEL_ENV === 'preview'\n ? logWarn\n : logDebug;\n log(\n 'Config',\n `Remote Components does not support Pages Router hosts on Next.js ${nextMajor}. ` +\n 'Pages Router remotes are unaffected. Upgrade to Next.js 16+ for host support.',\n );\n }\n }\n\n if (process.env.TURBOPACK) {\n if (\n !(configSchema as ZodSchema).safeParse({\n turbopack: {\n resolveAlias: {\n ...alias,\n },\n },\n compiler: {\n defineServer: {\n REMOTE_COMPONENTS_PROJECT_ID: projectId,\n },\n },\n }).success\n ) {\n logError(\n 'Config',\n 'Turbopack support requires a Next.js version that includes `compiler.defineServer`. ' +\n 'Upgrade Next.js to continue using Remote Components with Turbopack.',\n );\n process.exit(1);\n }\n nextConfig.turbopack = {\n ...nextConfig.turbopack,\n resolveAlias: {\n ...nextConfig.turbopack?.resolveAlias,\n ...alias,\n },\n };\n nextConfig.compiler = {\n ...nextConfig.compiler,\n defineServer: {\n ...nextConfig.compiler?.defineServer,\n 'process.env.REMOTE_COMPONENTS_PROJECT_ID': projectId,\n },\n };\n emitSharedFiles();\n return nextConfig;\n }\n\n // apply the webpack transform\n return webpackTransform(nextConfig, {\n app: { name: projectId },\n alias,\n emitSharedFiles,\n });\n}\n","import { readFileSync } from 'node:fs';\nimport { findUpSync } from 'find-up';\nimport { resolveProjectIdFromEnv } from './project-id-env';\n\n/**\n * Resolves the project ID using environment variables first, then\n * falling back to `.vercel/project.json` and finally the package name.\n * Node-only — requires file system access.\n */\nexport function resolveProjectId(packageName: string): string {\n const fromEnv = resolveProjectIdFromEnv();\n if (fromEnv) return fromEnv;\n\n try {\n const projectPath = findUpSync('.vercel/project.json', {\n cwd: process.cwd(),\n });\n if (projectPath) {\n return (\n JSON.parse(readFileSync(projectPath, 'utf8')) as { projectId: string }\n ).projectId;\n }\n } catch {\n // fallback below\n }\n\n return packageName;\n}\n","/**\n * Resolves the project ID from environment variables only.\n * Safe for edge/browser contexts where file system access is unavailable.\n */\nexport function resolveProjectIdFromEnv(): string | undefined {\n return (\n process.env.REMOTE_COMPONENTS_PROJECT_ID ||\n process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION ||\n process.env.VERCEL_PROJECT_ID ||\n undefined\n );\n}\n","import { join } from 'node:path';\nimport type { NextConfig } from 'next';\nimport type { WebpackOptionsNormalized } from 'webpack';\nimport { ConditionalExecPlugin } from './plugins/conditional-exec';\nimport { ModuleIdEmbedPlugin } from './plugins/module-id-embed';\nimport { PatchRequirePlugin } from './plugins/patch-require';\nimport { RemoteWebpackRequirePlugin } from './plugins/remote-webpack-require';\n\nexport function transform(\n nextConfig: NextConfig,\n {\n app,\n alias = {},\n emitSharedFiles = () => {\n // no-op by default\n },\n }: {\n app: { name: string };\n alias?: Record<string, string>;\n emitSharedFiles?: () => void;\n },\n) {\n const webpackConfig = nextConfig.webpack;\n\n nextConfig.webpack = (\n baseConfig: WebpackOptionsNormalized,\n webpackContext,\n ) => {\n // execute the client config first, otherwise their config may accidentally\n // overwrite our required config - leading to unexpected errors.\n const config = (\n typeof webpackConfig === 'function'\n ? (webpackConfig(baseConfig, webpackContext) ?? baseConfig)\n : baseConfig\n ) as WebpackOptionsNormalized;\n\n // remote component specific plugins\n config.plugins.push(\n new RemoteWebpackRequirePlugin(app.name),\n new ModuleIdEmbedPlugin(app.name, { isServer: webpackContext.isServer }),\n new ConditionalExecPlugin(app.name),\n new PatchRequirePlugin(app.name),\n );\n if (!webpackContext.isServer) {\n // change the chunk loading global to avoid conflicts with other remote components\n config.output.chunkLoadingGlobal = `__remote_chunk_loading_global_${app.name}__`;\n }\n\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve.alias,\n ...Object.fromEntries(\n Object.entries(alias).map(([key, value]) => [\n key,\n join(process.cwd(), value),\n ]),\n ),\n },\n };\n\n emitSharedFiles();\n return config;\n };\n\n return nextConfig;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,WAAW,gBAAAA,eAAc,qBAAqB;AACnE,SAAS,UAAU,SAAS,QAAAC,OAAM,gBAAgB;AAClD,OAAO,qBAAqB;AAC5B,SAAS,cAAAC,mBAAkB;AAE3B,SAAS,oBAAoB;AAC7B,OAAO,gCAAgC;;;ACNvC,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;;;ACGpB,SAAS,0BAA8C;AAC5D,SACE,QAAQ,IAAI,gCACZ,QAAQ,IAAI,uCACZ,QAAQ,IAAI,qBACZ;AAEJ;;;ADFO,SAAS,iBAAiB,aAA6B;AAC5D,QAAM,UAAU,wBAAwB;AACxC,MAAI;AAAS,WAAO;AAEpB,MAAI;AACF,UAAM,cAAc,WAAW,wBAAwB;AAAA,MACrD,KAAK,QAAQ,IAAI;AAAA,IACnB,CAAC;AACD,QAAI,aAAa;AACf,aACE,KAAK,MAAM,aAAa,aAAa,MAAM,CAAC,EAC5C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cAAc;AAAA,QACZ,GAAG,WAAW,UAAU;AAAA,QACxB,4CAA4C;AAAA,MAC9C;AAAA,IACF;AACA,oBAAgB;AAChB,WAAO;AAAA,EACT;AAGA,SAAO,UAAiB,YAAY;AAAA,IAClC,KAAK,EAAE,MAAM,UAAU;AAAA,IACvB;AAAA,IACA;AAAA,EACF,CAAC;AACH;","names":["readFileSync","join","findUpSync","findUpSync","readFileSync","join"]}
1
+ {"version":3,"sources":["../../src/config/nextjs/index.ts","../../src/utils/project-id.ts","../../src/utils/project-id-env.ts","../../src/config/webpack/nextjs.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { basename, dirname, join, relative } from 'node:path';\nimport enhancedResolve from 'enhanced-resolve';\nimport { findUpSync } from 'find-up';\nimport type { NextConfig } from 'next';\nimport TsConfigPathsWebpackPlugin from 'tsconfig-paths-webpack-plugin';\nimport { SHARED_MODULE_MANIFEST_PROTOCOL } from '#internal/host/shared/shared-broker';\nimport {\n CORE_REACT_SHARED_KEYS,\n VENDOR_SHARED,\n} from '#internal/host/shared/shared-module-resolver';\nimport { logDebug, logError, logWarn } from '#internal/utils/logger';\nimport { resolveProjectId } from '#internal/utils/project-id';\nimport { transform as webpackTransform } from '../webpack/nextjs';\n\nfunction getNextMajorVersion(): number | undefined {\n try {\n const nextPkgPath = findUpSync('node_modules/next/package.json', {\n cwd: process.cwd(),\n });\n if (!nextPkgPath) return undefined;\n const { version } = JSON.parse(readFileSync(nextPkgPath, 'utf8')) as {\n version: string;\n };\n const major = version.split('.')[0];\n return major ? Number.parseInt(major, 10) : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction hasPagesDirectory(): boolean {\n return (\n existsSync(join(process.cwd(), 'pages')) ||\n existsSync(join(process.cwd(), 'src/pages'))\n );\n}\n\ninterface ZodSchema {\n safeParse: (data: unknown) => { success: boolean };\n}\n\n/**\n * Returns true when the installed Next.js version's config schema accepts\n * `turbopack.chunkLoadingGlobal`. The turbopack schema uses `z.strictObject`\n * so unrecognised keys fail — a successful parse means the field is present.\n *\n * Exported for unit testing.\n */\nexport function isChunkLoadingGlobalSupported(schema: ZodSchema): boolean {\n return schema.safeParse({ turbopack: { chunkLoadingGlobal: '__test__' } })\n .success;\n}\n\n/**\n * Loads `next/dist/server/config-schema.js` from the consuming app's own\n * `node_modules` (resolved from `process.cwd()`), not from the location of\n * this package. This ensures the schema reflects the exact Next.js version\n * installed in the app rather than whatever is hoisted to the workspace root.\n */\nfunction loadAppConfigSchema(): ZodSchema | undefined {\n try {\n const appRequire = createRequire(join(process.cwd(), 'package.json'));\n const mod = appRequire('next/dist/server/config-schema.js') as {\n configSchema: ZodSchema;\n };\n return mod.configSchema;\n } catch {\n return undefined;\n }\n}\n\nfunction readProjectPackageJson(): { name: string; type: string } {\n const defaults = { name: basename(process.cwd()), type: 'module' };\n try {\n const packageJsonPath = findUpSync('package.json', {\n cwd: process.cwd(),\n });\n if (packageJsonPath) {\n return {\n ...defaults,\n ...(JSON.parse(readFileSync(packageJsonPath, 'utf8')) as {\n name: string;\n type: string;\n }),\n };\n }\n } catch {\n // noop\n }\n return defaults;\n}\n\ninterface WithRemoteComponentsOptions {\n /**\n * An array of package names that should be shared between the host and remote components.\n * This is useful for ensuring that both the host and remote components use the same version\n * of shared libraries.\n *\n * Essential packages are included by default: `react`, `react-dom`, `next/navigation`, `next/link`, `next/form`, `next/image` (loader only), and `next/script`.\n */\n shared?: string[];\n}\n\n/**\n * This function configures Next.js to support Remote Components.\n * You need to also use the `withMicrofrontends` function to extend your Next.js configuration.\n *\n * @param nextConfig - The Next.js configuration object.\n * @param options - Optional configuration for remote components.\n * @returns The modified Next.js configuration object with remote components support.\n *\n * @example\n *\n * ```js\n * import { withMicrofrontends } from '@vercel/microfrontends/next/config';\n * import { withRemoteComponentsConfig } from 'remote-components/config/nextjs';\n *\n * const nextConfig = {\n * // your Next.js configuration\n * };\n *\n * export default withRemoteComponentsConfig(\n * withMicrofrontends(nextConfig),\n * {\n * shared: ['some-package', 'another-package'],\n * },\n * );\n * ```\n */\nexport function withRemoteComponentsConfig(\n nextConfig: NextConfig,\n options?: WithRemoteComponentsOptions,\n) {\n const virtualRemoteComponentAppSharedRemote = join(\n process.cwd(),\n '.remote-components/shared/app-remote.tsx',\n );\n const virtualRemoteComponentPagesSharedRemote = join(\n process.cwd(),\n '.remote-components/shared/pages-remote.tsx',\n );\n const virtualRemoteComponentAppSharedHost = join(\n process.cwd(),\n '.remote-components/shared/app-host.tsx',\n );\n const virtualRemoteComponentPagesSharedHost = join(\n process.cwd(),\n '.remote-components/shared/pages-host.tsx',\n );\n\n const appShared = new Set([\n ...CORE_REACT_SHARED_KEYS,\n 'next/navigation',\n 'next/dist/client/components/navigation',\n 'next/link',\n 'next/dist/client/app-dir/link',\n 'next/form',\n 'next/dist/client/app-dir/form',\n 'next/dist/shared/lib/image-loader',\n 'next/script',\n 'next/dist/client/script',\n 'next/dist/build/polyfills/process',\n ...(options?.shared ?? []),\n ]);\n const pagesShared = new Set([\n ...CORE_REACT_SHARED_KEYS,\n 'next/router',\n 'next/link',\n 'next/dist/shared/lib/image-loader',\n 'next/script',\n 'next/form',\n ...(options?.shared ?? []),\n ]);\n\n const vendorShared = { ...VENDOR_SHARED };\n\n // resolve using enhanced-resolve\n // named import does not work with enhanced-resolve when using cjs\n // eslint-disable-next-line import/no-named-as-default-member\n const resolve = enhancedResolve.create.sync({\n conditionNames: ['browser', 'import', 'module', 'require'],\n ...(existsSync(join(process.cwd(), 'tsconfig.json'))\n ? {\n extensions: ['.js', '.jsx', '.ts', '.tsx'],\n plugins: [\n new TsConfigPathsWebpackPlugin({\n configFile: join(process.cwd(), 'tsconfig.json'),\n }) as unknown as enhancedResolve.Plugin,\n ],\n }\n : {}),\n });\n\n const packageJson = readProjectPackageJson();\n\n const generateSharedModule = ({\n sharedEntries,\n sharedManifest,\n }: {\n sharedEntries: string[];\n sharedManifest?: string;\n }) => {\n const shared = sharedEntries.join('\\n');\n\n if (packageJson.type !== 'module') {\n const exports = [`shared: {\\n${shared}\\n}`];\n if (sharedManifest) {\n exports.push(`sharedManifest: ${sharedManifest}`);\n }\n return `'use client';\\nmodule.exports = {\\n${exports.join(',\\n')}\\n};\\n`;\n }\n\n return `'use client';\\nexport const shared = {\\n${shared}\\n};\\n${\n sharedManifest ? `export const sharedManifest = ${sharedManifest};\\n` : ''\n }`;\n };\n\n const resolveSharedPath = (moduleName: string): string | undefined => {\n try {\n const resolved = resolve(process.cwd(), moduleName);\n if (resolved) {\n return relative(process.cwd(), resolved).replace(\n /^(?<relative>\\.\\.\\/)+/,\n '',\n );\n }\n } catch {\n // if module resolution using enhanced-resolve fails, fallback to require.resolve called in the shared/remote file\n }\n };\n\n const sharedKeyExpression = (moduleName: string): string => {\n const path = resolveSharedPath(moduleName);\n return (\n vendorShared[moduleName] ??\n (path ? `'${path}'` : `require.resolve('${moduleName}')`)\n );\n };\n\n const generateSharedRemote = (sharedRemote: Set<string>) => {\n const sharedEntries = Array.from(sharedRemote).reduce<string[]>(\n (acc, curr) => {\n const id = sharedKeyExpression(curr);\n // @legacy(remote-components<=0.4.x): keep emitting the historical\n // shared map until hosts on 0.4.x are outside the compatibility window.\n acc.push(`[${id}]: '${curr}',`);\n acc.push(\n `['__remote_shared_module_${curr}']: () => import('${curr}'),`,\n );\n return acc;\n },\n [],\n );\n const requirements = Array.from(sharedRemote)\n .map(\n (curr) =>\n `{ id: ${sharedKeyExpression(curr)}, specifier: '${curr}', required: true, singleton: true }`,\n )\n .join(',\\n');\n return generateSharedModule({\n sharedEntries,\n sharedManifest: `{ protocol: '${SHARED_MODULE_MANIFEST_PROTOCOL}', requirements: [\\n${requirements}\\n] }`,\n });\n };\n const generateSharedHost = (sharedHost: Set<string>) =>\n generateSharedModule({\n sharedEntries: Array.from(sharedHost).reduce<string[]>((acc, curr) => {\n acc.push(`['${curr}']: () => import('${curr}'),`);\n return acc;\n }, []),\n });\n\n const appSharedRemote = generateSharedRemote(appShared);\n const pagesSharedRemote = generateSharedRemote(pagesShared);\n\n const appSharedHost = generateSharedHost(appShared);\n const pagesSharedHost = generateSharedHost(pagesShared);\n\n const emitSharedFiles = () => {\n mkdirSync(dirname(virtualRemoteComponentAppSharedRemote), {\n recursive: true,\n });\n\n writeFileSync(\n virtualRemoteComponentAppSharedRemote,\n appSharedRemote,\n 'utf-8',\n );\n writeFileSync(\n virtualRemoteComponentPagesSharedRemote,\n pagesSharedRemote,\n 'utf-8',\n );\n writeFileSync(virtualRemoteComponentAppSharedHost, appSharedHost, 'utf-8');\n writeFileSync(\n virtualRemoteComponentPagesSharedHost,\n pagesSharedHost,\n 'utf-8',\n );\n };\n\n nextConfig.transpilePackages = [\n ...(nextConfig.transpilePackages ?? []),\n 'remote-components',\n ];\n\n nextConfig.env = {\n ...nextConfig.env,\n REMOTE_COMPONENTS_CONFIGURED: '1',\n };\n\n const alias = {\n '#remote-components/remote/defaults/app': `./${relative(\n process.cwd(),\n virtualRemoteComponentAppSharedRemote,\n )}`,\n '#remote-components/remote/defaults/pages': `./${relative(\n process.cwd(),\n virtualRemoteComponentPagesSharedRemote,\n )}`,\n '#remote-components/host/defaults/app': `./${relative(\n process.cwd(),\n virtualRemoteComponentAppSharedHost,\n )}`,\n '#remote-components/host/defaults/pages': `./${relative(\n process.cwd(),\n virtualRemoteComponentPagesSharedHost,\n )}`,\n };\n\n const projectId = resolveProjectId(packageJson.name);\n process.env.REMOTE_COMPONENTS_PROJECT_ID = projectId;\n\n if (hasPagesDirectory()) {\n // Log instead of throwing for the version check because\n // withRemoteComponentsConfig is shared by both hosts and remotes.\n // Only Pages Router hosts are broken on Next.js < 16 — remotes\n // work fine and must not have their builds blocked.\n const nextMajor = getNextMajorVersion();\n if (nextMajor !== undefined && nextMajor < 16) {\n const log =\n process.env.NODE_ENV !== 'production' ||\n process.env.VERCEL_ENV === 'preview'\n ? logWarn\n : logDebug;\n log(\n 'Config',\n `Remote Components does not support Pages Router hosts on Next.js ${nextMajor}. ` +\n 'Pages Router remotes are unaffected. Upgrade to Next.js 16+ for host support.',\n );\n }\n }\n\n if (process.env.TURBOPACK) {\n const appConfigSchema = loadAppConfigSchema();\n if (\n !appConfigSchema?.safeParse({\n turbopack: {\n resolveAlias: {\n ...alias,\n },\n },\n compiler: {\n defineServer: {\n REMOTE_COMPONENTS_PROJECT_ID: projectId,\n },\n },\n }).success\n ) {\n logError(\n 'Config',\n 'Turbopack support requires a Next.js version that includes `compiler.defineServer`. ' +\n 'Upgrade Next.js to continue using Remote Components with Turbopack.',\n );\n process.exit(1);\n }\n const chunkLoadingGlobalSupported =\n appConfigSchema !== undefined &&\n isChunkLoadingGlobalSupported(appConfigSchema);\n // Next.js auto-prefixes chunkLoadingGlobal with \"TURBOPACK_\" when the value\n // doesn't already start with it. We set the prefix ourselves so the final\n // global name is predictable: TURBOPACK_remote_chunk_loading_global_<id>.\n const chunkLoadingGlobalValue = `TURBOPACK_remote_chunk_loading_global_${projectId}`;\n if (chunkLoadingGlobalSupported) {\n logDebug(\n 'Config',\n `Turbopack chunkLoadingGlobal set to \"${chunkLoadingGlobalValue}\" — ` +\n 'chunks will use a build-time scoped global (no runtime TURBOPACK rename needed).',\n );\n } else {\n logDebug(\n 'Config',\n 'Turbopack chunkLoadingGlobal not supported by this Next.js version — ' +\n 'falling back to runtime TURBOPACK global rename.',\n );\n }\n nextConfig.turbopack = {\n ...nextConfig.turbopack,\n resolveAlias: {\n ...nextConfig.turbopack?.resolveAlias,\n ...alias,\n },\n ...(chunkLoadingGlobalSupported\n ? { chunkLoadingGlobal: chunkLoadingGlobalValue }\n : {}),\n };\n nextConfig.compiler = {\n ...nextConfig.compiler,\n defineServer: {\n ...nextConfig.compiler?.defineServer,\n 'process.env.REMOTE_COMPONENTS_PROJECT_ID': projectId,\n },\n };\n emitSharedFiles();\n return nextConfig;\n }\n\n // apply the webpack transform\n return webpackTransform(nextConfig, {\n app: { name: projectId },\n alias,\n emitSharedFiles,\n });\n}\n","import { readFileSync } from 'node:fs';\nimport { findUpSync } from 'find-up';\nimport { resolveProjectIdFromEnv } from './project-id-env';\n\n/**\n * Resolves the project ID using environment variables first, then\n * falling back to `.vercel/project.json` and finally the package name.\n * Node-only — requires file system access.\n */\nexport function resolveProjectId(packageName: string): string {\n const fromEnv = resolveProjectIdFromEnv();\n if (fromEnv) return fromEnv;\n\n try {\n const projectPath = findUpSync('.vercel/project.json', {\n cwd: process.cwd(),\n });\n if (projectPath) {\n return (\n JSON.parse(readFileSync(projectPath, 'utf8')) as { projectId: string }\n ).projectId;\n }\n } catch {\n // fallback below\n }\n\n return packageName;\n}\n","/**\n * Resolves the project ID from environment variables only.\n * Safe for edge/browser contexts where file system access is unavailable.\n */\nexport function resolveProjectIdFromEnv(): string | undefined {\n return (\n process.env.REMOTE_COMPONENTS_PROJECT_ID ||\n process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION ||\n process.env.VERCEL_PROJECT_ID ||\n undefined\n );\n}\n","import { join } from 'node:path';\nimport type { NextConfig } from 'next';\nimport type { WebpackOptionsNormalized } from 'webpack';\nimport { ConditionalExecPlugin } from './plugins/conditional-exec';\nimport { ModuleIdEmbedPlugin } from './plugins/module-id-embed';\nimport { PatchRequirePlugin } from './plugins/patch-require';\nimport { RemoteWebpackRequirePlugin } from './plugins/remote-webpack-require';\n\nexport function transform(\n nextConfig: NextConfig,\n {\n app,\n alias = {},\n emitSharedFiles = () => {\n // no-op by default\n },\n }: {\n app: { name: string };\n alias?: Record<string, string>;\n emitSharedFiles?: () => void;\n },\n) {\n const webpackConfig = nextConfig.webpack;\n\n nextConfig.webpack = (\n baseConfig: WebpackOptionsNormalized,\n webpackContext,\n ) => {\n // execute the client config first, otherwise their config may accidentally\n // overwrite our required config - leading to unexpected errors.\n const config = (\n typeof webpackConfig === 'function'\n ? (webpackConfig(baseConfig, webpackContext) ?? baseConfig)\n : baseConfig\n ) as WebpackOptionsNormalized;\n\n // remote component specific plugins\n config.plugins.push(\n new RemoteWebpackRequirePlugin(app.name),\n new ModuleIdEmbedPlugin(app.name, { isServer: webpackContext.isServer }),\n new ConditionalExecPlugin(app.name),\n new PatchRequirePlugin(app.name),\n );\n if (!webpackContext.isServer) {\n // change the chunk loading global to avoid conflicts with other remote components\n config.output.chunkLoadingGlobal = `__remote_chunk_loading_global_${app.name}__`;\n }\n\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve.alias,\n ...Object.fromEntries(\n Object.entries(alias).map(([key, value]) => [\n key,\n join(process.cwd(), value),\n ]),\n ),\n },\n };\n\n emitSharedFiles();\n return config;\n };\n\n return nextConfig;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,WAAW,gBAAAA,eAAc,qBAAqB;AACnE,SAAS,qBAAqB;AAC9B,SAAS,UAAU,SAAS,QAAAC,OAAM,gBAAgB;AAClD,OAAO,qBAAqB;AAC5B,SAAS,cAAAC,mBAAkB;AAE3B,OAAO,gCAAgC;;;ACNvC,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;;;ACGpB,SAAS,0BAA8C;AAC5D,SACE,QAAQ,IAAI,gCACZ,QAAQ,IAAI,uCACZ,QAAQ,IAAI,qBACZ;AAEJ;;;ADFO,SAAS,iBAAiB,aAA6B;AAC5D,QAAM,UAAU,wBAAwB;AACxC,MAAI;AAAS,WAAO;AAEpB,MAAI;AACF,UAAM,cAAc,WAAW,wBAAwB;AAAA,MACrD,KAAK,QAAQ,IAAI;AAAA,IACnB,CAAC;AACD,QAAI,aAAa;AACf,aACE,KAAK,MAAM,aAAa,aAAa,MAAM,CAAC,EAC5C;AAAA,IACJ;AAAA,EACF,QAAE;AAAA,EAEF;AAEA,SAAO;AACT;;;AE3BA,SAAS,YAAY;AAQd,SAAS,UACd,YACA;AAAA,EACE;AAAA,EACA,QAAQ,CAAC;AAAA,EACT,kBAAkB,MAAM;AAAA,EAExB;AACF,GAKA;AACA,QAAM,gBAAgB,WAAW;AAEjC,aAAW,UAAU,CACnB,YACA,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AA6B;AAC/B;AAAA,QACE;AAAA,QACA,wCAAwC;AAAA,MAE1C;AAAA,IACF,OAAO;AACL;AAAA,QACE;AAAA,QACA;AAAA,MAEF;AAAA,IACF;AACA,eAAW,YAAY;AAAA,MACrB,GAAG,WAAW;AAAA,MACd,cAAc;AAAA,QACZ,GAAG,WAAW,WAAW;AAAA,QACzB,GAAG;AAAA,MACL;AAAA,MACA,GAAI,8BACA,EAAE,oBAAoB,wBAAwB,IAC9C,CAAC;AAAA,IACP;AACA,eAAW,WAAW;AAAA,MACpB,GAAG,WAAW;AAAA,MACd,cAAc;AAAA,QACZ,GAAG,WAAW,UAAU;AAAA,QACxB,4CAA4C;AAAA,MAC9C;AAAA,IACF;AACA,oBAAgB;AAChB,WAAO;AAAA,EACT;AAGA,SAAO,UAAiB,YAAY;AAAA,IAClC,KAAK,EAAE,MAAM,UAAU;AAAA,IACvB;AAAA,IACA;AAAA,EACF,CAAC;AACH;","names":["readFileSync","join","findUpSync","findUpSync","readFileSync","join"]}
@@ -7,10 +7,10 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkCELPDJVYcjs = require('../chunk-CELPDJVY.cjs');
10
+ var _chunkPNASFKWAcjs = require('../chunk-PNASFKWA.cjs');
11
11
  require('../chunk-4MLJE6UP.cjs');
12
- require('../chunk-76W64VJG.cjs');
13
- require('../chunk-7ZQ7SWZM.cjs');
12
+ require('../chunk-7OD5S534.cjs');
13
+ require('../chunk-W5FSHVWU.cjs');
14
14
  require('../chunk-3AX5WLZD.cjs');
15
15
 
16
16
 
@@ -125,10 +125,10 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
125
125
  };
126
126
  }
127
127
  if (type === "webpack") {
128
- const { webpackRuntime } = await Promise.resolve().then(() => _interopRequireWildcard(require("../webpack-2QRFGZIF.cjs")));
128
+ const { webpackRuntime } = await Promise.resolve().then(() => _interopRequireWildcard(require("../webpack-FWUNUWLF.cjs")));
129
129
  return webpackRuntime(bundle, shared, remoteShared, resolveClientUrl);
130
130
  } else if (type === "turbopack") {
131
- const { turbopackRuntime } = await Promise.resolve().then(() => _interopRequireWildcard(require("../turbopack-L7JU77FH.cjs")));
131
+ const { turbopackRuntime } = await Promise.resolve().then(() => _interopRequireWildcard(require("../turbopack-Q6KJAEOX.cjs")));
132
132
  return turbopackRuntime(
133
133
  url,
134
134
  bundle,
@@ -154,10 +154,10 @@ if (typeof HTMLElement !== "undefined") {
154
154
 
155
155
  __init3() {this.__next = null}
156
156
  __init4() {this.fouc = null}
157
- __init5() {this.hostState = _chunkCELPDJVYcjs.createHostState.call(void 0, )}
157
+ __init5() {this.hostState = _chunkPNASFKWAcjs.createHostState.call(void 0, )}
158
158
  __init6() {this.root = null}
159
159
 
160
- __init7() {this.emitter = _chunkCELPDJVYcjs.makeEventEmitter.call(void 0, this)}
160
+ __init7() {this.emitter = _chunkPNASFKWAcjs.makeEventEmitter.call(void 0, this)}
161
161
 
162
162
 
163
163
 
@@ -279,10 +279,10 @@ if (typeof HTMLElement !== "undefined") {
279
279
  let url = null;
280
280
  let html = this.innerHTML;
281
281
  if (src) {
282
- url = _chunkCELPDJVYcjs.getClientOrServerUrl.call(void 0, src, window.location.href);
283
- this.name = _chunkCELPDJVYcjs.resolveNameFromSrc.call(void 0, src, this.name);
282
+ url = _chunkPNASFKWAcjs.getClientOrServerUrl.call(void 0, src, window.location.href);
283
+ this.name = _chunkPNASFKWAcjs.resolveNameFromSrc.call(void 0, src, this.name);
284
284
  }
285
- const resolveClientUrl = url ? _chunkCELPDJVYcjs.bindResolveClientUrl.call(void 0, this.resolveClientUrl, url.href) : void 0;
285
+ const resolveClientUrl = url ? _chunkPNASFKWAcjs.bindResolveClientUrl.call(void 0, this.resolveClientUrl, url.href) : void 0;
286
286
  if (!remoteComponentChild && url) {
287
287
  const fetchInit = {
288
288
  credentials: this.credentials || "same-origin"
@@ -293,7 +293,7 @@ if (typeof HTMLElement !== "undefined") {
293
293
  );
294
294
  let res;
295
295
  try {
296
- res = await _chunkCELPDJVYcjs.fetchWithHooks.call(void 0, resolvedUrl, fetchInit, {
296
+ res = await _chunkPNASFKWAcjs.fetchWithHooks.call(void 0, resolvedUrl, fetchInit, {
297
297
  onRequest: this.onRequest,
298
298
  onResponse: this.onResponse,
299
299
  abortController: this.hostState.abortController
@@ -320,7 +320,7 @@ if (typeof HTMLElement !== "undefined") {
320
320
  }
321
321
  }
322
322
  const effectiveUrl = _nullishCoalesce(url, () => ( new URL(window.location.href)));
323
- const { doc, parsed } = _chunkCELPDJVYcjs.preparePipeline.call(void 0, {
323
+ const { doc, parsed } = _chunkPNASFKWAcjs.preparePipeline.call(void 0, {
324
324
  html,
325
325
  name: this.name,
326
326
  url: effectiveUrl,
@@ -568,7 +568,7 @@ if (typeof HTMLElement !== "undefined") {
568
568
  name,
569
569
  initial
570
570
  }) => {
571
- const stream = _chunkCELPDJVYcjs.createRSCStream.call(void 0,
571
+ const stream = _chunkPNASFKWAcjs.createRSCStream.call(void 0,
572
572
  rscName,
573
573
  _nullishCoalesce(self[rscName], () => ( [`0:[null]
574
574
  `]))
package/dist/host/html.js CHANGED
@@ -7,10 +7,10 @@ import {
7
7
  makeEventEmitter,
8
8
  preparePipeline,
9
9
  resolveNameFromSrc
10
- } from "../chunk-3XXIKTRR.js";
10
+ } from "../chunk-O4A6CJGI.js";
11
11
  import "../chunk-WGSS7TJP.js";
12
- import "../chunk-2VLOQRNR.js";
13
- import "../chunk-7X64ZGV5.js";
12
+ import "../chunk-NZM2SI6U.js";
13
+ import "../chunk-PT3R275L.js";
14
14
  import "../chunk-LEKG4YWI.js";
15
15
  import {
16
16
  DEFAULT_BUNDLE_NAME,
@@ -125,10 +125,10 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
125
125
  };
126
126
  }
127
127
  if (type === "webpack") {
128
- const { webpackRuntime } = await import("../webpack-V4ZH7KA2.js");
128
+ const { webpackRuntime } = await import("../webpack-AQ34DAJZ.js");
129
129
  return webpackRuntime(bundle, shared, remoteShared, resolveClientUrl);
130
130
  } else if (type === "turbopack") {
131
- const { turbopackRuntime } = await import("../turbopack-ABJOQO3J.js");
131
+ const { turbopackRuntime } = await import("../turbopack-55EJDSUT.js");
132
132
  return turbopackRuntime(
133
133
  url,
134
134
  bundle,
@@ -1,13 +1,13 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
2
2
 
3
3
 
4
- var _chunk5GPOQVC3cjs = require('../../../chunk-5GPOQVC3.cjs');
4
+ var _chunkTWO3XB6Hcjs = require('../../../chunk-TWO3XB6H.cjs');
5
5
 
6
6
 
7
- var _chunkCELPDJVYcjs = require('../../../chunk-CELPDJVY.cjs');
7
+ var _chunkPNASFKWAcjs = require('../../../chunk-PNASFKWA.cjs');
8
8
  require('../../../chunk-4MLJE6UP.cjs');
9
- require('../../../chunk-76W64VJG.cjs');
10
- require('../../../chunk-7ZQ7SWZM.cjs');
9
+ require('../../../chunk-7OD5S534.cjs');
10
+ require('../../../chunk-W5FSHVWU.cjs');
11
11
  require('../../../chunk-3AX5WLZD.cjs');
12
12
  require('../../../chunk-N3SQTOSE.cjs');
13
13
 
@@ -32,7 +32,7 @@ function resolveForBundle(unbound, bundle) {
32
32
  if (!unbound)
33
33
  return void 0;
34
34
  const remoteSrc = _nullishCoalesce(_optionalChain([_chunkI7VKDF3Ecjs.getScope.call(void 0, bundle), 'optionalAccess', _2 => _2.url, 'access', _3 => _3.href]), () => ( ""));
35
- return _chunkCELPDJVYcjs.bindResolveClientUrl.call(void 0, unbound, remoteSrc);
35
+ return _chunkPNASFKWAcjs.bindResolveClientUrl.call(void 0, unbound, remoteSrc);
36
36
  }
37
37
  function createImageLoaderSharedEntries({
38
38
  bound,
@@ -191,7 +191,7 @@ function ConsumeRemoteComponent2(props) {
191
191
  return _nullishCoalesce(props.children, () => ( null));
192
192
  }
193
193
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
194
- _chunk5GPOQVC3cjs.ConsumeRemoteComponent,
194
+ _chunkTWO3XB6Hcjs.ConsumeRemoteComponent,
195
195
  {
196
196
  ...props,
197
197
  shared: sharedModules(props.shared, props.resolveClientUrl)
@@ -1,13 +1,13 @@
1
1
  "use client";
2
2
  import {
3
3
  ConsumeRemoteComponent
4
- } from "../../../chunk-QNPKWDSY.js";
4
+ } from "../../../chunk-MJ2KYXGR.js";
5
5
  import {
6
6
  bindResolveClientUrl
7
- } from "../../../chunk-3XXIKTRR.js";
7
+ } from "../../../chunk-O4A6CJGI.js";
8
8
  import "../../../chunk-WGSS7TJP.js";
9
- import "../../../chunk-2VLOQRNR.js";
10
- import "../../../chunk-7X64ZGV5.js";
9
+ import "../../../chunk-NZM2SI6U.js";
10
+ import "../../../chunk-PT3R275L.js";
11
11
  import "../../../chunk-LEKG4YWI.js";
12
12
  import "../../../chunk-RHGEBXPL.js";
13
13
  import {
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunk5GPOQVC3cjs = require('../chunk-5GPOQVC3.cjs');
5
- require('../chunk-CELPDJVY.cjs');
4
+ var _chunkTWO3XB6Hcjs = require('../chunk-TWO3XB6H.cjs');
5
+ require('../chunk-PNASFKWA.cjs');
6
6
  require('../chunk-4MLJE6UP.cjs');
7
- require('../chunk-76W64VJG.cjs');
8
- require('../chunk-7ZQ7SWZM.cjs');
7
+ require('../chunk-7OD5S534.cjs');
8
+ require('../chunk-W5FSHVWU.cjs');
9
9
  require('../chunk-3AX5WLZD.cjs');
10
10
  require('../chunk-N3SQTOSE.cjs');
11
11
  require('../chunk-I7VKDF3E.cjs');
@@ -18,5 +18,5 @@ require('../chunk-SHFJ5OQA.cjs');
18
18
 
19
19
 
20
20
 
21
- exports.ConsumeRemoteComponent = _chunk5GPOQVC3cjs.ConsumeRemoteComponent; exports.useRemoteNavigate = _chunk5GPOQVC3cjs.useRemoteNavigate;
21
+ exports.ConsumeRemoteComponent = _chunkTWO3XB6Hcjs.ConsumeRemoteComponent; exports.useRemoteNavigate = _chunkTWO3XB6Hcjs.useRemoteNavigate;
22
22
  //# sourceMappingURL=react.cjs.map
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  ConsumeRemoteComponent,
3
3
  useRemoteNavigate
4
- } from "../chunk-QNPKWDSY.js";
5
- import "../chunk-3XXIKTRR.js";
4
+ } from "../chunk-MJ2KYXGR.js";
5
+ import "../chunk-O4A6CJGI.js";
6
6
  import "../chunk-WGSS7TJP.js";
7
- import "../chunk-2VLOQRNR.js";
8
- import "../chunk-7X64ZGV5.js";
7
+ import "../chunk-NZM2SI6U.js";
8
+ import "../chunk-PT3R275L.js";
9
9
  import "../chunk-LEKG4YWI.js";
10
10
  import "../chunk-RHGEBXPL.js";
11
11
  import "../chunk-JZRA6DPE.js";
@@ -57,9 +57,28 @@ function loadChunkWithScope(scope, chunkId) {
57
57
  }
58
58
  ns.chunkCache[url] = new Promise((resolve, reject) => {
59
59
  fetch(resolvedUrl).then((res) => res.text()).then((code) => {
60
- const hasTurbopack = import_patterns2.TURBOPACK_GLOBAL_RE.test(code);
61
- if (hasTurbopack) {
62
- return handleTurbopackChunk(code, scope, url);
60
+ if (/importScripts\(\.\.\.self\.TURBOPACK_NEXT_CHUNK_URLS/.test(code)) {
61
+ const preloadLinks = document.querySelectorAll(
62
+ `link[rel="preload"][href="${new URL(url).pathname}"]`
63
+ );
64
+ preloadLinks.forEach((preloadLink) => preloadLink.remove());
65
+ return;
66
+ }
67
+ const hasTurbopackLegacyGlobal = import_patterns2.TURBOPACK_GLOBAL_RE.test(code);
68
+ const customGlobalProp = `TURBOPACK_remote_chunk_loading_global_${scope.name}`;
69
+ const hasCustomGlobal = code.includes(customGlobalProp);
70
+ const isTurbopackChunk = hasTurbopackLegacyGlobal || hasCustomGlobal;
71
+ if (isTurbopackChunk) {
72
+ (0, import_logger.logDebug)(
73
+ "ChunkLoader",
74
+ hasCustomGlobal && !hasTurbopackLegacyGlobal ? `Chunk "${url}" uses build-time chunkLoadingGlobal "${customGlobalProp}" \u2014 skipping runtime TURBOPACK rename.` : `Chunk "${url}" uses legacy globalThis.TURBOPACK \u2014 applying runtime rename for scope "${scope.scopedName}".`
75
+ );
76
+ return handleTurbopackChunk(
77
+ code,
78
+ scope,
79
+ url,
80
+ hasTurbopackLegacyGlobal
81
+ );
63
82
  }
64
83
  }).then(resolve).catch((error) => {
65
84
  const isProxied = (0, import_protected_rc_fallback.isProxiedUrl)(resolvedUrl);
@@ -90,36 +109,34 @@ function createChunkDispatcher() {
90
109
  return loadChunkWithScope(scope, chunkId);
91
110
  };
92
111
  }
93
- async function handleTurbopackChunk(code, scope, url) {
94
- if (/importScripts\(\.\.\.self.TURBOPACK_NEXT_CHUNK_URLS/.test(code)) {
95
- const preloadLinks = document.querySelectorAll(
96
- `link[rel="preload"][href="${new URL(url).pathname}"]`
97
- );
98
- preloadLinks.forEach((preloadLink) => preloadLink.remove());
99
- return;
100
- }
112
+ async function handleTurbopackChunk(code, scope, url, renameTurbopackGlobal) {
101
113
  const self = globalThis;
102
- const { globalKey } = scope;
103
- const transformedCode = code.replace(
104
- /globalThis\[\s*["']TURBOPACK["']\s*\]/g,
105
- `globalThis["TURBOPACK_${globalKey}"]`
106
- ).replace(
107
- /self\[\s*["']TURBOPACK["']\s*\]/g,
108
- `self["TURBOPACK_${globalKey}"]`
109
- ).replace(/globalThis\.TURBOPACK/g, `globalThis.TURBOPACK_${globalKey}`).replace(/self\.TURBOPACK(?!_)/g, `self.TURBOPACK_${globalKey}`).replace(
114
+ const { globalKey, name } = scope;
115
+ const globalProp = renameTurbopackGlobal ? `TURBOPACK_${globalKey}` : `TURBOPACK_remote_chunk_loading_global_${name}`;
116
+ let transformedCode = code;
117
+ if (renameTurbopackGlobal) {
118
+ transformedCode = transformedCode.replace(
119
+ /globalThis\[\s*["']TURBOPACK["']\s*\]/g,
120
+ `globalThis["TURBOPACK_${globalKey}"]`
121
+ ).replace(
122
+ /self\[\s*["']TURBOPACK["']\s*\]/g,
123
+ `self["TURBOPACK_${globalKey}"]`
124
+ ).replace(/globalThis\.TURBOPACK/g, `globalThis.TURBOPACK_${globalKey}`).replace(/self\.TURBOPACK(?!_)/g, `self.TURBOPACK_${globalKey}`).replace(/TURBOPACK_CHUNK_LISTS/g, `TURBOPACK_${globalKey}_CHUNK_LISTS`);
125
+ }
126
+ transformedCode = transformedCode.replace(
110
127
  /TURBOPACK_WORKER_LOCATION/g,
111
128
  `TURBOPACK_WORKER_LOCATION_${globalKey}`
112
129
  ).replace(
113
130
  /TURBOPACK_NEXT_CHUNK_URLS/g,
114
131
  `TURBOPACK_NEXT_CHUNK_URLS_${globalKey}`
115
- ).replace(/TURBOPACK_CHUNK_LISTS/g, `TURBOPACK_CHUNK_LISTS_${globalKey}`).replace(
132
+ ).replace(
116
133
  /TURBOPACK_CHUNK_UPDATE_LISTENERS/g,
117
134
  `TURBOPACK_CHUNK_UPDATE_LISTENERS_${globalKey}`
118
135
  ).replace(/__next_require__/g, `__${globalKey}_next_require__`).replace(
119
136
  /\/\/# sourceMappingURL=(?<name>.+)(?<optional>\._)?\.js\.map/g,
120
137
  `//# sourceMappingURL=${new URL(".", new URL(url, scope.url)).href}$1$2.js.map`
121
138
  );
122
- if (!self[`TURBOPACK_${globalKey}`]) {
139
+ if (!self[globalProp]) {
123
140
  const wrapPush = (target) => {
124
141
  const originalPush = target.push;
125
142
  if (typeof originalPush !== "function")
@@ -138,7 +155,6 @@ async function handleTurbopackChunk(code, scope, url) {
138
155
  };
139
156
  return target;
140
157
  };
141
- const globalProp = `TURBOPACK_${globalKey}`;
142
158
  let currentValue = wrapPush([]);
143
159
  Object.defineProperty(self, globalProp, {
144
160
  get() {
@@ -179,7 +195,7 @@ async function handleTurbopackChunk(code, scope, url) {
179
195
  };
180
196
  document.head.appendChild(script);
181
197
  });
182
- const chunkLists = self[`TURBOPACK_${globalKey}_CHUNK_LISTS`];
198
+ const chunkLists = self[`${globalProp}_CHUNK_LISTS`];
183
199
  const loadChunkPromises = [];
184
200
  while (chunkLists?.length) {
185
201
  const { chunks } = chunkLists.shift() ?? { chunks: [] };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/runtime/turbopack/chunk-loader.ts"],"sourcesContent":["import { RUNTIME_WEBPACK } from '#internal/runtime/constants';\nimport { getNamespace } from '#internal/runtime/namespace';\nimport { collapseDoubleSlashes } from '#internal/runtime/patterns';\nimport type { GlobalScope } from '#internal/runtime/types';\nimport { isProxiedUrl } from '#internal/runtime/url/protected-rc-fallback';\nimport {\n failedProxiedAssetError,\n RemoteComponentsError,\n} from '#internal/utils/error';\nimport {\n logDebug,\n logWarn,\n warnCrossOriginFetchError,\n} from '#internal/utils/logger';\nimport { TURBOPACK_GLOBAL_RE } from './patterns';\nimport {\n formatRemoteId,\n getScope,\n parseRemoteId,\n type RemoteScope,\n} from './remote-scope';\n\n/**\n * Loads a chunk using a specific scope. All state (base URL, proxy callback,\n * TURBOPACK global key) comes from the scope — no global lookups needed.\n *\n * This is the primary chunk loader called directly from:\n * - setupRemoteScope (initial chunks)\n * - TurbopackContext.l (module-level chunk loading)\n * - handleTurbopackChunk (CHUNK_LIST additional chunks)\n *\n * The global chunk dedup cache is keyed by absolute URL, so different origins\n * naturally get separate cache entries even when sharing a bundle name.\n */\nexport function loadChunkWithScope(\n scope: RemoteScope,\n chunkId: string,\n): Promise<unknown> | undefined {\n logDebug(\n 'ChunkLoader',\n `loadChunkWithScope: \"${chunkId}\" (scope: \"${scope.scopedName}\")`,\n );\n const self = globalThis as GlobalScope;\n const ns = getNamespace();\n\n const { bundle, path, prefix } = parseRemoteId(chunkId);\n\n // Skip webpack runtime chunks\n const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? 'default']\n ? self.__remote_webpack_require__[bundle ?? 'default']?.type || 'webpack'\n : scope.runtime;\n if (remoteRuntime === RUNTIME_WEBPACK) {\n return Promise.resolve(undefined);\n }\n\n const rawPath = path ? collapseDoubleSlashes(`${prefix}${path}`) : '/';\n const url = new URL(rawPath, scope.url).href;\n\n if (url.endsWith('.css')) {\n return;\n }\n\n if (ns.chunkCache[url]) {\n logDebug('ChunkLoader', `Cache hit for \"${chunkId}\" (url=\"${url}\")`);\n return ns.chunkCache[url];\n }\n\n const resolvedUrl = scope.resolveClientUrl?.(url) ?? url;\n if (resolvedUrl !== url) {\n logDebug('ChunkLoader', `Proxied chunk URL: \"${url}\" → \"${resolvedUrl}\"`);\n }\n\n ns.chunkCache[url] = new Promise((resolve, reject) => {\n fetch(resolvedUrl)\n .then((res) => res.text())\n .then((code) => {\n const hasTurbopack = TURBOPACK_GLOBAL_RE.test(code);\n if (hasTurbopack) {\n return handleTurbopackChunk(code, scope, url);\n }\n // Chunk doesn't contain Turbopack globals — nothing to process\n })\n .then(resolve)\n .catch((error) => {\n const isProxied = isProxiedUrl(resolvedUrl);\n if (isProxied) {\n reject(failedProxiedAssetError('chunk', url, resolvedUrl));\n } else {\n warnCrossOriginFetchError('ChunkLoader', url);\n reject(error);\n }\n });\n });\n\n return ns.chunkCache[url];\n}\n\n/**\n * Creates the global `__webpack_chunk_load__` dispatcher.\n * This is a thin wrapper called only by external code (React's RSC runtime).\n * It parses the chunkId, resolves the correct scope, and delegates to\n * `loadChunkWithScope`.\n */\nexport function createChunkDispatcher(): (\n chunkId: string,\n scriptBundle?: string,\n) => Promise<unknown> | undefined {\n return function __chunk_dispatcher__(chunkId: string, scriptBundle?: string) {\n logDebug('ChunkDispatcher', `Dispatching chunk: \"${chunkId}\"`);\n\n const { bundle } = parseRemoteId(chunkId);\n const bundleName = bundle || scriptBundle || 'default';\n\n // Works with both the scoped name (Next.js hosts with server-side\n // rewriting) and the plain bundle name (static/HTML hosts).\n const scope = getScope(bundleName);\n\n logDebug(\n 'ChunkDispatcher',\n `Scope resolution: bundle=\"${bundleName}\", scope=${scope?.scopedName ?? 'null'}`,\n );\n\n if (!scope) {\n logWarn('ChunkDispatcher', `No scope found for bundle \"${bundleName}\"`);\n return Promise.resolve(undefined);\n }\n\n return loadChunkWithScope(scope, chunkId);\n };\n}\n\n/**\n * Handles Turbopack chunk loading by transforming the chunk code to isolate\n * global variables per bundle and dynamically loading the transformed script.\n * Receives scope directly — no global state lookups needed.\n */\nasync function handleTurbopackChunk(\n code: string,\n scope: RemoteScope,\n url: string,\n): Promise<void> {\n // skip this chunk as it is not needed for remote components\n if (/importScripts\\(\\.\\.\\.self.TURBOPACK_NEXT_CHUNK_URLS/.test(code)) {\n const preloadLinks = document.querySelectorAll(\n `link[rel=\"preload\"][href=\"${new URL(url).pathname}\"]`,\n );\n preloadLinks.forEach((preloadLink) => preloadLink.remove());\n return;\n }\n\n const self = globalThis as GlobalScope;\n const { globalKey } = scope;\n\n // replace global variables with scope-specific ones to prevent collisions\n // between multiple remote component bundles\n const transformedCode = code\n .replace(\n /globalThis\\[\\s*[\"']TURBOPACK[\"']\\s*\\]/g,\n `globalThis[\"TURBOPACK_${globalKey}\"]`,\n )\n .replace(\n /self\\[\\s*[\"']TURBOPACK[\"']\\s*\\]/g,\n `self[\"TURBOPACK_${globalKey}\"]`,\n )\n .replace(/globalThis\\.TURBOPACK/g, `globalThis.TURBOPACK_${globalKey}`)\n .replace(/self\\.TURBOPACK(?!_)/g, `self.TURBOPACK_${globalKey}`)\n .replace(\n /TURBOPACK_WORKER_LOCATION/g,\n `TURBOPACK_WORKER_LOCATION_${globalKey}`,\n )\n .replace(\n /TURBOPACK_NEXT_CHUNK_URLS/g,\n `TURBOPACK_NEXT_CHUNK_URLS_${globalKey}`,\n )\n .replace(/TURBOPACK_CHUNK_LISTS/g, `TURBOPACK_CHUNK_LISTS_${globalKey}`)\n .replace(\n /TURBOPACK_CHUNK_UPDATE_LISTENERS/g,\n `TURBOPACK_CHUNK_UPDATE_LISTENERS_${globalKey}`,\n )\n .replace(/__next_require__/g, `__${globalKey}_next_require__`)\n .replace(\n /\\/\\/# sourceMappingURL=(?<name>.+)(?<optional>\\._)?\\.js\\.map/g,\n `//# sourceMappingURL=${new URL('.', new URL(url, scope.url)).href}$1$2.js.map`,\n );\n\n // Initialize TURBOPACK bundle as a real Array with a push interceptor.\n // Must be a true Array instance so Next.js 15.x turbopack runtimes whose\n // module-system IIFE guards with `Array.isArray(globalThis.TURBOPACK)`\n // don't bail out after we rewrite the global name.\n //\n // The interceptor captures module entries into scope.turbopackModules —\n // a flat array we control. We use Object.defineProperty to intercept\n // when the turbopack runtime replaces the global with a deferred-loading\n // dispatcher (canary builds), wrapping the replacement's push too.\n //\n // The scope is reused across loads of different components from the same\n // remote (see setupRemoteScope), so subsequent loads accumulate into\n // the same turbopackModules array. Chunk cache deduplication means\n // handleTurbopackChunk only runs once per unique chunk URL — all captured\n // modules remain available for any component that needs them.\n if (!self[`TURBOPACK_${globalKey}`]) {\n const wrapPush = <T extends { push?: (...args: unknown[]) => unknown }>(\n target: T,\n ): T => {\n const originalPush = target.push;\n if (typeof originalPush !== 'function') return target;\n target.push = (...items: unknown[]) => {\n for (const item of items) {\n if (Array.isArray(item)) {\n for (const entry of item) {\n scope.turbopackModules.push(entry);\n }\n } else {\n scope.turbopackModules.push(item);\n }\n }\n return originalPush.apply(target, items);\n };\n return target;\n };\n\n const globalProp = `TURBOPACK_${globalKey}`;\n let currentValue: unknown = wrapPush([] as unknown[]);\n Object.defineProperty(self, globalProp, {\n get() {\n return currentValue;\n },\n set(newValue: unknown) {\n // When the turbopack runtime replaces the array with a dispatcher,\n // wrap the new object's push so we keep capturing module entries.\n if (newValue && typeof newValue === 'object') {\n wrapPush(newValue as { push?: (...args: unknown[]) => unknown });\n }\n currentValue = newValue;\n },\n configurable: true,\n enumerable: true,\n });\n }\n\n // load the script dynamically using a Blob URL\n await new Promise<void>((scriptResolve, scriptReject) => {\n const blob = new Blob([transformedCode], {\n type: 'application/javascript; charset=UTF-8',\n });\n const scriptUrl = URL.createObjectURL(blob);\n const script = document.createElement('script');\n script.setAttribute('data-turbopack-src', url);\n script.src = scriptUrl;\n script.async = true;\n script.onload = () => {\n URL.revokeObjectURL(scriptUrl);\n scriptResolve(undefined);\n script.remove();\n };\n script.onerror = () => {\n URL.revokeObjectURL(scriptUrl);\n scriptReject(\n new RemoteComponentsError(\n `Failed to load <script src=\"${script.src}\"> for Remote Component. Check the URL is correct.`,\n ),\n );\n script.remove();\n };\n document.head.appendChild(script);\n });\n\n // process any additional chunks that were registered during script execution\n // These CHUNK_LIST chunks load directly via scope — no global dispatch needed.\n const chunkLists = self[`TURBOPACK_${globalKey}_CHUNK_LISTS`] as\n | { chunks: string[] }[]\n | undefined;\n const loadChunkPromises: (Promise<unknown> | undefined)[] = [];\n while (chunkLists?.length) {\n const { chunks } = chunkLists.shift() ?? { chunks: [] };\n if (chunks.length > 0) {\n for (const id of chunks) {\n const baseUrl = url.slice(0, url.indexOf('/_next'));\n const chunkLoadResult = loadChunkWithScope(\n scope,\n formatRemoteId(scope, `${baseUrl}/_next/${id}`),\n );\n if (chunkLoadResult) {\n loadChunkPromises.push(chunkLoadResult);\n }\n }\n }\n }\n if (loadChunkPromises.length > 0) {\n await Promise.all(loadChunkPromises);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAgC;AAChC,uBAA6B;AAC7B,sBAAsC;AAEtC,mCAA6B;AAC7B,mBAGO;AACP,oB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,aAAO,OAAO;AAAA,IAChB;AACA,WAAO,UAAU,MAAM;AACrB,UAAI,gBAAgB,SAAS;AAC7B;AAAA,QACE,IAAI;AAAA,UACF,+BAA+B,OAAO;AAAA,QACxC;AAAA,MACF;AACA,aAAO,OAAO;AAAA,IAChB;AACA,aAAS,KAAK,YAAY,MAAM;AAAA,EAClC,CAAC;AAID,QAAM,aAAa,KAAK,aAAa,uBAAuB;AAG5D,QAAM,oBAAsD,CAAC;AAC7D,SAAO,YAAY,QAAQ;AACzB,UAAM,EAAE,OAAO,IAAI,WAAW,MAAM,KAAK,EAAE,QAAQ,CAAC,EAAE;AACtD,QAAI,OAAO,SAAS,GAAG;AACrB,iBAAW,MAAM,QAAQ;AACvB,cAAM,UAAU,IAAI,MAAM,GAAG,IAAI,QAAQ,QAAQ,CAAC;AAClD,cAAM,kBAAkB;AAAA,UACtB;AAAA,cACA,oCAAe,OAAO,GAAG,iBAAiB,IAAI;AAAA,QAChD;AACA,YAAI,iBAAiB;AACnB,4BAAkB,KAAK,eAAe;AAAA,QACxC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,MAAI,kBAAkB,SAAS,GAAG;AAChC,UAAM,QAAQ,IAAI,iBAAiB;AAAA,EACrC;AACF;","names":["import_patterns"]}
1
+ {"version":3,"sources":["../../../../src/runtime/turbopack/chunk-loader.ts"],"sourcesContent":["import { RUNTIME_WEBPACK } from '#internal/runtime/constants';\nimport { getNamespace } from '#internal/runtime/namespace';\nimport { collapseDoubleSlashes } from '#internal/runtime/patterns';\nimport type { GlobalScope } from '#internal/runtime/types';\nimport { isProxiedUrl } from '#internal/runtime/url/protected-rc-fallback';\nimport {\n failedProxiedAssetError,\n RemoteComponentsError,\n} from '#internal/utils/error';\nimport {\n logDebug,\n logWarn,\n warnCrossOriginFetchError,\n} from '#internal/utils/logger';\nimport { TURBOPACK_GLOBAL_RE } from './patterns';\nimport {\n formatRemoteId,\n getScope,\n parseRemoteId,\n type RemoteScope,\n} from './remote-scope';\n\n/**\n * Loads a chunk using a specific scope. All state (base URL, proxy callback,\n * TURBOPACK global key) comes from the scope — no global lookups needed.\n *\n * This is the primary chunk loader called directly from:\n * - setupRemoteScope (initial chunks)\n * - TurbopackContext.l (module-level chunk loading)\n * - handleTurbopackChunk (CHUNK_LIST additional chunks)\n *\n * The global chunk dedup cache is keyed by absolute URL, so different origins\n * naturally get separate cache entries even when sharing a bundle name.\n */\nexport function loadChunkWithScope(\n scope: RemoteScope,\n chunkId: string,\n): Promise<unknown> | undefined {\n logDebug(\n 'ChunkLoader',\n `loadChunkWithScope: \"${chunkId}\" (scope: \"${scope.scopedName}\")`,\n );\n const self = globalThis as GlobalScope;\n const ns = getNamespace();\n\n const { bundle, path, prefix } = parseRemoteId(chunkId);\n\n // Skip webpack runtime chunks\n const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? 'default']\n ? self.__remote_webpack_require__[bundle ?? 'default']?.type || 'webpack'\n : scope.runtime;\n if (remoteRuntime === RUNTIME_WEBPACK) {\n return Promise.resolve(undefined);\n }\n\n const rawPath = path ? collapseDoubleSlashes(`${prefix}${path}`) : '/';\n const url = new URL(rawPath, scope.url).href;\n\n if (url.endsWith('.css')) {\n return;\n }\n\n if (ns.chunkCache[url]) {\n logDebug('ChunkLoader', `Cache hit for \"${chunkId}\" (url=\"${url}\")`);\n return ns.chunkCache[url];\n }\n\n const resolvedUrl = scope.resolveClientUrl?.(url) ?? url;\n if (resolvedUrl !== url) {\n logDebug('ChunkLoader', `Proxied chunk URL: \"${url}\" → \"${resolvedUrl}\"`);\n }\n\n ns.chunkCache[url] = new Promise((resolve, reject) => {\n fetch(resolvedUrl)\n .then((res) => res.text())\n .then((code) => {\n // Worker chunks reference self.TURBOPACK_NEXT_CHUNK_URLS and must be\n // skipped before Turbopack detection — they are not loadable as scripts.\n // Check this first so the detection below doesn't need to account for it.\n if (/importScripts\\(\\.\\.\\.self\\.TURBOPACK_NEXT_CHUNK_URLS/.test(code)) {\n const preloadLinks = document.querySelectorAll(\n `link[rel=\"preload\"][href=\"${new URL(url).pathname}\"]`,\n );\n preloadLinks.forEach((preloadLink) => preloadLink.remove());\n return;\n }\n\n const hasTurbopackLegacyGlobal = TURBOPACK_GLOBAL_RE.test(code);\n // When chunkLoadingGlobal is configured at build time, chunks use the\n // custom scoped name instead of the shared TURBOPACK global, so\n // TURBOPACK_GLOBAL_RE won't match — detect via the custom name instead.\n // The config sets \"TURBOPACK_remote_chunk_loading_global_<name>\" which\n // Next.js leaves unchanged (it only auto-prefixes values that don't\n // already start with \"TURBOPACK_\"). Chunks emit bracket notation:\n // globalThis[\"TURBOPACK_remote_chunk_loading_global_<name>\"].\n const customGlobalProp = `TURBOPACK_remote_chunk_loading_global_${scope.name}`;\n const hasCustomGlobal = code.includes(customGlobalProp);\n const isTurbopackChunk = hasTurbopackLegacyGlobal || hasCustomGlobal;\n if (isTurbopackChunk) {\n logDebug(\n 'ChunkLoader',\n hasCustomGlobal && !hasTurbopackLegacyGlobal\n ? `Chunk \"${url}\" uses build-time chunkLoadingGlobal \"${customGlobalProp}\" — skipping runtime TURBOPACK rename.`\n : `Chunk \"${url}\" uses legacy globalThis.TURBOPACK — applying runtime rename for scope \"${scope.scopedName}\".`,\n );\n return handleTurbopackChunk(\n code,\n scope,\n url,\n hasTurbopackLegacyGlobal,\n );\n }\n // Chunk doesn't contain Turbopack globals — nothing to process\n })\n .then(resolve)\n .catch((error) => {\n const isProxied = isProxiedUrl(resolvedUrl);\n if (isProxied) {\n reject(failedProxiedAssetError('chunk', url, resolvedUrl));\n } else {\n warnCrossOriginFetchError('ChunkLoader', url);\n reject(error);\n }\n });\n });\n\n return ns.chunkCache[url];\n}\n\n/**\n * Creates the global `__webpack_chunk_load__` dispatcher.\n * This is a thin wrapper called only by external code (React's RSC runtime).\n * It parses the chunkId, resolves the correct scope, and delegates to\n * `loadChunkWithScope`.\n */\nexport function createChunkDispatcher(): (\n chunkId: string,\n scriptBundle?: string,\n) => Promise<unknown> | undefined {\n return function __chunk_dispatcher__(chunkId: string, scriptBundle?: string) {\n logDebug('ChunkDispatcher', `Dispatching chunk: \"${chunkId}\"`);\n\n const { bundle } = parseRemoteId(chunkId);\n const bundleName = bundle || scriptBundle || 'default';\n\n // Works with both the scoped name (Next.js hosts with server-side\n // rewriting) and the plain bundle name (static/HTML hosts).\n const scope = getScope(bundleName);\n\n logDebug(\n 'ChunkDispatcher',\n `Scope resolution: bundle=\"${bundleName}\", scope=${scope?.scopedName ?? 'null'}`,\n );\n\n if (!scope) {\n logWarn('ChunkDispatcher', `No scope found for bundle \"${bundleName}\"`);\n return Promise.resolve(undefined);\n }\n\n return loadChunkWithScope(scope, chunkId);\n };\n}\n\n/**\n * Handles Turbopack chunk loading by transforming the chunk code to isolate\n * global variables per bundle and dynamically loading the transformed script.\n * Receives scope directly — no global state lookups needed.\n *\n * `renameTurbopackGlobal` is true when chunks use the shared\n * `globalThis.TURBOPACK` name and must be renamed at runtime. When\n * `chunkLoadingGlobal` is configured at build time, chunks already use a\n * unique scoped name so those renames are skipped — only the remaining\n * hardcoded globals (WORKER_LOCATION, NEXT_CHUNK_URLS, CHUNK_UPDATE_LISTENERS,\n * etc.) still need renaming.\n */\nasync function handleTurbopackChunk(\n code: string,\n scope: RemoteScope,\n url: string,\n renameTurbopackGlobal: boolean,\n): Promise<void> {\n const self = globalThis as GlobalScope;\n const { globalKey, name } = scope;\n\n // When chunkLoadingGlobal is configured at build time, chunks already use a\n // unique name — no runtime rename needed for those four patterns. Otherwise\n // the shared globalThis.TURBOPACK must be renamed here.\n // For new-style chunks the prop matches exactly what config sets:\n // \"TURBOPACK_remote_chunk_loading_global_<name>\".\n const globalProp = renameTurbopackGlobal\n ? `TURBOPACK_${globalKey}`\n : `TURBOPACK_remote_chunk_loading_global_${name}`;\n\n let transformedCode = code;\n if (renameTurbopackGlobal) {\n // Legacy chunks use the shared globalThis.TURBOPACK name. Rename it and\n // the CHUNK_LISTS global (which Turbopack derives as \"{global}_CHUNK_LISTS\")\n // to per-scope names so multiple remotes don't collide.\n transformedCode = transformedCode\n .replace(\n /globalThis\\[\\s*[\"']TURBOPACK[\"']\\s*\\]/g,\n `globalThis[\"TURBOPACK_${globalKey}\"]`,\n )\n .replace(\n /self\\[\\s*[\"']TURBOPACK[\"']\\s*\\]/g,\n `self[\"TURBOPACK_${globalKey}\"]`,\n )\n .replace(/globalThis\\.TURBOPACK/g, `globalThis.TURBOPACK_${globalKey}`)\n .replace(/self\\.TURBOPACK(?!_)/g, `self.TURBOPACK_${globalKey}`)\n .replace(/TURBOPACK_CHUNK_LISTS/g, `TURBOPACK_${globalKey}_CHUNK_LISTS`);\n }\n // These globals are hardcoded in the Turbopack runtime JS (not derived from\n // chunkLoadingGlobal) so they need renaming for both legacy and new-style chunks.\n transformedCode = transformedCode\n .replace(\n /TURBOPACK_WORKER_LOCATION/g,\n `TURBOPACK_WORKER_LOCATION_${globalKey}`,\n )\n .replace(\n /TURBOPACK_NEXT_CHUNK_URLS/g,\n `TURBOPACK_NEXT_CHUNK_URLS_${globalKey}`,\n )\n .replace(\n /TURBOPACK_CHUNK_UPDATE_LISTENERS/g,\n `TURBOPACK_CHUNK_UPDATE_LISTENERS_${globalKey}`,\n )\n .replace(/__next_require__/g, `__${globalKey}_next_require__`)\n .replace(\n /\\/\\/# sourceMappingURL=(?<name>.+)(?<optional>\\._)?\\.js\\.map/g,\n `//# sourceMappingURL=${new URL('.', new URL(url, scope.url)).href}$1$2.js.map`,\n );\n\n // Initialize TURBOPACK bundle as a real Array with a push interceptor.\n // Must be a true Array instance so Next.js 15.x turbopack runtimes whose\n // module-system IIFE guards with `Array.isArray(globalThis.TURBOPACK)`\n // don't bail out after we rewrite the global name.\n //\n // The interceptor captures module entries into scope.turbopackModules —\n // a flat array we control. We use Object.defineProperty to intercept\n // when the turbopack runtime replaces the global with a deferred-loading\n // dispatcher (canary builds), wrapping the replacement's push too.\n //\n // The scope is reused across loads of different components from the same\n // remote (see setupRemoteScope), so subsequent loads accumulate into\n // the same turbopackModules array. Chunk cache deduplication means\n // handleTurbopackChunk only runs once per unique chunk URL — all captured\n // modules remain available for any component that needs them.\n if (!self[globalProp]) {\n const wrapPush = <T extends { push?: (...args: unknown[]) => unknown }>(\n target: T,\n ): T => {\n const originalPush = target.push;\n if (typeof originalPush !== 'function') return target;\n target.push = (...items: unknown[]) => {\n for (const item of items) {\n if (Array.isArray(item)) {\n for (const entry of item) {\n scope.turbopackModules.push(entry);\n }\n } else {\n scope.turbopackModules.push(item);\n }\n }\n return originalPush.apply(target, items);\n };\n return target;\n };\n\n let currentValue: unknown = wrapPush([] as unknown[]);\n Object.defineProperty(self, globalProp, {\n get() {\n return currentValue;\n },\n set(newValue: unknown) {\n // When the turbopack runtime replaces the array with a dispatcher,\n // wrap the new object's push so we keep capturing module entries.\n if (newValue && typeof newValue === 'object') {\n wrapPush(newValue as { push?: (...args: unknown[]) => unknown });\n }\n currentValue = newValue;\n },\n configurable: true,\n enumerable: true,\n });\n }\n\n // load the script dynamically using a Blob URL\n await new Promise<void>((scriptResolve, scriptReject) => {\n const blob = new Blob([transformedCode], {\n type: 'application/javascript; charset=UTF-8',\n });\n const scriptUrl = URL.createObjectURL(blob);\n const script = document.createElement('script');\n script.setAttribute('data-turbopack-src', url);\n script.src = scriptUrl;\n script.async = true;\n script.onload = () => {\n URL.revokeObjectURL(scriptUrl);\n scriptResolve(undefined);\n script.remove();\n };\n script.onerror = () => {\n URL.revokeObjectURL(scriptUrl);\n scriptReject(\n new RemoteComponentsError(\n `Failed to load <script src=\"${script.src}\"> for Remote Component. Check the URL is correct.`,\n ),\n );\n script.remove();\n };\n document.head.appendChild(script);\n });\n\n // process any additional chunks that were registered during script execution\n // These CHUNK_LIST chunks load directly via scope — no global dispatch needed.\n // For new-style chunks the list global is \"${globalProp}_CHUNK_LISTS\"; for\n // legacy it was renamed to \"TURBOPACK_${globalKey}_CHUNK_LISTS\" by the\n // transform above. Both cases are covered by reading from \"${globalProp}_CHUNK_LISTS\".\n const chunkLists = self[`${globalProp}_CHUNK_LISTS`] as\n | { chunks: string[] }[]\n | undefined;\n const loadChunkPromises: (Promise<unknown> | undefined)[] = [];\n while (chunkLists?.length) {\n const { chunks } = chunkLists.shift() ?? { chunks: [] };\n if (chunks.length > 0) {\n for (const id of chunks) {\n const baseUrl = url.slice(0, url.indexOf('/_next'));\n const chunkLoadResult = loadChunkWithScope(\n scope,\n formatRemoteId(scope, `${baseUrl}/_next/${id}`),\n );\n if (chunkLoadResult) {\n loadChunkPromises.push(chunkLoadResult);\n }\n }\n }\n }\n if (loadChunkPromises.length > 0) {\n await Promise.all(loadChunkPromises);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAgC;AAChC,uBAA6B;AAC7B,sBAAsC;AAEtC,mCAA6B;AAC7B,mBAGO;AACP,oBAIO;AACP,IAAAA,mBAAoC;AACpC,0BAKO;AAcA,SAAS,mBACd,OACA,SAC8B;AAC9B;AAAA,IACE;AAAA,IACA,wBAAwB,qBAAqB,MAAM;AAAA,EACrD;AACA,QAAM,OAAO;AACb,QAAM,SAAK,+BAAa;AAExB,QAAM,EAAE,QAAQ,MAAM,OAAO,QAAI,mCAAc,OAAO;AAGtD,QAAM,gBAAgB,KAAK,6BAA6B,UAAU,SAAS,IACvE,KAAK,2BAA2B,UAAU,SAAS,GAAG,QAAQ,YAC9D,MAAM;AACV,MAAI,kBAAkB,kCAAiB;AACrC,WAAO,QAAQ,QAAQ,MAAS;AAAA,EAClC;AAEA,QAAM,UAAU,WAAO,uCAAsB,GAAG,SAAS,MAAM,IAAI;AACnE,QAAM,MAAM,IAAI,IAAI,SAAS,MAAM,GAAG,EAAE;AAExC,MAAI,IAAI,SAAS,MAAM,GAAG;AACxB;AAAA,EACF;AAEA,MAAI,GAAG,WAAW,GAAG,GAAG;AACtB,gCAAS,eAAe,kBAAkB,kBAAkB,OAAO;AACnE,WAAO,GAAG,WAAW,GAAG;AAAA,EAC1B;AAEA,QA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