您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

RequireIncludeDependencyParserPlugin.js 687B

1234567891011121314151617181920212223
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const RequireIncludeDependency = require("./RequireIncludeDependency");
  7. module.exports = class RequireIncludeDependencyParserPlugin {
  8. apply(parser) {
  9. parser.hooks.call
  10. .for("require.include")
  11. .tap("RequireIncludeDependencyParserPlugin", expr => {
  12. if (expr.arguments.length !== 1) return;
  13. const param = parser.evaluateExpression(expr.arguments[0]);
  14. if (!param.isString()) return;
  15. const dep = new RequireIncludeDependency(param.string, expr.range);
  16. dep.loc = expr.loc;
  17. parser.state.current.addDependency(dep);
  18. return true;
  19. });
  20. }
  21. };