![JavaScript Leaders Demand Oracle Release the JavaScript Trademark](https://cdn.sanity.io/images/cgdhsj6q/production/0f098d751c5c76cf31e305286be5fed3575bf954-1024x1024.webp?w=400&fit=max&auto=format)
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 | 简体中文
🤔 You can think of this as the implementation of the official tutorial 👉 Virtual Modules Convention
📦 Out of the box, builtin Vue, React, Antd, Element and others
🌱 Support custom code snippets
✅ Browser, Node.js, Electron
npm i vite-plugin-resolve -D
You can load any code snippets you want (ESM format)
import resolve from 'vite-plugin-resolve'
export default {
plugins: [
resolve({
// Browser
vue: `
const vue = window.Vue;
const version = vue.version;
export {
vue as default,
version,
}
`,
// Node.js, Electron
electron: `
const { ipcRenderer, shell } = require('electron');
export {
ipcRenderer,
shell,
}
`,
}),
]
}
// Use in your app
import Vue, { version } from 'vue'
import { ipcRenderer, shell } from 'electron'
You can easy to use lib2esm()
to customize some things
import resolve, { lib2esm } from 'vite-plugin-resolve'
export default {
plugins: [
resolve({
// Let's use lodash as an example
lodash: lib2esm(
// lodash iife name
'_',
// export memebers
[
'chunk',
'curry',
'debounce',
'throttle',
],
),
}),
]
}
// Use in your app
import _, { chunk, curry, debounce, throttle } from 'lodash'
Use in Electron 👉 electron-vite-vue
This like Vite external plugin
import resolve from 'vite-plugin-resolve'
import {
antd_vue,
antd,
element_plus,
element_ui,
pinia,
react_dom,
react_router_dom,
react_router,
react,
redux,
vue_composition_api,
vue_router,
vue,
vuex,
} from 'vite-plugin-resolve/presets'
export default {
plugins: [
resolve({
// e.g.
// external-lib: lib-name.version
vue: vue.v3,
react: react.v18,
}),
]
}
// Use in your app
import Vue, { ref, reactive, computed, watch } from 'vue'
import React, { useState, useEffect } from 'react'
resolve(entries)
import type { Plugin } from 'vite';
export interface VitePluginResolve {
(entries: {
[moduleId: string]:
| ReturnType<Plugin['load']>
| ((...args: Parameters<Plugin['load']>) => ReturnType<Plugin['load']>)
}): Plugin[];
}
You can see the return value type definition here rollup/types.d.ts#L272
lib2esm(name[,members[,options]])
export interface Lib2esmOptions {
/**
* Generate code snippet format
*
* 🌰 e.g.
* ```js
* const _M_ = require('lib') // cjs
* const _M_ = window['lib'] // iife
* ```
*
* @default "iife"
*/
format?: "cjs" | "iife",
}
export interface Lib2esm {
(name: string, options?: Lib2esmOptions): string
(name: string, members: string[], options?: Lib2esmOptions): string
}
export declare const lib2esm: Lib2esm
There are two main differences
vite:resolve
plugin2.1.4-2.1.7 (2022-10-14)
🐞 fix npm publish
missing files
FAQs
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.