Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
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.
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
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.