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.1 to 1.0.2

5

index.d.ts

@@ -20,5 +20,4 @@ /*

/**
* Builds a resolver for files in the specified directory (which may be relative and is resolved
* relative to the current working directory).
* Builds an import resolver for the given importer file.
*/
export default function buildResolver(importerDir: string, options?: Partial<types.ResolverOptions>): (importer: string) => string|undefined;
export default function buildResolver(importer: string, options?: Partial<types.ResolverOptions>): (importer: string) => string|undefined;

6

index.js

@@ -319,9 +319,9 @@ /*

/**
* @param {string} importerDir
* @param {string} importer
* @param {Partial<types.ResolverOptions>=} options
* @return {(importee: string) => string|undefined}
*/
export default function buildResolver(importerDir, options) {
export default function buildResolver(importer, options) {
let handler = (importee) => {
const r = new Resolver(importerDir, options);
const r = new Resolver(importer, options);
handler = r.resolve.bind(r);

@@ -328,0 +328,0 @@ return handler(importee);

{
"name": "esm-resolve",
"version": "1.0.1",
"version": "1.0.2",
"description": "Resolves ESM imports in JS",

@@ -16,3 +16,4 @@ "main": "index.js",

"author": "Sam Thorogood <sam.thorogood@gmail.com>",
"license": "Apache-2.0",
"repository": "git@github.com:samthor/esm-resolve.git",
"license": "Apache-2",
"devDependencies": {

@@ -19,0 +20,0 @@ "@types/node": "^14.14.25",

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

This is written to be part of an [ESM dev server](https://github.com/samthor/dhost) or build process, as Node's import process is impossible to introspect.
It's also more permissive towards error cases and the default behavior of TypeScript (and therefore VSCode).
It also allows some cases which would otherwise be failures.

@@ -24,4 +24,10 @@ ## Usage

### Options
## Notes
You can [set options](./types/external.d.ts) via the second argument.
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).
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.
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