Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
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 }`,
}),
]
}
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 3,034 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
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.