We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ast.js代码中多处出现以下类似代码,用于判断代码结点是否为对函数名为require的调用,然后再获取其参数,比如模块 id
if(node instanceof UglifyJS.AST_Call && node.start.value === 'require')
此种方式对如下代码也能判断通过
require('module-a')('abc')
但是,此时 node.args[0] 其实是 'abc',而不是 'module-a',也就是说通过上述方式解析require 对应的模块 id 参数值,很有可能是错的
正确的方式应该是
if(node instanceof UglifyJS.AST_Call && node.expression.name === 'require') { var id = node.args[0].value }
The text was updated successfully, but these errors were encountered:
The test case https://github.com/spmjs/cmd-util/blob/master/tests/ast.test.js#L111 passed.
Sorry, something went wrong.
use expression.name. #4
f467ef4
Thanks for your feedback.
You can send a pull request the next time.
No branches or pull requests
ast.js代码中多处出现以下类似代码,用于判断代码结点是否为对函数名为require的调用,然后再获取其参数,比如模块 id
此种方式对如下代码也能判断通过
但是,此时 node.args[0] 其实是 'abc',而不是 'module-a',也就是说通过上述方式解析require 对应的模块 id 参数值,很有可能是错的
正确的方式应该是
The text was updated successfully, but these errors were encountered: