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

@jsenv/node-esm-resolution

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jsenv/node-esm-resolution - npm Package Compare versions

Comparing version 0.0.10 to 0.1.0

5

main.js
export { applyNodeEsmResolution } from "./src/node_esm_resolution.js"
export { determineModuleSystem } from "./src/determine_module_system.js"
export { applyFileSystemMagicResolution } from "./src/filesystem_magic_resolution.js"
export {
applyFileSystemMagicResolution,
getExtensionsToTry,
} from "./src/filesystem_magic_resolution.js"
export { defaultLookupPackageScope } from "./src/default_lookup_package_scope.js"
export { defaultReadPackageJson } from "./src/default_read_package_json.js"
export { readCustomConditionsFromProcessArgs } from "./src/custom_conditions.js"

4

package.json
{
"name": "@jsenv/node-esm-resolution",
"version": "0.0.10",
"version": "0.1.0",
"license": "MIT",

@@ -28,4 +28,4 @@ "repository": {

"scripts": {
"test": "node ./test/test.mjs"
"test": "node --conditions=development ./test/test.mjs"
}
}
import { statSync } from "node:fs"
import { urlToFilename } from "./url_utils.js"
import { urlToFilename, urlToExtension } from "./url_utils.js"

@@ -72,1 +72,17 @@ export const applyFileSystemMagicResolution = (

}
export const getExtensionsToTry = (magicExtensions, importer) => {
if (!magicExtensions) {
return []
}
const extensionsSet = new Set()
magicExtensions.forEach((magicExtension) => {
if (magicExtension === "inherit") {
const importerExtension = urlToExtension(importer)
extensionsSet.add(importerExtension)
} else {
extensionsSet.add(magicExtension)
}
})
return Array.from(extensionsSet.values())
}

@@ -57,1 +57,10 @@ export const asDirectoryUrl = (url) => {

}
export const urlToExtension = (url) => {
const filename = urlToFilename(url)
const dotLastIndex = filename.lastIndexOf(".")
if (dotLastIndex === -1) return ""
// if (dotLastIndex === pathname.length - 1) return ""
const extension = filename.slice(dotLastIndex)
return extension
}
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