UNPKG

1.05 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var path_1 = require("path");
4var Constants = require("../util/constants");
5var helpers_1 = require("../util/helpers");
6function cacheLoader(source, map, webpackContex) {
7 webpackContex.cacheable();
8 var callback = webpackContex.async();
9 try {
10 var context = helpers_1.getContext();
11 if (helpers_1.getBooleanPropertyValue(Constants.ENV_AOT_WRITE_TO_DISK)) {
12 var jsPath = helpers_1.changeExtension(path_1.resolve(path_1.normalize(webpackContex.resourcePath)), '.js');
13 var newSourceFile = { path: jsPath, content: source };
14 context.fileCache.set(jsPath, newSourceFile);
15 var mapPath = helpers_1.changeExtension(jsPath, '.js.map');
16 var newMapFile = { path: mapPath, content: JSON.stringify(map) };
17 context.fileCache.set(mapPath, newMapFile);
18 }
19 callback(null, source, map);
20 }
21 catch (ex) {
22 callback(ex);
23 }
24}
25exports.cacheLoader = cacheLoader;