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.webpackCommentRegExp = new RegExp(
  8. /(^|\W)webpack[A-Z]{1,}[A-Za-z]{1,}:/
  9. );
  10. // regexp to match at least one "magic comment"
  11. /**
  12. * @returns {import("vm").Context} magic comment context
  13. */
  14. module.exports.createMagicCommentContext = () =>
  15. require("vm").createContext(undefined, {
  16. name: "Webpack Magic Comment Parser",
  17. codeGeneration: { strings: false, wasm: false }
  18. });