Skip to content

Fix errors using loader with webpack 4.2 #1200

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

Open
wants to merge 10 commits into
base: 8.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ module.exports = function (content) {
var defaultLoaders = {
html: 'vue-html-loader',
css: 'vue-style-loader!css-loader',
js: 'babel-loader?presets[]=es2015&plugins[]=transform-runtime&comments=false'
js: 'babel-loader'
}

this.cacheable()
var loaderContext = this
var query = loaderUtils.getOptions(this) || {}
var options = Object.assign({}, this.options.vue, this.vue, query)
var options = Object.assign({}, this.options && this.options.vue, this.vue, query)
var filePath = this.resourcePath
var fileName = path.basename(filePath)
var moduleId = '_v-' + hash(filePath)

// respect user babel options
if (this.options.babel) {
if (this.options && this.options.babel) {
defaultLoaders.js = 'babel-loader'
}

Expand Down
4 changes: 2 additions & 2 deletions lib/style-rewriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = function (css, map) {
var cb = this.async()

var query = loaderUtils.getOptions(this) || {}
var options = this.options.vue || {}
var options = this.options && this.options.vue || {}
Copy link

@davidpelayo davidpelayo Apr 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In direct assignments you may be have to double coerce the first logic comparison to ensure it returns a boolean and fallbacks to {} if resolves to false. So it would be:

var options = (this.options && this.options.vue) || {}

var autoprefixOptions = options.autoprefixer
var postcssOptions = options.postcss

Expand All @@ -58,7 +58,7 @@ module.exports = function (css, map) {
autoprefixOptions = assign(
{},
// also respect autoprefixer-loader options
this.options.autoprefixer,
this.options && this.options.autoprefixer,
autoprefixOptions
)
var autoprefixer = require('autoprefixer')(autoprefixOptions)
Expand Down
20 changes: 8 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-loader",
"version": "8.7.1",
"version": "8.8.3",
"description": "Vue.js component loader for Webpack",
"main": "index.js",
"repository": {
Expand Down Expand Up @@ -29,7 +29,7 @@
"deploy-docs": "bash ./docs/deploy.sh"
},
"dependencies": {
"autoprefixer": "^6.0.3",
"autoprefixer": "9.*",
"consolidate": "^0.14.0",
"de-indent": "^1.0.0",
"hash-sum": "^1.0.2",
Expand All @@ -43,22 +43,18 @@
"vue-template-validator": "^1.0.0"
},
"peerDependencies": {
"babel-core": "^6.8.0",
"babel-loader": "^6.2.4",
"babel-plugin-transform-runtime": "^6.8.0",
"babel-preset-es2015": "^6.6.0",
"babel-runtime": "^6.0.0",
"@babel/core": "7.*",
"babel-loader": "7.*",
"@babel/runtime": "7.*",
"css-loader": "*",
"vue-hot-reload-api": "^1.2.0",
"vue-html-loader": "^1.0.0",
"vue-style-loader": "^1.0.0"
},
"devDependencies": {
"babel-core": "^6.8.0",
"babel-loader": "^6.2.4",
"babel-plugin-transform-runtime": "^6.8.0",
"babel-preset-es2015": "^6.6.0",
"babel-runtime": "^6.0.0",
"@babel/core": "7.*",
"@babel-loader": "7.*",
"@babel/runtime": "7.*",
"chai": "^3.0.0",
"coffee-loader": "^0.7.2",
"coffee-script": "^1.10.0",
Expand Down