Socket
Socket
Sign inDemoInstall

esm-resolve

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esm-resolve - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

24

index.js

@@ -83,2 +83,3 @@ /*

// Importers are actually the same for every file in a directory. Remove the last part.
const importerDir = path.join(path.resolve(importer), '..', path.sep);

@@ -94,3 +95,3 @@

loadSelfPackage() {
const candidatePath = this.#require.resolve.paths('.')?.[0];
let candidatePath = this.#require.resolve.paths('.')?.[0];
if (candidatePath === undefined) {

@@ -100,10 +101,17 @@ return;

let info;
try {
for (;;) {
const selfPackagePath = path.join(candidatePath, 'package.json');
info = JSON.parse(fs.readFileSync(selfPackagePath, 'utf-8'));
} catch (e) {
return;
try {
const info = JSON.parse(fs.readFileSync(selfPackagePath, 'utf-8'));
return { info, resolved: candidatePath };
} catch (e) {
// ignore
}
const next = path.dirname(candidatePath);
if (next === candidatePath) {
return;
}
candidatePath = next;
}
return { info, resolved: candidatePath };
}

@@ -283,2 +291,4 @@

/**
* This is public-visible API of this helper class.
*
* @param {string} importee

@@ -285,0 +295,0 @@ * @return {string=}

{
"name": "esm-resolve",
"version": "1.0.6",
"version": "1.0.7",
"description": "Resolves ESM imports in JS",

@@ -8,4 +8,6 @@ "main": "index.js",

".": {
"import": "./index.js",
"require": "./bundle.cjs"
"node": {
"import": "./index.js",
"require": "./bundle.cjs"
}
}

@@ -12,0 +14,0 @@ },

@@ -26,7 +26,7 @@ [![Tests](https://github.com/samthor/esm-resolve/workflows/Tests/badge.svg)](https://github.com/samthor/esm-resolve/actions)

This implements modern Node resolution, i.e., [subpath exports](https://nodejs.org/api/packages.html#packages_subpath_exports) and [conditional exports](https://nodejs.org/api/packages.html#packages_conditional_exports).
By default, it will rewrite to the "browser", "import" or "default" keys (not "node", as this is for your browser).
By default, it will rewrite to the "browser", "import" or "default" keys (not "node", as it's expected that you'll use this for browser builds).
It fails gracefully in many ways, including falling back to real paths if exports aren't defined.
It fails gracefully in many ways, including falling back to real paths if exports aren't defined.
It will also remove imports that point purely to ".d.ts" files (you don't need to create [peer JS](https://whistlr.info/2021/check-js-with-ts/#import-your-types)).
You can [set these options](./types/external.d.ts) via the resolver's second argument.
You can [configure all these options](./types/external.d.ts) via the resolver's second argument.

@@ -23,3 +23,3 @@ /*

* unspecified, this defaults to ["browser"]. The "imports" key will always be included, and if
* no constraint matches, the "default" key will always be followed.
* no constraint matches, the "default" key will be followed.
*

@@ -26,0 +26,0 @@ * @default ["browser"]

Sorry, the diff of this file is not supported yet

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