a zip code crypto-currency system good for red ONLY

HarmonyModulesPlugin.js 3.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const HarmonyImportDependency = require("./HarmonyImportDependency");
  7. const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDependency");
  8. const HarmonyCompatiblilityDependency = require("./HarmonyCompatibilityDependency");
  9. const HarmonyExportHeaderDependency = require("./HarmonyExportHeaderDependency");
  10. const HarmonyExportExpressionDependency = require("./HarmonyExportExpressionDependency");
  11. const HarmonyExportSpecifierDependency = require("./HarmonyExportSpecifierDependency");
  12. const HarmonyExportImportedSpecifierDependency = require("./HarmonyExportImportedSpecifierDependency");
  13. const HarmonyAcceptDependency = require("./HarmonyAcceptDependency");
  14. const HarmonyAcceptImportDependency = require("./HarmonyAcceptImportDependency");
  15. const NullFactory = require("../NullFactory");
  16. const HarmonyDetectionParserPlugin = require("./HarmonyDetectionParserPlugin");
  17. const HarmonyImportDependencyParserPlugin = require("./HarmonyImportDependencyParserPlugin");
  18. const HarmonyExportDependencyParserPlugin = require("./HarmonyExportDependencyParserPlugin");
  19. class HarmonyModulesPlugin {
  20. constructor(options) {
  21. this.options = options;
  22. }
  23. apply(compiler) {
  24. compiler.plugin("compilation", (compilation, params) => {
  25. const normalModuleFactory = params.normalModuleFactory;
  26. compilation.dependencyFactories.set(HarmonyImportDependency, normalModuleFactory);
  27. compilation.dependencyTemplates.set(HarmonyImportDependency, new HarmonyImportDependency.Template());
  28. compilation.dependencyFactories.set(HarmonyImportSpecifierDependency, new NullFactory());
  29. compilation.dependencyTemplates.set(HarmonyImportSpecifierDependency, new HarmonyImportSpecifierDependency.Template());
  30. compilation.dependencyFactories.set(HarmonyCompatiblilityDependency, new NullFactory());
  31. compilation.dependencyTemplates.set(HarmonyCompatiblilityDependency, new HarmonyCompatiblilityDependency.Template());
  32. compilation.dependencyFactories.set(HarmonyExportHeaderDependency, new NullFactory());
  33. compilation.dependencyTemplates.set(HarmonyExportHeaderDependency, new HarmonyExportHeaderDependency.Template());
  34. compilation.dependencyFactories.set(HarmonyExportExpressionDependency, new NullFactory());
  35. compilation.dependencyTemplates.set(HarmonyExportExpressionDependency, new HarmonyExportExpressionDependency.Template());
  36. compilation.dependencyFactories.set(HarmonyExportSpecifierDependency, new NullFactory());
  37. compilation.dependencyTemplates.set(HarmonyExportSpecifierDependency, new HarmonyExportSpecifierDependency.Template());
  38. compilation.dependencyFactories.set(HarmonyExportImportedSpecifierDependency, new NullFactory());
  39. compilation.dependencyTemplates.set(HarmonyExportImportedSpecifierDependency, new HarmonyExportImportedSpecifierDependency.Template());
  40. compilation.dependencyFactories.set(HarmonyAcceptDependency, new NullFactory());
  41. compilation.dependencyTemplates.set(HarmonyAcceptDependency, new HarmonyAcceptDependency.Template());
  42. compilation.dependencyFactories.set(HarmonyAcceptImportDependency, normalModuleFactory);
  43. compilation.dependencyTemplates.set(HarmonyAcceptImportDependency, new HarmonyAcceptImportDependency.Template());
  44. params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {
  45. if(typeof parserOptions.harmony !== "undefined" && !parserOptions.harmony)
  46. return;
  47. parser.apply(
  48. new HarmonyDetectionParserPlugin(),
  49. new HarmonyImportDependencyParserPlugin(this.options),
  50. new HarmonyExportDependencyParserPlugin()
  51. );
  52. });
  53. });
  54. }
  55. }
  56. module.exports = HarmonyModulesPlugin;