elm-webpack-loader 8.0.0 → 8.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.travis.yml +4 -4
- package/CHANGELOG.md +96 -0
- package/README.md +67 -131
- package/example/elm.json +1 -1
- package/example/webpack.config.js +1 -1
- package/index.js +13 -3
- package/package.json +3 -3
- package/test/fixtures/Good.elm +3 -0
- package/test/fixtures/elm.json +1 -1
- package/test/fixtures - with dashes/Good.elm +8 -0
- package/test/fixtures - with dashes/GoodDependency.elm +3 -0
- package/test/fixtures - with dashes/elm.json +25 -0
- package/test/loader.js +70 -4
package/.travis.yml
CHANGED
|
@@ -10,10 +10,10 @@ os:
|
|
|
10
10
|
|
|
11
11
|
env:
|
|
12
12
|
matrix:
|
|
13
|
-
- ELM_VERSION=0.19.0
|
|
14
|
-
- ELM_VERSION=0.19.0
|
|
15
|
-
- ELM_VERSION=0.19.0
|
|
16
|
-
- ELM_VERSION=0.19.0
|
|
13
|
+
- ELM_VERSION=0.19.3-0 TARGET_NODE_VERSION=8
|
|
14
|
+
- ELM_VERSION=0.19.3-0 TARGET_NODE_VERSION=10
|
|
15
|
+
- ELM_VERSION=0.19.3-0 TARGET_NODE_VERSION=11
|
|
16
|
+
- ELM_VERSION=0.19.3-0 TARGET_NODE_VERSION=12
|
|
17
17
|
|
|
18
18
|
before_install:
|
|
19
19
|
- if [ ${TRAVIS_OS_NAME} == "osx" ];
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 8.0.2
|
|
4
|
+
|
|
5
|
+
- Fix Elm compilation on Windows when source paths contain spaces or dashes.
|
|
6
|
+
- Refresh the README with a feature overview, quick start, and modern alternatives for new projects.
|
|
7
|
+
- Move the release history to a dedicated changelog.
|
|
8
|
+
|
|
9
|
+
## 8.0.1
|
|
10
|
+
|
|
11
|
+
- Include Elm compiler diagnostics in webpack compilation errors.
|
|
12
|
+
- Support Elm 0.19.2 and 0.19.3, and make Elm an optional dependency instead of a peer dependency.
|
|
13
|
+
|
|
14
|
+
## 8.0.0
|
|
15
|
+
|
|
16
|
+
- 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.
|
|
17
|
+
|
|
18
|
+
## 7.0.0
|
|
19
|
+
|
|
20
|
+
- Logs build output directly to stdout to retain formatting.
|
|
21
|
+
- Remove stack trace for errors, as they're never relevant.
|
|
22
|
+
- `optimize` and `debug` flags are now set by default depending on the webpack mode.
|
|
23
|
+
- Removed several options which provide little benefit.
|
|
24
|
+
- Reduced number of dependencies.
|
|
25
|
+
|
|
26
|
+
## 6.0.0
|
|
27
|
+
|
|
28
|
+
- Elm is now a peer dependency.
|
|
29
|
+
- Documentation fixes.
|
|
30
|
+
|
|
31
|
+
## 5.0.0
|
|
32
|
+
|
|
33
|
+
- Support for Elm 0.19, drops support for Elm 0.18.
|
|
34
|
+
|
|
35
|
+
## 4.3.1
|
|
36
|
+
|
|
37
|
+
- Fix a bug where maxInstances might end up being higher than expected
|
|
38
|
+
|
|
39
|
+
## 4.3.0
|
|
40
|
+
|
|
41
|
+
- Set maxInstances to 1
|
|
42
|
+
- Patch watching behaviour
|
|
43
|
+
- Add `forceWatch` to force watch mode
|
|
44
|
+
|
|
45
|
+
## 4.2.0
|
|
46
|
+
|
|
47
|
+
Make live reloading work more reliably
|
|
48
|
+
|
|
49
|
+
## 4.1.0
|
|
50
|
+
|
|
51
|
+
Added `maxInstances` for limiting of instances
|
|
52
|
+
|
|
53
|
+
## 4.0.0
|
|
54
|
+
|
|
55
|
+
Watching is now done based on elm-package.json, faster startup time via @eeue56
|
|
56
|
+
|
|
57
|
+
## 3.1.0
|
|
58
|
+
|
|
59
|
+
Add support for `--debug` via `node-elm-compiler`
|
|
60
|
+
|
|
61
|
+
## 3.0.6
|
|
62
|
+
|
|
63
|
+
Allow version bumps of node-elm-compiler.
|
|
64
|
+
|
|
65
|
+
## 3.0.5
|
|
66
|
+
|
|
67
|
+
Upgrade to latest node-elm-compiler, which fixes some dependency tracking issues.
|
|
68
|
+
|
|
69
|
+
## 3.0.4
|
|
70
|
+
|
|
71
|
+
Fix potential race condition between dependency checking and compilation.
|
|
72
|
+
|
|
73
|
+
## 3.0.3
|
|
74
|
+
|
|
75
|
+
Use node-elm-compiler 4.0.1+ for important bugfix.
|
|
76
|
+
|
|
77
|
+
## 3.0.2
|
|
78
|
+
|
|
79
|
+
Use node-elm-compiler 4.0.0+
|
|
80
|
+
|
|
81
|
+
## 3.0.1
|
|
82
|
+
|
|
83
|
+
Pass a real error object to webpack on failures.
|
|
84
|
+
|
|
85
|
+
## 3.0.0
|
|
86
|
+
|
|
87
|
+
Support Elm 0.17, and remove obsolete `appendExport` option.
|
|
88
|
+
|
|
89
|
+
## 2.0.0
|
|
90
|
+
|
|
91
|
+
Change `warn` to be a pass-through compiler flag rather than a way to specify
|
|
92
|
+
logging behavior.
|
|
93
|
+
|
|
94
|
+
## 1.0.0
|
|
95
|
+
|
|
96
|
+
Initial stable release.
|
package/README.md
CHANGED
|
@@ -1,23 +1,33 @@
|
|
|
1
|
-
# Elm
|
|
1
|
+
# Elm webpack loader
|
|
2
2
|
|
|
3
|
-
[
|
|
3
|
+
[](https://www.npmjs.com/package/elm-webpack-loader) [](https://matrix.to/#/#elm-dev:matrix.org)
|
|
4
|
+
[](https://app.travis-ci.com/elm-community/elm-webpack-loader)
|
|
5
|
+
[](https://github.com/elm-community/elm-webpack-loader/blob/master/LICENSE)
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
mode, if you `require` an Elm module from a Webpack entry point, not only will
|
|
7
|
-
that `.elm` file be watched for changes, but any other Elm modules it imports will
|
|
8
|
-
be watched for changes as well.
|
|
7
|
+
> Compile [Elm](https://elm-lang.org/) applications with [webpack](https://webpack.js.org/).
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
- 🔍 **Dependency-aware watch mode** rebuilds when imported Elm modules change.
|
|
10
|
+
- ⚙️ **Sensible defaults** enable the debugger in development and optimizations in production.
|
|
11
|
+
- 🔥 **Hot module reloading** works with `elm-hot-webpack-loader`.
|
|
12
|
+
- 🩺 **Compiler diagnostics** appear directly in webpack's error output.
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
> [!IMPORTANT]
|
|
15
|
+
> **For new projects, consider a modern alternative.**
|
|
16
|
+
>
|
|
17
|
+
> - **Pure Elm:** [elm-watch](https://lydell.github.io/elm-watch/)
|
|
18
|
+
> - **Mixed language/framework projects:** [vite-plugin-elm-watch](https://github.com/ryannhg/vite-plugin-elm-watch) or [vite-plugin-elm](https://github.com/hmsk/vite-plugin-elm)
|
|
19
|
+
|
|
20
|
+
Elm webpack loader connects the Elm compiler to webpack. It tracks Elm module imports, so watch mode rebuilds your application when any imported module changes—not just when the entry module changes.
|
|
15
21
|
|
|
16
|
-
##
|
|
22
|
+
## Quick start
|
|
17
23
|
|
|
18
|
-
|
|
24
|
+
Install the loader:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npm install --save-dev elm-webpack-loader
|
|
28
|
+
```
|
|
19
29
|
|
|
20
|
-
|
|
30
|
+
Add it to your [webpack module rules](https://webpack.js.org/configuration/module/#rule):
|
|
21
31
|
|
|
22
32
|
```js
|
|
23
33
|
module.exports = {
|
|
@@ -34,11 +44,21 @@ module.exports = {
|
|
|
34
44
|
};
|
|
35
45
|
```
|
|
36
46
|
|
|
37
|
-
|
|
47
|
+
Import your Elm module and initialize the application:
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
const { Elm } = require('./Main.elm');
|
|
51
|
+
|
|
52
|
+
Elm.Main.init({
|
|
53
|
+
node: document.getElementById('main')
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
See the [example](#example) for a complete project or configure the [loader options](#options) below.
|
|
38
58
|
|
|
39
|
-
|
|
59
|
+
## Options
|
|
40
60
|
|
|
41
|
-
|
|
61
|
+
### cwd (default null) *Recommended*
|
|
42
62
|
|
|
43
63
|
You can add `cwd=elmSource` to the loader:
|
|
44
64
|
|
|
@@ -59,9 +79,9 @@ will cause the compiler to look for **all** elm source files in the specified di
|
|
|
59
79
|
approach is recommended as it allows the compile to watch elm.json as well as every file
|
|
60
80
|
in the source directories.
|
|
61
81
|
|
|
62
|
-
|
|
82
|
+
### Optimize (default is `true` in production mode)
|
|
63
83
|
|
|
64
|
-
Set this to true to compile bundle in optimized mode. See <https://elm-lang.org/0.19.
|
|
84
|
+
Set this to `true` to compile bundle in optimized mode. See <https://elm-lang.org/0.19.3/optimize> for more information.
|
|
65
85
|
|
|
66
86
|
```js
|
|
67
87
|
...
|
|
@@ -74,9 +94,9 @@ Set this to true to compile bundle in optimized mode. See <https://elm-lang.org/
|
|
|
74
94
|
...
|
|
75
95
|
```
|
|
76
96
|
|
|
77
|
-
|
|
97
|
+
### Debug (default is true in development mode)
|
|
78
98
|
|
|
79
|
-
Set this to true to enable Elm's time traveling debugger.
|
|
99
|
+
Set this to true to enable Elm's time traveling debugger.
|
|
80
100
|
|
|
81
101
|
```js
|
|
82
102
|
...
|
|
@@ -89,7 +109,7 @@ Set this to true to enable Elm's time traveling debugger.
|
|
|
89
109
|
...
|
|
90
110
|
```
|
|
91
111
|
|
|
92
|
-
|
|
112
|
+
### RuntimeOptions (default `undefined`)
|
|
93
113
|
|
|
94
114
|
This allows you to control aspects of how `elm make` runs with [GHC Runtime Options](https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/runtime_control.html).
|
|
95
115
|
|
|
@@ -113,7 +133,7 @@ with some additional flags to give it more memory, `e.g. -A128M -H128M -n8m`.
|
|
|
113
133
|
...
|
|
114
134
|
```
|
|
115
135
|
|
|
116
|
-
|
|
136
|
+
### Files (default - path to 'required' file)
|
|
117
137
|
|
|
118
138
|
elm make allows you to specify multiple modules to be combined into a single bundle
|
|
119
139
|
|
|
@@ -140,6 +160,7 @@ module: {
|
|
|
140
160
|
]
|
|
141
161
|
}
|
|
142
162
|
```
|
|
163
|
+
|
|
143
164
|
(Note: It's only possible to pass array options when using the object style of loader configuration.)
|
|
144
165
|
|
|
145
166
|
You're then able to use this with
|
|
@@ -151,7 +172,26 @@ Elm.Main.init({node: document.getElementById("main")});
|
|
|
151
172
|
Elm.Path.To.OtherModule.init({node: document.getElementById("other")});
|
|
152
173
|
```
|
|
153
174
|
|
|
154
|
-
|
|
175
|
+
### Upstream options
|
|
176
|
+
|
|
177
|
+
All options are sent down as an `options` object to node-elm-compiler. For example, you can
|
|
178
|
+
explicitly pick the local `elm` binary by setting the option `pathToElm`:
|
|
179
|
+
|
|
180
|
+
```js
|
|
181
|
+
...
|
|
182
|
+
use: {
|
|
183
|
+
loader: 'elm-webpack-loader',
|
|
184
|
+
options: {
|
|
185
|
+
pathToElm: 'node_modules/.bin/elm'
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
...
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
For a list all possible options,
|
|
192
|
+
[consult the source](https://github.com/rtfeldman/node-elm-compiler/blob/3fde73d/index.js#L12-L23).
|
|
193
|
+
|
|
194
|
+
## Hot module reloading
|
|
155
195
|
|
|
156
196
|
Hot module reloading is supported by installing [elm-hot-webpack-loader](https://github.com/klazuka/elm-hot-webpack-loader)
|
|
157
197
|
and adding it to your list of loaders. It should look something like this:
|
|
@@ -173,29 +213,7 @@ module: {
|
|
|
173
213
|
|
|
174
214
|
**IMPORTANT**: `elm-hot-webpack-loader` must be placed in the list immediately *before* `elm-webpack-loader`.
|
|
175
215
|
|
|
176
|
-
|
|
177
|
-
#### Upstream options
|
|
178
|
-
|
|
179
|
-
All options are sent down as an `options` object to node-elm-compiler. For example, you can
|
|
180
|
-
explicitly pick the local `elm` binary by setting the option `pathToElm`:
|
|
181
|
-
|
|
182
|
-
```js
|
|
183
|
-
...
|
|
184
|
-
use: {
|
|
185
|
-
loader: 'elm-webpack-loader',
|
|
186
|
-
options: {
|
|
187
|
-
pathToElm: 'node_modules/.bin/elm'
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
...
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
For a list all possible options,
|
|
194
|
-
[consult the source](https://github.com/rtfeldman/node-elm-compiler/blob/3fde73d/index.js#L12-L23).
|
|
195
|
-
|
|
196
|
-
## Notes
|
|
197
|
-
|
|
198
|
-
### Example
|
|
216
|
+
## Example
|
|
199
217
|
|
|
200
218
|
You can find an example in the `example` folder.
|
|
201
219
|
To run:
|
|
@@ -211,7 +229,7 @@ You can run the webpack dev server with: `npm run dev`
|
|
|
211
229
|
|
|
212
230
|
For a full featured example project that uses elm-webpack-loader see [pmdesgn/elm-webpack-starter](https://github.com/pmdesgn/elm-webpack-starter) .
|
|
213
231
|
|
|
214
|
-
|
|
232
|
+
## noParse
|
|
215
233
|
|
|
216
234
|
Webpack can complain about precompiled files (files compiled by `elm make`).
|
|
217
235
|
You can silence this warning with
|
|
@@ -225,88 +243,6 @@ in the example.
|
|
|
225
243
|
}
|
|
226
244
|
```
|
|
227
245
|
|
|
228
|
-
##
|
|
229
|
-
|
|
230
|
-
### 8.0.0
|
|
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
|
-
|
|
234
|
-
### 7.0.0
|
|
235
|
-
|
|
236
|
-
- Logs build output directly to stdout to retain formatting.
|
|
237
|
-
- Remove stack trace for errors, as they're never relevant.
|
|
238
|
-
- `optimize` and `debug` flags are now set by default depending on the webpack mode.
|
|
239
|
-
- Removed several options which provide little benefit.
|
|
240
|
-
- Reduced number of dependencies.
|
|
241
|
-
|
|
242
|
-
### 6.0.0
|
|
243
|
-
|
|
244
|
-
- Elm is now a peer dependency.
|
|
245
|
-
- Documentation fixes.
|
|
246
|
-
|
|
247
|
-
### 5.0.0
|
|
248
|
-
|
|
249
|
-
- Support for Elm 0.19, drops support for Elm 0.18.
|
|
250
|
-
|
|
251
|
-
### 4.3.1
|
|
252
|
-
|
|
253
|
-
- Fix a bug where maxInstances might end up being higher than expected
|
|
254
|
-
|
|
255
|
-
### 4.3.0
|
|
256
|
-
|
|
257
|
-
- Set maxInstances to 1
|
|
258
|
-
- Patch watching behaviour
|
|
259
|
-
- Add `forceWatch` to force watch mode
|
|
260
|
-
|
|
261
|
-
### 4.2.0
|
|
262
|
-
|
|
263
|
-
Make live reloading work more reliably
|
|
264
|
-
|
|
265
|
-
### 4.1.0
|
|
266
|
-
|
|
267
|
-
Added `maxInstances` for limiting of instances
|
|
268
|
-
|
|
269
|
-
### 4.0.0
|
|
270
|
-
|
|
271
|
-
Watching is now done based on elm-package.json, faster startup time via @eeue56
|
|
272
|
-
|
|
273
|
-
### 3.1.0
|
|
274
|
-
|
|
275
|
-
Add support for `--debug` via `node-elm-compiler`
|
|
276
|
-
|
|
277
|
-
### 3.0.6
|
|
278
|
-
|
|
279
|
-
Allow version bumps of node-elm-compiler.
|
|
280
|
-
|
|
281
|
-
### 3.0.5
|
|
282
|
-
|
|
283
|
-
Upgrade to latest node-elm-compiler, which fixes some dependency tracking issues.
|
|
284
|
-
|
|
285
|
-
### 3.0.4
|
|
286
|
-
|
|
287
|
-
Fix potential race condition between dependency checking and compilation.
|
|
288
|
-
|
|
289
|
-
### 3.0.3
|
|
290
|
-
|
|
291
|
-
Use node-elm-compiler 4.0.1+ for important bugfix.
|
|
292
|
-
|
|
293
|
-
### 3.0.2
|
|
294
|
-
|
|
295
|
-
Use node-elm-compiler 4.0.0+
|
|
296
|
-
|
|
297
|
-
### 3.0.1
|
|
298
|
-
|
|
299
|
-
Pass a real error object to webpack on failures.
|
|
300
|
-
|
|
301
|
-
### 3.0.0
|
|
302
|
-
|
|
303
|
-
Support Elm 0.17, and remove obsolete `appendExport` option.
|
|
304
|
-
|
|
305
|
-
### 2.0.0
|
|
306
|
-
|
|
307
|
-
Change `warn` to be a pass-through compiler flag rather than a way to specify
|
|
308
|
-
logging behavior.
|
|
309
|
-
|
|
310
|
-
### 1.0.0
|
|
246
|
+
## Changelog
|
|
311
247
|
|
|
312
|
-
|
|
248
|
+
See [CHANGELOG.md](CHANGELOG.md) for the release history.
|
package/example/elm.json
CHANGED
package/index.js
CHANGED
|
@@ -163,20 +163,30 @@ function compile(sources, options) {
|
|
|
163
163
|
return reject(err);
|
|
164
164
|
}
|
|
165
165
|
options.output = info.path;
|
|
166
|
-
options.processOpts = { stdio: "inherit" };
|
|
166
|
+
options.processOpts = { stdio: ["inherit", "inherit", "pipe"] };
|
|
167
167
|
|
|
168
168
|
var compiler;
|
|
169
169
|
|
|
170
170
|
try {
|
|
171
|
-
|
|
171
|
+
var compilerSources = process.platform === "win32"
|
|
172
|
+
? sources.map(function(f) { return '"' + f + '"'; })
|
|
173
|
+
: sources;
|
|
174
|
+
compiler = elmCompiler.compile(compilerSources, options);
|
|
172
175
|
}
|
|
173
176
|
catch (compileError) {
|
|
174
177
|
return reject(compileError);
|
|
175
178
|
}
|
|
176
179
|
|
|
180
|
+
// Catch output from stderr so we can use it in `reject()`
|
|
181
|
+
var errorChunks = [];
|
|
182
|
+
compiler.stderr.on('data', function (data) {
|
|
183
|
+
errorChunks.push(data);
|
|
184
|
+
});
|
|
185
|
+
|
|
177
186
|
compiler.on("close", function (exitCode) {
|
|
178
187
|
if (exitCode !== 0) {
|
|
179
|
-
|
|
188
|
+
var errorText = Buffer.concat(errorChunks).toString();
|
|
189
|
+
return reject("Compilation failed! " + errorText);
|
|
180
190
|
}
|
|
181
191
|
|
|
182
192
|
fs.readFile(info.path, { encoding: "utf8" }, function (err, data) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elm-webpack-loader",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.2",
|
|
4
4
|
"description": "Webpack loader for the Elm programming language.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"chai": "^3.4.1",
|
|
33
33
|
"mocha": "^6.1.4"
|
|
34
34
|
},
|
|
35
|
-
"
|
|
36
|
-
"elm": "^0.19.1-3 || 0.19.0-no-deps"
|
|
35
|
+
"optionalDependencies": {
|
|
36
|
+
"elm": "^0.19.3-0 || ^0.19.2-0 || ^0.19.1-3 <0.19.1 || 0.19.0-no-deps"
|
|
37
37
|
}
|
|
38
38
|
}
|
package/test/fixtures/Good.elm
CHANGED
package/test/fixtures/elm.json
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"summary": "Tests for paths containing spaces and dashes.",
|
|
3
|
+
"type": "application",
|
|
4
|
+
"source-directories": [
|
|
5
|
+
"."
|
|
6
|
+
],
|
|
7
|
+
"elm-version": "0.19.3",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"direct": {
|
|
10
|
+
"elm/browser": "1.0.0",
|
|
11
|
+
"elm/core": "1.0.0",
|
|
12
|
+
"elm/html": "1.0.0"
|
|
13
|
+
},
|
|
14
|
+
"indirect": {
|
|
15
|
+
"elm/json": "1.0.0",
|
|
16
|
+
"elm/time": "1.0.0",
|
|
17
|
+
"elm/url": "1.0.0",
|
|
18
|
+
"elm/virtual-dom": "1.0.0"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"test-dependencies": {
|
|
22
|
+
"direct": {},
|
|
23
|
+
"indirect": {}
|
|
24
|
+
}
|
|
25
|
+
}
|
package/test/loader.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
var path = require('path');
|
|
2
2
|
var crypto = require('crypto');
|
|
3
|
+
var EventEmitter = require('events').EventEmitter;
|
|
3
4
|
var assert = require('chai').assert;
|
|
4
5
|
var compiler = require('node-elm-compiler');
|
|
5
6
|
var loader = require('../index.js');
|
|
@@ -10,6 +11,8 @@ var goodSource = path.join(fixturesDir, 'Good.elm');
|
|
|
10
11
|
var goodDependency = path.join(fixturesDir, 'GoodDependency.elm');
|
|
11
12
|
var elmPackage = path.join(fixturesDir, 'elm.json');
|
|
12
13
|
var otherElmSourceDir = path.join(__dirname, 'other_elm_source_dir');
|
|
14
|
+
var dashedFixturesDir = path.join(__dirname, 'fixtures - with dashes');
|
|
15
|
+
var dashedGoodSource = path.join(dashedFixturesDir, 'Good.elm');
|
|
13
16
|
|
|
14
17
|
var toString = Object.prototype.toString;
|
|
15
18
|
|
|
@@ -36,6 +39,7 @@ var mock = function (source, query, opts, callback, watchMode, cwd) {
|
|
|
36
39
|
var addedDirDependencies = [];
|
|
37
40
|
|
|
38
41
|
var result = {
|
|
42
|
+
_compiler: { options: {} },
|
|
39
43
|
loaders: [],
|
|
40
44
|
loaderIndex: 0,
|
|
41
45
|
|
|
@@ -72,8 +76,7 @@ var mock = function (source, query, opts, callback, watchMode, cwd) {
|
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
if (watchMode) {
|
|
75
|
-
result.
|
|
76
|
-
result.argv = {watch : true};
|
|
79
|
+
result._compiler.watching = true;
|
|
77
80
|
}
|
|
78
81
|
|
|
79
82
|
return result;
|
|
@@ -113,6 +116,64 @@ describe('async mode', function () {
|
|
|
113
116
|
loader.call(context, goodSource);
|
|
114
117
|
});
|
|
115
118
|
|
|
119
|
+
it('compiles resources with dashes and spaces in their paths', function (done) {
|
|
120
|
+
var options = {
|
|
121
|
+
cwd: dashedFixturesDir
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
var callback = function (loaderErr, loaderResult) {
|
|
125
|
+
try {
|
|
126
|
+
assert.isNull(loaderErr);
|
|
127
|
+
assert.isString(loaderResult);
|
|
128
|
+
assert.isAbove(loaderResult.length, 0);
|
|
129
|
+
done();
|
|
130
|
+
} catch (assertionError) {
|
|
131
|
+
done(assertionError);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
context = mock(dashedGoodSource, null, options, callback);
|
|
136
|
+
loader.call(context, dashedGoodSource);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('quotes compiler source paths on Windows', function (done) {
|
|
140
|
+
var originalCompile = compiler.compile;
|
|
141
|
+
var originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform');
|
|
142
|
+
var compilerSources;
|
|
143
|
+
var fakeCompiler = new EventEmitter();
|
|
144
|
+
fakeCompiler.stderr = new EventEmitter();
|
|
145
|
+
|
|
146
|
+
var restore = function () {
|
|
147
|
+
compiler.compile = originalCompile;
|
|
148
|
+
Object.defineProperty(process, 'platform', originalPlatform);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
compiler.compile = function (sources) {
|
|
152
|
+
compilerSources = sources;
|
|
153
|
+
process.nextTick(function () { fakeCompiler.emit('close', 1); });
|
|
154
|
+
return fakeCompiler;
|
|
155
|
+
};
|
|
156
|
+
Object.defineProperty(process, 'platform', { value: 'win32' });
|
|
157
|
+
|
|
158
|
+
var callback = function () {
|
|
159
|
+
restore();
|
|
160
|
+
try {
|
|
161
|
+
assert.deepEqual(compilerSources, ['"' + goodSource + '"']);
|
|
162
|
+
done();
|
|
163
|
+
} catch (assertionError) {
|
|
164
|
+
done(assertionError);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
context = mock(goodSource, null, { cwd: fixturesDir }, callback);
|
|
169
|
+
try {
|
|
170
|
+
loader.call(context, goodSource);
|
|
171
|
+
} catch (err) {
|
|
172
|
+
restore();
|
|
173
|
+
done(err);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
116
177
|
it('does not add dependencies in normal mode', function (done) {
|
|
117
178
|
var options = {
|
|
118
179
|
cwd: fixturesDir
|
|
@@ -187,8 +248,13 @@ describe('async mode', function () {
|
|
|
187
248
|
};
|
|
188
249
|
|
|
189
250
|
var callback = function (err) {
|
|
190
|
-
|
|
191
|
-
|
|
251
|
+
try {
|
|
252
|
+
assert.match(err.message, /Bad\.elm/);
|
|
253
|
+
assert.match(err.message, /UNFINISHED MODULE DECLARATION/i);
|
|
254
|
+
done();
|
|
255
|
+
} catch (assertionError) {
|
|
256
|
+
done(assertionError);
|
|
257
|
+
}
|
|
192
258
|
};
|
|
193
259
|
|
|
194
260
|
context = mock(badSource, null, options, callback);
|