
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
vite-plugin-resolve
Advanced tools
Custom resolve module content
English | 简体中文
✅ Browser, Node.js, Electron
🤔 You can think of this as the implementation of the official tutorial 👉 Virtual Modules Convention
npm i vite-plugin-resolve -D
You can load any code snippet you want
import resolve from 'vite-plugin-resolve'
export default {
plugins: [
resolve({
vue: `const vue = window.Vue; export { vue as default }`,
}),
]
}
In you App
import Vue from 'vue'
This like Vite external plugin
You you can see more about external 👉 vite-plugin-fast-external
Load a file
Support nested module id, support return Promise
import fs from 'fs'
resolve({
'path/filename': () => fs.promise.readFile('path', 'utf-8'),
})
Electron
Resolve Electron Renderer-process
resolve({
electron: `
const electron = require("electron");
export { electron as default }
const export shell = electron.shell;
const export ipcRenderer = electron.ipcRenderer;
// ...others
`,
})
In you App(Renderer-process)
import { shell, ipcRenderer } from 'electron'
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
There are two main differences
vite:resolve
pluginFAQs
Custom resolve module content.
The npm package vite-plugin-resolve receives a total of 4,390 weekly downloads. As such, vite-plugin-resolve popularity was classified as popular.
We found that vite-plugin-resolve demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.