Socket
Socket
Sign inDemoInstall

@yarnpkg/esbuild-plugin-pnp

Package Overview
Dependencies
Maintainers
6
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yarnpkg/esbuild-plugin-pnp - npm Package Compare versions

Comparing version 1.0.0-rc.2 to 1.0.0-rc.3

7

lib/index.d.ts
import type { OnLoadArgs, OnLoadResult, OnResolveArgs, OnResolveResult, Plugin } from 'esbuild';
declare type OnResolveParams = {
resolvedPath: string | null;
error?: Error;
};
export declare type PluginOptions = {

@@ -6,5 +10,6 @@ baseDir?: string;

filter?: RegExp;
onResolve?: (args: OnResolveArgs, resolvedPath: string | null) => Promise<OnResolveResult | null>;
onResolve?: (args: OnResolveArgs, params: OnResolveParams) => Promise<OnResolveResult | null>;
onLoad?: (args: OnLoadArgs) => Promise<OnLoadResult>;
};
export declare function pnpPlugin({ baseDir, extensions, filter, onResolve, onLoad, }?: PluginOptions): Plugin;
export {};

@@ -5,3 +5,3 @@ "use strict";

const tslib_1 = require("tslib");
const fs = (0, tslib_1.__importStar)(require("fs"));
const fs = tslib_1.__importStar(require("fs"));
const matchAll = /()/;

@@ -15,3 +15,23 @@ const defaultExtensions = [`.tsx`, `.ts`, `.jsx`, `.mjs`, `.cjs`, `.js`, `.css`, `.json`];

}
async function defaultOnResolve(args, resolvedPath) {
async function defaultOnResolve(args, { resolvedPath, error }) {
const problems = error ? [{ text: error.message }] : [];
// Sometimes dynamic resolve calls might be wrapped in a try / catch,
// but ESBuild neither skips them nor does it provide a way for us to tell.
// Because of that, we downgrade all errors to warnings in these situations.
// Issue: https://github.com/evanw/esbuild/issues/1127
let mergeWith;
switch (args.kind) {
case `require-call`:
case `require-resolve`:
case `dynamic-import`:
{
mergeWith = { warnings: problems };
}
break;
default:
{
mergeWith = { errors: problems };
}
break;
}
if (resolvedPath !== null) {

@@ -21,3 +41,3 @@ return { namespace: `pnp`, path: resolvedPath };

else {
return { external: true };
return { external: true, ...mergeWith };
}

@@ -41,7 +61,14 @@ }

return undefined;
const path = pnpApi.resolveRequest(args.path, effectiveImporter, {
considerBuiltins: true,
extensions,
});
return onResolve(args, path);
let path = null;
let error;
try {
path = pnpApi.resolveRequest(args.path, effectiveImporter, {
considerBuiltins: true,
extensions,
});
}
catch (e) {
error = e;
}
return onResolve(args, { resolvedPath: path, error });
});

@@ -48,0 +75,0 @@ // We register on the build to prevent ESBuild from reading the files

14

package.json
{
"name": "@yarnpkg/esbuild-plugin-pnp",
"version": "1.0.0-rc.2",
"version": "1.0.0-rc.3",
"license": "BSD-2-Clause",

@@ -10,7 +10,7 @@ "main": "./lib/index.js",

"peerDependencies": {
"esbuild": "^0.8.36"
"esbuild": ">=0.8.36"
},
"devDependencies": {
"@yarnpkg/pnp": "^3.0.0-rc.2",
"esbuild": "npm:esbuild-wasm@^0.8.36"
"@yarnpkg/pnp": "3.0.0-rc.3",
"esbuild": "npm:esbuild-wasm@^0.11.20"
},

@@ -36,7 +36,7 @@ "scripts": {

"engines": {
"node": ">=10.19.0"
"node": ">=12 <14 || 14.2 - 14.9 || >14.10.0"
},
"stableVersion": "0.0.1",
"bin": "./lib/cli.js",
"typings": "./lib/index.d.ts"
"typings": "./lib/index.d.ts",
"bin": "./lib/cli.js"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc