@yarnpkg/esbuild-plugin-pnp
Advanced tools
Comparing version 2.0.1 to 3.0.0-rc.1
@@ -29,4 +29,13 @@ "use strict"; | ||
else { | ||
if (path === external) { | ||
if (path === external) | ||
return true; | ||
// If the module "foo" has been marked as external, we also want to treat | ||
// paths into that module such as "foo/bar" as external too. | ||
// References: | ||
// - https://github.com/evanw/esbuild/blob/537195ae84bee1510fac14235906d588084c39cd/internal/resolver/resolver.go#L651-L652 | ||
// - https://github.com/evanw/esbuild/blob/537195ae84bee1510fac14235906d588084c39cd/internal/resolver/resolver.go#L1688-L1691 | ||
if (!external.startsWith(`/`) && !external.startsWith(`./`) && !external.startsWith(`../`) && external !== `.` && external !== `..`) { | ||
if (path.startsWith(`${external}/`)) { | ||
return true; | ||
} | ||
} | ||
@@ -80,3 +89,13 @@ } | ||
const externals = parseExternals((_a = build.initialOptions.external) !== null && _a !== void 0 ? _a : []); | ||
const isPlatformNode = ((_b = build.initialOptions.platform) !== null && _b !== void 0 ? _b : `browser`) === `node`; | ||
const platform = (_b = build.initialOptions.platform) !== null && _b !== void 0 ? _b : `browser`; | ||
const isPlatformNode = platform === `node`; | ||
// Reference: https://github.com/evanw/esbuild/blob/537195ae84bee1510fac14235906d588084c39cd/internal/resolver/resolver.go#L238-L253 | ||
const conditionsDefault = new Set(build.initialOptions.conditions); | ||
conditionsDefault.add(`default`); | ||
if (platform === `browser` || platform === `node`) | ||
conditionsDefault.add(platform); | ||
const conditionsImport = new Set(conditionsDefault); | ||
conditionsImport.add(`import`); | ||
const conditionsRequire = new Set(conditionsDefault); | ||
conditionsRequire.add(`require`); | ||
build.onResolve({ filter }, args => { | ||
@@ -86,2 +105,8 @@ var _a, _b; | ||
return { external: true }; | ||
// Reference: https://github.com/evanw/esbuild/blob/537195ae84bee1510fac14235906d588084c39cd/internal/resolver/resolver.go#L1495-L1502 | ||
let conditions = conditionsDefault; | ||
if (args.kind === `dynamic-import` || args.kind === `import-statement`) | ||
conditions = conditionsImport; | ||
else if (args.kind === `require-call` || args.kind === `require-resolve`) | ||
conditions = conditionsRequire; | ||
// The entry point resolution uses an empty string | ||
@@ -99,2 +124,3 @@ const effectiveImporter = args.importer | ||
path = pnpApi.resolveRequest(args.path, effectiveImporter, { | ||
conditions, | ||
considerBuiltins: isPlatformNode, | ||
@@ -101,0 +127,0 @@ extensions, |
{ | ||
"name": "@yarnpkg/esbuild-plugin-pnp", | ||
"version": "2.0.1", | ||
"version": "3.0.0-rc.1", | ||
"license": "BSD-2-Clause", | ||
@@ -13,3 +13,3 @@ "main": "./lib/index.js", | ||
"devDependencies": { | ||
"@yarnpkg/pnp": "^3.2.0", | ||
"@yarnpkg/pnp": "^4.0.0-rc.1", | ||
"esbuild": "npm:esbuild-wasm@^0.11.20" | ||
@@ -35,5 +35,6 @@ }, | ||
"engines": { | ||
"node": ">=12 <14 || 14.2 - 14.9 || >14.10.0" | ||
"node": ">=14.15.0" | ||
}, | ||
"stableVersion": "2.0.1", | ||
"typings": "./lib/index.d.ts" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9069
165
2