@yarnpkg/esbuild-plugin-pnp
Advanced tools
Comparing version 1.0.1-rc.8 to 2.0.0-rc.1
import type { OnLoadArgs, OnLoadResult, OnResolveArgs, OnResolveResult, Plugin } from 'esbuild'; | ||
declare type OnResolveParams = { | ||
resolvedPath: string | null; | ||
watchFiles: Array<string>; | ||
error?: Error; | ||
@@ -5,0 +6,0 @@ }; |
@@ -42,3 +42,3 @@ "use strict"; | ||
} | ||
async function defaultOnResolve(args, { resolvedPath, error }) { | ||
async function defaultOnResolve(args, { resolvedPath, error, watchFiles }) { | ||
const problems = error ? [{ text: error.message }] : []; | ||
@@ -65,6 +65,6 @@ // Sometimes dynamic resolve calls might be wrapped in a try / catch, | ||
if (resolvedPath !== null) { | ||
return { namespace: `pnp`, path: resolvedPath }; | ||
return { namespace: `pnp`, path: resolvedPath, watchFiles }; | ||
} | ||
else { | ||
return { external: true, ...mergeWith }; | ||
return { external: true, ...mergeWith, watchFiles }; | ||
} | ||
@@ -82,2 +82,3 @@ } | ||
build.onResolve({ filter }, args => { | ||
var _a, _b; | ||
if (isExternal(args.path, externals)) | ||
@@ -104,3 +105,13 @@ return { external: true }; | ||
} | ||
return onResolve(args, { resolvedPath: path, error }); | ||
const watchFiles = [pnpApi.resolveRequest(`pnpapi`, null)]; | ||
if (path) { | ||
const locator = pnpApi.findPackageLocator(path); | ||
if (locator) { | ||
const info = pnpApi.getPackageInformation(locator); | ||
if ((info === null || info === void 0 ? void 0 : info.linkType) === `SOFT`) { | ||
watchFiles.push((_b = (_a = pnpApi.resolveVirtual) === null || _a === void 0 ? void 0 : _a.call(pnpApi, path)) !== null && _b !== void 0 ? _b : path); | ||
} | ||
} | ||
} | ||
return onResolve(args, { resolvedPath: path, error, watchFiles }); | ||
}); | ||
@@ -107,0 +118,0 @@ // We register on the build to prevent ESBuild from reading the files |
{ | ||
"name": "@yarnpkg/esbuild-plugin-pnp", | ||
"version": "1.0.1-rc.8", | ||
"version": "2.0.0-rc.1", | ||
"license": "BSD-2-Clause", | ||
@@ -10,6 +10,6 @@ "main": "./lib/index.js", | ||
"peerDependencies": { | ||
"esbuild": ">=0.8.36" | ||
"esbuild": ">=0.10.0" | ||
}, | ||
"devDependencies": { | ||
"@yarnpkg/pnp": "^3.1.0-rc.4", | ||
"@yarnpkg/pnp": "^3.1.0-rc.5", | ||
"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
7137
138