typings-core
Advanced tools
Comparing version 1.3.2 to 1.4.0
@@ -34,11 +34,5 @@ "use strict"; | ||
"// Source: index.d.ts", | ||
"declare module '~example/index' {", | ||
"declare module 'example' {", | ||
"export { test } from '~example~test'", | ||
"}", | ||
'declare module \'example/index\' {', | ||
'export * from \'~example/index\';', | ||
'}', | ||
'declare module \'example\' {', | ||
'export * from \'~example/index\';', | ||
'}', | ||
'' | ||
@@ -45,0 +39,0 @@ ].join('\n')); |
@@ -88,3 +88,3 @@ "use strict"; | ||
var dependencies = {}; | ||
var entry = main == null ? main : path_3.resolveFrom(tree.src, path_3.normalizeToDefinition(main)); | ||
var entry = main == null ? undefined : path_3.normalizeToDefinition(main); | ||
var prefix = "" + (parent ? parent.prefix : '') + config_1.DEPENDENCY_SEPARATOR + options.name; | ||
@@ -95,3 +95,2 @@ return extend(options, { | ||
prefix: prefix, | ||
isTypings: isTypings, | ||
overrides: overrides, | ||
@@ -119,10 +118,4 @@ referenced: referenced, | ||
var tree = options.tree, entry = options.entry; | ||
if (path == null) { | ||
if (entry == null) { | ||
return Promise.reject(new error_1.default(("Unable to resolve entry \".d.ts\" file for \"" + options.name + "\", ") + | ||
'please make sure the module has a main or typings field')); | ||
} | ||
return stringifyDependencyPath(path_3.resolveFrom(tree.src, entry), options, parentModule); | ||
} | ||
return stringifyDependencyPath(path_3.resolveFrom(tree.src, path), options, parentModule); | ||
var dependencyPath = path_3.resolveFrom(tree.src, path || entry || 'index.d.ts'); | ||
return stringifyDependencyPath(dependencyPath, path, options, parentModule); | ||
} | ||
@@ -164,5 +157,5 @@ function cachedReadFileFrom(path, options) { | ||
} | ||
function stringifyDependencyPath(rawPath, options, moduleOptions) { | ||
function stringifyDependencyPath(rawPath, originalPath, options, moduleOptions) { | ||
var path = getPath(rawPath, options); | ||
var tree = options.tree, global = options.global, cwd = options.cwd, resolution = options.resolution, name = options.name, readFiles = options.readFiles, imported = options.imported, meta = options.meta, entry = options.entry, emitter = options.emitter; | ||
var tree = options.tree, global = options.global, cwd = options.cwd, resolution = options.resolution, name = options.name, readFiles = options.readFiles, imported = options.imported, meta = options.meta, emitter = options.emitter; | ||
var importedPath = importPath(rawPath, path_3.pathFromDefinition(rawPath), options); | ||
@@ -207,7 +200,7 @@ if (has(imported, importedPath)) { | ||
} | ||
return stringifyDependencyPath(path, options, childModuleOptions); | ||
return stringifyDependencyPath(path, importedFile, options, childModuleOptions); | ||
}); | ||
return Promise.all(imports) | ||
.then(function (imports) { | ||
var stringified = stringifySourceFile(sourceFile, options, childModuleOptions); | ||
var stringified = stringifySourceFile(sourceFile, originalPath, options, childModuleOptions); | ||
for (var _i = 0, referencedFiles_1 = referencedFiles; _i < referencedFiles_1.length; _i++) { | ||
@@ -226,3 +219,3 @@ var reference = referencedFiles_1[_i]; | ||
var relativePath = path_3.relativeTo(tree.src, path); | ||
if (rawPath === entry) { | ||
if (originalPath == null) { | ||
return Promise.reject(new error_1.default(("Unable to read typings for \"" + options.name + "\". ") + | ||
@@ -261,5 +254,5 @@ (authorPhrase + " check the entry paths in \"" + path_1.basename(tree.src) + "\" are up to date"), cause)); | ||
} | ||
function stringifySourceFile(sourceFile, options, moduleOptions) { | ||
var isExternal = moduleOptions.isExternal, path = moduleOptions.path, rawPath = moduleOptions.rawPath; | ||
var tree = options.tree, name = options.name, prefix = options.prefix, parent = options.parent, isTypings = options.isTypings, cwd = options.cwd, global = options.global, entry = options.entry; | ||
function stringifySourceFile(sourceFile, originalPath, options, moduleOptions) { | ||
var isExternal = moduleOptions.isExternal, path = moduleOptions.path; | ||
var tree = options.tree, name = options.name, prefix = options.prefix, parent = options.parent, cwd = options.cwd, global = options.global; | ||
var parentModule = moduleOptions.parent; | ||
@@ -350,6 +343,6 @@ var source = path_3.isHttp(path) ? path : path_3.normalizeSlashes(path_1.relative(cwd, path)); | ||
} | ||
var isEntry = rawPath === entry; | ||
var isEntry = originalPath == null; | ||
var moduleText = path_2.normalizeEOL(processTree(sourceFile, replacer, read), path_2.EOL); | ||
var moduleName = parent && parent.global ? name : prefix; | ||
if (isEntry && isTypings && !hasLocalImports) { | ||
if (isEntry && !hasLocalImports) { | ||
return meta + declareText(parent ? moduleName : name, moduleText); | ||
@@ -356,0 +349,0 @@ } |
@@ -201,3 +201,3 @@ "use strict"; | ||
t.equal(out.results.main, [ | ||
'declare module \'~foobar/file\' {', | ||
'declare module \'foobar\' {', | ||
'function foo (value: string): foo.Bar;', | ||
@@ -215,10 +215,2 @@ '', | ||
'}', | ||
'declare module \'foobar/file\' {', | ||
'import main = require(\'~foobar/file\');', | ||
'export = main;', | ||
'}', | ||
'declare module \'foobar\' {', | ||
'import main = require(\'~foobar/file\');', | ||
'export = main;', | ||
'}', | ||
'' | ||
@@ -247,3 +239,3 @@ ].join('\n')); | ||
t.equal(out.results.main, [ | ||
'declare module \'~test/index\' {', | ||
'declare module \'test\' {', | ||
'const foo: string;', | ||
@@ -253,8 +245,2 @@ '', | ||
'}', | ||
'declare module \'test/index\' {', | ||
'export { default } from \'~test/index\';', | ||
'}', | ||
'declare module \'test\' {', | ||
'export { default } from \'~test/index\';', | ||
'}', | ||
'' | ||
@@ -307,12 +293,6 @@ ].join('\n')); | ||
'', | ||
'declare module \'~test/index\' {', | ||
'declare module \'test\' {', | ||
'import * as x from \'~test~foo/x\'', | ||
'export * from \'~test~foo\'', | ||
'}', | ||
'declare module \'test/index\' {', | ||
'export * from \'~test/index\';', | ||
'}', | ||
'declare module \'test\' {', | ||
'export * from \'~test/index\';', | ||
'}', | ||
'' | ||
@@ -551,3 +531,3 @@ ].join('\n')); | ||
.catch(function (error) { | ||
t.ok(/^Unable to resolve entry "\.d\.ts" file for "main"/.test(error.message)); | ||
t.ok(/^Unable to read typings for "main"/.test(error.message)); | ||
}); | ||
@@ -608,3 +588,3 @@ }); | ||
'', | ||
'declare module \'~main/index\' {', | ||
'declare module \'main\' {', | ||
'import * as foo from \'~main/override\'', | ||
@@ -614,10 +594,2 @@ '', | ||
'}', | ||
'declare module \'main/index\' {', | ||
'import main = require(\'~main/index\');', | ||
'export = main;', | ||
'}', | ||
'declare module \'main\' {', | ||
'import main = require(\'~main/index\');', | ||
'export = main;', | ||
'}', | ||
'' | ||
@@ -655,8 +627,5 @@ ].join('\n')); | ||
t.equal(out.results.browser, [ | ||
'declare module \'~main~dep/index\' {', | ||
'declare module \'~main~dep\' {', | ||
'export function isDep (): boolean;', | ||
'}', | ||
'declare module \'~main~dep\' {', | ||
'export * from \'~main~dep/index\';', | ||
'}', | ||
'', | ||
@@ -663,0 +632,0 @@ 'declare module \'~main/index\' {', |
{ | ||
"name": "typings-core", | ||
"version": "1.3.2", | ||
"version": "1.4.0", | ||
"description": "The logic of Typings", | ||
@@ -5,0 +5,0 @@ "main": "dist/typings.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
468909
4214