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

extensionless

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extensionless - npm Package Compare versions

Comparing version 1.8.0 to 1.8.1

2

package.json
{
"name": "extensionless",
"version": "1.8.0",
"version": "1.8.1",
"type": "module",

@@ -5,0 +5,0 @@ "exports": {

@@ -25,5 +25,5 @@ import {readFile} from 'fs/promises'

lookFor: ['js']
}, {
}, pkgJson = await getPkgJson(argv1), {
lookFor
} = {...defaults, ...(await getPkgJson(argv1))?.extensionless}
} = {...defaults, ...pkgJson?.extensionless}

@@ -34,3 +34,3 @@ Array.isArray(lookFor) && lookFor.length && lookFor.every(a => typeof a === 'string' && /^[a-z]\w*$/i.test(a)) || (

return {lookFor}
return {lookFor, imports: pkgJson?.imports ?? {}}
}

@@ -11,33 +11,33 @@ import {extname} from 'path'

let indexFiles, candidates
let indexFiles, candidates, aliases
export async function initialize(data) {
let {lookFor} = await getConfig(data)
let {lookFor, imports} = await getConfig(data)
indexFiles = [lookFor.map(e => `index.${e}`), ['index.json']]
candidates = indexFiles.map(i => i.map(f => extname(f)).concat(i.map(f => `/${f}`)))
aliases = Object.entries(imports).map(([k, v]) => [k.split('*'), (v.node ?? v.default ?? v).split('*')])
}
let winAbsPath = /^[/\\]?[a-z]:[/\\]/i, relSpecs = ['.', '..']
let specStarts = ['./', '../', '/', '#', 'file://', 'https://', '.\\', '..\\', '\\']
let specStarts = ['./', '../', '/', 'file://', 'https://', '.\\', '..\\', '\\']
let knownExts = ['.js', '.cjs', '.mjs', '.json', '.node', '.wasm'], empty = [[], []]
export async function resolve(specifier, context, nextResolve) {
let prefix = winAbsPath.test(specifier) ? 'file://' : ''
let alias = specifier.startsWith('#') && aliases.find(a => a[0][1] !== undefined ? specifier.length > a[0][0].length + a[0][1].length && specifier.startsWith(a[0][0]) && specifier.endsWith(a[0][1]) : specifier === a[0][0])
let spec = alias ? alias[1][0] + (alias[1][1] !== undefined && alias[0][1] !== undefined ? specifier.substring(alias[0][0].length, specifier.length - alias[0][1].length) + alias[1][1] : '') : specifier
let prefix = winAbsPath.test(spec) ? 'file://' : ''
if (!prefix && !relSpecs.includes(specifier) && !specStarts.some(p => specifier.startsWith(p))) {
return await nextResolve(specifier)
if (!prefix && !relSpecs.includes(spec) && !specStarts.some(s => spec.startsWith(s))) {
return await nextResolve(spec)
}
let trySpec = specifier[0] === '#' ? specifier : new URL(prefix + specifier, context.parentURL).href
let selfURL = new URL(prefix + spec, context.parentURL).href
let {type} = context.importAttributes ?? context.importAssertions
let postfixes = (await initPromise, trySpec.endsWith('/') ? indexFiles : knownExts.includes(extname(trySpec)) ? empty : candidates)
let postfixes = (await initPromise, selfURL.endsWith('/') ? indexFiles : knownExts.includes(extname(selfURL)) ? empty : candidates)
for (let postfix of postfixes[+(type === 'json')]) {
try {
return await nextResolve(trySpec + postfix)
} catch {}
try {return await nextResolve(selfURL + postfix)} catch {}
}
return await nextResolve(trySpec)
return await nextResolve(selfURL)
}
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