【文件属性】:
文件名称:import-modify:修改导入模块的源
文件大小:4KB
文件格式:ZIP
更新时间:2021-05-26 07:59:14
JavaScript
导入修改
修改导入模块的源
安装
$ npm install --save import-modify
用法
替换一些文字
// greet.js
module . exports = ( ) => {
console . log ( 'hello' ) ;
} ;
const importModify = require ( 'import-modify' ) ;
const greet = importModify ( './greet' , source => {
return source . replace ( 'hello' , 'yo' ) ;
} ) ;
greet ( ) ;
//=> 'yo'
公开一个局部变量
// greet.js
const greet = ( ) => {
console . log ( 'hello' ) ;
} ;
con
【文件预览】:
import-modify-main
----index.js(177B)
----test.js(166B)
----package.json(715B)
----readme.md(957B)
----.github()
--------workflows()
----license(1KB)
----fixture.js(26B)
----.gitignore(13B)
----.editorconfig(175B)
----.gitattributes(29B)