Socket
Socket
Sign inDemoInstall

vite-plugin-resolve

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-resolve - npm Package Compare versions

Comparing version 1.4.4 to 1.5.0

4

index.d.ts
import { Plugin, UserConfig } from 'vite';
export interface Resolves {
[moduleId: string]: string | (() => string | Promise<string>);
[moduleId: string]: string | ((args: { dir: string }) => string | Promise<string | void> | void) | void;
}

@@ -47,3 +47,3 @@

export interface GenerateESModule {
(cacheDir: string, resolves: Resolves): Promise<void>;
(dir: string, resolves: Resolves): Promise<void>;
}

@@ -50,0 +50,0 @@

@@ -10,3 +10,3 @@ const fs = require('fs');

let root = process.cwd();
let cacheDir = '.vite-plugin-resolve';
let dir = '.vite-plugin-resolve';

@@ -23,3 +23,3 @@ return {

// absolute path
cacheDir = path.join(node_modules(root), cacheDir);
dir = path.join(node_modules(root), dir);

@@ -30,6 +30,6 @@ if (optimizeDepsExclude) modifyOptimizeDepsExclude(config, Object.keys(resolves));

config,
Object.keys(resolves).map(moduleId => ({ [moduleId]: path.join(cacheDir, moduleId) })),
Object.keys(resolves).map(moduleId => ({ [moduleId]: path.join(dir, moduleId) })),
);
await generateESModule(cacheDir, resolves);
await generateESModule(dir, resolves);
},

@@ -42,7 +42,8 @@ }

*/
async function generateESModule(cacheDir, resolves) {
async function generateESModule(dir, resolves) {
// generate custom-resolve module file
for (const [module, strOrFn] of Object.entries(resolves)) {
const moduleId = path.join(cacheDir, module + '.js');
const moduleContent = await (typeof strOrFn === 'function' ? strOrFn() : strOrFn);
const moduleId = path.join(dir, module + '.js');
const moduleContent = await (typeof strOrFn === 'function' ? strOrFn({ dir }) : strOrFn);
if (moduleContent == null) continue;

@@ -49,0 +50,0 @@ // supported nest moduleId ('@scope/name')

{
"name": "vite-plugin-resolve",
"version": "1.4.4",
"version": "1.5.0",
"description": "Custom resolve module content.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -48,3 +48,3 @@ # vite-plugin-resolve

export type viteResolve = (
resolves: [moduleId: string]: string | (() => string | Promise<string>),
resolves: [moduleId: string]: string | ((args: { dir: string }) => string | Promise<string | void> | void) | void,
options?: {

@@ -51,0 +51,0 @@ /**

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