Vue-loader: Upgrade vue-loader to webpack 3

Created on 20 Jun 2017  路  6Comments  路  Source: vuejs/vue-loader

What problem does this feature solve?

With the recent launch of webpack 3, some exciting features was added, including Scope Hoisting. As stated by the team:

"Migrating from webpack 2 to 3, should involve no effort beyond running the upgrade commands in your terminal. We marked this as a Major change because of internal breaking changes that could affect some plugins."

So, I believe the migration will be easy and will give only benefits:

npm install [email protected] --save-dev

Most helpful comment

I tried this today, vue loader works just fine with webpack 3, but when
new webpack.optimize.ModuleConcatenationPlugin() is enabled, it prevents webpack from concatenating the modules. Because vue-loader by default converts export statements in vue files to module.exports and ModuleConcatenationPlugin bailsout on these statements.

If you enable --display-optimization-bailout option during build, it clearly says

module is used with non-harmony imports from ./src/App.vue

more details:

[7] ./src/App.vue 998 bytes {4} [built]
[8] ./node_modules/extract-text-webpack-plugin/loader.js?{"omit":1,"remove":true}!./node_modules/vue-style-loader!./node_modules/css-loader?minimize!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-f5e1a3ba","scoped":false,"hasInlineConfig":true}!./node_modules/sass-loader/lib/loader.js!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/App.vue 41 bytes {4} [built]
[10] ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/App.vue 130 bytes {4} [built]
       ModuleConcatenation (inner): module is used with non-harmony imports from ./src/App.vue
[14] ./node_modules/vue-loader/lib/template-compiler?{"id":"data-v-f5e1a3ba","preserveWhitespace":false}!./node_modules/vue-loader/lib/selector.js?type=template&index=0!./src/App.vue 385 bytes {4} [built]

I've tried setting esModule to true in vue loader config. but that also didn't work.

All 6 comments

I tried this today, vue loader works just fine with webpack 3, but when
new webpack.optimize.ModuleConcatenationPlugin() is enabled, it prevents webpack from concatenating the modules. Because vue-loader by default converts export statements in vue files to module.exports and ModuleConcatenationPlugin bailsout on these statements.

If you enable --display-optimization-bailout option during build, it clearly says

module is used with non-harmony imports from ./src/App.vue

more details:

[7] ./src/App.vue 998 bytes {4} [built]
[8] ./node_modules/extract-text-webpack-plugin/loader.js?{"omit":1,"remove":true}!./node_modules/vue-style-loader!./node_modules/css-loader?minimize!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-f5e1a3ba","scoped":false,"hasInlineConfig":true}!./node_modules/sass-loader/lib/loader.js!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/App.vue 41 bytes {4} [built]
[10] ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/App.vue 130 bytes {4} [built]
       ModuleConcatenation (inner): module is used with non-harmony imports from ./src/App.vue
[14] ./node_modules/vue-loader/lib/template-compiler?{"id":"data-v-f5e1a3ba","preserveWhitespace":false}!./node_modules/vue-loader/lib/selector.js?type=template&index=0!./src/App.vue 385 bytes {4} [built]

I've tried setting esModule to true in vue loader config. but that also didn't work.

@erickpetru I'm not sure what you are asking - here should we update webpack? In this repository?

Or are you simply asking if vue-loader works with webpack 3?

The latter is: yes, but we are currently working on implementing true esmodule exports to reap the benefits of the ModuleConcatenationPlugin - which currently bails on .vue files as @serkanyersen correctly observed.

@LinusBorg I'm sorry for the confusion, I'll try to be clearer:

  1. Update the webpack version in this project package.json.
  2. Offer support out of the box to the ModuleConcatenationPlugin.

By the way, I'm happy to know you're already working on it.

Issue #860 is already merged & released with v13.

So is something still missing to achive out-of-the box support of ModuleConcatenationPlugin ?

No. This issue is still open as it's about an update of this repo to webpack3, which hasn't happened yet.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

frangio picture frangio  路  3Comments

snoopdouglas picture snoopdouglas  路  3Comments

TheVexatious picture TheVexatious  路  3Comments

sdvcrx picture sdvcrx  路  3Comments

yozman picture yozman  路  4Comments