🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

next-rsc-error-handler

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-rsc-error-handler - npm Package Compare versions

Comparing version

to
0.3.1

2

package.json
{
"name": "next-rsc-error-handler",
"version": "0.3.0",
"version": "0.3.1",
"description": "Webpack plugin that allow to handle RSC errors on the server side",

@@ -5,0 +5,0 @@ "main": "./src/index.js",

@@ -29,2 +29,4 @@ import parser from "@babel/parser";

const options = this.getOptions();
const noExtRelativePath = dropExtension(relativePath);

@@ -34,6 +36,2 @@ const isTrulyClientComponent = isClientComponent(source);

if (isTrulyClientComponent || clientComponents.has(noExtRelativePath)) {
if (!isTrulyClientComponent && serverComponents.has(noExtRelativePath)) {
throw new Error(`${relativePath} is used on both client and server`);
}
const ast = parser.parse(source, {

@@ -44,2 +42,4 @@ sourceType: "module",

let hasComponents = false;
traverse.default(ast, {

@@ -49,9 +49,28 @@ ImportDeclaration(p) {

},
// TODO add FunctionExpression
FunctionDeclaration(p) {
const functionName = p.node.id?.name ?? "";
if (options.componentName.test(functionName)) {
hasComponents = true;
}
},
ArrowFunctionExpression(p) {
const functionName = getArrowFunctionName(p);
if (options.componentName.test(functionName)) {
hasComponents = true;
}
},
});
if (
hasComponents &&
!isTrulyClientComponent &&
serverComponents.has(noExtRelativePath)
) {
throw new Error(`${relativePath} is used on both client and server`);
}
return source;
}
const options = this.getOptions();
const ast = parser.parse(source, {

@@ -58,0 +77,0 @@ sourceType: "module",