0.0.4 • Published 2 years ago

babel-plugin-externals v0.0.4

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

babel-plugin-externals

将es module中的import语句代码编译为引用全局变量,如下示例所示,配置的externals选项为

# externals
const options = {vue: 'Vue', react: 'React', 'react-dom': 'ReactDOM'}
import {renderList as _renderList, Fragment as _Fragment} from "vue"

console.log(_renderList, _Fragment)

// 不在externals排除选项中,跳过
import {defineConfig} from "vite"

console.log(defineConfig)

import * as VUE from "vue"

console.log(VUE)

import Vue, {Abc as abc} from "vue"

console.log(Vue, abc)

转换后

const {
    renderList: _renderList,
    Fragment: _Fragment
} = Vue;
console.log(_renderList, _Fragment);
import {defineConfig} from "vite";

console.log(defineConfig);
const VUE = Vue;
console.log(VUE);
const Vue = Vue;
const {
    Abc: abc
} = Vue;
console.log(Vue, abc);

不会影响export语句代码