magicComment.js 567 B

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