vuejs / vue-loader

📦 Webpack loader for Vue.js components
MIT License
4.99k stars 915 forks source link

vue-loader breaks since Webpack 2.1.0-beta.26 #464

Closed riovir closed 8 years ago

riovir commented 8 years ago

https://github.com/webpack/webpack/releases/tag/v2.1.0-beta.26 The breaking change now forces -loader to be used. Since vue-loader internally also uses loaders the problem might be caused by this change. See:

Error: Module '....../node_modules/less/index.js' is not a loader

riovir commented 8 years ago

In the loader.js the line 80 the following horrible hack solves the problem: getLoaderString(type, part, index, scoped).replace(/!less!/, '!less-loader!')

Naturally this is not a proposed fix, merely a step to pin down the issue.

riovir commented 8 years ago

An actual proposal here for a fix: loader.js@line 155 return loader + '!' + rewriter + lang + '-loader!'

Edit: the same idea seems to be necessary for 'script' and 'template cases' as well in getLoaderString

thorning commented 8 years ago

I had this problem using lang="stylus" and a (temporary) fix for me was to change it to lang="stylus-loader", I also had to update loader references in the webpack config.

A fix should be tested for pug/jade support in templates, as it seems these needs the normal modules (i.e. 'pug') and not the loader module ('pug-loader')

ylhuang0423 commented 8 years ago

I' m using Webpack 1.13.3 (npm version) resolveLoader.alias is set in webpack.config.js (i.e sugarss: 'postcss-loader?parser=sugarss') The fix would break my setting, because sugarss becomes sugarss-loader implicitly.

riovir commented 8 years ago

@thorning, I tested the "fix" with both Jade and Pug. For templates "raw" changes to "raw-loader" the engine query param stays the same. See: case 'template': return defaultLoaders.html + '!' + templateLoaderPath + '?raw-loader&engine=' + lang + '!'

@ylhuang0423, Breaking resolveLoader.alias is a different matter though. I don't have a good proposal on how to safely tell an aliased lang from a default one that needs a -loader suffix. Does anything make them special that the vue-loader can possibly recognize?

ylhuang0423 commented 8 years ago

@riovir, Maybe try...catch to require loaders (like what var hasBabel do) would be a possible solution. If the loader of lang is existed indeed then suffix -loader to it, or it'll be a Inline Loader Request or a alias.

Yet it's not a perfect solution for some special cases. (i.e babel could be aliased like: babel: 'babel-loader?presets[]=latest,presets[]=stage-3')

yyx990803 commented 8 years ago

Can you try 9.9.3?

riovir commented 8 years ago

9.9.3 works well with Webpack 2 beta 26 as far as I managed to verify, thank you.