You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

airlight-resolve

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

airlight-resolve - npm Package Compare versions

Comparing version

to
0.5.0

factory.js

24

interface.d.ts

@@ -1,11 +0,17 @@

import type { NapiResolveOptions, ResolverFactory } from 'oxc-resolver';
import type {
NapiResolveOptions,
ResolverFactory as ResolverFactoryBase
} from 'oxc-resolver';
declare function resolve(...args: string[]): string | undefined;
declare function create(opts: Partial<NapiResolveOptions>): typeof resolve;
export type ResolveOptions = NapiResolveOptions;
export type Resolver = ResolverFactory;
export {
type NapiResolveOptions as ResolveOptions,
type ResolverFactory,
create,
resolve as default
};
export class ResolverFactory extends ResolverFactoryBase {
static createResolver(opts: NapiResolveOptions): Resolver;
constructor(props: Partial<NapiResolveOptions>);
resolveSync(_: unknown, path: string, request: string): string | null;
}
export default Resolver;
{
"name": "airlight-resolve",
"version": "0.4.3",
"description": "[WIP] `require.resolve` faster implementation based on oxc-resolver",
"version": "0.5.0",
"description": "[WIP] `enhanced-resolve` faster implementation based on oxc-resolver",
"type": "module",
"main": "resolve.js",
"files": ["resolve.js", "interface.d.ts"],
"files": ["resolve.js", "factory.js", "interface.d.ts"],
"typings": "interface.d.ts",

@@ -9,0 +9,0 @@ "engines": {

# airlight-resolve \[WIP\]
\[WIP\] `require.resolve` faster implementation based on [oxc-resolver](https://github.com/oxc-project/oxc_resolver)
\[WIP\] `enhanced-resolve` faster implementation based on [oxc-resolver](https://github.com/oxc-project/oxc_resolver)

@@ -5,0 +5,0 @@ ## Installation

@@ -1,38 +0,5 @@

import { ResolverFactory } from 'oxc-resolver';
import ResolverFactory from './factory.js';
/** @type {Partial<import('./interface.js').ResolveOptions>} */
const defaultOptions = {
preferAbsolute: true,
fullySpecified: false,
mainFields: ['main', 'module', 'browser'],
extensions: ['.ts', '.js', '.d.ts', '.html', '.md', '.json']
};
const factory = ResolverFactory.createResolver();
export const create = (
/** @type {Partial<import('./interface.js').ResolveOptions>} */ opts = {}
) => {
const options = Object.assign(
{
syncRoot: process.cwd(),
cache: false
},
defaultOptions,
opts
);
const factory = new ResolverFactory(options);
/** @type {Map<string, string | undefined>} */
const cache = new Map();
// eslint-disable-next-line complexity
return (/** @type {string[]} */ ...args) => {
const key = args.length < 2 ? args[0] : args.join('/');
if (options.cache === false || !cache.has(key)) {
cache.set(key, factory.sync(options.syncRoot || args[0], key).path);
}
return cache.get(key);
};
};
export default create();
export { factory as default, ResolverFactory };