react-server-dom-webpack 18.3.0-next-fa4314841-20230502 → 19.0.0-beta-4508873393-20240430

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 (40) hide show
  1. package/cjs/react-server-dom-webpack-client.browser.development.js +1893 -1200
  2. package/cjs/react-server-dom-webpack-client.browser.production.js +931 -0
  3. package/cjs/react-server-dom-webpack-client.edge.development.js +1888 -241
  4. package/cjs/react-server-dom-webpack-client.edge.production.js +1093 -0
  5. package/cjs/react-server-dom-webpack-client.node.development.js +1876 -259
  6. package/cjs/react-server-dom-webpack-client.node.production.js +1070 -0
  7. package/cjs/react-server-dom-webpack-client.node.unbundled.development.js +1833 -212
  8. package/cjs/react-server-dom-webpack-client.node.unbundled.production.js +1049 -0
  9. package/cjs/react-server-dom-webpack-node-register.js +59 -10
  10. package/cjs/react-server-dom-webpack-plugin.js +389 -11
  11. package/cjs/react-server-dom-webpack-server.browser.development.js +2187 -937
  12. package/cjs/react-server-dom-webpack-server.browser.production.js +1935 -0
  13. package/cjs/react-server-dom-webpack-server.edge.development.js +2183 -941
  14. package/cjs/react-server-dom-webpack-server.edge.production.js +1956 -0
  15. package/cjs/react-server-dom-webpack-server.node.development.js +2169 -929
  16. package/cjs/react-server-dom-webpack-server.node.production.js +2083 -0
  17. package/cjs/react-server-dom-webpack-server.node.unbundled.development.js +2116 -881
  18. package/cjs/react-server-dom-webpack-server.node.unbundled.production.js +2051 -0
  19. package/client.browser.js +1 -1
  20. package/client.edge.js +1 -1
  21. package/client.node.js +1 -1
  22. package/client.node.unbundled.js +1 -1
  23. package/esm/{react-server-dom-webpack-node-loader.production.min.js → react-server-dom-webpack-node-loader.production.js} +20 -13
  24. package/package.json +8 -15
  25. package/server.browser.js +1 -1
  26. package/server.edge.js +1 -1
  27. package/server.node.js +1 -1
  28. package/server.node.unbundled.js +1 -1
  29. package/cjs/react-server-dom-webpack-client.browser.production.min.js +0 -34
  30. package/cjs/react-server-dom-webpack-client.edge.production.min.js +0 -28
  31. package/cjs/react-server-dom-webpack-client.node.production.min.js +0 -28
  32. package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +0 -26
  33. package/cjs/react-server-dom-webpack-server.browser.production.min.js +0 -62
  34. package/cjs/react-server-dom-webpack-server.edge.production.min.js +0 -62
  35. package/cjs/react-server-dom-webpack-server.node.production.min.js +0 -67
  36. package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +0 -65
  37. package/umd/react-server-dom-webpack-client.browser.development.js +0 -1731
  38. package/umd/react-server-dom-webpack-client.browser.production.min.js +0 -29
  39. package/umd/react-server-dom-webpack-server.browser.development.js +0 -2904
  40. package/umd/react-server-dom-webpack-server.browser.production.min.js +0 -51
@@ -8,13 +8,62 @@
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
10
 
11
- 'use strict';
12
-
13
- 'use strict';const n=require("acorn-loose"),p=require("url"),r=require("module");
14
- module.exports=function(){const h=Symbol.for("react.client.reference"),k=Symbol.for("react.server.reference"),t=Promise.prototype,u=Function.prototype.bind;Function.prototype.bind=function(a){const c=u.apply(this,arguments);if(this.$$typeof===k){const b=Array.prototype.slice.call(arguments,1);c.$$typeof=k;c.$$id=this.$$id;c.$$bound=this.$$bound?this.$$bound.concat(b):b}return c};const v={get:function(a,c){switch(c){case "$$typeof":return a.$$typeof;case "$$id":return a.$$id;case "$$async":return a.$$async;
15
- case "name":return a.name;case "displayName":return;case "defaultProps":return;case "toJSON":return;case Symbol.toPrimitive:return Object.prototype[Symbol.toPrimitive];case "Provider":throw Error("Cannot render a Client Context Provider on the Server. Instead, you can export a Client Component wrapper that itself renders a Client Context Provider.");}throw Error("Cannot access "+(String(a.name)+"."+String(c))+" on the server. You cannot dot into a client module from a server component. You can only pass the imported name through.");
16
- },set:function(){throw Error("Cannot assign to a client module from a server module.");}},q={get:function(a,c){switch(c){case "$$typeof":return a.$$typeof;case "$$id":return a.$$id;case "$$async":return a.$$async;case "name":return a.name;case "defaultProps":return;case "toJSON":return;case Symbol.toPrimitive:return Object.prototype[Symbol.toPrimitive];case "__esModule":const d=a.$$id;a.default=Object.defineProperties(function(){throw Error("Attempted to call the default export of "+d+" from the server but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.");
17
- },{$$typeof:{value:h},$$id:{value:a.$$id+"#"},$$async:{value:a.$$async}});return!0;case "then":if(a.then)return a.then;if(a.$$async)return;var b=Object.defineProperties({},{$$typeof:{value:h},$$id:{value:a.$$id},$$async:{value:!0}});const e=new Proxy(b,q);a.status="fulfilled";a.value=e;return a.then=Object.defineProperties(function(f){return Promise.resolve(f(e))},{$$typeof:{value:h},$$id:{value:a.$$id+"#then"},$$async:{value:!1}})}b=a[c];b||(b=Object.defineProperties(function(){throw Error("Attempted to call "+
18
- String(c)+"() from the server but "+String(c)+" is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.");},{name:{value:c},$$typeof:{value:h},$$id:{value:a.$$id+"#"+c},$$async:{value:a.$$async}}),b=a[c]=new Proxy(b,v));return b},getPrototypeOf(){return t},set:function(){throw Error("Cannot assign to a client module from a server module.");}},l=r.prototype._compile;r.prototype._compile=function(a,
19
- c){if(-1===a.indexOf("use client")&&-1===a.indexOf("use server"))return l.apply(this,arguments);try{var b=n.parse(a,{ecmaVersion:"2024",sourceType:"source"}).body}catch(m){return console.error("Error parsing %s %s",p,m.message),l.apply(this,arguments)}var d=!1,e=!1;for(var f=0;f<b.length;f++){var g=b[f];if("ExpressionStatement"!==g.type||!g.directive)break;"use client"===g.directive&&(d=!0);"use server"===g.directive&&(e=!0)}if(!d&&!e)return l.apply(this,arguments);if(d&&e)throw Error('Cannot have both "use client" and "use server" directives in the same file.');
20
- d&&(b=p.pathToFileURL(c).href,b=Object.defineProperties({},{$$typeof:{value:h},$$id:{value:b},$$async:{value:!1}}),this.exports=new Proxy(b,q));if(e)if(l.apply(this,arguments),e=p.pathToFileURL(c).href,b=this.exports,"function"===typeof b)Object.defineProperties(b,{$$typeof:{value:k},$$id:{value:e},$$bound:{value:null}});else for(d=Object.keys(b),f=0;f<d.length;f++){g=d[f];const m=b[d[f]];"function"===typeof m&&Object.defineProperties(m,{$$typeof:{value:k},$$id:{value:e+"#"+g},$$bound:{value:null}})}}};
11
+ "use strict";
12
+ const acorn = require("acorn-loose"),
13
+ url = require("url"),
14
+ Module = require("module");
15
+ module.exports = function () {
16
+ const Server = require("react-server-dom-webpack/server"),
17
+ registerServerReference = Server.registerServerReference,
18
+ createClientModuleProxy = Server.createClientModuleProxy,
19
+ originalCompile = Module.prototype._compile;
20
+ Module.prototype._compile = function (content, filename) {
21
+ if (
22
+ -1 === content.indexOf("use client") &&
23
+ -1 === content.indexOf("use server")
24
+ )
25
+ return originalCompile.apply(this, arguments);
26
+ try {
27
+ var body = acorn.parse(content, {
28
+ ecmaVersion: "2024",
29
+ sourceType: "source"
30
+ }).body;
31
+ } catch (x) {
32
+ return (
33
+ console.error("Error parsing %s %s", url, x.message),
34
+ originalCompile.apply(this, arguments)
35
+ );
36
+ }
37
+ var useClient = !1,
38
+ useServer = !1;
39
+ for (var i = 0; i < body.length; i++) {
40
+ var node = body[i];
41
+ if ("ExpressionStatement" !== node.type || !node.directive) break;
42
+ "use client" === node.directive && (useClient = !0);
43
+ "use server" === node.directive && (useServer = !0);
44
+ }
45
+ if (!useClient && !useServer) return originalCompile.apply(this, arguments);
46
+ if (useClient && useServer)
47
+ throw Error(
48
+ 'Cannot have both "use client" and "use server" directives in the same file.'
49
+ );
50
+ useClient &&
51
+ ((body = url.pathToFileURL(filename).href),
52
+ (this.exports = createClientModuleProxy(body)));
53
+ if (useServer)
54
+ if (
55
+ (originalCompile.apply(this, arguments),
56
+ (useServer = url.pathToFileURL(filename).href),
57
+ (body = this.exports),
58
+ "function" === typeof body)
59
+ )
60
+ registerServerReference(body, useServer, null);
61
+ else
62
+ for (useClient = Object.keys(body), i = 0; i < useClient.length; i++) {
63
+ node = useClient[i];
64
+ const value = body[useClient[i]];
65
+ "function" === typeof value &&
66
+ registerServerReference(value, useServer, node);
67
+ }
68
+ };
69
+ };
@@ -8,14 +8,392 @@
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
10
 
11
- 'use strict';
12
-
13
- 'use strict';var r=require("path"),u=require("url"),x=require("neo-async"),A=require("acorn-loose"),B=require("webpack/lib/dependencies/ModuleDependency"),C=require("webpack/lib/dependencies/NullDependency"),D=require("webpack/lib/Template"),E=require("webpack");const F=Array.isArray;class G extends B{constructor(b){super(b)}get type(){return"client-reference"}}const H=require.resolve("../client.browser.js");
14
- class I{constructor(b){this.ssrManifestFilename=this.clientManifestFilename=this.chunkName=this.clientReferences=void 0;if(!b||"boolean"!==typeof b.isServer)throw Error("React Server Plugin: You must specify the isServer option as a boolean.");if(b.isServer)throw Error("TODO: Implement the server compiler.");b.clientReferences?"string"!==typeof b.clientReferences&&F(b.clientReferences)?this.clientReferences=b.clientReferences:this.clientReferences=[b.clientReferences]:this.clientReferences=[{directory:".",
15
- recursive:!0,include:/\.(js|ts|jsx|tsx)$/}];"string"===typeof b.chunkName?(this.chunkName=b.chunkName,/\[(index|request)\]/.test(this.chunkName)||(this.chunkName+="[index]")):this.chunkName="client[index]";this.clientManifestFilename=b.clientManifestFilename||"react-client-manifest.json";this.ssrManifestFilename=b.ssrManifestFilename||"react-ssr-manifest.json"}apply(b){const n=this;let p,t=!1;b.hooks.beforeCompile.tapAsync("React Server Plugin",(e,g)=>{e=e.contextModuleFactory;const l=b.resolverFactory.get("context",
16
- {}),a=b.resolverFactory.get("normal");n.resolveAllClientFiles(b.context,l,a,b.inputFileSystem,e,function(c,d){c?g(c):(p=d,g())})});b.hooks.thisCompilation.tap("React Server Plugin",(e,g)=>{g=g.normalModuleFactory;e.dependencyFactories.set(G,g);e.dependencyTemplates.set(G,new C.Template);e=l=>{l.hooks.program.tap("React Server Plugin",()=>{const a=l.state.module;if(a.resource===H&&(t=!0,p))for(let d=0;d<p.length;d++){const m=p[d];var c=n.chunkName.replace(/\[index\]/g,""+d).replace(/\[request\]/g,
17
- D.toPath(m.userRequest));c=new E.AsyncDependenciesBlock({name:c},null,m.request);c.addDependency(m);a.addBlock(c)}})};g.hooks.parser.for("javascript/auto").tap("HarmonyModulesPlugin",e);g.hooks.parser.for("javascript/esm").tap("HarmonyModulesPlugin",e);g.hooks.parser.for("javascript/dynamic").tap("HarmonyModulesPlugin",e)});b.hooks.make.tap("React Server Plugin",e=>{e.hooks.processAssets.tap({name:"React Server Plugin",stage:E.Compilation.PROCESS_ASSETS_STAGE_REPORT},function(){if(!1===t)e.warnings.push(new E.WebpackError("Client runtime at react-server-dom-webpack/client was not found. React Server Components module map file "+
18
- n.clientManifestFilename+" was not created."));else{var g=new Set((p||[]).map(d=>d.request)),l={},a={};e.chunkGroups.forEach(function(d){function m(k,f){if(g.has(f.resource)&&(f=u.pathToFileURL(f.resource).href,void 0!==f)){const h={};l[f]={id:k,chunks:q,name:"*"};h["*"]={specifier:f,name:"*"};a[k]=h}}const q=d.chunks.map(function(k){return k.id});d.chunks.forEach(function(k){k=e.chunkGraph.getChunkModulesIterable(k);Array.from(k).forEach(function(f){const h=e.chunkGraph.getModuleId(f);m(h,f);f.modules&&
19
- f.modules.forEach(v=>{m(h,v)})})})});var c=JSON.stringify(l,null,2);e.emitAsset(n.clientManifestFilename,new E.sources.RawSource(c,!1));c=JSON.stringify(a,null,2);e.emitAsset(n.ssrManifestFilename,new E.sources.RawSource(c,!1))}})})}resolveAllClientFiles(b,n,p,t,e,g){function l(a){if(-1===a.indexOf("use client"))return!1;let c;try{c=A.parse(a,{ecmaVersion:"2024",sourceType:"module"}).body}catch(d){return!1}for(a=0;a<c.length;a++){const d=c[a];if("ExpressionStatement"!==d.type||!d.directive)break;
20
- if("use client"===d.directive)return!0}return!1}x.map(this.clientReferences,(a,c)=>{"string"===typeof a?c(null,[new G(a)]):n.resolve({},b,a.directory,{},(d,m)=>{if(d)return c(d);e.resolveDependencies(t,{resource:m,resourceQuery:"",recursive:void 0===a.recursive?!0:a.recursive,regExp:a.include,include:void 0,exclude:a.exclude},(q,k)=>{if(q)return c(q);q=k.map(f=>{var h=r.join(m,f.userRequest);h=new G(h);h.userRequest=f.userRequest;return h});x.filter(q,(f,h)=>{p.resolve({},b,f.request,{},(v,y)=>{if(v||
21
- "string"!==typeof y)return h(null,!1);t.readFile(y,"utf-8",(w,z)=>{if(w||"string"!==typeof z)return h(null,!1);w=l(z);h(null,w)})})},c)})})},(a,c)=>{if(a)return g(a);a=[];for(let d=0;d<c.length;d++)a.push.apply(a,c[d]);g(null,a)})}}module.exports=I;
11
+ "use strict";
12
+ var path = require("path"),
13
+ url = require("url"),
14
+ asyncLib = require("neo-async"),
15
+ acorn = require("acorn-loose"),
16
+ ModuleDependency = require("webpack/lib/dependencies/ModuleDependency"),
17
+ NullDependency = require("webpack/lib/dependencies/NullDependency"),
18
+ Template = require("webpack/lib/Template"),
19
+ webpack = require("webpack");
20
+ function _unsupportedIterableToArray(o, minLen) {
21
+ if (o) {
22
+ if ("string" === typeof o) return _arrayLikeToArray(o, minLen);
23
+ var n = Object.prototype.toString.call(o).slice(8, -1);
24
+ "Object" === n && o.constructor && (n = o.constructor.name);
25
+ if ("Map" === n || "Set" === n) return Array.from(o);
26
+ if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
27
+ return _arrayLikeToArray(o, minLen);
28
+ }
29
+ }
30
+ function _arrayLikeToArray(arr, len) {
31
+ if (null == len || len > arr.length) len = arr.length;
32
+ for (var i = 0, arr2 = Array(len); i < len; i++) arr2[i] = arr[i];
33
+ return arr2;
34
+ }
35
+ function _createForOfIteratorHelper(o, allowArrayLike) {
36
+ var it;
37
+ if ("undefined" === typeof Symbol || null == o[Symbol.iterator]) {
38
+ if (
39
+ Array.isArray(o) ||
40
+ (it = _unsupportedIterableToArray(o)) ||
41
+ (allowArrayLike && o && "number" === typeof o.length)
42
+ ) {
43
+ it && (o = it);
44
+ var i = 0;
45
+ allowArrayLike = function () {};
46
+ return {
47
+ s: allowArrayLike,
48
+ n: function () {
49
+ return i >= o.length ? { done: !0 } : { done: !1, value: o[i++] };
50
+ },
51
+ e: function (e) {
52
+ throw e;
53
+ },
54
+ f: allowArrayLike
55
+ };
56
+ }
57
+ throw new TypeError(
58
+ "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
59
+ );
60
+ }
61
+ var normalCompletion = !0,
62
+ didErr = !1,
63
+ err;
64
+ return {
65
+ s: function () {
66
+ it = o[Symbol.iterator]();
67
+ },
68
+ n: function () {
69
+ var step = it.next();
70
+ normalCompletion = step.done;
71
+ return step;
72
+ },
73
+ e: function (e) {
74
+ didErr = !0;
75
+ err = e;
76
+ },
77
+ f: function () {
78
+ try {
79
+ normalCompletion || null == it.return || it.return();
80
+ } finally {
81
+ if (didErr) throw err;
82
+ }
83
+ }
84
+ };
85
+ }
86
+ const isArrayImpl = Array.isArray;
87
+ class ClientReferenceDependency extends ModuleDependency {
88
+ constructor(request) {
89
+ super(request);
90
+ }
91
+ get type() {
92
+ return "client-reference";
93
+ }
94
+ }
95
+ const clientFileName = require.resolve("../client.browser.js");
96
+ class ReactFlightWebpackPlugin {
97
+ constructor(options) {
98
+ this.ssrManifestFilename =
99
+ this.clientManifestFilename =
100
+ this.chunkName =
101
+ this.clientReferences =
102
+ void 0;
103
+ if (!options || "boolean" !== typeof options.isServer)
104
+ throw Error(
105
+ "React Server Plugin: You must specify the isServer option as a boolean."
106
+ );
107
+ if (options.isServer) throw Error("TODO: Implement the server compiler.");
108
+ options.clientReferences
109
+ ? "string" !== typeof options.clientReferences &&
110
+ isArrayImpl(options.clientReferences)
111
+ ? (this.clientReferences = options.clientReferences)
112
+ : (this.clientReferences = [options.clientReferences])
113
+ : (this.clientReferences = [
114
+ { directory: ".", recursive: !0, include: /\.(js|ts|jsx|tsx)$/ }
115
+ ]);
116
+ "string" === typeof options.chunkName
117
+ ? ((this.chunkName = options.chunkName),
118
+ /\[(index|request)\]/.test(this.chunkName) ||
119
+ (this.chunkName += "[index]"))
120
+ : (this.chunkName = "client[index]");
121
+ this.clientManifestFilename =
122
+ options.clientManifestFilename || "react-client-manifest.json";
123
+ this.ssrManifestFilename =
124
+ options.ssrManifestFilename || "react-ssr-manifest.json";
125
+ }
126
+ apply(compiler) {
127
+ const _this = this;
128
+ let resolvedClientReferences,
129
+ clientFileNameFound = !1;
130
+ compiler.hooks.beforeCompile.tapAsync(
131
+ "React Server Plugin",
132
+ (_ref, callback) => {
133
+ _ref = _ref.contextModuleFactory;
134
+ const contextResolver = compiler.resolverFactory.get("context", {}),
135
+ normalResolver = compiler.resolverFactory.get("normal");
136
+ _this.resolveAllClientFiles(
137
+ compiler.context,
138
+ contextResolver,
139
+ normalResolver,
140
+ compiler.inputFileSystem,
141
+ _ref,
142
+ function (err, resolvedClientRefs) {
143
+ err
144
+ ? callback(err)
145
+ : ((resolvedClientReferences = resolvedClientRefs), callback());
146
+ }
147
+ );
148
+ }
149
+ );
150
+ compiler.hooks.thisCompilation.tap(
151
+ "React Server Plugin",
152
+ (compilation, _ref2) => {
153
+ _ref2 = _ref2.normalModuleFactory;
154
+ compilation.dependencyFactories.set(ClientReferenceDependency, _ref2);
155
+ compilation.dependencyTemplates.set(
156
+ ClientReferenceDependency,
157
+ new NullDependency.Template()
158
+ );
159
+ compilation = parser => {
160
+ parser.hooks.program.tap("React Server Plugin", () => {
161
+ const module = parser.state.module;
162
+ if (
163
+ module.resource === clientFileName &&
164
+ ((clientFileNameFound = !0), resolvedClientReferences)
165
+ )
166
+ for (let i = 0; i < resolvedClientReferences.length; i++) {
167
+ const dep = resolvedClientReferences[i];
168
+ var chunkName = _this.chunkName
169
+ .replace(/\[index\]/g, "" + i)
170
+ .replace(/\[request\]/g, Template.toPath(dep.userRequest));
171
+ chunkName = new webpack.AsyncDependenciesBlock(
172
+ { name: chunkName },
173
+ null,
174
+ dep.request
175
+ );
176
+ chunkName.addDependency(dep);
177
+ module.addBlock(chunkName);
178
+ }
179
+ });
180
+ };
181
+ _ref2.hooks.parser
182
+ .for("javascript/auto")
183
+ .tap("HarmonyModulesPlugin", compilation);
184
+ _ref2.hooks.parser
185
+ .for("javascript/esm")
186
+ .tap("HarmonyModulesPlugin", compilation);
187
+ _ref2.hooks.parser
188
+ .for("javascript/dynamic")
189
+ .tap("HarmonyModulesPlugin", compilation);
190
+ }
191
+ );
192
+ compiler.hooks.make.tap("React Server Plugin", compilation => {
193
+ compilation.hooks.processAssets.tap(
194
+ {
195
+ name: "React Server Plugin",
196
+ stage: webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT
197
+ },
198
+ function () {
199
+ if (!1 === clientFileNameFound)
200
+ compilation.warnings.push(
201
+ new webpack.WebpackError(
202
+ "Client runtime at react-server-dom-webpack/client was not found. React Server Components module map file " +
203
+ _this.clientManifestFilename +
204
+ " was not created."
205
+ )
206
+ );
207
+ else {
208
+ var configuredCrossOriginLoading =
209
+ compilation.outputOptions.crossOriginLoading;
210
+ configuredCrossOriginLoading =
211
+ "string" === typeof configuredCrossOriginLoading
212
+ ? "use-credentials" === configuredCrossOriginLoading
213
+ ? configuredCrossOriginLoading
214
+ : "anonymous"
215
+ : null;
216
+ var resolvedClientFiles = new Set(
217
+ (resolvedClientReferences || []).map(ref => ref.request)
218
+ ),
219
+ clientManifest = {},
220
+ moduleMap = {};
221
+ configuredCrossOriginLoading = {
222
+ moduleLoading: {
223
+ prefix: compilation.outputOptions.publicPath || "",
224
+ crossOrigin: configuredCrossOriginLoading
225
+ },
226
+ moduleMap
227
+ };
228
+ var runtimeChunkFiles = new Set();
229
+ compilation.entrypoints.forEach(entrypoint => {
230
+ (entrypoint = entrypoint.getRuntimeChunk()) &&
231
+ entrypoint.files.forEach(runtimeFile => {
232
+ runtimeChunkFiles.add(runtimeFile);
233
+ });
234
+ });
235
+ compilation.chunkGroups.forEach(function (chunkGroup) {
236
+ function recordModule(id, module) {
237
+ if (
238
+ resolvedClientFiles.has(module.resource) &&
239
+ ((module = url.pathToFileURL(module.resource).href),
240
+ void 0 !== module)
241
+ ) {
242
+ const ssrExports = {};
243
+ clientManifest[module] = { id, chunks, name: "*" };
244
+ ssrExports["*"] = { specifier: module, name: "*" };
245
+ moduleMap[id] = ssrExports;
246
+ }
247
+ }
248
+ const chunks = [];
249
+ chunkGroup.chunks.forEach(function (c) {
250
+ var _iterator = _createForOfIteratorHelper(c.files),
251
+ _step;
252
+ try {
253
+ for (_iterator.s(); !(_step = _iterator.n()).done; ) {
254
+ const file = _step.value;
255
+ if (!file.endsWith(".js")) break;
256
+ if (file.endsWith(".hot-update.js")) break;
257
+ chunks.push(c.id, file);
258
+ break;
259
+ }
260
+ } catch (err) {
261
+ _iterator.e(err);
262
+ } finally {
263
+ _iterator.f();
264
+ }
265
+ });
266
+ chunkGroup.chunks.forEach(function (chunk) {
267
+ chunk = compilation.chunkGraph.getChunkModulesIterable(chunk);
268
+ Array.from(chunk).forEach(function (module) {
269
+ const moduleId = compilation.chunkGraph.getModuleId(module);
270
+ recordModule(moduleId, module);
271
+ module.modules &&
272
+ module.modules.forEach(concatenatedMod => {
273
+ recordModule(moduleId, concatenatedMod);
274
+ });
275
+ });
276
+ });
277
+ });
278
+ var clientOutput = JSON.stringify(clientManifest, null, 2);
279
+ compilation.emitAsset(
280
+ _this.clientManifestFilename,
281
+ new webpack.sources.RawSource(clientOutput, !1)
282
+ );
283
+ configuredCrossOriginLoading = JSON.stringify(
284
+ configuredCrossOriginLoading,
285
+ null,
286
+ 2
287
+ );
288
+ compilation.emitAsset(
289
+ _this.ssrManifestFilename,
290
+ new webpack.sources.RawSource(configuredCrossOriginLoading, !1)
291
+ );
292
+ }
293
+ }
294
+ );
295
+ });
296
+ }
297
+ resolveAllClientFiles(
298
+ context,
299
+ contextResolver,
300
+ normalResolver,
301
+ fs,
302
+ contextModuleFactory,
303
+ callback
304
+ ) {
305
+ function hasUseClientDirective(source) {
306
+ if (-1 === source.indexOf("use client")) return !1;
307
+ let body;
308
+ try {
309
+ body = acorn.parse(source, {
310
+ ecmaVersion: "2024",
311
+ sourceType: "module"
312
+ }).body;
313
+ } catch (x) {
314
+ return !1;
315
+ }
316
+ for (source = 0; source < body.length; source++) {
317
+ const node = body[source];
318
+ if ("ExpressionStatement" !== node.type || !node.directive) break;
319
+ if ("use client" === node.directive) return !0;
320
+ }
321
+ return !1;
322
+ }
323
+ asyncLib.map(
324
+ this.clientReferences,
325
+ (clientReferencePath, cb) => {
326
+ "string" === typeof clientReferencePath
327
+ ? cb(null, [new ClientReferenceDependency(clientReferencePath)])
328
+ : contextResolver.resolve(
329
+ {},
330
+ context,
331
+ clientReferencePath.directory,
332
+ {},
333
+ (err, resolvedDirectory) => {
334
+ if (err) return cb(err);
335
+ contextModuleFactory.resolveDependencies(
336
+ fs,
337
+ {
338
+ resource: resolvedDirectory,
339
+ resourceQuery: "",
340
+ recursive:
341
+ void 0 === clientReferencePath.recursive
342
+ ? !0
343
+ : clientReferencePath.recursive,
344
+ regExp: clientReferencePath.include,
345
+ include: void 0,
346
+ exclude: clientReferencePath.exclude
347
+ },
348
+ (err2, deps) => {
349
+ if (err2) return cb(err2);
350
+ err2 = deps.map(dep => {
351
+ var request = path.join(
352
+ resolvedDirectory,
353
+ dep.userRequest
354
+ );
355
+ request = new ClientReferenceDependency(request);
356
+ request.userRequest = dep.userRequest;
357
+ return request;
358
+ });
359
+ asyncLib.filter(
360
+ err2,
361
+ (clientRefDep, filterCb) => {
362
+ normalResolver.resolve(
363
+ {},
364
+ context,
365
+ clientRefDep.request,
366
+ {},
367
+ (err3, resolvedPath) => {
368
+ if (err3 || "string" !== typeof resolvedPath)
369
+ return filterCb(null, !1);
370
+ fs.readFile(
371
+ resolvedPath,
372
+ "utf-8",
373
+ (err4, content) => {
374
+ if (err4 || "string" !== typeof content)
375
+ return filterCb(null, !1);
376
+ err4 = hasUseClientDirective(content);
377
+ filterCb(null, err4);
378
+ }
379
+ );
380
+ }
381
+ );
382
+ },
383
+ cb
384
+ );
385
+ }
386
+ );
387
+ }
388
+ );
389
+ },
390
+ (err, result) => {
391
+ if (err) return callback(err);
392
+ err = [];
393
+ for (let i = 0; i < result.length; i++) err.push.apply(err, result[i]);
394
+ callback(null, err);
395
+ }
396
+ );
397
+ }
398
+ }
399
+ module.exports = ReactFlightWebpackPlugin;