New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-server-dom-webpack

Package Overview
Dependencies
Maintainers
5
Versions
1459
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-server-dom-webpack - npm Package Compare versions

Comparing version 0.0.0-experimental-71d16750c-20211202 to 0.0.0-experimental-720de7f81a-20241220

cjs/react-server-dom-webpack-client.browser.development.js

100

cjs/react-server-dom-webpack-node-register.js

@@ -1,5 +0,6 @@

/** @license React vundefined
/**
* @license React
* react-server-dom-webpack-node-register.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -12,93 +13,4 @@ * This source code is licensed under the MIT license found in the

'use strict';
var url = require('url'); // $FlowFixMe
var Module = require('module');
module.exports = function register() {
var MODULE_REFERENCE = Symbol.for('react.module.reference');
var proxyHandlers = {
get: function (target, name, receiver) {
switch (name) {
// These names are read by the Flight runtime if you end up using the exports object.
case '$$typeof':
// These names are a little too common. We should probably have a way to
// have the Flight runtime extract the inner target instead.
return target.$$typeof;
case 'filepath':
return target.filepath;
case 'name':
return target.name;
// We need to special case this because createElement reads it if we pass this
// reference.
case 'defaultProps':
return undefined;
case '__esModule':
// Something is conditionally checking which export to use. We'll pretend to be
// an ESM compat module but then we'll check again on the client.
target.default = {
$$typeof: MODULE_REFERENCE,
filepath: target.filepath,
// This a placeholder value that tells the client to conditionally use the
// whole object or just the default export.
name: ''
};
return true;
}
var cachedReference = target[name];
if (!cachedReference) {
cachedReference = target[name] = {
$$typeof: MODULE_REFERENCE,
filepath: target.filepath,
name: name
};
}
return cachedReference;
},
set: function () {
throw new Error('Cannot assign to a client module from a server module.');
}
};
require.extensions['.client.js'] = function (module, path) {
var moduleId = url.pathToFileURL(path).href;
var moduleReference = {
$$typeof: MODULE_REFERENCE,
filepath: moduleId,
name: '*' // Represents the whole object instead of a particular import.
};
module.exports = new Proxy(moduleReference, proxyHandlers);
};
var originalResolveFilename = Module._resolveFilename;
Module._resolveFilename = function (request, parent, isMain, options) {
var resolved = originalResolveFilename.apply(this, arguments);
if (resolved.endsWith('.server.js')) {
if (parent && parent.filename && !parent.filename.endsWith('.server.js')) {
var reason;
if (request.endsWith('.server.js')) {
reason = "\"" + request + "\"";
} else {
reason = "\"" + request + "\" (which expands to \"" + resolved + "\")";
}
throw new Error("Cannot import " + reason + " from \"" + parent.filename + "\". " + 'By react-server convention, .server.js files can only be imported from other .server.js files. ' + 'That way nobody accidentally sends these to the client by indirectly importing it.');
}
}
return resolved;
};
};
'use strict';const h=require("acorn-loose"),l=require("url"),q=require("module");
module.exports=function(){const m=require("react-server-dom-webpack/server"),n=m.registerServerReference,r=m.createClientModuleProxy,f=q.prototype._compile;q.prototype._compile=function(k,p){if(-1===k.indexOf("use client")&&-1===k.indexOf("use server"))return f.apply(this,arguments);try{var a=h.parse(k,{ecmaVersion:"2024",sourceType:"source"}).body}catch(g){return console.error("Error parsing %s %s",l,g.message),f.apply(this,arguments)}var b=!1,d=!1;for(var c=0;c<a.length;c++){var e=a[c];if("ExpressionStatement"!==
e.type||!e.directive)break;"use client"===e.directive&&(b=!0);"use server"===e.directive&&(d=!0)}if(!b&&!d)return f.apply(this,arguments);if(b&&d)throw Error('Cannot have both "use client" and "use server" directives in the same file.');b&&(a=l.pathToFileURL(p).href,this.exports=r(a));if(d)if(f.apply(this,arguments),d=l.pathToFileURL(p).href,a=this.exports,"function"===typeof a)n(a,d,null);else for(b=Object.keys(a),c=0;c<b.length;c++){e=b[c];const g=a[b[c]];"function"===typeof g&&n(g,d,e)}}};

@@ -1,5 +0,6 @@

/** @license React vundefined
/**
* @license React
* react-server-dom-webpack-plugin.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -12,240 +13,14 @@ * This source code is licensed under the MIT license found in the

'use strict';
var path = require('path');
var url = require('url');
var asyncLib = require('neo-async');
var ModuleDependency = require('webpack/lib/dependencies/ModuleDependency');
var NullDependency = require('webpack/lib/dependencies/NullDependency');
var Template = require('webpack/lib/Template');
var webpack = require('webpack');
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
function isArray(a) {
return isArrayImpl(a);
}
class ClientReferenceDependency extends ModuleDependency {
constructor(request) {
super(request);
}
get type() {
return 'client-reference';
}
} // This is the module that will be used to anchor all client references to.
// I.e. it will have all the client files as async deps from this point on.
// We use the Flight client implementation because you can't get to these
// without the client runtime so it's the first time in the loading sequence
// you might want them.
var clientImportName = 'react-server-dom-webpack';
var clientFileName = require.resolve('../');
var PLUGIN_NAME = 'React Server Plugin';
class ReactFlightWebpackPlugin {
constructor(options) {
if (!options || typeof options.isServer !== 'boolean') {
throw new Error(PLUGIN_NAME + ': You must specify the isServer option as a boolean.');
}
if (options.isServer) {
throw new Error('TODO: Implement the server compiler.');
}
if (!options.clientReferences) {
this.clientReferences = [{
directory: '.',
recursive: true,
include: /\.client\.(js|ts|jsx|tsx)$/
}];
} else if (typeof options.clientReferences === 'string' || !isArray(options.clientReferences)) {
this.clientReferences = [options.clientReferences];
} else {
this.clientReferences = options.clientReferences;
}
if (typeof options.chunkName === 'string') {
this.chunkName = options.chunkName;
if (!/\[(index|request)\]/.test(this.chunkName)) {
this.chunkName += '[index]';
}
} else {
this.chunkName = 'client[index]';
}
this.manifestFilename = options.manifestFilename || 'react-client-manifest.json';
}
apply(compiler) {
var _this = this;
var resolvedClientReferences;
var clientFileNameFound = false; // Find all client files on the file system
compiler.hooks.beforeCompile.tapAsync(PLUGIN_NAME, function (_ref, callback) {
var contextModuleFactory = _ref.contextModuleFactory;
var contextResolver = compiler.resolverFactory.get('context', {});
_this.resolveAllClientFiles(compiler.context, contextResolver, compiler.inputFileSystem, contextModuleFactory, function (err, resolvedClientRefs) {
if (err) {
callback(err);
return;
}
resolvedClientReferences = resolvedClientRefs;
callback();
});
});
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, function (compilation, _ref2) {
var normalModuleFactory = _ref2.normalModuleFactory;
compilation.dependencyFactories.set(ClientReferenceDependency, normalModuleFactory);
compilation.dependencyTemplates.set(ClientReferenceDependency, new NullDependency.Template());
var handler = function (parser) {
// We need to add all client references as dependency of something in the graph so
// Webpack knows which entries need to know about the relevant chunks and include the
// map in their runtime. The things that actually resolves the dependency is the Flight
// client runtime. So we add them as a dependency of the Flight client runtime.
// Anything that imports the runtime will be made aware of these chunks.
parser.hooks.program.tap(PLUGIN_NAME, function () {
var module = parser.state.module;
if (module.resource !== clientFileName) {
return;
}
clientFileNameFound = true;
if (resolvedClientReferences) {
for (var i = 0; i < resolvedClientReferences.length; i++) {
var dep = resolvedClientReferences[i];
var chunkName = _this.chunkName.replace(/\[index\]/g, '' + i).replace(/\[request\]/g, Template.toPath(dep.userRequest));
var block = new webpack.AsyncDependenciesBlock({
name: chunkName
}, null, dep.request);
block.addDependency(dep);
module.addBlock(block);
}
}
});
};
normalModuleFactory.hooks.parser.for('javascript/auto').tap('HarmonyModulesPlugin', handler);
normalModuleFactory.hooks.parser.for('javascript/esm').tap('HarmonyModulesPlugin', handler);
normalModuleFactory.hooks.parser.for('javascript/dynamic').tap('HarmonyModulesPlugin', handler);
});
compiler.hooks.make.tap(PLUGIN_NAME, function (compilation) {
compilation.hooks.processAssets.tap({
name: PLUGIN_NAME,
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT
}, function () {
if (clientFileNameFound === false) {
compilation.warnings.push(new webpack.WebpackError("Client runtime at " + clientImportName + " was not found. React Server Components module map file " + _this.manifestFilename + " was not created."));
return;
}
var json = {};
compilation.chunkGroups.forEach(function (chunkGroup) {
var chunkIds = chunkGroup.chunks.map(function (c) {
return c.id;
});
function recordModule(id, module) {
// TODO: Hook into deps instead of the target module.
// That way we know by the type of dep whether to include.
// It also resolves conflicts when the same module is in multiple chunks.
if (!/\.client\.(js|ts)x?$/.test(module.resource)) {
return;
}
var moduleProvidedExports = compilation.moduleGraph.getExportsInfo(module).getProvidedExports();
var moduleExports = {};
['', '*'].concat(Array.isArray(moduleProvidedExports) ? moduleProvidedExports : []).forEach(function (name) {
moduleExports[name] = {
id: id,
chunks: chunkIds,
name: name
};
});
var href = url.pathToFileURL(module.resource).href;
if (href !== undefined) {
json[href] = moduleExports;
}
}
chunkGroup.chunks.forEach(function (chunk) {
var chunkModules = compilation.chunkGraph.getChunkModulesIterable(chunk);
Array.from(chunkModules).forEach(function (module) {
var moduleId = compilation.chunkGraph.getModuleId(module);
recordModule(moduleId, module); // If this is a concatenation, register each child to the parent ID.
if (module.modules) {
module.modules.forEach(function (concatenatedMod) {
recordModule(moduleId, concatenatedMod);
});
}
});
});
});
var output = JSON.stringify(json, null, 2);
compilation.emitAsset(_this.manifestFilename, new webpack.sources.RawSource(output, false));
});
});
} // This attempts to replicate the dynamic file path resolution used for other wildcard
// resolution in Webpack is using.
resolveAllClientFiles(context, contextResolver, fs, contextModuleFactory, callback) {
asyncLib.map(this.clientReferences, function (clientReferencePath, cb) {
if (typeof clientReferencePath === 'string') {
cb(null, [new ClientReferenceDependency(clientReferencePath)]);
return;
}
var clientReferenceSearch = clientReferencePath;
contextResolver.resolve({}, context, clientReferencePath.directory, {}, function (err, resolvedDirectory) {
if (err) return cb(err);
var options = {
resource: resolvedDirectory,
resourceQuery: '',
recursive: clientReferenceSearch.recursive === undefined ? true : clientReferenceSearch.recursive,
regExp: clientReferenceSearch.include,
include: undefined,
exclude: clientReferenceSearch.exclude
};
contextModuleFactory.resolveDependencies(fs, options, function (err2, deps) {
if (err2) return cb(err2);
var clientRefDeps = deps.map(function (dep) {
// use userRequest instead of request. request always end with undefined which is wrong
var request = path.join(resolvedDirectory, dep.userRequest);
var clientRefDep = new ClientReferenceDependency(request);
clientRefDep.userRequest = dep.userRequest;
return clientRefDep;
});
cb(null, clientRefDeps);
});
});
}, function (err, result) {
if (err) return callback(err);
var flat = [];
for (var i = 0; i < result.length; i++) {
flat.push.apply(flat, result[i]);
}
callback(null, flat);
});
}
}
module.exports = ReactFlightWebpackPlugin;
'use strict';var w=require("path"),x=require("url"),y=require("neo-async"),z=require("acorn-loose"),B=require("webpack/lib/dependencies/ModuleDependency"),C=require("webpack/lib/dependencies/NullDependency"),D=require("webpack/lib/Template"),E=require("webpack");
function F(a,g){if(a){if("string"===typeof a)return G(a,g);var c=Object.prototype.toString.call(a).slice(8,-1);"Object"===c&&a.constructor&&(c=a.constructor.name);if("Map"===c||"Set"===c)return Array.from(a);if("Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c))return G(a,g)}}function G(a,g){if(null==g||g>a.length)g=a.length;for(var c=0,n=Array(g);c<g;c++)n[c]=a[c];return n}
function H(a,g){var c;if("undefined"===typeof Symbol||null==a[Symbol.iterator]){if(Array.isArray(a)||(c=F(a))||g&&a&&"number"===typeof a.length){c&&(a=c);var n=0;g=function(){};return{s:g,n:function(){return n>=a.length?{done:!0}:{done:!1,value:a[n++]}},e:function(b){throw b;},f:g}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var d=!0,e=!1,p;return{s:function(){c=a[Symbol.iterator]()},
n:function(){var b=c.next();d=b.done;return b},e:function(b){e=!0;p=b},f:function(){try{d||null==c.return||c.return()}finally{if(e)throw p;}}}}const I=Array.isArray;class J extends B{constructor(a){super(a)}get type(){return"client-reference"}}const K=require.resolve("../client.browser.js");
class L{constructor(a){this.ssrManifestFilename=this.clientManifestFilename=this.chunkName=this.clientReferences=void 0;if(!a||"boolean"!==typeof a.isServer)throw Error("React Server Plugin: You must specify the isServer option as a boolean.");if(a.isServer)throw Error("TODO: Implement the server compiler.");a.clientReferences?"string"!==typeof a.clientReferences&&I(a.clientReferences)?this.clientReferences=a.clientReferences:this.clientReferences=[a.clientReferences]:this.clientReferences=[{directory:".",
recursive:!0,include:/\.(js|ts|jsx|tsx)$/}];"string"===typeof a.chunkName?(this.chunkName=a.chunkName,/\[(index|request)\]/.test(this.chunkName)||(this.chunkName+="[index]")):this.chunkName="client[index]";this.clientManifestFilename=a.clientManifestFilename||"react-client-manifest.json";this.ssrManifestFilename=a.ssrManifestFilename||"react-ssr-manifest.json"}apply(a){const g=this;let c,n=!1;a.hooks.beforeCompile.tapAsync("React Server Plugin",(d,e)=>{d=d.contextModuleFactory;const p=a.resolverFactory.get("context",
{}),b=a.resolverFactory.get("normal");g.resolveAllClientFiles(a.context,p,b,a.inputFileSystem,d,function(f,h){f?e(f):(c=h,e())})});a.hooks.thisCompilation.tap("React Server Plugin",(d,e)=>{e=e.normalModuleFactory;d.dependencyFactories.set(J,e);d.dependencyTemplates.set(J,new C.Template);d=p=>{p.hooks.program.tap("React Server Plugin",()=>{const b=p.state.module;if(b.resource===K&&(n=!0,c))for(let h=0;h<c.length;h++){const t=c[h];var f=g.chunkName.replace(/\[index\]/g,""+h).replace(/\[request\]/g,
D.toPath(t.userRequest));f=new E.AsyncDependenciesBlock({name:f},null,t.request);f.addDependency(t);b.addBlock(f)}})};e.hooks.parser.for("javascript/auto").tap("HarmonyModulesPlugin",d);e.hooks.parser.for("javascript/esm").tap("HarmonyModulesPlugin",d);e.hooks.parser.for("javascript/dynamic").tap("HarmonyModulesPlugin",d)});a.hooks.make.tap("React Server Plugin",d=>{d.hooks.processAssets.tap({name:"React Server Plugin",stage:E.Compilation.PROCESS_ASSETS_STAGE_REPORT},function(){if(!1===n)d.warnings.push(new E.WebpackError("Client runtime at react-server-dom-webpack/client was not found. React Server Components module map file "+
g.clientManifestFilename+" was not created."));else{var e=d.outputOptions.crossOriginLoading;e="string"===typeof e?"use-credentials"===e?e:"anonymous":null;var p=new Set((c||[]).map(m=>m.request)),b={},f={};e={moduleLoading:{prefix:d.outputOptions.publicPath||"",crossOrigin:e},moduleMap:f};var h=new Set;d.entrypoints.forEach(m=>{(m=m.getRuntimeChunk())&&m.files.forEach(v=>{h.add(v)})});d.chunkGroups.forEach(function(m){function v(k,l){if(p.has(l.resource)&&(l=x.pathToFileURL(l.resource).href,void 0!==
l)){const q={};b[l]={id:k,chunks:u,name:"*"};q["*"]={specifier:l,name:"*"};f[k]=q}}const u=[];m.chunks.forEach(function(k){var l=H(k.files),q;try{for(l.s();!(q=l.n()).done;){const r=q.value;if(!r.endsWith(".js"))break;if(r.endsWith(".hot-update.js"))break;u.push(k.id,r);break}}catch(r){l.e(r)}finally{l.f()}});m.chunks.forEach(function(k){k=d.chunkGraph.getChunkModulesIterable(k);Array.from(k).forEach(function(l){const q=d.chunkGraph.getModuleId(l);v(q,l);l.modules&&l.modules.forEach(r=>{v(q,r)})})})});
var t=JSON.stringify(b,null,2);d.emitAsset(g.clientManifestFilename,new E.sources.RawSource(t,!1));e=JSON.stringify(e,null,2);d.emitAsset(g.ssrManifestFilename,new E.sources.RawSource(e,!1))}})})}resolveAllClientFiles(a,g,c,n,d,e){function p(b){if(-1===b.indexOf("use client"))return!1;let f;try{f=z.parse(b,{ecmaVersion:"2024",sourceType:"module"}).body}catch(h){return!1}for(b=0;b<f.length;b++){const h=f[b];if("ExpressionStatement"!==h.type||!h.directive)break;if("use client"===h.directive)return!0}return!1}
y.map(this.clientReferences,(b,f)=>{"string"===typeof b?f(null,[new J(b)]):g.resolve({},a,b.directory,{},(h,t)=>{if(h)return f(h);d.resolveDependencies(n,{resource:t,resourceQuery:"",recursive:void 0===b.recursive?!0:b.recursive,regExp:b.include,include:void 0,exclude:b.exclude},(m,v)=>{if(m)return f(m);m=v.map(u=>{var k=w.join(t,u.userRequest);k=new J(k);k.userRequest=u.userRequest;return k});y.filter(m,(u,k)=>{c.resolve({},a,u.request,{},(l,q)=>{if(l||"string"!==typeof q)return k(null,!1);n.readFile(q,
"utf-8",(r,A)=>{if(r||"string"!==typeof A)return k(null,!1);r=p(A);k(null,r)})})},f)})})},(b,f)=>{if(b)return e(b);b=[];for(let h=0;h<f.length;h++)b.push.apply(b,f[h]);e(null,b)})}}module.exports=L;

@@ -0,7 +1,12 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-server-dom-webpack.production.min.js');
} else {
module.exports = require('./cjs/react-server-dom-webpack.development.js');
}
throw new Error('Use react-server-dom-webpack/client instead.');
{
"name": "react-server-dom-webpack",
"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.",
"version": "0.0.0-experimental-71d16750c-20211202",
"version": "0.0.0-experimental-720de7f81a-20241220",
"keywords": [

@@ -14,8 +14,14 @@ "react"

"README.md",
"build-info.json",
"index.js",
"plugin.js",
"writer.js",
"writer.browser.server.js",
"writer.node.server.js",
"client.js",
"client.browser.js",
"client.edge.js",
"client.node.js",
"client.node.unbundled.js",
"server.js",
"server.browser.js",
"server.edge.js",
"server.node.js",
"server.node.unbundled.js",
"node-register.js",

@@ -29,12 +35,36 @@ "cjs/",

"./plugin": "./plugin.js",
"./writer": {
"./client": {
"workerd": "./client.edge.js",
"deno": "./client.edge.js",
"worker": "./client.edge.js",
"node": {
"webpack": "./client.node.js",
"default": "./client.node.unbundled.js"
},
"edge-light": "./client.edge.js",
"browser": "./client.browser.js",
"default": "./client.browser.js"
},
"./client.browser": "./client.browser.js",
"./client.edge": "./client.edge.js",
"./client.node": "./client.node.js",
"./client.node.unbundled": "./client.node.unbundled.js",
"./server": {
"react-server": {
"node": "./writer.node.server.js",
"browser": "./writer.browser.server.js"
"workerd": "./server.edge.js",
"deno": "./server.browser.js",
"node": {
"webpack": "./server.node.js",
"default": "./server.node.unbundled.js"
},
"edge-light": "./server.edge.js",
"browser": "./server.browser.js"
},
"default": "./writer.js"
"default": "./server.js"
},
"./writer.node.server": "./writer.node.server.js",
"./writer.browser.server": "./writer.browser.server.js",
"./node-loader": "./esm/react-server-dom-webpack-node-loader.js",
"./server.browser": "./server.browser.js",
"./server.edge": "./server.edge.js",
"./server.node": "./server.node.js",
"./server.node.unbundled": "./server.node.unbundled.js",
"./node-loader": "./esm/react-server-dom-webpack-node-loader.production.min.js",
"./node-register": "./node-register.js",

@@ -53,11 +83,10 @@ "./package.json": "./package.json"

"peerDependencies": {
"react": "0.0.0-experimental-71d16750c-20211202",
"react-dom": "0.0.0-experimental-71d16750c-20211202",
"react": "0.0.0-experimental-720de7f81a-20241220",
"react-dom": "0.0.0-experimental-720de7f81a-20241220",
"webpack": "^5.59.0"
},
"dependencies": {
"acorn": "^6.2.1",
"acorn-loose": "^8.3.0",
"neo-async": "^2.6.1",
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1"
"loose-envify": "^1.1.0"
},

@@ -64,0 +93,0 @@ "browserify": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc