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

Custom resolve module content.


Version published
Weekly downloads
4.5K
increased by5.33%
Maintainers
1
Weekly downloads
 
Created

Readme

Source

vite-plugin-resolve NPM version awesome-vite

Custom resolve module content

English | 简体中文

  • Compatible Browser, Node.js and Electron
  • You can think of this as the implementation of the official tutorial 👉 Virtual Modules Convention

Install

npm i vite-plugin-resolve -D

Usage

Resolve custom module content, this like Vite external plugin

import resolve from 'vite-plugin-resolve'

export default {
  plugins: [
    resolve({
      vue: `const vue = window.Vue; export { vue as default }`,
    }),
  ]
}

You you can see more about external 👉 vite-plugin-fast-external

Load a file

Support nested module id, support return Promise

resolve({
  'path/filename': () => require('fs/promises').readFile('path', 'utf-8'),
})
Electron

Resolve Electron ipcRenderer in Renderer-process

resolve({
  electron: `const { ipcRenderer } = require('electron'); export { ipcRenderer };`,
})

API

resolve(entries)

entries

{
  [moduleId: string]:
    | ReturnType<Plugin['load']>
    | ((...args: Parameters<Plugin['load']>) => ReturnType<Plugin['load']>)
}

You can see the return value type definition here rollup/types.d.ts#L272

What's different from the official Demo?

There are two main differences

  1. Bypass the builtin vite:resolve plugin
  2. Reasonably avoid Pre-Bundling

Keywords

FAQs

Package last updated on 16 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc