New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

apack

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apack - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

5

package.json
{
"name": "apack",
"version": "1.0.2",
"version": "1.0.3",
"description": "yet another bundle packer",

@@ -19,3 +19,4 @@ "main": "./src/index.js",

"lodash": "^3.10.1",
"memory-fs": "^0.3.0"
"memory-fs": "^0.3.0",
"node-libs-browser": "~1.0.0"
},

@@ -22,0 +23,0 @@ "devDependencies": {

@@ -13,2 +13,3 @@ 'use strict';

const co = require('co');
const CoreLibs = require('node-libs-browser');

@@ -451,2 +452,19 @@ const CWD = process.cwd();

let extName = (depName[0] === '/' || depName[0] === '.') ? path.resolve(dir, depName) : depName;
if (CoreLibs.hasOwnProperty(extName) && !CoreLibs[extName]) {
let coreModule = this._curLoopEntry.getModule(extName);
if (!coreModule) {
let cachedModule = this.moduleMap.has(extName) ? this.moduleMap.get(extName) : null;
if (!cachedModule) {
cachedModule = Module.createNull(extName);
this.moduleMap.set(extName, cachedModule);
}
coreModule = new Container(cachedModule);
this._curLoopEntry.addModule(coreModule);
}
cm.depMap.set(depName, coreModule.module);
cm.addDep(coreModule);
coreModule.addRef(cm);
this._checkState(cm, cm.depMap);
return;
}
if (this._externals.has(extName)) {

@@ -453,0 +471,0 @@ let exModule = this._curLoopEntry.getModule(extName);

12

src/core/Worker.js

@@ -6,2 +6,4 @@ 'use strict';

const Module = require('../struct/Module.js');
const path = require('path');
const CORE_MODULE_DIR = path.resolve(__dirname, '../../node_modules');

@@ -62,2 +64,3 @@ class Worker {

file: info.file,
isCore: info.file.indexOf(CORE_MODULE_DIR) === 0,
category: 'js',

@@ -80,8 +83,7 @@ content: '',

if (!handled) {
process.stderr.cursorTo(0);
util.error(`Module ${info.file} could not be loaded. You may need some loader to handle it.`);
module.state = 'no-loader';
module.category = 'js';
process.stderr.cursorTo(0);
util.error(`Module ${info.file} could not be loaded. You may need some loader to handle it.`);
module.state = 'no-loader';
module.category = 'js';
}
}).then(sf, sf);

@@ -88,0 +90,0 @@

@@ -40,3 +40,4 @@ 'use strict';

}
_shouldHandle(file) {
_shouldHandle(module) {
let file = module.file;
if (!this.test || !checkTests(this.test, file, true)) {

@@ -57,6 +58,4 @@ // 首先要满足 test 条件

*parse(module, context) {
let file = module.file;
for(let i = 0; i < this.test.length; i++) {
if (this._shouldHandle(file)) {
if (this._shouldHandle(module)) {
yield this._doParse(module, context);

@@ -63,0 +62,0 @@ module.category = this.category;

@@ -6,3 +6,3 @@ 'use strict';

this.file = '';
this.type = 'file'; // file, external, error, no-loader
this.type = 'file'; // file, core, external, error, no-loader
this.category = 'js';

@@ -44,2 +44,15 @@ this.notFound = false;

Module.createNull = function(depName) {
let m = new Module();
m.content = `module.exports = null;`;
m.file = depName;
m.type = 'core';
m.sourceMap = {
originContent: m.content,
mappings: 'AAAA;'
};
m.state = Module.State.READY;
return m;
};
Module.createExternal = function(extName, extVal) {

@@ -46,0 +59,0 @@ let m = new Module();

@@ -6,2 +6,3 @@ 'use strict';

const _ = require('lodash');
const CoreLibs = require('node-libs-browser');

@@ -19,5 +20,7 @@ class Resolver {

}
_getApackName(baseDir, name) {
return name[0] !== '/' && name[0] !== '.' ? `${baseDir}___$apack$___${name}` : path.resolve(baseDir, name)
}
clear() {

@@ -28,2 +31,3 @@ this.cache.clear();

}
*resolve(baseDir, name) {

@@ -35,22 +39,33 @@ let fullName = this._getApackName(baseDir, name);

}
let file;
if (name[0] !== '/' && name[0] !== '.') {
for (let k = 0; k < this.browserModuleList.length; k++) {
let m = this.browserModuleList[k];
if (baseDir.indexOf(m.dir) === 0 && name === m.name) {
file = m.file;
break;
}
let file;
if (name[0] !== '/' && name[0] !== '.') {
for (let k = 0; k < this.browserModuleList.length; k++) {
let m = this.browserModuleList[k];
if (baseDir.indexOf(m.dir) === 0 && name === m.name) {
file = m.file;
break;
}
if (!file) {
file = yield this.resolveModules(this.root, baseDir, name);
}
if (!file && CoreLibs.hasOwnProperty(name)) {
let stat = yield util.stat(CoreLibs[name]);
if (stat && stat.isFile()) {
console.log('res core lib', CoreLibs[name]);
file = {
filename: CoreLibs[name],
mtime: stat.mtime.getTime()
};
}
} else {
file = yield this.resolveFile(fullName, this.resolves);
}
if (file) {
this.cache.set(fullName, file);
if (!file) {
file = yield this.resolveModules(this.root, baseDir, name);
}
return file;
} else {
file = yield this.resolveFile(fullName, this.resolves);
}
if (file) {
this.cache.set(fullName, file);
}
return file;
}
*resolveModules(root, dir, name) {

@@ -62,3 +77,3 @@ let rel = path.relative(root, dir);

let m;
while(m = r.exec(rel)) {
while (m = r.exec(rel)) {
lastIndex = m.index + m[0].length - 1;

@@ -85,2 +100,3 @@ tries.push(path.join(root, rel.substring(0, lastIndex), name));

}
*resolveFile(fullName, customResolves) {

@@ -103,3 +119,3 @@ var _d = fullName === '/Users/xiaoge/alipay/antd-layout3/node_modules/object-path-parse/lib/index.js';

} else if (customResolves) {
for(let i = 0; i < customResolves.length; i++) {
for (let i = 0; i < customResolves.length; i++) {
const res = customResolves[i];

@@ -129,2 +145,3 @@ if (!res) {

}
*resolveDir(dir) {

@@ -141,3 +158,3 @@ let tryFile = path.join(dir, 'package.json');

}
for(let k = 0; k < this.resolves.length; k++) {
for (let k = 0; k < this.resolves.length; k++) {
tryFile = path.join(dir, 'index' + this.resolves[k]);

@@ -157,2 +174,3 @@ stat = yield util.stat(tryFile);

}
*resolvePkg(dir, file) {

@@ -170,3 +188,3 @@ let pkgContent = yield util.readFile(file);

}
for(let k in pkg.browser) {
for (let k in pkg.browser) {
let v = pkg.browser[k];

@@ -173,0 +191,0 @@ if (!v) {

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