Created
August 19, 2018 17:46
-
-
Save songlairui/d50cc20f26ec611eeef53159bdd23190 to your computer and use it in GitHub Desktop.
通过修改全局require的方式,更改自己期望require的文件。临时性trick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 临时修复mpvue-loader 1.0.15复制node_modules目录的bug | |
module.constructor.prototype.require = function (modulePath) { | |
if ( | |
modulePath === './modules/transform-require' && | |
this.id.indexOf('mpvue-loader/lib/template-compiler/index.js') > -1 | |
) { | |
modulePath = path.resolve(__dirname, 'utils', 'fixRequire.js') | |
} | |
return this.constructor._load(modulePath, this) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
依赖的mpvue-loader 1.0.15 进行了不兼容性升级。
而自己的项目一个迭代之内无法完成不兼容重构。
需要临时性修改一下依赖包的源代码,于是通过更改全局require的方式,针对此特定文件进行替换。
参考链接:https://stackoverflow.com/questions/19903398/node-js-customize-require-function-globally