Skip to content

Commit 666a7e0

Browse files
committed
Fix pre-processing
1 parent effd173 commit 666a7e0

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

src/babel/core/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export interface StateContext {
4040
identifiers: Map<t.Identifier, ImportIdentifierSpecifier>;
4141
namespaces: Map<t.Identifier, ImportIdentifierSpecifier[]>;
4242
};
43-
processed: boolean;
4443
filename: string | undefined;
4544
bundler: RuntimeType;
4645
fixRender: boolean;

src/babel/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,27 +179,29 @@ function setupProgram(
179179
state: StateContext,
180180
path: babel.NodePath<t.Program>,
181181
comments: t.Comment[] | undefined | null,
182-
): void {
182+
): boolean {
183183
let shouldSkip = false;
184+
let isDone = false;
184185
if (comments) {
185186
for (const { value: comment } of comments) {
186187
if (/^\s*@refresh skip\s*$/.test(comment)) {
187-
state.processed = true;
188+
isDone = true;
188189
shouldSkip = true;
189190
break;
190191
}
191192
if (/^\s*@refresh reload\s*$/.test(comment)) {
192-
state.processed = true;
193+
isDone = true;
193194
path.pushContainer('body', getHMRDeclineCall(state, path));
194195
break;
195196
}
196197
}
197198
}
198199

199-
captureIdentifiers(state, path);
200200
if (!shouldSkip && state.fixRender) {
201+
captureIdentifiers(state, path);
201202
fixRenderCalls(state, path);
202203
}
204+
return isDone;
203205
}
204206

205207
function isStatementTopLevel(path: babel.NodePath<t.Statement>): boolean {
@@ -346,13 +348,11 @@ export default function solidRefreshPlugin(): babel.PluginObj<State> {
346348
identifiers: new Map(),
347349
namespaces: new Map(),
348350
},
349-
processed: false,
350351
filename: context.filename,
351352
bundler: context.opts.bundler || 'standard',
352353
fixRender: context.opts.fixRender ?? true,
353354
};
354-
setupProgram(state, programPath, context.file.ast.comments);
355-
if (state.processed) {
355+
if (setupProgram(state, programPath, context.file.ast.comments)) {
356356
return;
357357
}
358358
programPath.traverse({

0 commit comments

Comments
 (0)