Skip to content

Commit 1b420b5

Browse files
committed
feat: Only expose the Analysis interface, not the actual class.
1 parent 5de751f commit 1b420b5

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

packages/css-blocks/src/Analyzer/Analysis.ts

+2
Original file line numberDiff line numberDiff line change
@@ -400,3 +400,5 @@ export class Analysis<K extends keyof TemplateTypes> {
400400
return optAnalysis;
401401
}
402402
}
403+
404+
export interface IAnalysis<K extends keyof TemplateTypes> extends Analysis<K> {}

packages/css-blocks/src/Analyzer/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export { Analysis, SerializedAnalysis } from "./Analysis";
1+
export { IAnalysis as Analysis, SerializedAnalysis } from "./Analysis";
22
export { Analyzer, AnalysisOptions, SerializedAnalyzer } from "./Analyzer";
33
export * from "./ElementAnalysis";
44
export {

packages/jsx/src/transformer/babel.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export interface CssBlocksVisitor {
4646
elementAnalyzer: JSXElementAnalyzer;
4747
filename: string;
4848
mapping: StyleMapping<TEMPLATE_TYPE>;
49-
analysis: Analysis<TEMPLATE_TYPE>;
49+
analysis: Analysis<TEMPLATE_TYPE> | undefined;
5050
cssBlockOptions: CSSBlocksConfiguration;
5151
shouldProcess: boolean;
5252
}
@@ -78,15 +78,14 @@ export function makePlugin(transformOpts: { rewriter: Rewriter }): () => PluginO
7878

7979
this.mapping = rewriter.blocks[this.filename];
8080
if (this.mapping && this.mapping.analyses) {
81-
let a = this.mapping.analyses.find(a => a.template.identifier === this.filename);
82-
if (a instanceof Analysis) this.analysis = a;
81+
this.analysis = this.mapping.analyses.find(a => a.template.identifier === this.filename);
8382
} else {
8483
this.shouldProcess = false;
8584
}
8685
let ext = parse(this.filename).ext;
87-
this.shouldProcess = CAN_PARSE_EXTENSIONS[ext] && this.analysis && this.analysis.blockCount() > 0;
86+
this.shouldProcess = CAN_PARSE_EXTENSIONS[ext] && this.analysis && this.analysis.blockCount() > 0 || false;
8887

89-
if (this.shouldProcess) {
88+
if (this.analysis && this.shouldProcess) {
9089
debug(`Rewriting discovered dependency ${this.filename}`);
9190
// TODO: We use this to re-analyze elements in the rewriter.
9291
// We've already done this work and should be able to

0 commit comments

Comments
 (0)