Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/compiler-on-oxc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@solidjs/ogp': patch
---

- The compiler runs on oxc and returns a source map. Babel is no longer a dependency.
- Values inside objects in a `DynamicImage`, such as `style={{ color: color() }}`, are passed to the server function.
- An aliased import, such as `import { createMemo as memo }`, no longer stops the compiler from adding the import it needs.
16 changes: 16 additions & 0 deletions oxlint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,20 @@ export default defineConfig({
// Compiler fixtures are test data: their outputs must match the compiler byte for byte.
// Agent worktrees under .claude/ hold other branches' work in progress.
ignorePatterns: ['dist/**', '**/tests/fixtures/**', '.claude/**'],
overrides: [
{
// The compiler works on a structural AST type, so property access is
// untyped there.
files: ['packages/ogp/src/compiler/**'],
rules: {
'typescript/no-unsafe-argument': 'off',
'typescript/no-unsafe-assignment': 'off',
'typescript/no-unsafe-call': 'off',
'typescript/no-unsafe-member-access': 'off',
'typescript/no-unsafe-return': 'off',
'typescript/no-unsafe-type-assertion': 'off',
'typescript/no-explicit-any': 'off',
},
},
],
});
11 changes: 5 additions & 6 deletions packages/ogp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,19 @@
"test": "vitest run"
},
"dependencies": {
"@babel/core": "^7.28.0",
"@solid-mediakit/shared": "^0.0.6",
"@vercel/og": "^1.0.1",
"magic-string": "^1.4.5",
"oxc-parser": "^0.158.0",
"satori-html": "^0.3.2",
"unplugin": "^3.3.0"
"unplugin": "^3.3.0",
"unplugin-utils": "^0.3.2"
},
"devDependencies": {
"@arethetypeswrong/core": "^0.18.5",
"@babel/preset-typescript": "^7.27.0",
"@solidjs/vite-plugin": "3.0.0-next.27",
"@solidjs/web": "2.0.0-rc.21",
"@types/babel__core": "^7.20.5",
"@types/node": "^26.2.0",
"babel-plugin-tester": "^12.0.0",
"prettier": "^3.9.10",
"publint": "^0.3.23",
"solid-js": "2.0.0-rc.21",
"tsdown": "^0.22.14",
Expand Down
40 changes: 40 additions & 0 deletions packages/ogp/src/compiler/ast.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
export interface Node {
type: string;
start: number;
end: number;
// The compiler walks a structural AST; property access is untyped by design.
[key: string]: any;
}

/** Keys that hold TypeScript type-space nodes; never traversed. */
const TYPE_KEYS = new Set([
'typeAnnotation',
'typeArguments',
'typeParameters',
'returnType',
'superTypeArguments',
'implements',
]);

function isNode(value: unknown): value is Node {
return value != null && typeof value === 'object' && typeof (value as Node).type === 'string';
}

/** Invokes `cb` for every direct child node, skipping TypeScript type-space keys. */
export function eachChild(node: Node, cb: (child: Node) => void): void {
for (const key of Object.keys(node)) {
if (TYPE_KEYS.has(key)) {
continue;
}
const value = node[key];
if (Array.isArray(value)) {
for (const item of value) {
if (isNode(item)) {
cb(item);
}
}
} else if (isNode(value)) {
cb(value);
}
}
}
Loading
Loading