esm-resolve
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -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; |
@@ -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. |
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
30886
31
531