-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack-loader.js
61 lines (49 loc) · 1.71 KB
/
webpack-loader.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
61
// Generated by CoffeeScript 1.12.7
(function() {
var CaffeineEight, CaffeineMc, cafSourceMaps, getEnv, loaderUtils, log, ref;
CaffeineMc = require('./index');
CaffeineEight = require('caffeine-eight');
loaderUtils = require('loader-utils');
ref = require('art-standard-lib'), log = ref.log, getEnv = ref.getEnv;
/*
TODO: Fix SOURCEMAPS (SBD 2018-07-30 notes)
'cafSourceMaps' is a temporary hack for testing.
This current code actually works with webpack4/webpack-dev-server3 && Safari,
but it DOESNT work in Chrome. Chrome seems to actually get the sourcemap correctly,
but it won't show the original source.
SO - cafSourceMaps is off by default, but you can turn it on if you want:
> cafSourceMaps=true webpack-dev-server
*/
cafSourceMaps = getEnv.cafSourceMaps;
module.exports = function(source) {
var e, js, out, ref1, sourceFile, sourceMap;
if (typeof this.cacheable === "function") {
this.cacheable();
}
sourceFile = loaderUtils.getRemainingRequest(this);
try {
ref1 = CaffeineMc.FileCompiler.compileFileSync(sourceFile, {
source: source,
debug: this.debug,
sourceRoot: "",
cache: true,
inlineMap: !!cafSourceMaps,
prettier: !cafSourceMaps
}).compiled, js = ref1.js, sourceMap = ref1.sourceMap;
return this.callback(null, js, sourceMap);
} catch (error) {
e = error;
if (e instanceof CaffeineEight.CaffeineEightCompileError) {
out = new Error(e.toString());
out.stack = "";
throw out;
} else {
log.error({
"CaffeineMc webpack-loader error": e
});
}
throw e;
}
};
module.exports.separable = true;
}).call(this);