vite-plugin-fast-external
Advanced tools
Comparing version 2.2.1 to 2.2.2
{ | ||
"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" | ||
] | ||
} |
@@ -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 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37177
19
1466
154