Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
76 lines (67 loc) · 2.82 KB

File metadata and controls

76 lines (67 loc) · 2.82 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
var utils = require('loader-utils');
var bootstrapModule = /(\.bootstrapModule|\.bootstrapModuleFactory)\((.+)\)/gm;
var bootLoader = /((hmr_1|r)\.bootloader)\((.+)\)/gm;
function Angular2HMRLoader(source, sourcemap) {
var self = this;
// Not cacheable during unit tests;
self.cacheable && self.cacheable();
var query = utils.getOptions(self) || {};
function done(src, srcmap) {
// Support for tests
if (self.callback) {
self.callback(null, src, srcmap);
} else {
return src;
}
}
if (query.prod) {
source = source.replace(bootLoader, function (match, boot, ngmodule, main, offset, src) {
// return updated metadata
return '(document.readyState === "complete" || document.readyState === "interactive") ? ' + main +
'() : document.addEventListener("DOMContentLoaded", function() { ' + main + '()' + ' })';
});
return done(source, sourcemap);
}
source = source.replace(bootstrapModule, function (match, boot, ngmodule, offset, src) {
// return updated metadata
var newLine = ' ';
if (query.pretty) {
newLine = '\n';
}
return boot + '(' + ngmodule + ')' +
'.then(function(MODULE_REF) {'+ newLine +
' if (module["hot"]) {'+ newLine +
' module["hot"]["accept"]();'+ newLine +
' '+ newLine +
' if (MODULE_REF.instance["hmrOnInit"]) {'+ newLine +
' module["hot"]["data"] && MODULE_REF.instance["hmrOnInit"](module["hot"]["data"]);'+ newLine +
' }'+ newLine +
' if (MODULE_REF.instance["hmrOnStatus"]) {'+ newLine +
' module["hot"]["apply"](function(status) {'+ newLine +
' MODULE_REF.instance["hmrOnStatus"](status);'+ newLine +
' });'+ newLine +
' }'+ newLine +
' if (MODULE_REF.instance["hmrOnCheck"]) {'+ newLine +
' module["hot"]["check"](function(err, outdatedModules) {'+ newLine +
' MODULE_REF.instance["hmrOnCheck"](err, outdatedModules);'+ newLine +
' });'+ newLine +
' }'+ newLine +
' if (MODULE_REF.instance["hmrOnDecline"]) {'+ newLine +
' module["hot"]["decline"](function(dependencies) {'+ newLine +
' MODULE_REF.instance["hmrOnDecline"](dependencies);'+ newLine +
' });'+ newLine +
' }'+ newLine +
' module["hot"]["dispose"](function(store) {'+ newLine +
' MODULE_REF.instance["hmrOnDestroy"] && MODULE_REF.instance["hmrOnDestroy"](store);'+ newLine +
' MODULE_REF.destroy();'+ newLine +
' MODULE_REF.instance["hmrAfterDestroy"] && MODULE_REF.instance["hmrAfterDestroy"](store);'+ newLine +
' });'+ newLine +
' }'+ newLine +
' return MODULE_REF;'+ newLine +
'})'
});
return done(source, sourcemap)
};
// Make sure it works anyway you import it
Angular2HMRLoader.default = Angular2HMRLoader;
module.exports = Angular2HMRLoader
Morty Proxy This is a proxified and sanitized view of the page, visit original site.