-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
297 additions
and
593 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
{ | ||
"name": "root", | ||
"private": true, | ||
"workspaces": [ | ||
"packages/*", | ||
"examples/*" | ||
], | ||
"workspaces": ["packages/*", "examples/*"], | ||
"devDependencies": { | ||
"@biomejs/biome": "^1.4.1", | ||
"@biomejs/biome": "^1.5.1", | ||
"lerna": "^7.4.1", | ||
"typescript": "^5.2.2" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,20 @@ | ||
import * as babel from '@babel/core'; | ||
import plugin from 'forgetti'; | ||
import { readFile } from 'fs/promises'; | ||
import { readFile } from 'node:fs/promises'; | ||
|
||
const options = { | ||
preset: 'react', | ||
}; | ||
|
||
async function compile(code) { | ||
const result = await babel.transformAsync(code, { | ||
plugins: [ | ||
[plugin, options], | ||
], | ||
plugins: [[plugin, options]], | ||
parserOpts: { | ||
plugins: [ | ||
'jsx', | ||
], | ||
plugins: ['jsx'], | ||
}, | ||
}); | ||
|
||
return result?.code ?? ''; | ||
} | ||
|
||
console.log(await compile(await readFile('./input.js', 'utf-8'))); | ||
console.log(await compile(await readFile('./input.js', 'utf-8'))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
function Example(props) { | ||
return <styled.H1>{props.greeting}, {props.receiver}!</styled.H1>; | ||
} | ||
return ( | ||
<styled.H1> | ||
{props.greeting}, {props.receiver}! | ||
</styled.H1> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ | |
".": "src/index.ts", | ||
"./runtime": "runtime/index.ts" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import type * as babel from '@babel/core'; | ||
|
||
export function getDescriptiveName( | ||
path: babel.NodePath, | ||
defaultName: string, | ||
): string { | ||
let current: babel.NodePath | null = path; | ||
while (current) { | ||
switch (current.node.type) { | ||
case 'FunctionDeclaration': | ||
case 'FunctionExpression': { | ||
if (current.node.id) { | ||
return current.node.id.name; | ||
} | ||
break; | ||
} | ||
case 'VariableDeclarator': { | ||
if (current.node.id.type === 'Identifier') { | ||
return current.node.id.name; | ||
} | ||
break; | ||
} | ||
case 'ClassPrivateMethod': | ||
case 'ClassMethod': | ||
case 'ObjectMethod': { | ||
switch (current.node.key.type) { | ||
case 'Identifier': | ||
return current.node.key.name; | ||
case 'PrivateName': | ||
return current.node.key.id.name; | ||
default: | ||
break; | ||
} | ||
break; | ||
} | ||
default: | ||
break; | ||
} | ||
current = current.parentPath; | ||
} | ||
return defaultName; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.