marko-js-archive / marko-loader

DEPRECATED: see https://github.com/marko-js/webpack
MIT License
10 stars 12 forks source link

marko-loader does not infer loaders correctly when Webpack 2.x `module.rules` is in use #4

Closed jrop closed 7 years ago

jrop commented 7 years ago

As of webpack 2.x, loaders are now specified as rules:

// wepback.config.js
module.exports = {
    module: {
        loaders: [...], // old (webpack 1)
        rules: [...],   // new (wepack 2)
    },
}

When an inline style is used with less (style.less {...}) The marko-loader only searches through options.module.loaders for the less-loader.

This may be non-trivial to fix, because loader rules are more complex in webpack 2.0, and the logic in marko-loader/index.js:getLoaderMatch() may have to be significantly more complex to support rules.

patrick-steele-idem commented 7 years ago

Thanks for letting us know @jrop. Would you be interested in helping us with Webpack 2 compatibility? We are happy to receive contributions. Thanks, again.

jrop commented 7 years ago

I would be; I started looking into what I would do to create a pull-request, however, I am unfamiliar with the internals of webpack at the moment.

patrick-steele-idem commented 7 years ago

Ok, if you are able to figure it out that would be awesome. I am also unfamiliar with the internals of Webpack, but @mlrawlings did spend a lot of time getting this loader to work (he probably won't be able to take a look until later this week).

jrop commented 7 years ago

Just to keep this issue up to date: I created a pull request in which I pulled in the ResultSet.js file from webpack's source: this file is responsible for finding matching rules based on a file, so it replaces getMatchingLoader(...). Why not just require('webpack/lib/ResultSet')? Well, if we want to support webpack 1.x, this file does not exist in the webpack source, so I opted to pull it into this modules source. This could probably be opened for discussion, as I could see pros/cons of doing it this way.

patrick-steele-idem commented 7 years ago

Thanks for the PR @jrop! Very much appreciated. I'm going to ask @mlrawlings to review the PR tomorrow when he is available since he worked on the first version of marko-loader.

austinkelleher commented 7 years ago

I'm going to go ahead and close out this issue. This should be resolved in PR #14. Let me know if you still see any issues.