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

@arshaw/dts-bundle

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arshaw/dts-bundle - npm Package Compare versions

Comparing version 0.7.3-fork to 0.7.3-fork.1

62

lib/index.js

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

parse.exports.forEach(function (name) {
assert(!(name in exportMap), 'already got export for: ' + name);
exportMap[name] = parse;
(exportMap[name] || (exportMap[name] = [])).push(parse);
trace('- %s -> %s', name, parse.file);

@@ -176,16 +175,31 @@ });

parse.externalImports.forEach(function (name) {
var p = exportMap[name];
var parses = exportMap[name];
if (!externals) {
trace(' - exclude external %s', name);
pushUnique(externalDependencies, !p ? name : p.file);
return;
if (parses) {
for (var _i = 0, parses_1 = parses; _i < parses_1.length; _i++) {
var p = parses_1[_i];
pushUnique(externalDependencies, p.file);
}
}
else {
pushUnique(externalDependencies, name);
}
}
if (isExclude(path.relative(baseDir, p.file), true)) {
trace(' - exclude external filter %s', name);
pushUnique(excludedTypings, p.file);
return;
else {
if (parses) {
for (var _a = 0, parses_2 = parses; _a < parses_2.length; _a++) {
var p = parses_2[_a];
if (isExclude(path.relative(baseDir, p.file), true)) {
trace(' - exclude external filter %s', name);
pushUnique(excludedTypings, p.file);
}
else {
trace(' - include external %s', name);
assert(p, name);
queue_1.push(p);
}
}
}
}
trace(' - include external %s', name);
assert(p, name);
queue_1.push(p);
});

@@ -410,11 +424,20 @@ parse.relativeImports.forEach(function (file) {

}
function transformModuleBody(moduleBody, moduleName) {
if (typeof options.transformModuleBody === 'function') {
moduleBody = options.transformModuleBody(moduleBody, moduleName);
}
return moduleBody;
}
function formatModule(file, lines) {
var out = '';
var moduleBody = mergeModulesLines(lines);
if (outputAsModuleFolder) {
return mergeModulesLines(lines);
moduleBody = transformModuleBody(moduleBody);
return moduleBody;
}
out += 'declare module \'' + getExpName(file) + '\' {' + newline;
out += mergeModulesLines(lines);
out += '}' + newline;
return out;
else {
var moduleName = getExpName(file);
moduleBody = transformModuleBody(moduleBody, moduleName);
return 'declare module \'' + moduleName + '\' {' + newline +
moduleBody + '}' + newline;
}
}

@@ -581,2 +604,5 @@ function parseFile(file) {

pushUnique(res.exports, moduleName);
if (inSourceTypings(file)) {
line = line.replace('declare module', 'module');
}
var modLine = {

@@ -583,0 +609,0 @@ original: inSourceTypings(file) ? removeDeclares(line) : line

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

headerText: string;
transformModuleBody: (moduleBody: string, moduleName?: string) => string
}

@@ -237,8 +238,7 @@

let exportMap = Object.create(null);
let exportMap = Object.create(null); // values are arrays of parsed files
Object.keys(fileMap).forEach(file => {
let parse = fileMap[file];
parse.exports.forEach(name => {
assert(!(name in exportMap), 'already got export for: ' + name);
exportMap[name] = parse;
(exportMap[name] || (exportMap[name] = [])).push(parse);
trace('- %s -> %s', name, parse.file);

@@ -273,16 +273,28 @@ });

parse.externalImports.forEach(name => {
let p = exportMap[name];
let parses = exportMap[name];
if (!externals) {
trace(' - exclude external %s', name);
pushUnique(externalDependencies, !p ? name : p.file);
return;
if (parses) {
for (let p of parses) {
pushUnique(externalDependencies, p.file);
}
} else {
pushUnique(externalDependencies, name);
}
} else {
if (parses) {
for (let p of parses) {
if (isExclude(path.relative(baseDir, p.file), true)) {
trace(' - exclude external filter %s', name);
pushUnique(excludedTypings, p.file);
} else {
trace(' - include external %s', name);
assert(p, name);
queue.push(p);
}
}
}
}
if (isExclude(path.relative(baseDir, p.file), true)) {
trace(' - exclude external filter %s', name);
pushUnique(excludedTypings, p.file);
return;
}
trace(' - include external %s', name);
assert(p, name);
queue.push(p);
});

@@ -552,12 +564,23 @@ parse.relativeImports.forEach(file => {

function transformModuleBody(moduleBody: string, moduleName?: string) {
if (typeof options.transformModuleBody === 'function') {
moduleBody = options.transformModuleBody(moduleBody, moduleName);
}
return moduleBody
}
function formatModule(file: string, lines: string[]) {
let out = '';
let moduleBody = mergeModulesLines(lines);
if (outputAsModuleFolder) {
return mergeModulesLines(lines);
moduleBody = transformModuleBody(moduleBody);
return moduleBody;
} else {
let moduleName = getExpName(file);
moduleBody = transformModuleBody(moduleBody, moduleName);
return 'declare module \'' + moduleName + '\' {' + newline +
moduleBody + '}' + newline;
}
out += 'declare module \'' + getExpName(file) + '\' {' + newline;
out += mergeModulesLines(lines);
out += '}' + newline;
return out;
}

@@ -773,2 +796,7 @@

pushUnique(res.exports, moduleName);
// for internal typings, can't have nested declares w/ modules
if (inSourceTypings(file)) {
line = line.replace('declare module', 'module');
}
let modLine: ModLine = {

@@ -775,0 +803,0 @@ original: inSourceTypings(file) ? removeDeclares(line) : line

{
"name": "@arshaw/dts-bundle",
"version": "0.7.3-fork",
"version": "0.7.3-fork.1",
"description": "Export TypeScript .d.ts files as an external module definition",

@@ -5,0 +5,0 @@ "keywords": [

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