Skip to content

Commit

Permalink
Upgrade to Elm 0.19 (#1691)
Browse files Browse the repository at this point in the history
Notable changes that affect webpacker:

- elm-package.json renamed to elm.json
- the old hot loader doesn't support Elm 0.19, so it has been
  replaced by klazuka/elm-hot-webpack-loader
- the Elm compiler no longer accepts the `--warn` flag
- elm-webpack-loader renamed the 'pathToMake' option to 'pathToElm'
  • Loading branch information
klazuka authored and gauravtiwari committed Sep 10, 2018
1 parent 5b481bd commit 353bda3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 4 additions & 3 deletions lib/install/elm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@

say "Installing all Elm dependencies"
run "yarn add elm elm-webpack-loader"
run "yarn add --dev elm-hot-loader"
run "yarn run elm package install -- --yes"
run "yarn add --dev elm-hot-webpack-loader"
run "yarn run elm init"
run "yarn run elm make"

say "Updating webpack paths to include .elm file extension"
insert_into_file Webpacker.config.config_path, "- .elm\n".indent(4), after: /extensions:\n/

say "Updating Elm source location"
gsub_file "elm-package.json", /\"\.\"\n/,
gsub_file "elm.json", /\"\src\"\n/,
%("#{Webpacker.config.source_path.relative_path_from(Rails.root)}"\n)

say "Updating .gitignore to include elm-stuff folder"
Expand Down
7 changes: 3 additions & 4 deletions lib/install/loaders/elm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ const { resolve } = require('path')

const isProduction = process.env.NODE_ENV === 'production'
const elmSource = resolve(process.cwd())
const elmMake = `${elmSource}/node_modules/.bin/elm-make`
const elmBinary = `${elmSource}/node_modules/.bin/elm`

const elmDefaultOptions = { cwd: elmSource, pathToMake: elmMake }
const elmDefaultOptions = { cwd: elmSource, pathToElm: elmBinary }
const developmentOptions = Object.assign({}, elmDefaultOptions, {
verbose: true,
warn: true,
debug: true
})

Expand All @@ -19,5 +18,5 @@ const elmWebpackLoader = {
module.exports = {
test: /\.elm(\.erb)?$/,
exclude: [/elm-stuff/, /node_modules/],
use: isProduction ? [elmWebpackLoader] : [{ loader: 'elm-hot-loader' }, elmWebpackLoader]
use: isProduction ? [elmWebpackLoader] : [{ loader: 'elm-hot-webpack-loader' }, elmWebpackLoader]
}

0 comments on commit 353bda3

Please sign in to comment.