elm-css-modules-loader icon indicating copy to clipboard operation
elm-css-modules-loader copied to clipboard

Update dependencies for elm 0.19.1

Open arian opened this issue 6 years ago • 5 comments
trafficstars

Updated the dependencies to use elm 0.19.1

To make it really work, elm-css-modules-plugin need to be patched: https://github.com/cultureamp/elm-css-modules-plugin/pull/6

arian avatar Nov 07 '19 14:11 arian

@sentience @zioroboco Any reason this is being held back?

Currently, Elm 0.19.1 users need to fork this repo to get this loader to work. After shuffling for a while, I learned Yarn users can get around this using selective dependency resolution.

Until then, I'll leave this here for other distraught developers that find themselves looking at this PR...

{
  "devDependencies": {
    "css-loader": "^3.4.2",
    "elm": "^0.19.1-3",
    "elm-css-modules-loader": "^3.0.4",
    "elm-webpack-loader": "^6.0.1",
    "style-loader": "^1.1.3",
    "webpack": "^4.42.0",
    "webpack-cli": "^3.3.11",
    "webpack-dev-server": "^3.10.3"
  },
  // Only available with Yarn
  "resolutions": {
    "elm-css-modules-loader/elm-css-modules-plugin": "^1.0.2"
  }
}

NPM users might also be able to get this to work using npm-force-resolutions, but this in only a workaround.

maxmellen avatar Mar 10 '20 11:03 maxmellen

Short answer for why we haven't moved on this yet is that Culture Amp hasn't upgraded to 0.19.1 yet. We should do that soon, though.

I'll check with @zioroboco to see if merging this in the meantime is an option. (We could stick to the previous version of the package until we're ready to upgrade.)

sentience avatar Mar 10 '20 12:03 sentience

Thanks for the bump @maxmellen, and thanks @arian!

This is introducing the new plugin version to the loader — looks good to me, and will be compatible with Elm versions 0.180.19.1.

If anyone's wondering we don't use this loader internally, but instead use the babel plugin https://github.com/cultureamp/elm-css-modules-plugin directly (with the existing Elm package). This is faster on a large codebases, as it removes unnecessary tokenisation steps from running babel-loader multiple times.

zioroboco avatar Mar 10 '20 23:03 zioroboco

@zioroboco Thanks for the insight! I managed to get elm-css-modules-plugin to work with babel-loader directly.

So if I understand correctly, all elm-css-modules-loader really is is a specialized alternative to babel-loader preconfigured to use elm-css-modules-plugin. Is that correct?

Here's my minimal Webpack 4 config if anyone might wanna take inspiration:

let path = require("path");
let elmCssModulesPlugin = require("elm-css-modules-plugin");
let srcDir = path.resolve(__dirname, "src");

module.exports = {
  module: {
    rules: [
      {
        test: /.css$/,
        include: srcDir,
        use: [
          { loader: "style-loader" },
          { loader: "css-loader", options: { modules: true } }
        ]
      },
      {
        test: /.elm$/,
        include: srcDir,
        use: [
          {
            loader: "babel-loader",
            options: { plugins: [elmCssModulesPlugin] }
          },
          { loader: "elm-webpack-loader" }
        ]
      }
    ]
  }
};

Would this maybe be worth adding to elm-css-modules-plugin's README? Would you accept a PR for that?

maxmellen avatar Mar 12 '20 23:03 maxmellen

@zioroboco Sorry to reiterate but would you accept a PR to each repo's REAMDEs:

  • one on this repo letting people know that elm-css-modules-plugin can be used directly with Babel rather than through elm-css-modules-loader
  • one on elm-css-modules-plugin showing basic usage of that plugin with Babel

I'd happily contribute if I get a green light

maxmellen avatar Apr 16 '20 07:04 maxmellen