Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vite-plugin-fast-external

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-fast-external - npm Package Compare versions

Comparing version 2.2.1 to 2.2.2

presets/vue-composition-api.js

5

package.json
{
"name": "vite-plugin-fast-external",
"version": "2.2.1",
"version": "2.2.2",
"description": "Without lexical transform, support custom external code.",

@@ -25,4 +25,5 @@ "main": "index.js",

"antd",
"element"
"element",
"composition-api"
]
}

1

presets/index.d.ts

@@ -18,3 +18,4 @@

export declare const react_v18: () => string
export declare const vue_composition_api: () => string
export declare const vue_v2: () => string
export declare const vue_v3: () => string

@@ -10,2 +10,3 @@ const antd_vue_v1 = require('./ant-design-vue-v1');

const react_v18 = require('./react-v18');
const vue_composition_api = require('./vue-composition-api');
const vue_v2 = require('./vue-v2');

@@ -18,4 +19,52 @@ const vue_v3 = require('./vue-v3');

exports.libMeta2external = function libMeta2external(libMeta) {
const keywords = [
'await',
'break',
'case',
'catch',
'class',
'const',
'continue',
'debugger',
'default',
'delete',
'do',
'else',
'enum',
'export',
'extends',
'false',
'finally',
'for',
'function',
'if',
'implements',
'import',
'in',
'instanceof',
'interface',
'let',
'new',
'null',
'package',
'private',
'protected',
'public',
'return',
'super',
'switch',
'static',
'this',
'throw',
'try',
'true',
'typeof',
'var',
'void',
'while',
'with',
'yield',
];
const exportMembers = libMeta.members
.filter(e => e !== 'default')
.filter(e => !keywords.includes(e))
.map(e => `export const ${e} = _M_['${e}'];`)

@@ -34,12 +83,13 @@ .join('\n');

exports.antd_vue_v1 = this.libMeta2external(antd_vue_v1)
exports.antd_vue_v3 = this.libMeta2external(antd_vue_v3)
exports.antd_v4 = this.libMeta2external(antd_v4)
exports.element_plus = this.libMeta2external(element_plus)
exports.element_ui = this.libMeta2external(element_ui)
exports.react_dom_v17 = this.libMeta2external(react_dom_v17)
exports.react_dom_v18 = this.libMeta2external(react_dom_v18)
exports.react_v17 = this.libMeta2external(react_v17)
exports.react_v18 = this.libMeta2external(react_v18)
exports.vue_v2 = this.libMeta2external(vue_v2)
exports.vue_v3 = this.libMeta2external(vue_v3)
exports.antd_vue_v1 = this.libMeta2external(antd_vue_v1);
exports.antd_vue_v3 = this.libMeta2external(antd_vue_v3);
exports.antd_v4 = this.libMeta2external(antd_v4);
exports.element_plus = this.libMeta2external(element_plus);
exports.element_ui = this.libMeta2external(element_ui);
exports.react_dom_v17 = this.libMeta2external(react_dom_v17);
exports.react_dom_v18 = this.libMeta2external(react_dom_v18);
exports.react_v17 = this.libMeta2external(react_v17);
exports.react_v18 = this.libMeta2external(react_v18);
exports.vue_composition_api = this.libMeta2external(vue_composition_api);
exports.vue_v2 = this.libMeta2external(vue_v2);
exports.vue_v3 = this.libMeta2external(vue_v3);

@@ -27,3 +27,3 @@ # vite-plugin-fast-external

```js
import external from 'vite-plugin-fast-external';
import external from 'vite-plugin-fast-external'

@@ -44,3 +44,3 @@ export default {

```js
import external from 'vite-plugin-fast-external';
import external from 'vite-plugin-fast-external'
import {

@@ -56,5 +56,6 @@ antd_vue_v1,

react_v18,
vue_composition_api,
vue_v2,
vue_v3,
} from 'vite-plugin-fast-external/presets';
} from 'vite-plugin-fast-external/presets'

@@ -68,4 +69,5 @@ export default {

'element-ui': element_ui,
'react-dom': react_dom_v18,
'react-dom/client': react_dom_v18,
react: react_v18,
'@vue/composition-api': vue_composition_api,
vue: vue_v3,

@@ -77,2 +79,39 @@ }),

In your web App
```js
// Vue v3
import { ref, reactive, watch } from 'vue'
// Vue v2
import { ref, reactive, watch } from '@vue/composition-api'
// React v18
import { useState, useEffect, useMemo } from 'react'
// ReactDOM v18
import { createRoot } from 'react-dom/client'
// Antd v4
import { Button, Table } from 'antd'
```
If you want to modify the builtin module
```js
import { libMeta2external } from 'vite-plugin-fast-external/presets'
import vue_v2 from 'vite-plugin-fast-external/presets/vue-v2'
// interface Vue_v2 extends LibMeta {
// name: string
// members: string[]
// }
vue_v2.name = 'ExtendVue'
vue_v2.members = vue_v2.members.push('ExtendAPI')
export default {
plugins: [
external({
vue: libMeta2external(vue_v2),
}),
],
}
```
#### Customize (Advance)

@@ -79,0 +118,0 @@

@@ -54,2 +54,3 @@ # vite-plugin-fast-external

react_v18,
vue_composition_api,
vue_v2,

@@ -66,4 +67,5 @@ vue_v3,

'element-ui': element_ui,
'react-dom': react_dom_v18,
'react-dom/client': react_dom_v18,
react: react_v18,
'@vue/composition-api': vue_composition_api,
vue: vue_v3,

@@ -75,2 +77,39 @@ }),

在你的代码中使用
```js
// Vue v3
import { ref, reactive, watch } from 'vue'
// Vue v2
import { ref, reactive, watch } from '@vue/composition-api'
// React v18
import { useState, useEffect, useMemo } from 'react'
// ReactDOM v18
import { createRoot } from 'react-dom/client'
// Antd v4
import { Button, Table } from 'antd'
```
如果你想修改内置模块
```js
import { libMeta2external } from 'vite-plugin-fast-external/presets'
import vue_v2 from 'vite-plugin-fast-external/presets/vue-v2'
// interface Vue_v2 extends LibMeta {
// name: string
// members: string[]
// }
vue_v2.name = 'ExtendVue'
vue_v2.members = vue_v2.members.push('ExtendAPI')
export default {
plugins: [
external({
vue: libMeta2external(vue_v2),
}),
],
}
```
#### 自定义(高级部分)

@@ -77,0 +116,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