cache-loader-impl.js 1.0KB

1234567891011121314151617181920212223242526
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var path_1 = require("path");
  4. var Constants = require("../util/constants");
  5. var helpers_1 = require("../util/helpers");
  6. function 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. }
  25. exports.cacheLoader = cacheLoader;