Skip to content

Commit 552e028

Browse files
chore: cleanup
1 parent ac78648 commit 552e028

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

packages/vite-plugin-angular/src/lib/angular-vite-plugin.ts

+33-33
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ interface EmitFileResult {
9494
}
9595
type FileEmitter = (
9696
file: string,
97-
source?: ts.SourceFile
97+
source?: ts.SourceFile,
9898
) => Promise<EmitFileResult | undefined>;
9999

100100
/**
@@ -169,7 +169,7 @@ export function angular(options?: PluginOptions): Plugin[] {
169169
let viteServer: ViteDevServer | undefined;
170170
let styleTransform: (
171171
code: string,
172-
filename: string
172+
filename: string,
173173
) => ReturnType<typeof preprocessCSS> | undefined;
174174

175175
const styleUrlsResolver = new StyleUrlsResolver();
@@ -200,7 +200,7 @@ export function angular(options?: PluginOptions): Plugin[] {
200200
config.root || '.',
201201
process.env['NODE_ENV'] === 'test'
202202
? './tsconfig.spec.json'
203-
: './tsconfig.app.json'
203+
: './tsconfig.app.json',
204204
);
205205

206206
return {
@@ -219,7 +219,7 @@ export function angular(options?: PluginOptions): Plugin[] {
219219
incremental: watchMode,
220220
},
221221
isTest,
222-
!isAstroIntegration
222+
!isAstroIntegration,
223223
),
224224
],
225225
define: {
@@ -264,7 +264,7 @@ export function angular(options?: PluginOptions): Plugin[] {
264264
const angularComponentMiddleware: Connect.HandleFunction = async (
265265
req: Connect.IncomingMessage,
266266
res: ServerResponse<Connect.IncomingMessage>,
267-
next: Connect.NextFunction
267+
next: Connect.NextFunction,
268268
) => {
269269
if (req.url === undefined || res.writableEnded) {
270270
return;
@@ -351,7 +351,7 @@ export function angular(options?: PluginOptions): Plugin[] {
351351
) {
352352
const relativeFileId = `${relative(
353353
process.cwd(),
354-
fileId
354+
fileId,
355355
)}@${classNames.get(fileId)}`;
356356

357357
sendHMRComponentUpdate(ctx.server, relativeFileId);
@@ -372,15 +372,15 @@ export function angular(options?: PluginOptions): Plugin[] {
372372
* for an external resource (styles, html).
373373
*/
374374
const isDirect = ctx.modules.find(
375-
(mod) => ctx.file === mod.file && mod.id?.includes('?direct')
375+
(mod) => ctx.file === mod.file && mod.id?.includes('?direct'),
376376
);
377377
if (isDirect) {
378378
if (pluginOptions.liveReload && isDirect?.id && isDirect.file) {
379379
const isComponentStyle =
380380
isDirect.type === 'css' && isComponentStyleSheet(isDirect.id);
381381
if (isComponentStyle) {
382382
const { encapsulation } = getComponentStyleSheetMeta(
383-
isDirect.id
383+
isDirect.id,
384384
);
385385

386386
// Track if the component uses ShadowDOM encapsulation
@@ -438,7 +438,7 @@ export function angular(options?: PluginOptions): Plugin[] {
438438
updates.forEach((updateId) => {
439439
const impRelativeFileId = `${relative(
440440
process.cwd(),
441-
updateId
441+
updateId,
442442
)}@${classNames.get(updateId)}`;
443443

444444
sendHMRComponentUpdate(ctx.server, impRelativeFileId);
@@ -464,14 +464,14 @@ export function angular(options?: PluginOptions): Plugin[] {
464464
if (id.startsWith('angular:jit:')) {
465465
const path = id.split(';')[1];
466466
return `${normalizePath(
467-
resolve(dirname(importer as string), path)
467+
resolve(dirname(importer as string), path),
468468
)}?raw`;
469469
}
470470

471471
// Map angular external styleUrls to the source file
472472
if (isComponentStyleSheet(id)) {
473473
const componentStyles = externalComponentStyles?.get(
474-
getFilenameFromPath(id)
474+
getFilenameFromPath(id),
475475
);
476476
if (componentStyles) {
477477
return componentStyles + new URL(id, 'http://localhost').search;
@@ -484,7 +484,7 @@ export function angular(options?: PluginOptions): Plugin[] {
484484
// Map angular inline styles to the source text
485485
if (isComponentStyleSheet(id)) {
486486
const componentStyles = inlineComponentStyles?.get(
487-
getFilenameFromPath(id)
487+
getFilenameFromPath(id),
488488
);
489489
if (componentStyles) {
490490
return componentStyles;
@@ -506,8 +506,8 @@ export function angular(options?: PluginOptions): Plugin[] {
506506
const result = await fileEmitter?.(
507507
resolve(
508508
process.cwd(),
509-
decodeURIComponent(componentId).split('@')[0]
510-
)
509+
decodeURIComponent(componentId).split('@')[0],
510+
),
511511
);
512512

513513
return result?.hmrUpdateCode || '';
@@ -620,23 +620,23 @@ export function angular(options?: PluginOptions): Plugin[] {
620620
if (jit && data.includes('angular:jit:')) {
621621
data = data.replace(
622622
/angular:jit:style:inline;/g,
623-
'virtual:angular:jit:style:inline;'
623+
'virtual:angular:jit:style:inline;',
624624
);
625625

626626
templateUrls.forEach((templateUrlSet) => {
627627
const [templateFile, resolvedTemplateUrl] =
628628
templateUrlSet.split('|');
629629
data = data.replace(
630630
`angular:jit:template:file;${templateFile}`,
631-
`${resolvedTemplateUrl}?raw`
631+
`${resolvedTemplateUrl}?raw`,
632632
);
633633
});
634634

635635
styleUrls.forEach((styleUrlSet) => {
636636
const [styleFile, resolvedStyleUrl] = styleUrlSet.split('|');
637637
data = data.replace(
638638
`angular:jit:style:file;${styleFile}`,
639-
`${resolvedStyleUrl}?inline`
639+
`${resolvedStyleUrl}?inline`,
640640
);
641641
});
642642
}
@@ -663,7 +663,7 @@ export function angular(options?: PluginOptions): Plugin[] {
663663
const metadata = await getFrontmatterMetadata(
664664
code,
665665
id,
666-
pluginOptions.markdownTemplateTransforms || []
666+
pluginOptions.markdownTemplateTransforms || [],
667667
);
668668
data += metadata;
669669
}
@@ -712,18 +712,18 @@ export function angular(options?: PluginOptions): Plugin[] {
712712

713713
const fg = require('fast-glob');
714714
const appRoot = normalizePath(
715-
resolve(pluginOptions.workspaceRoot, config.root || '.')
715+
resolve(pluginOptions.workspaceRoot, config.root || '.'),
716716
);
717717
const workspaceRoot = normalizePath(resolve(pluginOptions.workspaceRoot));
718718

719719
const globs = [
720720
`${appRoot}/**/*.{analog,agx,ag}`,
721721
...extraGlobs.map((glob) => `${workspaceRoot}${glob}.{analog,agx,ag}`),
722722
...(pluginOptions.additionalContentDirs || [])?.map(
723-
(glob) => `${workspaceRoot}${glob}/**/*.agx`
723+
(glob) => `${workspaceRoot}${glob}/**/*.agx`,
724724
),
725725
...pluginOptions.include.map((glob) =>
726-
`${workspaceRoot}${glob}`.replace(/\.ts$/, '.analog')
726+
`${workspaceRoot}${glob}`.replace(/\.ts$/, '.analog'),
727727
),
728728
];
729729

@@ -830,7 +830,7 @@ export function angular(options?: PluginOptions): Plugin[] {
830830
rootNames,
831831
compilerOptions,
832832
host as CompilerHost,
833-
nextProgram as any
833+
nextProgram as any,
834834
);
835835
angularCompiler = angularProgram.compiler;
836836
typeScriptProgram = angularProgram.getTsProgram();
@@ -840,7 +840,7 @@ export function angular(options?: PluginOptions): Plugin[] {
840840
ts.createEmitAndSemanticDiagnosticsBuilderProgram(
841841
typeScriptProgram,
842842
host,
843-
builderProgram
843+
builderProgram,
844844
);
845845

846846
await angularCompiler.analyzeAsync();
@@ -852,7 +852,7 @@ export function angular(options?: PluginOptions): Plugin[] {
852852
rootNames,
853853
compilerOptions,
854854
host,
855-
nextProgram as any
855+
nextProgram as any,
856856
);
857857

858858
typeScriptProgram = builder.getProgram();
@@ -874,7 +874,7 @@ export function angular(options?: PluginOptions): Plugin[] {
874874
...(jit
875875
? [
876876
compilerCli.constructorParametersDownlevelTransform(
877-
builder.getProgram()
877+
builder.getProgram(),
878878
),
879879
createJitResourceTransformer(getTypeChecker),
880880
]
@@ -885,12 +885,12 @@ export function angular(options?: PluginOptions): Plugin[] {
885885
afterDeclarations:
886886
pluginOptions.advanced.tsTransformers.afterDeclarations,
887887
},
888-
jit ? {} : angularCompiler!.prepareEmit().transformers
888+
jit ? {} : angularCompiler!.prepareEmit().transformers,
889889
),
890890
() => [],
891891
angularCompiler!,
892892
pluginOptions.liveReload,
893-
pluginOptions.disableTypeChecking
893+
pluginOptions.disableTypeChecking,
894894
);
895895
}
896896
}
@@ -910,7 +910,7 @@ export function createFileEmitter(
910910
onAfterEmit?: (sourceFile: ts.SourceFile) => void,
911911
angularCompiler?: NgtscProgram['compiler'],
912912
liveReload?: boolean,
913-
disableTypeChecking?: boolean
913+
disableTypeChecking?: boolean,
914914
): FileEmitter {
915915
return async (file: string, stale?: ts.SourceFile) => {
916916
const sourceFile = program.getSourceFile(file);
@@ -922,7 +922,7 @@ export function createFileEmitter(
922922
const hmrEligible = !!analyzeFileUpdates(
923923
stale,
924924
sourceFile,
925-
angularCompiler!
925+
angularCompiler!,
926926
);
927927
return { dependencies: [], hmrEligible };
928928
}
@@ -931,15 +931,15 @@ export function createFileEmitter(
931931
sourceFile,
932932
!!disableTypeChecking,
933933
program,
934-
angularCompiler
934+
angularCompiler,
935935
);
936936

937937
const errors = diagnostics
938938
.filter((d) => d.category === ts.DiagnosticCategory?.Error)
939939
.map((d) =>
940940
typeof d.messageText === 'object'
941941
? d.messageText.messageText
942-
: d.messageText
942+
: d.messageText,
943943
);
944944

945945
const warnings = diagnostics
@@ -967,7 +967,7 @@ export function createFileEmitter(
967967
},
968968
undefined /* cancellationToken */,
969969
undefined /* emitOnlyDtsFiles */,
970-
transformers
970+
transformers,
971971
);
972972

973973
onAfterEmit?.(sourceFile);
@@ -980,7 +980,7 @@ function getDiagnosticsForSourceFile(
980980
sourceFile: ts.SourceFile,
981981
disableTypeChecking: boolean,
982982
program: ts.BuilderProgram,
983-
angularCompiler?: NgtscProgram['compiler']
983+
angularCompiler?: NgtscProgram['compiler'],
984984
) {
985985
const syntacticDiagnostics = program.getSyntacticDiagnostics(sourceFile);
986986

0 commit comments

Comments
 (0)