# babel-plugin-externals **Repository Path**: martsforever-pot/babel-plugin-externals ## Basic Information - **Project Name**: babel-plugin-externals - **Description**: 将esmodule代码中的import语句编译为引用全局变量; 不影响export代码语句; - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-01-04 - **Last Updated**: 2022-01-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # babel-plugin-externals 将es module中的import语句代码编译为引用全局变量,如下示例所示,配置的externals选项为 ```js # externals const options = {vue: 'Vue', react: 'React', 'react-dom': 'ReactDOM'} ``` ```js 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) ``` 转换后 ```js 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语句代码