Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack 4.0.0 Error #134

Closed
mickeyvip opened this issue Feb 25, 2018 · 11 comments
Closed

Webpack 4.0.0 Error #134

mickeyvip opened this issue Feb 25, 2018 · 11 comments

Comments

@mickeyvip
Copy link

I am trying to use Webpack v4.0.0 and get the following:

ERROR in ./src/Main.elm
Module build failed: TypeError: Cannot read property 'elm' of undefined
    at Object.getOptions (/Users/me/dev/Projects/Elm/webpack4/node_modules/elm-webpack-loader/index.js:37:35)
    at Object.module.exports (/Users/me/dev/Projects/Elm/webpack4/node_modules/elm-webpack-loader/index.js:117:28)
 @ ./src/index.js 1:10-31

webpack.config.js

module.exports = {
	module: {
		rules: [
			{
				test: /\.elm$/,
				exclude: [/elm-stuff/, /node_modules/],
				use: {
					loader: 'elm-webpack-loader'
				}
			}
		],
		noParse: [/\.elm$/]
	}
};

src/index.js

const Elm = require('./Main.elm');
// import Elm from './Main.elm'
console.log('App started...');

src/Main.elm

module Main exposing (main)

import Html exposing (Html, text)


main : Html msg
main =
    text "Hello, Elm!"
@gmaugard
Copy link

I had the same error. Try to use webpack 2.2 :)

@ghost
Copy link

ghost commented Feb 26, 2018

There's a minor error that can be bypassed to compile elm code with webpack 4. I'll make a pull request to at the very least get it to compile

@ghost
Copy link

ghost commented Feb 26, 2018

#136

@kirisaki
Copy link

webpack 4: migration guide for plugins/loaders – webpack – Medium
https://medium.com/webpack/webpack-4-migration-guide-for-plugins-loaders-20a79b927202

Loaders should receive all options via this.query.

@mickeyvip
Copy link
Author

@kirisaki , so the #136 should be updated to use this.query instead of this.options?

@eeue56
Copy link
Contributor

eeue56 commented Feb 28, 2018

We need to have continued support for older versions of webpack, too. Will changing to this.query affect that?

@mickeyvip
Copy link
Author

So the code can look like this?

var globalOptions = this.options
    ? this.options.elm || {}
    : this.query.elm || {};

@meowgorithm
Copy link

meowgorithm commented Mar 6, 2018

I believe this is fixed in master, which is not yet published (see #131). Try the following in your package.json:

"elm-webpack-loader": "git://github.com/elm-community/elm-webpack-loader#7d1c6d939ea5b8b8a8f2aa2eb497e7fba49e6c71"

@ghost
Copy link

ghost commented Mar 6, 2018

@meowgorithm - yes, as per #136, the change we discussed here has been made. I imagine the issue stays up until the new version is published, to avoid more issues about it.

@praveenperera
Copy link

@eeue56 Is there something else that needs to be done before publishing a new version to npm with #136 ?

@eeue56
Copy link
Contributor

eeue56 commented Mar 15, 2018

published as 4.5.0

@eeue56 eeue56 closed this as completed Mar 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants