Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

break imports order #423

Open
tangjinzhou opened this issue Mar 10, 2020 · 4 comments · May be fixed by #459
Open

break imports order #423

tangjinzhou opened this issue Mar 10, 2020 · 4 comments · May be fixed by #459

Comments

@tangjinzhou
Copy link

tangjinzhou commented Mar 10, 2020

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
Copy link
Contributor

afc163 commented Mar 20, 2020

来个 PR 吧

@Amour1688
Copy link

来个 PR 吧

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

@ldwonday
Copy link

@afc163 这个bug赶紧修复啊

@zhangyuang
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants