react-server-dom-webpack 18.3.0-next-6ff1733e6-20230225 → 18.3.0-next-41110021f-20230301

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.
@@ -10,12 +10,12 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- 'use strict';const m=require("acorn"),n=require("url"),r=require("module");
13
+ 'use strict';const n=require("acorn"),p=require("url"),r=require("module");
14
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.$$filepath=this.$$filepath;c.$$name=this.$$name;c.$$bound=this.$$bound.concat(b)}return c};const v={get:function(a,c){switch(c){case "$$typeof":return a.$$typeof;case "filepath":return a.filepath;
15
15
  case "name":return a.name;case "displayName":return;case "async":return a.async;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.");}switch(a.name){case "":a=String(c);break;case "*":a=String(c);break;default:a=String(a.name)+"."+String(c)}throw Error("Cannot access "+
16
- a+" on the server. You cannot dot into a client module from a server component. You can only pass the imported name through.");},set:function(){throw Error("Cannot assign to a client module from a server module.");}},p={get:function(a,c){switch(c){case "$$typeof":return a.$$typeof;case "filepath":return a.filepath;case "name":return a.name;case "async":return a.async;case "defaultProps":return;case "toJSON":return;case Symbol.toPrimitive:return Object.prototype[Symbol.toPrimitive];case "__esModule":const d=
16
+ a+" on the server. You cannot dot into a client module from a server component. You can only pass the imported name through.");},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 "filepath":return a.filepath;case "name":return a.name;case "async":return a.async;case "defaultProps":return;case "toJSON":return;case Symbol.toPrimitive:return Object.prototype[Symbol.toPrimitive];case "__esModule":const d=
17
17
  a.filepath;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.");},{name:{value:""},$$typeof:{value:h},filepath:{value:a.filepath},async:{value:a.async}});return!0;case "then":if(a.then)return a.then;if(a.async)return;var b=Object.defineProperties({},{name:{value:"*"},
18
- $$typeof:{value:h},filepath:{value:a.filepath},async:{value:!0}});const e=new Proxy(b,p);a.status="fulfilled";a.value=e;return a.then=Object.defineProperties(function(f){return Promise.resolve(f(e))},{name:{value:"then"},$$typeof:{value:h},filepath:{value:a.filepath},async:{value:!1}})}b=a[c];b||(b=Object.defineProperties(function(){throw Error("Attempted to call "+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.");
19
- },{name:{value:c},$$typeof:{value:h},filepath:{value:a.filepath},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,c){if(-1===a.indexOf("use client")&&-1===a.indexOf("use server"))return l.apply(this,arguments);var b=m.parse(a,{ecmaVersion:"2019",sourceType:"source"}).body,d=!1,e=!1;for(var f=0;f<b.length;f++){var g=b[f];if("ExpressionStatement"!==
20
- 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.');d&&(b=n.pathToFileURL(c).href,b=Object.defineProperties({},{name:{value:"*"},$$typeof:{value:h},filepath:{value:b},async:{value:!1}}),this.exports=new Proxy(b,p));if(e)if(l.apply(this,arguments),e=n.pathToFileURL(c).href,b=this.exports,"function"===typeof b)Object.defineProperties(b,
21
- {$$typeof:{value:k},$$filepath:{value:e},$$name:{value:"*"},$$bound:{value:[]}});else for(d=Object.keys(b),f=0;f<d.length;f++){g=d[f];const q=b[d[f]];"function"===typeof q&&Object.defineProperties(q,{$$typeof:{value:k},$$filepath:{value:e},$$name:{value:g},$$bound:{value:[]}})}}};
18
+ $$typeof:{value:h},filepath:{value:a.filepath},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))},{name:{value:"then"},$$typeof:{value:h},filepath:{value:a.filepath},async:{value:!1}})}b=a[c];b||(b=Object.defineProperties(function(){throw Error("Attempted to call "+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.");
19
+ },{name:{value:c},$$typeof:{value:h},filepath:{value:a.filepath},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,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",
20
+ 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.');d&&(b=p.pathToFileURL(c).href,b=Object.defineProperties({},{name:{value:"*"},$$typeof:{value:h},filepath:{value:b},async:{value:!1}}),this.exports=
21
+ 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},$$filepath:{value:e},$$name:{value:"*"},$$bound:{value:[]}});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},$$filepath:{value:e},$$name:{value:g},$$bound:{value:[]}})}}};
@@ -10,11 +10,11 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- 'use strict';var q=require("path"),r=require("url"),x=require("neo-async"),y=require("webpack/lib/dependencies/ModuleDependency"),z=require("webpack/lib/dependencies/NullDependency"),A=require("webpack/lib/Template"),B=require("webpack");const C=Array.isArray;class D extends y{constructor(b){super(b)}get type(){return"client-reference"}}const E=require.resolve("../client.browser.js");
14
- class F{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&&C(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 m=this;let p,t=!1;b.hooks.beforeCompile.tapAsync("React Server Plugin",(c,a)=>{c=c.contextModuleFactory;const d=b.resolverFactory.get("context",
16
- {});m.resolveAllClientFiles(b.context,d,b.inputFileSystem,c,function(e,g){e?a(e):(p=g,a())})});b.hooks.thisCompilation.tap("React Server Plugin",(c,a)=>{a=a.normalModuleFactory;c.dependencyFactories.set(D,a);c.dependencyTemplates.set(D,new z.Template);c=d=>{d.hooks.program.tap("React Server Plugin",()=>{const e=d.state.module;if(e.resource===E&&(t=!0,p))for(let h=0;h<p.length;h++){const n=p[h];var g=m.chunkName.replace(/\[index\]/g,""+h).replace(/\[request\]/g,A.toPath(n.userRequest));g=new B.AsyncDependenciesBlock({name:g},
17
- null,n.request);g.addDependency(n);e.addBlock(g)}})};a.hooks.parser.for("javascript/auto").tap("HarmonyModulesPlugin",c);a.hooks.parser.for("javascript/esm").tap("HarmonyModulesPlugin",c);a.hooks.parser.for("javascript/dynamic").tap("HarmonyModulesPlugin",c)});b.hooks.make.tap("React Server Plugin",c=>{c.hooks.processAssets.tap({name:"React Server Plugin",stage:B.Compilation.PROCESS_ASSETS_STAGE_REPORT},function(){if(!1===t)c.warnings.push(new B.WebpackError("Client runtime at react-server-dom-webpack/client was not found. React Server Components module map file "+
18
- m.clientManifestFilename+" was not created."));else{var a={},d={};c.chunkGroups.forEach(function(g){function h(k,f){if(/\.(js|ts)x?$/.test(f.resource)){var l=c.moduleGraph.getExportsInfo(f).getProvidedExports(),u={},w={};d[k]=w;["","*"].concat(Array.isArray(l)?l:[]).forEach(function(v){u[v]={id:k,chunks:n,name:v};w[v]={specifier:f.resource,name:v}});l=r.pathToFileURL(f.resource).href;void 0!==l&&(a[l]=u,d[l]=w)}}const n=g.chunks.map(function(k){return k.id});g.chunks.forEach(function(k){k=c.chunkGraph.getChunkModulesIterable(k);
19
- Array.from(k).forEach(function(f){const l=c.chunkGraph.getModuleId(f);h(l,f);f.modules&&f.modules.forEach(u=>{h(l,u)})})})});var e=JSON.stringify(a,null,2);c.emitAsset(m.clientManifestFilename,new B.sources.RawSource(e,!1));e=JSON.stringify(d,null,2);c.emitAsset(m.ssrManifestFilename,new B.sources.RawSource(e,!1))}})})}resolveAllClientFiles(b,m,p,t,c){x.map(this.clientReferences,(a,d)=>{"string"===typeof a?d(null,[new D(a)]):m.resolve({},b,a.directory,{},(e,g)=>{if(e)return d(e);t.resolveDependencies(p,
20
- {resource:g,resourceQuery:"",recursive:void 0===a.recursive?!0:a.recursive,regExp:a.include,include:void 0,exclude:a.exclude},(h,n)=>{if(h)return d(h);h=n.map(k=>{var f=q.join(g,k.userRequest);f=new D(f);f.userRequest=k.userRequest;return f});d(null,h)})})},(a,d)=>{if(a)return c(a);a=[];for(let e=0;e<d.length;e++)a.push.apply(a,d[e]);c(null,a)})}}module.exports=F;
13
+ 'use strict';var p=require("path"),r=require("url"),y=require("neo-async"),z=require("webpack/lib/dependencies/ModuleDependency"),A=require("webpack/lib/dependencies/NullDependency"),B=require("webpack/lib/Template"),C=require("webpack");const D=Array.isArray;class E extends z{constructor(b){super(b)}get type(){return"client-reference"}}const F=require.resolve("../client.browser.js");
14
+ class G{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&&D(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 l=this;let n,t=!1;b.hooks.beforeCompile.tapAsync("React Server Plugin",(c,a)=>{c=c.contextModuleFactory;const e=b.resolverFactory.get("context",
16
+ {});l.resolveAllClientFiles(b.context,e,b.inputFileSystem,c,function(d,g){d?a(d):(n=g,a())})});b.hooks.thisCompilation.tap("React Server Plugin",(c,a)=>{a=a.normalModuleFactory;c.dependencyFactories.set(E,a);c.dependencyTemplates.set(E,new A.Template);c=e=>{e.hooks.program.tap("React Server Plugin",()=>{const d=e.state.module;if(d.resource===F&&(t=!0,n))for(let h=0;h<n.length;h++){const m=n[h];var g=l.chunkName.replace(/\[index\]/g,""+h).replace(/\[request\]/g,B.toPath(m.userRequest));g=new C.AsyncDependenciesBlock({name:g},
17
+ null,m.request);g.addDependency(m);d.addBlock(g)}})};a.hooks.parser.for("javascript/auto").tap("HarmonyModulesPlugin",c);a.hooks.parser.for("javascript/esm").tap("HarmonyModulesPlugin",c);a.hooks.parser.for("javascript/dynamic").tap("HarmonyModulesPlugin",c)});b.hooks.make.tap("React Server Plugin",c=>{c.hooks.processAssets.tap({name:"React Server Plugin",stage:C.Compilation.PROCESS_ASSETS_STAGE_REPORT},function(){if(!1===t)c.warnings.push(new C.WebpackError("Client runtime at react-server-dom-webpack/client was not found. React Server Components module map file "+
18
+ l.clientManifestFilename+" was not created."));else{var a={},e={};c.chunkGroups.forEach(function(g){function h(k,f){if(/\.(js|ts)x?$/.test(f.resource)){var q=c.moduleGraph.getExportsInfo(f).getProvidedExports(),u={},x={},w=r.pathToFileURL(f.resource).href;void 0!==w&&(["","*"].concat(Array.isArray(q)?q:[]).forEach(function(v){u[v]={id:k,chunks:m,name:v};x[v]={specifier:w,name:v}}),a[w]=u,e[k]=x)}}const m=g.chunks.map(function(k){return k.id});g.chunks.forEach(function(k){k=c.chunkGraph.getChunkModulesIterable(k);
19
+ Array.from(k).forEach(function(f){const q=c.chunkGraph.getModuleId(f);h(q,f);f.modules&&f.modules.forEach(u=>{h(q,u)})})})});var d=JSON.stringify(a,null,2);c.emitAsset(l.clientManifestFilename,new C.sources.RawSource(d,!1));d=JSON.stringify(e,null,2);c.emitAsset(l.ssrManifestFilename,new C.sources.RawSource(d,!1))}})})}resolveAllClientFiles(b,l,n,t,c){y.map(this.clientReferences,(a,e)=>{"string"===typeof a?e(null,[new E(a)]):l.resolve({},b,a.directory,{},(d,g)=>{if(d)return e(d);t.resolveDependencies(n,
20
+ {resource:g,resourceQuery:"",recursive:void 0===a.recursive?!0:a.recursive,regExp:a.include,include:void 0,exclude:a.exclude},(h,m)=>{if(h)return e(h);h=m.map(k=>{var f=p.join(g,k.userRequest);f=new E(f);f.userRequest=k.userRequest;return f});e(null,h)})})},(a,e)=>{if(a)return c(a);a=[];for(let d=0;d<e.length;d++)a.push.apply(a,e[d]);c(null,a)})}}module.exports=G;
@@ -228,11 +228,18 @@ async function parseExportNamesInto(body, names, parentURL, loader) {
228
228
  throw new Error('Expected the transformed source to be a string.');
229
229
  }
230
230
 
231
- const _acorn$parse = acorn.parse(source, {
232
- ecmaVersion: '2019',
233
- sourceType: 'module'
234
- }),
235
- childBody = _acorn$parse.body;
231
+ let childBody;
232
+
233
+ try {
234
+ childBody = acorn.parse(source, {
235
+ ecmaVersion: '2024',
236
+ sourceType: 'module'
237
+ }).body;
238
+ } catch (x) {
239
+ // eslint-disable-next-line react-internal/no-production-logging
240
+ console.error('Error parsing %s %s', url, x.message);
241
+ continue;
242
+ }
236
243
 
237
244
  await parseExportNamesInto(childBody, names, url, loader);
238
245
  continue;
@@ -324,11 +331,18 @@ async function transformModuleIfNeeded(source, url, loader) {
324
331
  return source;
325
332
  }
326
333
 
327
- const _acorn$parse2 = acorn.parse(source, {
328
- ecmaVersion: '2019',
329
- sourceType: 'module'
330
- }),
331
- body = _acorn$parse2.body;
334
+ let body;
335
+
336
+ try {
337
+ body = acorn.parse(source, {
338
+ ecmaVersion: '2024',
339
+ sourceType: 'module'
340
+ }).body;
341
+ } catch (x) {
342
+ // eslint-disable-next-line react-internal/no-production-logging
343
+ console.error('Error parsing %s %s', url, x.message);
344
+ return source;
345
+ }
332
346
 
333
347
  let useClient = false;
334
348
  let useServer = false;
@@ -385,9 +399,9 @@ async function transformSource(source, context, defaultTransformSource) {
385
399
  return transformed;
386
400
  }
387
401
  async function load(url, context, defaultLoad) {
388
- if (context.format === 'module') {
389
- const result = await defaultLoad(url, context, defaultLoad);
402
+ const result = await defaultLoad(url, context, defaultLoad);
390
403
 
404
+ if (result.format === 'module') {
391
405
  if (typeof result.source !== 'string') {
392
406
  throw new Error('Expected source to have been loaded into a string.');
393
407
  }
@@ -399,7 +413,7 @@ async function load(url, context, defaultLoad) {
399
413
  };
400
414
  }
401
415
 
402
- return defaultLoad(url, context, defaultLoad);
416
+ return result;
403
417
  }
404
418
 
405
419
  export { getSource, load, resolve, transformSource };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-server-dom-webpack",
3
3
  "description": "React Server Components bindings for DOM using Webpack. This is intended to be integrated into meta-frameworks. It is not intended to be imported directly.",
4
- "version": "18.3.0-next-6ff1733e6-20230225",
4
+ "version": "18.3.0-next-41110021f-20230301",
5
5
  "keywords": [
6
6
  "react"
7
7
  ],
@@ -78,8 +78,8 @@
78
78
  "node": ">=0.10.0"
79
79
  },
80
80
  "peerDependencies": {
81
- "react": "18.3.0-next-6ff1733e6-20230225",
82
- "react-dom": "18.3.0-next-6ff1733e6-20230225",
81
+ "react": "18.3.0-next-41110021f-20230301",
82
+ "react-dom": "18.3.0-next-41110021f-20230301",
83
83
  "webpack": "^5.59.0"
84
84
  },
85
85
  "dependencies": {