@jsenv/node-esm-resolution
Advanced tools
Comparing version 0.0.10 to 0.1.0
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" |
{ | ||
"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 | ||
} |
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
33959
1267