elm-community/elm-webpack-loader

node-elm-compiler receiving warn option

DavidVII opened this issue · 4 comments

Anytime I save my a .elm source file, everything seems to compile just fine, but whenever I save my app.js file I get the following error:

Uncaught Error: Module build failed:
Error: Compiler process exited with error "node-elm-compiler received the `warn` option,
but that was removed in Elm 0.19.
Try re-running without passing the `warn` option."

My webpack

const path = require('path');
const glob = require('glob');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');

console.log("THE PATH: ", path.resolve(__dirname, 'elm'))

module.exports = (env, options) => ({
  optimization: {
    minimizer: [
      new UglifyJsPlugin({ cache: true, parallel: true, sourceMap: false }),
      new OptimizeCSSAssetsPlugin({})
    ]
  },
  entry: {
    './js/app.js': ['./js/app.js'].concat(glob.sync('./vendor/**/*.js'))
  },
  output: {
    filename: 'app.js',
    path: path.resolve(__dirname, '../priv/static/js')
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader'
        }
      },
      {
        test: /\.elm$/,
        exclude: ["/elm-stuff", "/node_modules"],
        loader: "elm-webpack-loader",
        options: {
          cwd: path.resolve(__dirname, 'elm'),
          debug: options.mode === 'development',
          verbose: options.mode === 'development',
          optimize: options.mode !== 'development'
        }
      },
      {
        test: /\.scss$/,
        use: [
          MiniCssExtractPlugin.loader,
          'css-loader',
          'sass-loader',
          'postcss-loader'
        ]
      }
    ],
    noParse: [/.elm$/]
  },
  plugins: [
    new MiniCssExtractPlugin({ filename: '../css/app.css' }),
    new CopyWebpackPlugin([{ from: 'static/', to: '../' }])
  ]
});

and my app.js file

import { Elm } from "../elm/src/Onboarding.elm"

const elmElement = document.getElementById("elm-onboard")

if (elmElement) {
  Elm.Onboarding.init({ node: elmElement })
}

Any idea what's going on here?

verbose: options.mode === 'development', might be the problem

@simonh1000 this did not have an effect.

I recently noticed that I've also been getting another error

Uncaught Error: Module build failed: Error: Compiler process exited with error Compilation failed
-- NO elm.json FILE ------------------------------------------------------------

It looks like you are starting a new Elm project. Very exciting! Try running:

    elm init

It will help you get set up. It is really simple!

I feel that the elm source isn't being compiled after saving my main JS entry point. Whenever I change and save my elm source, it all compiles fine and works as expected.

@DavidVII Any luck tracking down your problem ? It looks I have the exact same problem.

@nikolis this is going to sound odd, but try restarting your computer. Something somewhere got jacked up along the way (though my app was a super basic set up at the time).