mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 02:15:10 -05: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*/
|
||||
|
||||
Reference in New Issue
Block a user