mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Add helpers from source files to the bundleInfo to be used later
This commit is contained in:
@@ -572,6 +572,12 @@ namespace ts {
|
||||
if (bundleFileInfo) {
|
||||
bundleFileInfo.sections.push({ pos, end: writer.getTextPos(), kind: BundleFileSectionKind.Text });
|
||||
// Source file metadata if needed later on
|
||||
|
||||
// Store helpes
|
||||
const helpers = getHelpersFromBundledSourceFiles(bundle);
|
||||
if (helpers) {
|
||||
bundleFileInfo.sources.helpers = helpers;
|
||||
}
|
||||
}
|
||||
|
||||
reset();
|
||||
@@ -1142,6 +1148,27 @@ namespace ts {
|
||||
pipelinePhase(hint, substituteNode(hint, node));
|
||||
}
|
||||
|
||||
function getHelpersFromBundledSourceFiles(bundle: Bundle): string[] | undefined {
|
||||
let result: string[] | undefined;
|
||||
if (moduleKind === ModuleKind.None || printerOptions.noEmitHelpers) {
|
||||
return undefined;
|
||||
}
|
||||
const bundledHelpers = createMap<boolean>();
|
||||
for (const sourceFile of bundle.sourceFiles) {
|
||||
const shouldSkip = getExternalHelpersModuleName(sourceFile) !== undefined;
|
||||
const helpers = getSortedEmitHelpers(sourceFile);
|
||||
if (!helpers) continue;
|
||||
for (const helper of helpers) {
|
||||
if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) {
|
||||
bundledHelpers.set(helper.name, true);
|
||||
(result || (result = [])).push(helper.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function emitHelpers(node: Node) {
|
||||
let helpersEmitted = false;
|
||||
const bundle = node.kind === SyntaxKind.Bundle ? <Bundle>node : undefined;
|
||||
|
||||
@@ -5529,6 +5529,8 @@ namespace ts {
|
||||
|
||||
/*@internal*/
|
||||
export interface SourceFileInfo {
|
||||
// List of helpers in own source files emitted if no prepend is present
|
||||
helpers?: string[];
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
|
||||
+10
-2
@@ -31,7 +31,11 @@
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/first/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/first/bin/first-output.d.ts]
|
||||
@@ -498,7 +502,11 @@ const { b, ...rest } = { a: 10, b: 30, yy: 30 };
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/third/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/third/thirdjs/output/third-output.d.ts]
|
||||
|
||||
+14
-2
@@ -43,7 +43,13 @@
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/first/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest",
|
||||
"typescript:read",
|
||||
"typescript:spread"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/first/bin/first-output.d.ts]
|
||||
@@ -695,7 +701,13 @@ const { b, ...rest } = { a: 10, b: 30, yy: 30 };
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/third/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest",
|
||||
"typescript:read",
|
||||
"typescript:spread"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/third/thirdjs/output/third-output.d.ts]
|
||||
|
||||
+10
-2
@@ -31,7 +31,11 @@
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/first/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/first/bin/first-output.d.ts]
|
||||
@@ -510,7 +514,11 @@ const { b, ...rest } = { a: 10, b: 30, yy: 30 };
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/third/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/third/thirdjs/output/third-output.d.ts]
|
||||
|
||||
+10
-2
@@ -31,7 +31,11 @@
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/first/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/first/bin/first-output.js]
|
||||
@@ -362,7 +366,11 @@ const { b, ...rest } = { a: 10, b: 30, yy: 30 };
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/third/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/third/thirdjs/output/third-output.js]
|
||||
|
||||
+14
-2
@@ -43,7 +43,13 @@
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/first/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest",
|
||||
"typescript:read",
|
||||
"typescript:spread"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/first/bin/first-output.js]
|
||||
@@ -528,7 +534,13 @@ const { b, ...rest } = { a: 10, b: 30, yy: 30 };
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/third/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest",
|
||||
"typescript:read",
|
||||
"typescript:spread"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/third/thirdjs/output/third-output.js]
|
||||
|
||||
+10
-2
@@ -31,7 +31,11 @@
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/first/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/first/bin/first-output.js]
|
||||
@@ -374,7 +378,11 @@ const { b, ...rest } = { a: 10, b: 30, yy: 30 };
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/third/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/third/thirdjs/output/third-output.js]
|
||||
|
||||
+5
-1
@@ -424,7 +424,11 @@ function forfirstfirst_PART1Rest() { }
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/third/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/third/thirdjs/output/third-output.d.ts.map]
|
||||
|
||||
+5
-1
@@ -31,7 +31,11 @@
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/first/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/first/bin/first-output.d.ts.map]
|
||||
|
||||
+13
-2
@@ -37,7 +37,12 @@
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/first/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:read",
|
||||
"typescript:spread"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/first/bin/first-output.d.ts.map]
|
||||
@@ -620,7 +625,13 @@ function forfirstfirst_PART1Rest() { }
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/third/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest",
|
||||
"typescript:read",
|
||||
"typescript:spread"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/third/thirdjs/output/third-output.d.ts.map]
|
||||
|
||||
+5
-1
@@ -436,7 +436,11 @@ function forfirstfirst_PART1Rest() { }
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/third/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/third/thirdjs/output/third-output.d.ts.map]
|
||||
|
||||
+15
-3
@@ -31,7 +31,11 @@
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/second/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/2/second-output.d.ts]
|
||||
@@ -541,7 +545,11 @@ sourceFile:../second/second_part2.ts
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/first/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/first/bin/first-output.d.ts]
|
||||
@@ -1024,7 +1032,11 @@ const { b, ...rest } = { a: 10, b: 30, yy: 30 };
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/third/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/third/thirdjs/output/third-output.d.ts]
|
||||
|
||||
+5
-1
@@ -31,7 +31,11 @@
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/second/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/2/second-output.d.ts]
|
||||
|
||||
+21
-3
@@ -43,7 +43,13 @@
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/second/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest",
|
||||
"typescript:read",
|
||||
"typescript:spread"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/2/second-output.d.ts]
|
||||
@@ -740,7 +746,13 @@ sourceFile:../second/second_part2.ts
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/first/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest",
|
||||
"typescript:read",
|
||||
"typescript:spread"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/first/bin/first-output.d.ts]
|
||||
@@ -1467,7 +1479,13 @@ secondsecond_part2Spread(...[10, 20, 30]);
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/third/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest",
|
||||
"typescript:read",
|
||||
"typescript:spread"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/third/thirdjs/output/third-output.d.ts]
|
||||
|
||||
+16
-3
@@ -37,7 +37,12 @@
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/second/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:read",
|
||||
"typescript:spread"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/2/second-output.d.ts]
|
||||
@@ -633,7 +638,11 @@ sourceFile:../second/second_part2.ts
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/first/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/first/bin/first-output.d.ts]
|
||||
@@ -1147,7 +1156,11 @@ secondsecond_part1Spread(...[10, 20, 30]);
|
||||
}
|
||||
],
|
||||
"commonSourceDirectory": "/src/third/",
|
||||
"sources": {}
|
||||
"sources": {
|
||||
"helpers": [
|
||||
"typescript:rest"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/third/thirdjs/output/third-output.d.ts]
|
||||
|
||||
Reference in New Issue
Block a user