magicComment.js 645 B

12345678910111213141516171819202122232425
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Alexander Akait @alexander-akait
  4. */
  5. "use strict";
  6. const memoize = require("./memoize");
  7. const getVm = memoize(() => require("vm"));
  8. // regexp to match at least one "magic comment"
  9. module.exports.createMagicCommentContext = () =>
  10. getVm().createContext(undefined, {
  11. name: "Webpack Magic Comment Parser",
  12. codeGeneration: { strings: false, wasm: false }
  13. });
  14. module.exports.webpackCommentRegExp = new RegExp(
  15. /(^|\W)webpack[A-Z]{1,}[A-Za-z]{1,}:/
  16. );
  17. // regexp to match at least one "magic comment"
  18. /**
  19. * @returns {import("vm").Context} magic comment context
  20. */