a zip code crypto-currency system good for red ONLY

ImportPlugin.js 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const ImportDependency = require("./ImportDependency");
  7. const ImportEagerDependency = require("./ImportEagerDependency");
  8. const ImportWeakDependency = require("./ImportWeakDependency");
  9. const ImportEagerContextDependency = require("./ImportEagerContextDependency");
  10. const ImportWeakContextDependency = require("./ImportWeakContextDependency");
  11. const ImportLazyOnceContextDependency = require("./ImportLazyOnceContextDependency");
  12. const ImportLazyContextDependency = require("./ImportLazyContextDependency");
  13. const ImportParserPlugin = require("./ImportParserPlugin");
  14. class ImportPlugin {
  15. constructor(options) {
  16. this.options = options;
  17. }
  18. apply(compiler) {
  19. const options = this.options;
  20. compiler.plugin("compilation", (compilation, params) => {
  21. const normalModuleFactory = params.normalModuleFactory;
  22. const contextModuleFactory = params.contextModuleFactory;
  23. compilation.dependencyFactories.set(ImportDependency, normalModuleFactory);
  24. compilation.dependencyTemplates.set(ImportDependency, new ImportDependency.Template());
  25. compilation.dependencyFactories.set(ImportEagerDependency, normalModuleFactory);
  26. compilation.dependencyTemplates.set(ImportEagerDependency, new ImportEagerDependency.Template());
  27. compilation.dependencyFactories.set(ImportWeakDependency, normalModuleFactory);
  28. compilation.dependencyTemplates.set(ImportWeakDependency, new ImportWeakDependency.Template());
  29. compilation.dependencyFactories.set(ImportEagerContextDependency, contextModuleFactory);
  30. compilation.dependencyTemplates.set(ImportEagerContextDependency, new ImportEagerContextDependency.Template());
  31. compilation.dependencyFactories.set(ImportWeakContextDependency, contextModuleFactory);
  32. compilation.dependencyTemplates.set(ImportWeakContextDependency, new ImportWeakContextDependency.Template());
  33. compilation.dependencyFactories.set(ImportLazyOnceContextDependency, contextModuleFactory);
  34. compilation.dependencyTemplates.set(ImportLazyOnceContextDependency, new ImportLazyOnceContextDependency.Template());
  35. compilation.dependencyFactories.set(ImportLazyContextDependency, contextModuleFactory);
  36. compilation.dependencyTemplates.set(ImportLazyContextDependency, new ImportLazyContextDependency.Template());
  37. normalModuleFactory.plugin("parser", (parser, parserOptions) => {
  38. if(typeof parserOptions.import !== "undefined" && !parserOptions.import)
  39. return;
  40. parser.apply(
  41. new ImportParserPlugin(options)
  42. );
  43. });
  44. });
  45. }
  46. }
  47. module.exports = ImportPlugin;