@yarnpkg/esbuild-plugin-pnp
Advanced tools
Comparing version 1.0.0-rc.5 to 1.0.0-rc.6
@@ -8,2 +8,30 @@ "use strict"; | ||
const defaultExtensions = [`.tsx`, `.ts`, `.jsx`, `.mjs`, `.cjs`, `.js`, `.css`, `.json`]; | ||
// Reference: https://github.com/evanw/esbuild/blob/537195ae84bee1510fac14235906d588084c39cd/pkg/api/api_impl.go#L366-L388 | ||
function parseExternals(externals) { | ||
return externals.map(external => { | ||
// ESBuild's validation pass runs before this function is called so there's no need to assert that there's a single wildcard | ||
const wildcardIdx = external.indexOf(`*`); | ||
if (wildcardIdx !== -1) | ||
return { prefix: external.slice(0, wildcardIdx), suffix: external.slice(wildcardIdx + 1) }; | ||
return external; | ||
}); | ||
} | ||
function isExternal(path, externals) { | ||
for (const external of externals) { | ||
if (typeof external === `object`) { | ||
// Reference: https://github.com/evanw/esbuild/blob/537195ae84bee1510fac14235906d588084c39cd/internal/resolver/resolver.go#L372-L381 | ||
if (path.length >= external.prefix.length + external.suffix.length | ||
&& path.startsWith(external.prefix) | ||
&& path.endsWith(external.suffix)) { | ||
return true; | ||
} | ||
} | ||
else { | ||
if (path === external) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
async function defaultOnLoad(args) { | ||
@@ -47,6 +75,10 @@ return { | ||
setup(build) { | ||
var _a; | ||
const { findPnpApi } = require(`module`); | ||
if (typeof findPnpApi === `undefined`) | ||
return; | ||
const externals = parseExternals((_a = build.initialOptions.external) !== null && _a !== void 0 ? _a : []); | ||
build.onResolve({ filter }, args => { | ||
if (isExternal(args.path, externals)) | ||
return { external: true }; | ||
// The entry point resolution uses an empty string | ||
@@ -53,0 +85,0 @@ const effectiveImporter = args.importer |
{ | ||
"name": "@yarnpkg/esbuild-plugin-pnp", | ||
"version": "1.0.0-rc.5", | ||
"version": "1.0.0-rc.6", | ||
"license": "BSD-2-Clause", | ||
@@ -13,3 +13,3 @@ "main": "./lib/index.js", | ||
"devDependencies": { | ||
"@yarnpkg/pnp": "3.0.0-rc.5", | ||
"@yarnpkg/pnp": "3.0.0-rc.6", | ||
"esbuild": "npm:esbuild-wasm@^0.11.20" | ||
@@ -16,0 +16,0 @@ }, |
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
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
6401
126