Skip to content

Commit

Permalink
refactor: remove unneeded function args
Browse files Browse the repository at this point in the history
  • Loading branch information
SegaraRai committed Jul 2, 2024
1 parent 3bf0755 commit 028b886
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
11 changes: 2 additions & 9 deletions src/codegen/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { CodegenContext } from "./context";
import { generateModuleJSCode, generateTopJSCode } from "./js";
import {
getFilteredModuleImportsRecursive,
waitForModuleIdsToBeStable,
waitAndResolveAllModuleIds,
} from "./utils";

export * from "./context";
Expand Down Expand Up @@ -121,16 +121,9 @@ export async function generateCode(

switch (layer.mode) {
case "global": {
await waitForModuleIdsToBeStable(
codegenContext,
(resolvedId: string): boolean =>
shouldIncludeImport(resolvedId, null)
);
const allModuleIds = await waitAndResolveAllModuleIds(codegenContext);

const allContents: ContentSpec[] = [];
const allModuleIds = getAllModuleIds().filter((resolvedId) =>
shouldIncludeImport(resolvedId, null)
);
for (const id of allModuleIds) {
allContents.push({
raw: await getTailwindCSSContent(id),
Expand Down
15 changes: 9 additions & 6 deletions src/codegen/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,15 @@ export async function hasCircularDependencies(
return false;
}

export async function waitForModuleIdsToBeStable(
{ getAllModuleIds, resolveModuleImports }: CodegenContext,
shouldInclude: (resolvedId: string) => boolean
): Promise<void> {
export async function waitAndResolveAllModuleIds({
getAllModuleIds,
resolveModuleImports,
shouldIncludeImport,
}: CodegenContext): Promise<string[]> {
for (;;) {
const moduleIds = getAllModuleIds();
for (const resolvedId of moduleIds) {
if (!shouldInclude(resolvedId)) {
if (!shouldIncludeImport(resolvedId, null)) {
continue;
}

Expand All @@ -77,7 +78,9 @@ export async function waitForModuleIdsToBeStable(

const afterCount = getAllModuleIds().length;
if (moduleIds.length === afterCount) {
break;
return moduleIds.filter((resolvedId) =>
shouldIncludeImport(resolvedId, null)
);
}
}
}

0 comments on commit 028b886

Please sign in to comment.