forked from parcel-bundler/parcel
/
elm.js
60 lines (48 loc) 路 1.79 KB
/
elm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const assert = require('assert');
const fs = require('@parcel/fs');
const {bundle, assertBundleTree, run} = require('./utils');
describe('elm', function() {
it('should produce a basic Elm bundle', async function() {
let b = await bundle(__dirname + '/integration/elm/index.js');
await assertBundleTree(b, {
type: 'js',
assets: ['Main.elm', 'index.js']
});
let output = await run(b);
assert.equal(typeof output().Elm.Main.init, 'function');
});
it('should produce a elm bundle with debugger', async function() {
let b = await bundle(__dirname + '/integration/elm/index.js');
await run(b);
let js = await fs.readFile(__dirname + '/dist/index.js', 'utf8');
assert(js.includes('elm$browser$Debugger'));
});
it('should apply elm-hot if HMR is enabled', async function() {
let b = await bundle(__dirname + '/integration/elm/index.js', {
hmr: true
});
await assertBundleTree(b, {
type: 'js',
assets: ['Main.elm', 'hmr-runtime.js', 'index.js']
});
let js = await fs.readFile(__dirname + '/dist/index.js', 'utf8');
assert(js.includes('[elm-hot]'));
});
it('should remove debugger in production', async function() {
let b = await bundle(__dirname + '/integration/elm/index.js', {
production: true
});
await run(b);
let js = await fs.readFile(__dirname + '/dist/index.js', 'utf8');
assert(!js.includes('elm$browser$Debugger'));
});
it('should minify Elm in production mode', async function() {
let b = await bundle(__dirname + '/integration/elm/index.js', {
production: true
});
let output = await run(b);
assert.equal(typeof output().Elm.Main.init, 'function');
let js = await fs.readFile(__dirname + '/dist/index.js', 'utf8');
assert(!js.includes('elm$core'));
});
});