next-rsc-error-handler
Advanced tools
Comparing version
{ | ||
"name": "next-rsc-error-handler", | ||
"version": "0.3.4", | ||
"version": "0.4.0", | ||
"description": "Webpack plugin that allow to handle RSC errors on the server side", | ||
@@ -31,4 +31,5 @@ "main": "./src/index.js", | ||
"client-only": "^0.0.1", | ||
"server-only": "^0.0.1" | ||
"server-only": "^0.0.1", | ||
"typescript": "~5.4.5" | ||
} | ||
} |
@@ -5,3 +5,2 @@ import parser from "@babel/parser"; | ||
import * as t from "@babel/types"; | ||
import path from "node:path"; | ||
@@ -15,2 +14,3 @@ import { | ||
} from "./utils.js"; | ||
import { resolveTsAlias } from "./ts-path-alias.js"; | ||
@@ -42,5 +42,10 @@ const WRAPPER_NAME = "__rscWrapper"; | ||
const getImportRelativePath = (p) => { | ||
const val = resolveTsAlias(p.node.source.value); | ||
return getRelativePath(this.utils.absolutify(this.context, val)); | ||
}; | ||
traverse.default(ast, { | ||
ImportDeclaration(p) { | ||
clientComponents.add(getImportRelativePath(resourcePath, p)); | ||
clientComponents.add(getImportRelativePath(p)); | ||
}, | ||
@@ -154,11 +159,3 @@ // TODO add FunctionExpression | ||
function dropExtension(relativePath) { | ||
return relativePath.replace(/\.[^/.]+$/, ""); | ||
return relativePath.replace(/\.[^\/.]+$/, ""); | ||
} | ||
function getImportRelativePath(resourcePath, p) { | ||
return dropExtension( | ||
getRelativePath( | ||
path.resolve(path.dirname(resourcePath), p.node.source.value) | ||
) | ||
); | ||
} |
11453
12.92%9
12.5%325
14.44%7
16.67%+ Added
+ Added