a zip code crypto-currency system good for red ONLY

SystemPlugin.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const ParserHelpers = require("../ParserHelpers");
  7. class SystemPlugin {
  8. constructor(options) {
  9. this.options = options;
  10. }
  11. apply(compiler) {
  12. compiler.plugin("compilation", (compilation, params) => {
  13. params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {
  14. if(typeof parserOptions.system !== "undefined" && !parserOptions.system)
  15. return;
  16. function setNotSupported(name) {
  17. parser.plugin("evaluate typeof " + name, ParserHelpers.evaluateToString("undefined"));
  18. parser.plugin("expression " + name,
  19. ParserHelpers.expressionIsUnsupported(name + " is not supported by webpack.")
  20. );
  21. }
  22. parser.plugin("typeof System.import", ParserHelpers.toConstantDependency(JSON.stringify("function")));
  23. parser.plugin("evaluate typeof System.import", ParserHelpers.evaluateToString("function"));
  24. parser.plugin("typeof System", ParserHelpers.toConstantDependency(JSON.stringify("object")));
  25. parser.plugin("evaluate typeof System", ParserHelpers.evaluateToString("object"));
  26. setNotSupported("System.set");
  27. setNotSupported("System.get");
  28. setNotSupported("System.register");
  29. parser.plugin("expression System", function() {
  30. const systemPolyfillRequire = ParserHelpers.requireFileAsExpression(
  31. this.state.module.context, require.resolve("../../buildin/system.js"));
  32. return ParserHelpers.addParsedVariableToModule(this, "System", systemPolyfillRequire);
  33. });
  34. });
  35. });
  36. }
  37. }
  38. module.exports = SystemPlugin;