
Security News
Feross on Risky Business Weekly Podcast: npm’s Ongoing Supply Chain Attacks
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
简单的将CommonJS代码转成前端直接能src的代码,支持amd
, global
加载。
npm install dist-wrap --save-dev
必须 在源文件中包含一行 module.exports = someModule
比如源source
:
/* hello */
var hello = 'hello';
module.exports = hello; //这个必须有
执行
var wrap = require('dist-wrap');
var result = wrap(source);
结果result:
/* hello */
(function(){
//dist-wrap top
var hello = 'hello';
//module.exports = hello;
//dist-wrap bottom
if(typeof define === 'function' && define.amd) {
define(function(){
return hello;
});
}else{
this.hello = hello; //this是全局,.hello可以自定义,见下文
}
})();
如果想要绑定到全局的名字不一样,你可以用第二个参数:
wrap(source, 'HELLO');
FAQs
Used for front-end dist, module, amd, global wrap source.
We found that dist-wrap demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.