Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-amd-wrap

Package Overview
Dependencies
Maintainers
8
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-amd-wrap - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

dist/addRequireConfig.d.ts

2

dist/hook.d.ts

@@ -16,2 +16,4 @@ export declare function amdWrap(option: IAmdWrap): any;

anonymousModule?: string[];
/** 生成的ModuleId 是否需要md5后缀来避免其他模块引用 如 @molecule/toptip2_134dfas */
useMd5?: any;
}

@@ -18,0 +20,0 @@ interface IAmdWrapCustomOption {

@@ -14,2 +14,4 @@ "use strict";

var prefix = option.prefix || '';
var useMd5 = option.useMd5 || false;
// let location = parseBase(file.path);
if (filter_1.include(file.path, option.exclude, option.baseUrl)) {

@@ -24,2 +26,3 @@ // 在exlude名单中 do nothing

removeModuleId: filter_1.include(file.path, option.anonymousModule, option.baseUrl),
useMd5: useMd5
});

@@ -26,0 +29,0 @@ file.contents = new Buffer(parser.getContent());

export { amdWrap } from './hook';
export { absolutize } from './absolutize';
export { addRequireConfig } from './addRequireConfig';

6

dist/index.js

@@ -5,4 +5,4 @@ "use strict";

* @Date: 2019-04-23 11:18:08
* @Last Modified by: qiansc
* @Last Modified time: 2019-06-05 17:33:33
* @Last Modified by: liangjiaying@baidu.com
* @Last Modified time: 2019-08-08 19:20:06
*/

@@ -14,1 +14,3 @@ Object.defineProperty(exports, "__esModule", { value: true });

exports.absolutize = absolutize_1.absolutize;
var addRequireConfig_1 = require("./addRequireConfig");
exports.addRequireConfig = addRequireConfig_1.addRequireConfig;

@@ -21,3 +21,4 @@ /// <reference types="node" />

removeModuleId?: boolean;
useMd5?: any;
}
export {};

@@ -6,4 +6,4 @@ "use strict";

* @Date: 2019-04-28 14:43:21
* @Last Modified by: qiansc
* @Last Modified time: 2019-06-05 10:45:51
* @Last Modified by: liangjiaying@baidu.com
* @Last Modified time: 2019-08-19 10:49:24
*/

@@ -13,6 +13,9 @@ var escodegen_1 = require("escodegen");

var estraverse_1 = require("estraverse");
var path_1 = require("path");
var async_analyzer_1 = require("./async-analyzer");
var dependency_analyzer_1 = require("./dependency-analyzer");
var moduleID_1 = require("./moduleID");
var filter_1 = require("./filter");
var path_1 = require("path");
var fs_1 = require("fs");
var md5File = require('md5-file');
var Parser = /** @class */ (function () {

@@ -42,2 +45,16 @@ function Parser(contents, filePath, root, prefix) {

if (hookOption === void 0) { hookOption = {}; }
/** 生成的ModuleId md5后缀来避免其他模块引用 @molecule/toptip2_134dfas */
var md5Value = '';
if (hookOption.useMd5 === true || hookOption.useMd5 && hookOption.useMd5.useMd5) {
var exlude = hookOption.useMd5.exlude; // 要被排除的文件
if (!filter_1.include(path_1.resolve(this.filePath), exlude, this.root)) {
// 不在md5排除名单中
try {
md5Value = '_' + md5File.sync(this.filePath.replace('.js', '.ts')).slice(0, 7);
}
catch (e) {
console.log(e);
}
}
}
// console.log(this.contents.toString());

@@ -54,5 +71,5 @@ estraverse_1.traverse(this.ast, {

}
// 首参数是依赖数组,推入moduleId
// 首参数推入moduleId => define("@molecule/toptip/main",xxxx)
if (node.arguments[0].type === 'ArrayExpression') {
node.arguments.unshift({ type: 'Literal', value: moduleID_1.parseBase(_this.root, _this.filePath, _this.prefix) });
node.arguments.unshift({ type: 'Literal', value: moduleID_1.parseBase(_this.root, _this.filePath, _this.prefix) + md5Value });
}

@@ -64,2 +81,16 @@ var analyzer = new dependency_analyzer_1.DependencyAnalyzer(_this.cwd, node, _this.root);

});
// 第二参数是依赖数组 => define("", ['require', 'exports', 'md5-file'])
if (node.arguments[1].elements) {
node.arguments[1].elements.forEach(function (element, index) {
var valueString = element.value;
/** depPath: 实际依赖的相对路径文件。如果是node_module就为空 */
var depPath = moduleID_1.parseAbsolute(path_1.dirname(_this.filePath), valueString + '.ts');
if (fs_1.existsSync(depPath)) {
var md5 = '_' + md5File.sync(depPath).slice(0, 7);
// moduleid 示例:@molecule/toptip/main_dc85e717d6352fa285bc70bc2d1d3595
var moduleid = moduleID_1.parseBase(_this.root, depPath, _this.prefix) + md5;
node.arguments[1].elements[index].value = moduleid;
}
});
}
if (node.arguments[1] && !_this.isHasObj(node.arguments[1].elements, 'require')) {

@@ -66,0 +97,0 @@ node.arguments[1].elements.push({ type: 'Literal', value: 'require' });

{
"name": "gulp-amd-wrap",
"version": "1.0.7",
"version": "1.0.8",
"discription": "gulp-amd-wrap",

@@ -85,2 +85,3 @@ "scripts": {

"estraverse": "^4.2.0",
"md5-file": "^4.0.0",
"minimatch": "^3.0.4",

@@ -87,0 +88,0 @@ "readable-stream": "^3.3.0"

@@ -17,3 +17,4 @@ {

"no-var-requires": false,
"quotemark": [true, "single"]
"quotemark": [true, "single"],
"ordered-imports": false
// "use-input-property-decorator": true,

@@ -24,3 +25,2 @@ // "use-output-property-decorator": true,

// "max-classes-per-file": false,
// "ordered-imports": false,
// "variable-name": false,

@@ -27,0 +27,0 @@ // "prefer-const": false,

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc