typescript#VariableDeclaration TypeScript Examples
The following examples show how to use
typescript#VariableDeclaration.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: library-template.loader.ts From angular-miniprogram with MIT License | 5 votes |
export default async function (
this: webpack.LoaderContext<any>,
data: string,
map: string
) {
const callback = this.async();
const selector = createCssSelectorForTs(data);
const injector: Injector = (this._compilation! as any)[InjectorSymbol];
const buildPlatform = injector.get(BuildPlatform);
const templateScopeOutside = (this._compilation as any)[
TemplateScopeSymbol
] as TemplateScopeOutside;
const selfTemplateNode = selector.queryOne(
`VariableDeclaration[name="$self_${GLOBAL_TEMPLATE_SUFFIX}"]`
) as VariableDeclaration;
if (selfTemplateNode) {
const content = selfTemplateNode.initializer!.getText();
const config: ExtraTemplateData = literalResolve(content);
this.emitFile(
config.outputPath + buildPlatform.fileExtname.contentTemplate,
literalResolve<LibraryTemplateLiteralConvertOptions>(
`\`${config.template}\``,
{
directivePrefix:
buildPlatform.templateTransform.getData().directivePrefix,
eventListConvert: buildPlatform.templateTransform.eventListConvert,
templateInterpolation:
buildPlatform.templateTransform.templateInterpolation,
fileExtname: buildPlatform.fileExtname,
}
)
);
}
const libraryTemplateNode = selector.queryOne(
`VariableDeclaration[name="library_${GLOBAL_TEMPLATE_SUFFIX}"]`
) as VariableDeclaration;
if (libraryTemplateNode) {
const content = libraryTemplateNode.initializer!.getText();
const config: Record<string, ExtraTemplateData> = literalResolve(content);
for (const key in config) {
if (Object.prototype.hasOwnProperty.call(config, key)) {
const element = config[key];
templateScopeOutside.setScopeExtraUseComponents(key, {
useComponents: element.useComponents!,
templateList: [element.template],
});
}
}
}
callback(undefined, data, map);
}