无路径遍历或无效片段
【No path traversal or invalid segments】
导出目标不得解析到包根目录之外的位置。此外,在 target 字符串的初始 ./ 之后以及替换到目标模式中的任何 subpath 部分中,通常不允许出现像 .(单点)、..(双点)或 node_modules(及其 URL 编码等效项)这样的路径段。
【Export targets must not resolve to a location outside the package's root
directory. Additionally, path segments like . (single dot), .. (double dot),
or node_modules (and their URL-encoded equivalents) are generally disallowed
within the target string after the initial ./ and in any subpath part
substituted into a target pattern.】
// package.json
{
"name": "my-package",
"exports": {
// ".": "./dist/../../elsewhere/file.js", // Invalid: path traversal
// ".": "././dist/main.js", // Invalid: contains "." segment
// ".": "./dist/../dist/main.js", // Invalid: contains ".." segment
// "./utils/./helper.js": "./utils/helper.js" // Key has invalid segment
}
}