Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

resolvewithplus

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resolvewithplus - npm Package Compare versions

Comparing version 0.8.5 to 0.8.7

resolvewithplus.js

12

package.json
{
"name": "resolvewithplus",
"version": "0.8.5",
"version": "0.8.7",
"engines": {
"node": ">=12.16.0"
},
"license": "ISC",
"main": "resolvewithplus.mjs",
"main": "resolvewithplus.js",
"exports": {
"import": "./resolvewithplus.js"
},
"readmeFilename": "README.md",

@@ -10,3 +16,3 @@ "description": "resolvewith with extra power",

"files": [
"resolvewithplus.mjs"
"resolvewithplus.js"
],

@@ -13,0 +19,0 @@ "repository": {

resolvewithplus
===============
[![npm version](https://badge.fury.io/js/resolvewithplus.svg)](https://badge.fury.io/js/resolvewithplus) [![Build Status](https://github.com/iambumblehead/resolvewithplus/workflows/nodejs-ci/badge.svg)][2][[![install size](https://packagephobia.now.sh/badge?p=resolvewithplus)](https://packagephobia.now.sh/result?p=resolvewithplus)
![npm](https://img.shields.io/npm/v/resolvewithplus) ![Build Status](https://github.com/iambumblehead/resolvewithplus/workflows/nodejs-ci/badge.svg) [![install size](https://packagephobia.now.sh/badge?p=resolvewithplus)](https://packagephobia.now.sh/result?p=resolvewithplus)
_resolvewithplus_ iterates on the _resolvewith_ package for resolving CJS modules following [the original node.js spec.][2] _resolvewithplus_ is changed to an ESM module and adds support for ESM `import 'name'` resolutions.
When a package exports both ESM and CJS, `resolvewithplus` returns the ESM path (tries to). Resolving ESM paths is complex and ESM support will be lacking for edge-cases.
```javascript
// ESM paths are returned by default rather than CJS paths
resolvewithplus('koa', '/Users/bumble/resolvewith/test/');
// '/Users/bumble/resolvewith/node_modules/koa/dist/koa.mjs'
resolvewithplus('koa', '/root/resolvewith/test/')
// '/root/resolvewith/node_modules/koa/dist/koa.mjs'
```
// A CJS path is returned when the ESM path is not found
resolvewithplus('./testfiles/testscript.js', '/Users/bumble/resolvewith/test/')
// '/Users/bumble/resolvewith/test/testfiles/testscript.js'
`resolvewithplus` resolves module paths à la [node.js' import.meta.resolve function][33] and the [import-meta-resolve npm package.][35] It exists mostly to be small and to resolve module paths for `esmock`. [It's size is ~6kB][36] compared to [import-meta-resolve's ~182kB size.][37] For more details, [see the wiki.](https://github.com/iambumblehead/resolvewithplus/wiki)
// use the older 'resolvewith' package to resolve CJS paths
resolvewith('koa', '/Users/bumble/resolvewith/test/');
// '/Users/bumble/resolvewith/node_modules/koa/lib/application.js'
```
![scrounge](https://github.com/iambumblehead/scroungejs/raw/master/img/hand.png)
_resolvewithplus_ caches and reuse results it generates. The first call follows rules to locate the file. Subsequent calls using the values return reults from a key store.
[33]: https://nodejs.org/api/esm.html#importmetaresolvespecifier-parent
[35]: https://www.npmjs.com/package/import-meta-resolve
[36]: https://packagephobia.com/result?p=resolvewithplus
[37]: https://packagephobia.com/result?p=import-meta-resolve
[39]: https://github.com/iambumblehead/resolvewithplus
[1]: https://github.com/iambumblehead/resolvewith/blob/master/src/resolvewith.js
[2]: https://nodejs.org/api/modules.html#modules_module_require_id
![scrounge](https://github.com/iambumblehead/scroungejs/raw/master/img/hand.png)
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