Skip to content

Commit 09a93c9

Browse files
authored
Merge pull request #199 from sporto/webpack-5
Update for Webpack 5. Change compiler.options.watch to compiler.watching
2 parents 2bbe487 + 3bb6661 commit 09a93c9

File tree

9 files changed

+3449
-8605
lines changed

9 files changed

+3449
-8605
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[Webpack](https://webpack.js.org/) loader for the [Elm](http://elm-lang.org/) programming language.
44

5-
It is aware of Elm dependencies and tracks them. This means that in `--watch`
5+
It is aware of Elm dependencies and tracks them. This means that in watch
66
mode, if you `require` an Elm module from a Webpack entry point, not only will
77
that `.elm` file be watched for changes, but any other Elm modules it imports will
88
be watched for changes as well.
@@ -227,6 +227,10 @@ in the example.
227227

228228
## Revisions
229229

230+
### 7.0.2
231+
232+
- Fix watching when using the dev server. Use `compiler.watching` instead of `compiler.options.watch` as the latter doesn't work with the dev server.
233+
230234
### 7.0.0
231235

232236
- Logs build output directly to stdout to retain formatting.

example/elm.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"version": "0.0.0",
33
"type": "application",
4-
"summary": "Example using webpack 4",
4+
"summary": "Example using webpack 5",
55
"repository": "https://github.com/elm-community/elm-webpack-loader.git",
66
"license": "BSD-3-Clause",
77
"source-directories": [
88
"src"
99
],
10-
"elm-version": "0.19.0",
10+
"elm-version": "0.19.1",
1111
"dependencies": {
1212
"direct": {
1313
"elm/browser": "1.0.0",

example/package-lock.json

Lines changed: 3419 additions & 8580 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
"scripts": {
77
"build": "webpack --mode production",
88
"watch": "webpack --mode development --watch",
9-
"dev": "webpack-dev-server --mode development --port 3000",
9+
"dev": "webpack serve --mode development --port 3000",
1010
"errors": "webpack --mode development --display-error-details"
1111
},
12-
"dependencies": {
12+
"dependencies": {},
13+
"devDependencies": {
1314
"file-loader": "1.1.10",
14-
"loader-utils": "1.1.0",
15-
"webpack": "4.0.1",
16-
"webpack-cli": "2.0.9",
17-
"webpack-dev-server": "3.9.0"
15+
"loader-utils": "2.0.0",
16+
"webpack": "^5.20.0",
17+
"webpack-cli": "^4.5.0",
18+
"webpack-dev-server": "^3.11.0"
1819
}
1920
}

example/src/Main.elm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Main exposing (..)
22

3-
import Html exposing (text)
43
import Hello.World exposing (hello)
4+
import Html exposing (text)
55

66

77
main : Html.Html a

example/webpack.config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = {
88
rules: [{
99
test: /\.html$/,
1010
exclude: /node_modules/,
11-
loader: 'file-loader?name=[name].[ext]'
11+
loader: 'file-loader'
1212
},
1313
{
1414
test: /\.elm$/,
@@ -21,7 +21,8 @@ module.exports = {
2121
},
2222

2323
devServer: {
24-
inline: true,
24+
contentBase: path.join(__dirname, "src"),
2525
stats: 'errors-only'
26-
}
26+
},
27+
2728
};

index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,9 @@ module.exports = function() {
9797

9898
var promises = [];
9999

100-
101100
// we only need to track deps if we are in watch mode
102101
// otherwise, we trust elm to do it's job
103-
if (compiler.options.watch) {
102+
if (compiler.watching) {
104103
// we can do a glob to track deps we care about if cwd is set
105104
if (typeof options.cwd !== "undefined" && options.cwd !== null){
106105
// watch elm.json

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"homepage": "https://github.com/elm-community/elm-webpack-loader",
2727
"dependencies": {
28-
"loader-utils": "^1.4.0",
28+
"loader-utils": "^2.0.0",
2929
"node-elm-compiler": "^5.0.0"
3030
},
3131
"devDependencies": {

0 commit comments

Comments
 (0)