Socket
Socket
Sign inDemoInstall

vite-plugin-resolve

Package Overview
Dependencies
Maintainers
3
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-resolve - npm Package Compare versions

Comparing version 2.0.9 to 2.1.0

presets/ant-design-vue-v1.js

2

package.json
{
"name": "vite-plugin-resolve",
"version": "2.0.9",
"version": "2.1.0",
"description": "Custom resolve module content.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -12,2 +12,4 @@ # vite-plugin-resolve

🤔 You can think of this as the implementation of the official tutorial 👉 [Virtual Modules Convention](https://vitejs.dev/guide/api-plugin.html#virtual-modules-convention)
📦 **Out of the box**, builtin Vue, React, Antd, Element and others
🌱 Support custom code snippets
✅ Browser, Node.js, Electron

@@ -31,3 +33,17 @@

resolve({
vue: `const vue = window.Vue; export { vue as default }`,
// Browser
vue: `
const vue = window.Vue;
export { vue as default }
export const version = vue.version;
`,
// Node.js, Electron
electron: `
const { ipcRenderer, shell } = require('electron');
export {
ipcRenderer,
shell,
}
// ...others
`,
}),

@@ -42,7 +58,5 @@ ]

import Vue from 'vue'
import { ipcRenderer, shell } from 'electron'
```
This like Vite external plugin
You you can see more about external 👉 [vite-plugin-fast-external](https://github.com/caoxiemeihao/vite-plugins/tree/main/packages/fast-external)
**Load a file**

@@ -60,24 +74,2 @@

**Electron**
Resolve Electron Renderer-process
```ts
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)
```ts
import { shell, ipcRenderer } from 'electron'
```
## API

@@ -99,2 +91,68 @@

## Use builtin modules
This like Vite external plugin
```js
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({
vue: vue.v3,
}),
]
}
// Use in your app
import { h, ref, reactive, watch } from 'vue'
```
**Advance**, you can use `lib2esm()` to customize some things
```js
import resolve from 'vite-plugin-resolve'
import { lib2esm } from 'vite-plugin-resolve/presets'
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](https://github.com/electron-vite/electron-vite-vue/blob/main/packages/renderer/vite.config.ts)
## What's different from the official Demo?

@@ -101,0 +159,0 @@

@@ -12,2 +12,4 @@ # vite-plugin-resolve

🤔 你可以认为它是官方教程的一个实现 👉 [Virtual Modules Convention](https://vitejs.dev/guide/api-plugin.html#virtual-modules-convention)
📦 **开箱即用**, 内置 Vue, React, Antd, Element 等等
🌱 支持自定义 external 代码段
✅ Browser, Node.js, Electron

@@ -31,3 +33,17 @@

resolve({
vue: `const vue = window.Vue; export { vue as default }`,
// Browser
vue: `
const vue = window.Vue;
export { vue as default }
export const version = vue.version;
`,
// Node.js, Electron
electron: `
const { ipcRenderer, shell } = require('electron');
export {
ipcRenderer,
shell,
}
// ...others
`,
}),

@@ -42,9 +58,7 @@ ]

import Vue from 'vue'
import { ipcRenderer, shell } from 'electron'
```
这个场景就是 external
你可以看看关于 external 👉 [vite-plugin-fast-external](https://github.com/caoxiemeihao/vite-plugins/tree/main/packages/fast-external)
**加载文件**
#### 加载文件
支持嵌套模块命名,支持返回 Promise

@@ -60,24 +74,2 @@

#### Electron
加载 Electron 渲染进程
```ts
resolve({
electron: `
const electron = require("electron");
export { electron as default }
const export shell = electron.shell;
const export ipcRenderer = electron.ipcRenderer;
// ...其他成员
`,
})
```
在渲染进程中使用
```ts
import { shell, ipcRenderer } from 'electron'
```
## API

@@ -99,2 +91,68 @@

## 使用内置模块
这个场景就是 Vite external plugin
```js
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({
vue: vue.v3,
}),
]
}
// 使用
import { h, ref, reactive, watch } from 'vue'
```
**Advance**, you can use `lib2esm()` to customize some things
```js
import resolve from 'vite-plugin-resolve'
import { lib2esm } from 'vite-plugin-resolve/presets'
export default {
plugins: [
resolve({
// 用 lodash 举个 🌰
lodash: lib2esm(
// lodash 全局名称
'_',
// export memebers
[
'chunk',
'curry',
'debounce',
'throttle',
],
),
}),
]
}
// 使用
import { chunk, curry, debounce, throttle } from 'lodash'
```
**在 Electron 中使用** 👉 [electron-vite-vue](https://github.com/electron-vite/electron-vite-vue/blob/main/packages/renderer/vite.config.ts)
## 这与官方的 Demo 有何异同?

@@ -101,0 +159,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc