umijs / babel-plugin-import

Modularly import plugin for babel.
3.16k stars 404 forks source link

break imports order #423

Open tangjinzhou opened 4 years ago

tangjinzhou commented 4 years ago
import 'babel-polyfill';
import { DatePicker } from 'ant-design-vue';

编译后: // 伪代码,仅展示顺序

import DatePicker from 'ant-design-vue....'
import xxx from 'core-js/xxx';
import 'polyfill';

core.js 应该在文件的最顶部。配置了按需加载的组件总是出现在最顶部。

详细: 源代码:

import "@babel/polyfill";
import Vue from "vue";
import App from "./App.vue";
import { Button } from "ant-design-vue";

Vue.use(Button);
Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

构建后:代码有省略,主要问题是按需加载后的代码出现在了最前面,polyfill相关的代码出现在了后面

__webpack_require__.r(__webpack_exports__);
/* harmony import */ var ant_design_vue_es_button_style__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ant-design-vue/es/button/style */ "./node_modules/ant-design-vue/es/button/style/index.js");
/* harmony import */ var ant_design_vue_es_button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ant-design-vue/es/button */ "./node_modules/ant-design-vue/es/button/index.js");
/* harmony import */ var core_js_modules_es6_array_copy_within__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core-js/modules/es6.array.copy-within */ "./node_modules/core-js/modules/es6.array.copy-within.js");
/* harmony import */ var core_js_modules_es6_array_copy_within__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es6_array_copy_within__WEBPACK_IMPORTED_MODULE_2__);
afc163 commented 4 years ago

来个 PR 吧

Amour1688 commented 4 years ago

来个 PR 吧

ImportDeclaration 这部分的逻辑应该要改成 path.replaceWithMultiple,不能通过importMethod了吧

ldwonday commented 2 years ago

@afc163 这个bug赶紧修复啊

zhangyuang commented 2 years ago

同样的问题,这里有计划修复吗