Skip to content

Commit e874269

Browse files
committed
style: format
1 parent 507ec22 commit e874269

26 files changed

Lines changed: 294 additions & 245 deletions

docs/superpowers/specs/2026-06-20-fragment-children-flattening-design.md

Lines changed: 0 additions & 63 deletions
This file was deleted.

packages/cli/src/compiler/index.ts

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@ import YAMLLoader from "./yaml-loader.js";
1414
import JSONLoader from "./json-loader.js";
1515
import { resolveRootDir } from "../utils.js";
1616
import { writeIfChanged, hashContent, hashFile, hashJSON } from "./fs-cache.js";
17-
import {
18-
BuildManifest,
19-
ManifestEntry,
20-
ManifestOutput,
21-
hashConfig,
22-
} from "./build-manifest.js";
17+
import { BuildManifest, ManifestEntry, ManifestOutput, hashConfig } from "./build-manifest.js";
2318
import {
2419
AnyLoader,
2520
CompilerContext,
@@ -472,7 +467,7 @@ export default async function compile(file: string, compilerOptions: CompilerOpt
472467
// Add content hash to URL to bust Node's ESM cache.
473468
// Without this, the same URL always returns the cached module object,
474469
// causing stale content to be used in subsequent builds.
475-
const contentHash = crypto.createHash('md5').update(content).digest('hex').slice(0, 8);
470+
const contentHash = crypto.createHash("md5").update(content).digest("hex").slice(0, 8);
476471
const importUrl = pathToFileURL(cache.outputPath).href + `?v=${contentHash}`;
477472
cache.resolve((await import(importUrl)) as Module);
478473
} catch (importErr) {
@@ -591,8 +586,11 @@ export default async function compile(file: string, compilerOptions: CompilerOpt
591586
finalizeEntry(resolvedPath, loaders, result.data);
592587
try {
593588
// Add content hash to URL to bust Node's ESM cache.
594-
const contentStr = typeof result.content === 'string' ? result.content : JSON.stringify(result.content ?? '');
595-
const contentHash = crypto.createHash('md5').update(contentStr).digest('hex').slice(0, 8);
589+
const contentStr =
590+
typeof result.content === "string"
591+
? result.content
592+
: JSON.stringify(result.content ?? "");
593+
const contentHash = crypto.createHash("md5").update(contentStr).digest("hex").slice(0, 8);
596594
const importUrl = pathToFileURL(cache.outputPath).href + `?v=${contentHash}`;
597595
cache.resolve((await import(importUrl)) as Module);
598596
} catch (importErr) {
@@ -636,8 +634,7 @@ export default async function compile(file: string, compilerOptions: CompilerOpt
636634
fs.mkdirpSync(outputDir);
637635
}
638636
logger.info(`Emitting ${name}`);
639-
const writable =
640-
typeof content === "string" ? content : new Uint8Array(content);
637+
const writable = typeof content === "string" ? content : new Uint8Array(content);
641638
const wrote = writeIfChanged(outputPath, writable);
642639
if (wrote) {
643640
changedOutputs.add(outputPath);
@@ -737,7 +734,9 @@ export default async function compile(file: string, compilerOptions: CompilerOpt
737734
const entry: ManifestEntry = {
738735
sourceHash,
739736
loaders: loaders.map((l) => l.loader.name || "anonymous"),
740-
loaderOptionsHash: hashJSON(loaders.map((l) => ({ name: l.loader.name, options: l.options }))),
737+
loaderOptionsHash: hashJSON(
738+
loaders.map((l) => ({ name: l.loader.name, options: l.options }))
739+
),
741740
dependencies: deps,
742741
outputs,
743742
componentConfig: extractComponentConfigForEntry(entryPath, data),
@@ -766,10 +765,7 @@ export default async function compile(file: string, compilerOptions: CompilerOpt
766765
* 增量短路:若 manifest 里该 entry 的源/依赖/产物全部命中,则跳过 loader 链。
767766
* 跳过时仍需把 componentConfig merge 回 AppComponentsCompiler(通过触发 loadModule 钩子)。
768767
*/
769-
async function tryReuseEntry(
770-
entryPath: string,
771-
loaders: ResolvedLoaderRule[]
772-
): Promise<boolean> {
768+
async function tryReuseEntry(entryPath: string, loaders: ResolvedLoaderRule[]): Promise<boolean> {
773769
if (options.force) return false;
774770
const cached = manifest.get(entryPath);
775771
if (!cached) return false;
@@ -778,10 +774,7 @@ export default async function compile(file: string, compilerOptions: CompilerOpt
778774
const loaderOptionsHash = hashJSON(
779775
loaders.map((l) => ({ name: l.loader.name, options: l.options }))
780776
);
781-
if (
782-
cached.sourceHash !== sourceHash ||
783-
cached.loaderOptionsHash !== loaderOptionsHash
784-
) {
777+
if (cached.sourceHash !== sourceHash || cached.loaderOptionsHash !== loaderOptionsHash) {
785778
return false;
786779
}
787780
if (!manifest.validateDependencies(cached)) return false;

packages/cli/src/compiler/ts-loader.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ function shouldDeriveNameFromRoute(resourcePath: string) {
4040
*/
4141
const componentNameRegistries = new Map<string, Map<string, string>>();
4242

43-
function registerComponentName(
44-
rootContext: string,
45-
componentName: string,
46-
resourcePath: string
47-
) {
43+
function registerComponentName(rootContext: string, componentName: string, resourcePath: string) {
4844
let registry = componentNameRegistries.get(rootContext);
4945
if (!registry) {
5046
registry = new Map();
@@ -112,7 +108,11 @@ export default async function TsLoader(this: LoaderContext, content: LoaderInput
112108
node.attributes
113109
);
114110
}
115-
if (ts.isFunctionDeclaration(node) && node.name && isComponentFunc(node.name.getText(sourceFile))) {
111+
if (
112+
ts.isFunctionDeclaration(node) &&
113+
node.name &&
114+
isComponentFunc(node.name.getText(sourceFile))
115+
) {
116116
localComponents.push({
117117
name: node.name.getText(sourceFile),
118118
kind: getExportKind(node) ?? "internal",
@@ -242,9 +242,7 @@ export default async function TsLoader(this: LoaderContext, content: LoaderInput
242242
(c) => c.displayName === meta.name || c.name === meta.name
243243
) as (React.FC & { displayName?: string; shouldPreRender?: boolean }) | undefined;
244244
if (!component) {
245-
throw new Error(
246-
`Could not find component "${meta.name}" in componentList after transpile`
247-
);
245+
throw new Error(`Could not find component "${meta.name}" in componentList after transpile`);
248246
}
249247
if (component.shouldPreRender) {
250248
return null;

packages/cli/test/build.test.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@ import assert from "assert";
22
import fs from "fs-extra";
33
import path from "path";
44
import compile from "../lib/compiler/index.js";
5-
import {
6-
fixturesDir,
7-
withCwd,
8-
ensureLcuiReact,
9-
cleanGenerated,
10-
} from "./helpers.js";
5+
import { fixturesDir, withCwd, ensureLcuiReact, cleanGenerated } from "./helpers.js";
116

127
describe("compile (build) — non-AppRouter project (no app/ directory)", () => {
138
const fixtureDir = path.join(fixturesDir, "build-no-router");

packages/cli/test/css-loader.test.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@ import assert from "assert";
22
import fs from "fs-extra";
33
import path from "path";
44
import compile from "../lib/compiler/index.js";
5-
import {
6-
fixturesDir,
7-
withCwd,
8-
ensureLcuiReact,
9-
cleanGenerated,
10-
} from "./helpers.js";
5+
import { fixturesDir, withCwd, ensureLcuiReact, cleanGenerated } from "./helpers.js";
116

127
describe("css-loader — tailwindcss integration", () => {
138
const fixtureDir = path.join(fixturesDir, "css-loader-tailwind");
@@ -23,10 +18,7 @@ describe("css-loader — tailwindcss integration", () => {
2318
await withCwd(fixtureDir, () => compile(undefined, {}));
2419

2520
const cssHPath = path.join(fixtureDir, "app", "global.css.h");
26-
assert.ok(
27-
fs.existsSync(cssHPath),
28-
`expected css-loader to emit ${cssHPath}`
29-
);
21+
assert.ok(fs.existsSync(cssHPath), `expected css-loader to emit ${cssHPath}`);
3022
const cssH = fs.readFileSync(cssHPath, "utf-8");
3123

3224
// 1. 头文件骨架仍在:css-loader 应当生成 `static const char *css_str_global = ...`

packages/cli/test/fixtures/ts-loader-explicit-displayname/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
"version": "0.0.0",
44
"private": true,
55
"type": "module"
6-
}
6+
}

packages/cli/test/fixtures/ts-loader-explicit-displayname/src/widgets.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ export default function WidgetsApp() {
1414
<AnotherWidget />
1515
</div>
1616
);
17-
}
17+
}

packages/cli/test/fixtures/ts-loader-multi-component/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
"version": "0.0.0",
44
"private": true,
55
"type": "module"
6-
}
6+
}

packages/cli/test/fixtures/ts-loader-multi-component/src/helpers.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ export default function App() {
1414
<MyButton />
1515
</div>
1616
);
17-
}
17+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export default function RootLayout() {
22
return <div>root layout</div>;
3-
}
3+
}

0 commit comments

Comments
 (0)