remote-components 0.3.5 → 0.3.7

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 (142) hide show
  1. package/dist/app-63L5THIQ.js +12 -0
  2. package/dist/app-63L5THIQ.js.map +1 -0
  3. package/dist/app-A5QE7XRH.cjs +12 -0
  4. package/dist/app-A5QE7XRH.cjs.map +1 -0
  5. package/dist/chunk-52BJ7VFA.js +202 -0
  6. package/dist/chunk-52BJ7VFA.js.map +1 -0
  7. package/dist/chunk-AWWWK2ZY.cjs +670 -0
  8. package/dist/chunk-AWWWK2ZY.cjs.map +1 -0
  9. package/dist/chunk-CTUJSWCM.js +215 -0
  10. package/dist/chunk-CTUJSWCM.js.map +1 -0
  11. package/dist/chunk-D5GNZB6O.js +61 -0
  12. package/dist/chunk-D5GNZB6O.js.map +1 -0
  13. package/dist/chunk-ENYGL5CO.js +11 -0
  14. package/dist/chunk-ENYGL5CO.js.map +1 -0
  15. package/dist/chunk-GAXJTFBV.js +20 -0
  16. package/dist/chunk-GAXJTFBV.js.map +1 -0
  17. package/dist/chunk-GBFUPMMI.js +670 -0
  18. package/dist/chunk-GBFUPMMI.js.map +1 -0
  19. package/dist/chunk-I47KE3EC.cjs +703 -0
  20. package/dist/chunk-I47KE3EC.cjs.map +1 -0
  21. package/dist/chunk-KE7QPAQ4.cjs +21 -0
  22. package/dist/chunk-KE7QPAQ4.cjs.map +1 -0
  23. package/dist/chunk-LCXO7BUY.cjs +57 -0
  24. package/dist/chunk-LCXO7BUY.cjs.map +1 -0
  25. package/dist/chunk-LQ7VQ74E.js +155 -0
  26. package/dist/chunk-LQ7VQ74E.js.map +1 -0
  27. package/dist/chunk-N5VQR2PW.cjs +215 -0
  28. package/dist/chunk-N5VQR2PW.cjs.map +1 -0
  29. package/dist/chunk-NZAB7REE.js +703 -0
  30. package/dist/chunk-NZAB7REE.js.map +1 -0
  31. package/dist/chunk-QKB74MLO.js +709 -0
  32. package/dist/chunk-QKB74MLO.js.map +1 -0
  33. package/dist/chunk-RJW3EZJP.cjs +709 -0
  34. package/dist/chunk-RJW3EZJP.cjs.map +1 -0
  35. package/dist/chunk-RUWR74XQ.cjs +152 -0
  36. package/dist/chunk-RUWR74XQ.cjs.map +1 -0
  37. package/dist/chunk-S2A4TFLS.js +152 -0
  38. package/dist/chunk-S2A4TFLS.js.map +1 -0
  39. package/dist/chunk-SHFJ5OQA.cjs +11 -0
  40. package/dist/chunk-SHFJ5OQA.cjs.map +1 -0
  41. package/dist/chunk-SJM7AAGU.js +358 -0
  42. package/dist/chunk-SJM7AAGU.js.map +1 -0
  43. package/dist/chunk-SZFCBE54.js +57 -0
  44. package/dist/chunk-SZFCBE54.js.map +1 -0
  45. package/dist/chunk-T64P7BAG.cjs +202 -0
  46. package/dist/chunk-T64P7BAG.cjs.map +1 -0
  47. package/dist/chunk-TCFLEBQM.cjs +20 -0
  48. package/dist/chunk-TCFLEBQM.cjs.map +1 -0
  49. package/dist/chunk-TZT7DLO5.cjs +155 -0
  50. package/dist/chunk-TZT7DLO5.cjs.map +1 -0
  51. package/dist/chunk-X6W464D6.cjs +358 -0
  52. package/dist/chunk-X6W464D6.cjs.map +1 -0
  53. package/dist/chunk-X6YKUJKH.js +21 -0
  54. package/dist/chunk-X6YKUJKH.js.map +1 -0
  55. package/dist/chunk-Z2SLBFQL.cjs +61 -0
  56. package/dist/chunk-Z2SLBFQL.cjs.map +1 -0
  57. package/dist/config/nextjs.cjs +74 -355
  58. package/dist/config/nextjs.cjs.map +1 -1
  59. package/dist/config/nextjs.js +25 -271
  60. package/dist/config/nextjs.js.map +1 -1
  61. package/dist/config/webpack.cjs +12 -240
  62. package/dist/config/webpack.cjs.map +1 -1
  63. package/dist/config/webpack.js +6 -207
  64. package/dist/config/webpack.js.map +1 -1
  65. package/dist/host/html.cjs +128 -2494
  66. package/dist/host/html.cjs.map +1 -1
  67. package/dist/host/html.js +45 -2382
  68. package/dist/host/html.js.map +1 -1
  69. package/dist/host/nextjs/app/client-only.cjs +53 -2939
  70. package/dist/host/nextjs/app/client-only.cjs.map +1 -1
  71. package/dist/host/nextjs/app/client-only.js +31 -2894
  72. package/dist/host/nextjs/app/client-only.js.map +1 -1
  73. package/dist/host/proxy/client.cjs +8 -38
  74. package/dist/host/proxy/client.cjs.map +1 -1
  75. package/dist/host/proxy/client.js +4 -7
  76. package/dist/host/proxy/client.js.map +1 -1
  77. package/dist/host/proxy.cjs +19 -56
  78. package/dist/host/proxy.cjs.map +1 -1
  79. package/dist/host/proxy.js +8 -20
  80. package/dist/host/proxy.js.map +1 -1
  81. package/dist/host/react.cjs +17 -2870
  82. package/dist/host/react.cjs.map +1 -1
  83. package/dist/host/react.js +13 -2837
  84. package/dist/host/react.js.map +1 -1
  85. package/dist/internal/config/webpack/next-client-pages-loader.cjs +27 -15
  86. package/dist/internal/config/webpack/next-client-pages-loader.cjs.map +1 -1
  87. package/dist/internal/config/webpack/next-client-pages-loader.d.ts +3 -5
  88. package/dist/internal/config/webpack/next-client-pages-loader.js +27 -15
  89. package/dist/internal/config/webpack/next-client-pages-loader.js.map +1 -1
  90. package/dist/internal/host/nextjs/app-client.d.ts +1 -1
  91. package/dist/internal/host/react/context.d.ts +2 -2
  92. package/dist/internal/host/server/fetch-remote-component.cjs +1 -18
  93. package/dist/internal/host/server/fetch-remote-component.cjs.map +1 -1
  94. package/dist/internal/host/server/fetch-remote-component.js +1 -18
  95. package/dist/internal/host/server/fetch-remote-component.js.map +1 -1
  96. package/dist/internal/host/shared/pipeline.d.ts +2 -2
  97. package/dist/internal/runtime/loaders/component-loader.cjs +5 -2
  98. package/dist/internal/runtime/loaders/component-loader.cjs.map +1 -1
  99. package/dist/internal/runtime/loaders/component-loader.d.ts +2 -2
  100. package/dist/internal/runtime/loaders/component-loader.js +5 -2
  101. package/dist/internal/runtime/loaders/component-loader.js.map +1 -1
  102. package/dist/internal/runtime/loaders/static-loader.d.ts +2 -1
  103. package/dist/internal/runtime/namespace.cjs +1 -0
  104. package/dist/internal/runtime/namespace.cjs.map +1 -1
  105. package/dist/internal/runtime/namespace.d.ts +2 -1
  106. package/dist/internal/runtime/namespace.js +1 -0
  107. package/dist/internal/runtime/namespace.js.map +1 -1
  108. package/dist/internal/runtime/turbopack/remote-scope.cjs +1 -5
  109. package/dist/internal/runtime/turbopack/remote-scope.cjs.map +1 -1
  110. package/dist/internal/runtime/turbopack/remote-scope.js +1 -5
  111. package/dist/internal/runtime/turbopack/remote-scope.js.map +1 -1
  112. package/dist/internal/runtime/types.d.ts +2 -1
  113. package/dist/internal/utils.cjs +1 -1
  114. package/dist/internal/utils.cjs.map +1 -1
  115. package/dist/internal/utils.d.ts +5 -5
  116. package/dist/internal/utils.js +1 -1
  117. package/dist/internal/utils.js.map +1 -1
  118. package/dist/remote/html.cjs +15 -314
  119. package/dist/remote/html.cjs.map +1 -1
  120. package/dist/remote/html.js +7 -305
  121. package/dist/remote/html.js.map +1 -1
  122. package/dist/remote/middleware.cjs +16 -41
  123. package/dist/remote/middleware.cjs.map +1 -1
  124. package/dist/script-D5AD7HLV.cjs +26 -0
  125. package/dist/script-D5AD7HLV.cjs.map +1 -0
  126. package/dist/script-VPOI7ARP.js +26 -0
  127. package/dist/script-VPOI7ARP.js.map +1 -0
  128. package/dist/{server-handoff-ce13bebc.d.ts → server-handoff-8c89b856.d.ts} +2 -2
  129. package/dist/static-loader-OHSAUD62.js +11 -0
  130. package/dist/static-loader-OHSAUD62.js.map +1 -0
  131. package/dist/static-loader-UDIXK5MV.cjs +11 -0
  132. package/dist/static-loader-UDIXK5MV.cjs.map +1 -0
  133. package/dist/turbopack-5LW6V6IT.js +55 -0
  134. package/dist/turbopack-5LW6V6IT.js.map +1 -0
  135. package/dist/turbopack-KRKECGY2.cjs +55 -0
  136. package/dist/turbopack-KRKECGY2.cjs.map +1 -0
  137. package/dist/{types-59251814.d.ts → types-8b0edd78.d.ts} +7 -0
  138. package/dist/webpack-NPZNXRNL.js +92 -0
  139. package/dist/webpack-NPZNXRNL.js.map +1 -0
  140. package/dist/webpack-TTZDARNY.cjs +92 -0
  141. package/dist/webpack-TTZDARNY.cjs.map +1 -0
  142. package/package.json +9 -2
@@ -1,98 +1,33 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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; }
29
2
 
30
- // src/config/nextjs/index.ts
31
- var nextjs_exports = {};
32
- __export(nextjs_exports, {
33
- withRemoteComponentsConfig: () => withRemoteComponentsConfig
34
- });
35
- module.exports = __toCommonJS(nextjs_exports);
36
- var import_node_fs2 = require("fs");
37
- var import_node_path3 = require("path");
38
- var import_enhanced_resolve = __toESM(require("enhanced-resolve"), 1);
39
- var import_find_up2 = require("find-up");
40
- var import_config_schema = require("next/dist/server/config-schema.js");
41
- var import_tsconfig_paths_webpack_plugin = __toESM(require("tsconfig-paths-webpack-plugin"), 1);
42
3
 
43
- // src/utils/error.ts
44
- var RemoteComponentsError = class extends Error {
45
- code = "REMOTE_COMPONENTS_ERROR";
46
- constructor(message, options) {
47
- super(message, options);
48
- this.name = "RemoteComponentsError";
49
- }
50
- };
4
+ var _chunkX6W464D6cjs = require('../chunk-X6W464D6.cjs');
5
+ require('../chunk-Z2SLBFQL.cjs');
51
6
 
52
- // src/utils/logger.ts
53
- var PREFIX = "remote-components";
54
- var DEBUG = typeof window !== "undefined" && localStorage.getItem("RC_DEBUG") === "true" || typeof process !== "undefined" && process.env.RC_DEBUG === "true";
55
- function logDebug(location2, message) {
56
- if (DEBUG) {
57
- console.debug(`[${PREFIX}:${location2}]: ${message}`);
58
- }
59
- }
60
- function logWarn(location2, message) {
61
- console.warn(`[${PREFIX}:${location2}]: ${message}`);
62
- }
63
- function logError(location2, message, cause) {
64
- console.error(
65
- new RemoteComponentsError(`[${PREFIX}:${location2}]: ${message}`, {
66
- cause
67
- })
68
- );
69
- }
70
7
 
71
- // src/host/shared/polyfill.tsx
72
- var import_jsx_runtime = require("react/jsx-runtime");
73
8
 
74
- // src/host/shared/shared-module-resolver.ts
75
- var CORE_REACT_SHARED_KEYS = [
76
- "react",
77
- "react/jsx-dev-runtime",
78
- "react/jsx-runtime",
79
- "react-dom",
80
- "react-dom/client"
81
- ];
82
- var CORE_REACT_PATH_MAP = {
83
- react: "/react/index.js",
84
- "react/jsx-dev-runtime": "/react/jsx-dev-runtime.js",
85
- "react/jsx-runtime": "/react/jsx-runtime.js",
86
- "react-dom": "/react-dom/index.js",
87
- "react-dom/client": "/react-dom/client.js"
88
- };
89
- var VENDOR_SHARED = Object.fromEntries(
90
- Object.entries(CORE_REACT_PATH_MAP).filter(([key]) => key !== "react-dom/client").map(([key, path]) => [key, `'${path}'`])
91
- );
9
+
10
+ var _chunkRUWR74XQcjs = require('../chunk-RUWR74XQ.cjs');
11
+
12
+
13
+
14
+
15
+
16
+ var _chunkN5VQR2PWcjs = require('../chunk-N5VQR2PW.cjs');
17
+ require('../chunk-KE7QPAQ4.cjs');
18
+ require('../chunk-SHFJ5OQA.cjs');
19
+
20
+ // src/config/nextjs/index.ts
21
+ var _fs = require('fs');
22
+ var _path = require('path');
23
+ var _enhancedresolve = require('enhanced-resolve'); var _enhancedresolve2 = _interopRequireDefault(_enhancedresolve);
24
+ var _findup = require('find-up');
25
+ var _configschemajs = require('next/dist/server/config-schema.js');
26
+ var _tsconfigpathswebpackplugin = require('tsconfig-paths-webpack-plugin'); var _tsconfigpathswebpackplugin2 = _interopRequireDefault(_tsconfigpathswebpackplugin);
92
27
 
93
28
  // src/utils/project-id.ts
94
- var import_node_fs = require("fs");
95
- var import_find_up = require("find-up");
29
+
30
+
96
31
 
97
32
  // src/utils/project-id-env.ts
98
33
  function resolveProjectIdFromEnv() {
@@ -105,229 +40,19 @@ function resolveProjectId(packageName) {
105
40
  if (fromEnv)
106
41
  return fromEnv;
107
42
  try {
108
- const projectPath = (0, import_find_up.findUpSync)(".vercel/project.json", {
43
+ const projectPath = _findup.findUpSync.call(void 0, ".vercel/project.json", {
109
44
  cwd: process.cwd()
110
45
  });
111
46
  if (projectPath) {
112
- return JSON.parse((0, import_node_fs.readFileSync)(projectPath, "utf8")).projectId;
47
+ return JSON.parse(_fs.readFileSync.call(void 0, projectPath, "utf8")).projectId;
113
48
  }
114
- } catch {
49
+ } catch (e) {
115
50
  }
116
51
  return packageName;
117
52
  }
118
53
 
119
54
  // src/config/webpack/nextjs.ts
120
- var import_node_path2 = require("path");
121
-
122
- // src/config/webpack/plugins/conditional-exec.ts
123
- var ConditionalExecPlugin = class {
124
- appName;
125
- constructor(appName) {
126
- this.appName = appName;
127
- }
128
- apply(compiler) {
129
- const { Compilation, sources } = compiler.webpack;
130
- compiler.hooks.thisCompilation.tap(
131
- "ConditionalExecPlugin",
132
- (compilation) => {
133
- compilation.hooks.processAssets.tap(
134
- {
135
- name: "ConditionalExecPlugin",
136
- stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
137
- },
138
- (assets) => {
139
- for (const [name, source] of Object.entries(assets)) {
140
- if (name.endsWith(".js")) {
141
- const patchedSource = source.source().toString().replace(
142
- `var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))`,
143
- `var __webpack_exec__ = (moduleId) => { if (globalThis.__DISABLE_WEBPACK_EXEC__ && globalThis.__DISABLE_WEBPACK_EXEC__["${this.appName}"]) return; return __webpack_require__(__webpack_require__.s = moduleId); }`
144
- );
145
- compilation.updateAsset(
146
- name,
147
- new sources.RawSource(patchedSource)
148
- );
149
- }
150
- }
151
- }
152
- );
153
- }
154
- );
155
- }
156
- };
157
55
 
158
- // src/config/webpack/plugins/module-id-embed.ts
159
- var import_node_path = require("path");
160
-
161
- // src/config/webpack/plugins/module-id-embed-runtime-module.ts
162
- function createModuleIdEmbedRuntimeModule(webpack) {
163
- return class ModuleIdEmbedRuntimeModule extends webpack.RuntimeModule {
164
- appName;
165
- moduleMap;
166
- constructor(appName, moduleMap) {
167
- super("remote-webpack-module-id-embed");
168
- this.appName = appName;
169
- this.moduleMap = moduleMap;
170
- }
171
- generate() {
172
- return `globalThis.__remote_webpack_module_map__ = globalThis.__remote_webpack_module_map__ || {}; globalThis.__remote_webpack_module_map__["${this.appName}"] = ${JSON.stringify(this.moduleMap)};`;
173
- }
174
- };
175
- }
176
-
177
- // src/config/webpack/plugins/module-id-embed.ts
178
- var cwd = process.cwd();
179
- var ModuleIdEmbedPlugin = class {
180
- appName;
181
- includeAllModules;
182
- isServer;
183
- constructor(appName, options) {
184
- this.appName = appName;
185
- this.includeAllModules = options?.includeAllModules ?? false;
186
- this.isServer = options?.isServer ?? false;
187
- }
188
- apply(compiler) {
189
- const ModuleIdEmbedRuntimeModule = createModuleIdEmbedRuntimeModule(
190
- compiler.webpack
191
- );
192
- compiler.hooks.thisCompilation.tap("ModuleIdEmbedPlugin", (compilation) => {
193
- const moduleMap = {};
194
- compilation.hooks.runtimeRequirementInTree.for(compiler.webpack.RuntimeGlobals.require).tap("ModuleIdEmbedPlugin", (chunk, set) => {
195
- for (const mod of compilation.modules) {
196
- const id = compilation.chunkGraph.getModuleId(mod);
197
- if (id && (this.includeAllModules || mod.layer?.endsWith("browser") || !this.isServer && mod.layer === null)) {
198
- const normalModule = mod;
199
- if (normalModule.resource || normalModule.request) {
200
- moduleMap[(0, import_node_path.relative)(cwd, normalModule.resource || normalModule.request)] = id;
201
- }
202
- }
203
- }
204
- if (Object.keys(moduleMap).length > 0) {
205
- compilation.addRuntimeModule(
206
- chunk,
207
- new ModuleIdEmbedRuntimeModule(
208
- this.appName,
209
- moduleMap
210
- )
211
- );
212
- set.add(compiler.webpack.RuntimeGlobals.require);
213
- }
214
- });
215
- });
216
- }
217
- };
218
-
219
- // src/config/webpack/plugins/patch-require.ts
220
- var PatchRequirePlugin = class {
221
- appName;
222
- constructor(appName) {
223
- this.appName = appName;
224
- }
225
- apply(compiler) {
226
- const { sources } = compiler.webpack;
227
- compiler.hooks.thisCompilation.tap("PatchRequirePlugin", (compilation) => {
228
- compilation.mainTemplate.hooks.requireExtensions.tap(
229
- "PatchRequirePlugin",
230
- (source) => {
231
- return new sources.ConcatSource(
232
- source,
233
- `const __webpack_require_orig__ = __webpack_require__;
234
- const REMOTE_RE = /\\[(?<bundle>[^\\]]+)\\] (?<id>.*)/;
235
- __webpack_require__ = function __remote_webpack_require__(remoteId) {
236
- const match = REMOTE_RE.exec(remoteId);
237
- const bundle = match?.groups?.bundle;
238
- const id = match?.groups?.id;
239
- if (!(id && bundle)) {
240
- return __webpack_require_orig__(remoteId);
241
- }
242
- if (typeof self.__remote_webpack_require__?.[bundle] !== 'function') {
243
- const error = new Error(\`Remote Components are not available in "\${bundle}". Did you forget to wrap the Next.js config with \\\`withRemoteComponentsConfig\\\` on both host and remote?\`);
244
- error.name = 'RemoteComponentsError';
245
- error.code = 'REMOTE_COMPONENTS_ERROR';
246
- throw error;
247
- }
248
- return self.__remote_webpack_require__[bundle](self.__remote_webpack_require__[bundle].type === 'turbopack' ? remoteId : id);
249
- };
250
- Object.assign(__webpack_require__, __webpack_require_orig__);
251
- const __webpack_require_l__ = __webpack_require__.l;
252
- __webpack_require__.l = function __remote_webpack_require_l__(url, done, key, chunkId) {
253
- const match = REMOTE_RE.exec(chunkId);
254
- const bundle = match?.groups?.bundle;
255
- const id = match?.groups?.id;
256
- if (!(id && bundle)) {
257
- // __remote_bundle_url__[appName] is the *host app's own* asset base URL
258
- // (set by the HTML host or setupWebpackRuntime). It is NOT a remote
259
- // bundle URL \u2014 it just ensures the host's own chunks resolve correctly
260
- // when the page is served from a CDN or different origin.
261
- return __webpack_require_l__(new URL(url, globalThis.__remote_bundle_url__?.["${this.appName}"] ?? location.origin).href, done, key, chunkId);
262
- }
263
- return done();
264
- };
265
- const __webpack_require_o__ = __webpack_require__.o;
266
- __webpack_require__.o = function __remote_webpack_require_o__(installedChunks, chunkId) {
267
- const match = REMOTE_RE.exec(chunkId);
268
- const bundle = match?.groups?.bundle;
269
- const id = match?.groups?.id;
270
- if (!(id && bundle)) {
271
- return __webpack_require_o__(installedChunks, chunkId);
272
- }
273
- return installedChunks[chunkId] = 0;
274
- };
275
- const __webpack_require_e__ = __webpack_require__.e;
276
- __webpack_require__.e = function __remote_webpack_require_e__(chunkId) {
277
- const match = REMOTE_RE.exec(chunkId);
278
- const bundle = match?.groups?.bundle;
279
- const id = match?.groups?.id;
280
- if (!(id && bundle)) {
281
- return __webpack_require_e__(chunkId);
282
- }
283
- return Promise.resolve([]);
284
- };`
285
- ).source().toString();
286
- }
287
- );
288
- });
289
- }
290
- };
291
-
292
- // src/config/webpack/plugins/remote-webpack-require-runtime-module.ts
293
- function createRemoteWebpackRequireRuntimeModule(webpack) {
294
- return class RemoteWebpackRequireRuntimeModule extends webpack.RuntimeModule {
295
- appName;
296
- constructor(appName) {
297
- super("remote-webpack-require");
298
- this.appName = appName;
299
- }
300
- generate() {
301
- return `globalThis.__remote_webpack_require__ = globalThis.__remote_webpack_require__ || {}; globalThis.__remote_webpack_require__["${this.appName}"] = __webpack_require__;`;
302
- }
303
- };
304
- }
305
-
306
- // src/config/webpack/plugins/remote-webpack-require.ts
307
- var RemoteWebpackRequirePlugin = class {
308
- appName;
309
- constructor(appName) {
310
- this.appName = appName;
311
- }
312
- apply(compiler) {
313
- const RemoteWebpackRequireRuntimeModule = createRemoteWebpackRequireRuntimeModule(compiler.webpack);
314
- compiler.hooks.thisCompilation.tap(
315
- "RemoteWebpackRequirePlugin",
316
- (compilation) => {
317
- compilation.hooks.runtimeRequirementInTree.for("__webpack_require__").tap("RemoteWebpackRequirePlugin", (chunk) => {
318
- compilation.addRuntimeModule(
319
- chunk,
320
- new RemoteWebpackRequireRuntimeModule(
321
- this.appName
322
- )
323
- );
324
- });
325
- }
326
- );
327
- }
328
- };
329
-
330
- // src/config/webpack/nextjs.ts
331
56
  function transform(nextConfig, {
332
57
  app,
333
58
  alias = {},
@@ -336,12 +61,12 @@ function transform(nextConfig, {
336
61
  }) {
337
62
  const webpackConfig = nextConfig.webpack;
338
63
  nextConfig.webpack = (baseConfig, webpackContext) => {
339
- const config = typeof webpackConfig === "function" ? webpackConfig(baseConfig, webpackContext) ?? baseConfig : baseConfig;
64
+ const config = typeof webpackConfig === "function" ? _nullishCoalesce(webpackConfig(baseConfig, webpackContext), () => ( baseConfig)) : baseConfig;
340
65
  config.plugins.push(
341
- new RemoteWebpackRequirePlugin(app.name),
342
- new ModuleIdEmbedPlugin(app.name, { isServer: webpackContext.isServer }),
343
- new ConditionalExecPlugin(app.name),
344
- new PatchRequirePlugin(app.name)
66
+ new (0, _chunkN5VQR2PWcjs.RemoteWebpackRequirePlugin)(app.name),
67
+ new (0, _chunkN5VQR2PWcjs.ModuleIdEmbedPlugin)(app.name, { isServer: webpackContext.isServer }),
68
+ new (0, _chunkN5VQR2PWcjs.ConditionalExecPlugin)(app.name),
69
+ new (0, _chunkN5VQR2PWcjs.PatchRequirePlugin)(app.name)
345
70
  );
346
71
  if (!webpackContext.isServer) {
347
72
  config.output.chunkLoadingGlobal = `__remote_chunk_loading_global_${app.name}__`;
@@ -353,7 +78,7 @@ function transform(nextConfig, {
353
78
  ...Object.fromEntries(
354
79
  Object.entries(alias).map(([key, value]) => [
355
80
  key,
356
- (0, import_node_path2.join)(process.cwd(), value)
81
+ _path.join.call(void 0, process.cwd(), value)
357
82
  ])
358
83
  )
359
84
  }
@@ -367,56 +92,56 @@ function transform(nextConfig, {
367
92
  // src/config/nextjs/index.ts
368
93
  function getNextMajorVersion() {
369
94
  try {
370
- const nextPkgPath = (0, import_find_up2.findUpSync)("node_modules/next/package.json", {
95
+ const nextPkgPath = _findup.findUpSync.call(void 0, "node_modules/next/package.json", {
371
96
  cwd: process.cwd()
372
97
  });
373
98
  if (!nextPkgPath)
374
99
  return void 0;
375
- const { version } = JSON.parse((0, import_node_fs2.readFileSync)(nextPkgPath, "utf8"));
100
+ const { version } = JSON.parse(_fs.readFileSync.call(void 0, nextPkgPath, "utf8"));
376
101
  const major = version.split(".")[0];
377
102
  return major ? Number.parseInt(major, 10) : void 0;
378
- } catch {
103
+ } catch (e2) {
379
104
  return void 0;
380
105
  }
381
106
  }
382
107
  function hasPagesDirectory() {
383
- return (0, import_node_fs2.existsSync)((0, import_node_path3.join)(process.cwd(), "pages")) || (0, import_node_fs2.existsSync)((0, import_node_path3.join)(process.cwd(), "src/pages"));
108
+ return _fs.existsSync.call(void 0, _path.join.call(void 0, process.cwd(), "pages")) || _fs.existsSync.call(void 0, _path.join.call(void 0, process.cwd(), "src/pages"));
384
109
  }
385
110
  function readProjectPackageJson() {
386
- const defaults = { name: (0, import_node_path3.basename)(process.cwd()), type: "module" };
111
+ const defaults = { name: _path.basename.call(void 0, process.cwd()), type: "module" };
387
112
  try {
388
- const packageJsonPath = (0, import_find_up2.findUpSync)("package.json", {
113
+ const packageJsonPath = _findup.findUpSync.call(void 0, "package.json", {
389
114
  cwd: process.cwd()
390
115
  });
391
116
  if (packageJsonPath) {
392
117
  return {
393
118
  ...defaults,
394
- ...JSON.parse((0, import_node_fs2.readFileSync)(packageJsonPath, "utf8"))
119
+ ...JSON.parse(_fs.readFileSync.call(void 0, packageJsonPath, "utf8"))
395
120
  };
396
121
  }
397
- } catch {
122
+ } catch (e3) {
398
123
  }
399
124
  return defaults;
400
125
  }
401
126
  function withRemoteComponentsConfig(nextConfig, options) {
402
- const virtualRemoteComponentAppSharedRemote = (0, import_node_path3.join)(
127
+ const virtualRemoteComponentAppSharedRemote = _path.join.call(void 0,
403
128
  process.cwd(),
404
129
  ".remote-components/shared/app-remote.tsx"
405
130
  );
406
- const virtualRemoteComponentPagesSharedRemote = (0, import_node_path3.join)(
131
+ const virtualRemoteComponentPagesSharedRemote = _path.join.call(void 0,
407
132
  process.cwd(),
408
133
  ".remote-components/shared/pages-remote.tsx"
409
134
  );
410
- const virtualRemoteComponentAppSharedHost = (0, import_node_path3.join)(
135
+ const virtualRemoteComponentAppSharedHost = _path.join.call(void 0,
411
136
  process.cwd(),
412
137
  ".remote-components/shared/app-host.tsx"
413
138
  );
414
- const virtualRemoteComponentPagesSharedHost = (0, import_node_path3.join)(
139
+ const virtualRemoteComponentPagesSharedHost = _path.join.call(void 0,
415
140
  process.cwd(),
416
141
  ".remote-components/shared/pages-host.tsx"
417
142
  );
418
143
  const appShared = /* @__PURE__ */ new Set([
419
- ...CORE_REACT_SHARED_KEYS,
144
+ ..._chunkX6W464D6cjs.CORE_REACT_SHARED_KEYS,
420
145
  "next/navigation",
421
146
  "next/dist/client/components/navigation",
422
147
  "next/link",
@@ -427,25 +152,25 @@ function withRemoteComponentsConfig(nextConfig, options) {
427
152
  "next/script",
428
153
  "next/dist/client/script",
429
154
  "next/dist/build/polyfills/process",
430
- ...options?.shared ?? []
155
+ ..._nullishCoalesce(_optionalChain([options, 'optionalAccess', _ => _.shared]), () => ( []))
431
156
  ]);
432
157
  const pagesShared = /* @__PURE__ */ new Set([
433
- ...CORE_REACT_SHARED_KEYS,
158
+ ..._chunkX6W464D6cjs.CORE_REACT_SHARED_KEYS,
434
159
  "next/router",
435
160
  "next/link",
436
161
  "next/dist/shared/lib/image-loader",
437
162
  "next/script",
438
163
  "next/form",
439
- ...options?.shared ?? []
164
+ ..._nullishCoalesce(_optionalChain([options, 'optionalAccess', _2 => _2.shared]), () => ( []))
440
165
  ]);
441
- const vendorShared = { ...VENDOR_SHARED };
442
- const resolve = import_enhanced_resolve.default.create.sync({
166
+ const vendorShared = { ..._chunkX6W464D6cjs.VENDOR_SHARED };
167
+ const resolve = _enhancedresolve2.default.create.sync({
443
168
  conditionNames: ["browser", "import", "module", "require"],
444
- ...(0, import_node_fs2.existsSync)((0, import_node_path3.join)(process.cwd(), "tsconfig.json")) ? {
169
+ ..._fs.existsSync.call(void 0, _path.join.call(void 0, process.cwd(), "tsconfig.json")) ? {
445
170
  extensions: [".js", ".jsx", ".ts", ".tsx"],
446
171
  plugins: [
447
- new import_tsconfig_paths_webpack_plugin.default({
448
- configFile: (0, import_node_path3.join)(process.cwd(), "tsconfig.json")
172
+ new (0, _tsconfigpathswebpackplugin2.default)({
173
+ configFile: _path.join.call(void 0, process.cwd(), "tsconfig.json")
449
174
  })
450
175
  ]
451
176
  } : {}
@@ -457,19 +182,19 @@ function withRemoteComponentsConfig(nextConfig, options) {
457
182
  try {
458
183
  const resolved = resolve(process.cwd(), moduleName);
459
184
  if (resolved) {
460
- return (0, import_node_path3.relative)(process.cwd(), resolved).replace(
185
+ return _path.relative.call(void 0, process.cwd(), resolved).replace(
461
186
  /^(?<relative>\.\.\/)+/,
462
187
  ""
463
188
  );
464
189
  }
465
- } catch {
190
+ } catch (e4) {
466
191
  }
467
192
  };
468
193
  const generateSharedRemote = (sharedRemote) => `'use client';
469
194
  ${exportPre}${Array.from(sharedRemote).reduce((acc, curr) => {
470
195
  const path = resolveSharedPath(curr);
471
196
  acc.push(
472
- `[${vendorShared[curr] ?? (path ? `'${path}'` : `require.resolve('${curr}')`)}]: '${curr}',`
197
+ `[${_nullishCoalesce(vendorShared[curr], () => ( (path ? `'${path}'` : `require.resolve('${curr}')`)))}]: '${curr}',`
473
198
  );
474
199
  acc.push(
475
200
  `['__remote_shared_module_${curr}']: () => import('${curr}'),`
@@ -486,28 +211,28 @@ ${exportPre}${Array.from(sharedHost).reduce((acc, curr) => {
486
211
  const appSharedHost = generateSharedHost(appShared);
487
212
  const pagesSharedHost = generateSharedHost(pagesShared);
488
213
  const emitSharedFiles = () => {
489
- (0, import_node_fs2.mkdirSync)((0, import_node_path3.dirname)(virtualRemoteComponentAppSharedRemote), {
214
+ _fs.mkdirSync.call(void 0, _path.dirname.call(void 0, virtualRemoteComponentAppSharedRemote), {
490
215
  recursive: true
491
216
  });
492
- (0, import_node_fs2.writeFileSync)(
217
+ _fs.writeFileSync.call(void 0,
493
218
  virtualRemoteComponentAppSharedRemote,
494
219
  appSharedRemote,
495
220
  "utf-8"
496
221
  );
497
- (0, import_node_fs2.writeFileSync)(
222
+ _fs.writeFileSync.call(void 0,
498
223
  virtualRemoteComponentPagesSharedRemote,
499
224
  pagesSharedRemote,
500
225
  "utf-8"
501
226
  );
502
- (0, import_node_fs2.writeFileSync)(virtualRemoteComponentAppSharedHost, appSharedHost, "utf-8");
503
- (0, import_node_fs2.writeFileSync)(
227
+ _fs.writeFileSync.call(void 0, virtualRemoteComponentAppSharedHost, appSharedHost, "utf-8");
228
+ _fs.writeFileSync.call(void 0,
504
229
  virtualRemoteComponentPagesSharedHost,
505
230
  pagesSharedHost,
506
231
  "utf-8"
507
232
  );
508
233
  };
509
234
  nextConfig.transpilePackages = [
510
- ...nextConfig.transpilePackages ?? [],
235
+ ..._nullishCoalesce(nextConfig.transpilePackages, () => ( [])),
511
236
  "remote-components"
512
237
  ];
513
238
  nextConfig.env = {
@@ -515,19 +240,19 @@ ${exportPre}${Array.from(sharedHost).reduce((acc, curr) => {
515
240
  REMOTE_COMPONENTS_CONFIGURED: "1"
516
241
  };
517
242
  const alias = {
518
- "#remote-components/remote/defaults/app": `./${(0, import_node_path3.relative)(
243
+ "#remote-components/remote/defaults/app": `./${_path.relative.call(void 0,
519
244
  process.cwd(),
520
245
  virtualRemoteComponentAppSharedRemote
521
246
  )}`,
522
- "#remote-components/remote/defaults/pages": `./${(0, import_node_path3.relative)(
247
+ "#remote-components/remote/defaults/pages": `./${_path.relative.call(void 0,
523
248
  process.cwd(),
524
249
  virtualRemoteComponentPagesSharedRemote
525
250
  )}`,
526
- "#remote-components/host/defaults/app": `./${(0, import_node_path3.relative)(
251
+ "#remote-components/host/defaults/app": `./${_path.relative.call(void 0,
527
252
  process.cwd(),
528
253
  virtualRemoteComponentAppSharedHost
529
254
  )}`,
530
- "#remote-components/host/defaults/pages": `./${(0, import_node_path3.relative)(
255
+ "#remote-components/host/defaults/pages": `./${_path.relative.call(void 0,
531
256
  process.cwd(),
532
257
  virtualRemoteComponentPagesSharedHost
533
258
  )}`
@@ -535,14 +260,9 @@ ${exportPre}${Array.from(sharedHost).reduce((acc, curr) => {
535
260
  const projectId = resolveProjectId(packageJson.name);
536
261
  process.env.REMOTE_COMPONENTS_PROJECT_ID = projectId;
537
262
  if (hasPagesDirectory()) {
538
- if (process.env.TURBOPACK) {
539
- throw new RemoteComponentsError(
540
- "Remote Components does not support Next.js Pages Router with Turbopack. Use webpack instead (`next dev` / `next build` without `--turbo`)."
541
- );
542
- }
543
263
  const nextMajor = getNextMajorVersion();
544
264
  if (nextMajor !== void 0 && nextMajor < 16) {
545
- const log = process.env.NODE_ENV !== "production" || process.env.VERCEL_ENV === "preview" ? logWarn : logDebug;
265
+ const log = process.env.NODE_ENV !== "production" || process.env.VERCEL_ENV === "preview" ? _chunkRUWR74XQcjs.logWarn : _chunkRUWR74XQcjs.logDebug;
546
266
  log(
547
267
  "Config",
548
268
  `Remote Components does not support Pages Router hosts on Next.js ${nextMajor}. Pages Router remotes are unaffected. Upgrade to Next.js 16+ for host support.`
@@ -550,7 +270,7 @@ ${exportPre}${Array.from(sharedHost).reduce((acc, curr) => {
550
270
  }
551
271
  }
552
272
  if (process.env.TURBOPACK) {
553
- if (!import_config_schema.configSchema.safeParse({
273
+ if (!_configschemajs.configSchema.safeParse({
554
274
  turbopack: {
555
275
  resolveAlias: {
556
276
  ...alias
@@ -562,7 +282,7 @@ ${exportPre}${Array.from(sharedHost).reduce((acc, curr) => {
562
282
  }
563
283
  }
564
284
  }).success) {
565
- logError(
285
+ _chunkRUWR74XQcjs.logError.call(void 0,
566
286
  "Config",
567
287
  "Turbopack support requires a Next.js version that includes `compiler.defineServer`. Upgrade Next.js to continue using Remote Components with Turbopack."
568
288
  );
@@ -571,14 +291,14 @@ ${exportPre}${Array.from(sharedHost).reduce((acc, curr) => {
571
291
  nextConfig.turbopack = {
572
292
  ...nextConfig.turbopack,
573
293
  resolveAlias: {
574
- ...nextConfig.turbopack?.resolveAlias,
294
+ ..._optionalChain([nextConfig, 'access', _3 => _3.turbopack, 'optionalAccess', _4 => _4.resolveAlias]),
575
295
  ...alias
576
296
  }
577
297
  };
578
298
  nextConfig.compiler = {
579
299
  ...nextConfig.compiler,
580
300
  defineServer: {
581
- ...nextConfig.compiler?.defineServer,
301
+ ..._optionalChain([nextConfig, 'access', _5 => _5.compiler, 'optionalAccess', _6 => _6.defineServer]),
582
302
  "process.env.REMOTE_COMPONENTS_PROJECT_ID": projectId
583
303
  }
584
304
  };
@@ -591,8 +311,7 @@ ${exportPre}${Array.from(sharedHost).reduce((acc, curr) => {
591
311
  emitSharedFiles
592
312
  });
593
313
  }
594
- // Annotate the CommonJS export names for ESM import in node:
595
- 0 && (module.exports = {
596
- withRemoteComponentsConfig
597
- });
314
+
315
+
316
+ exports.withRemoteComponentsConfig = withRemoteComponentsConfig;
598
317
  //# sourceMappingURL=nextjs.cjs.map