mirror of
https://github.com/mdgriffith/elm-optimize-level-2.git
synced 2024-11-25 22:50:42 +03:00
accidental commit.
This commit is contained in:
parent
5e16fe457b
commit
36e77be58a
@ -56,14 +56,7 @@ async function run(inputFilePath: string | undefined) {
|
||||
verbose: true,
|
||||
assetSizes: true,
|
||||
runBenchmark: [
|
||||
{
|
||||
browser: Browser.Chrome,
|
||||
headless: true,
|
||||
},
|
||||
{
|
||||
browser: Browser.V8JitLog,
|
||||
headless: true,
|
||||
},
|
||||
{ browser: Browser.Firefox }
|
||||
],
|
||||
transforms: { ...benchmarkDefaults, ...{replacements: replacements} }
|
||||
};
|
||||
|
@ -2,7 +2,6 @@ import ts from 'typescript';
|
||||
|
||||
export const recordUpdate = (): ts.TransformerFactory<ts.SourceFile> =>
|
||||
(context) => (sourceFile) => {
|
||||
console.log('record update');
|
||||
const registry = new RecordRegistry();
|
||||
ts.visitNode(sourceFile, replaceObjectLiterals(registry, context));
|
||||
return sourceFile;
|
||||
@ -18,23 +17,29 @@ class RecordRegistry {
|
||||
this.map = new Map();
|
||||
}
|
||||
|
||||
register(recordAst: ts.Node) {
|
||||
register(recordAst: ts.Node): String {
|
||||
console.log(recordAst);
|
||||
}
|
||||
}
|
||||
|
||||
function replaceObjectLiterals(_registry: RecordRegistry, _ctx: ts.TransformationContext) {
|
||||
function replaceObjectLiterals(_registry: RecordRegistry, ctx: ts.TransformationContext) {
|
||||
const visitorHelp = (node: ts.Node): ts.VisitResult<ts.Node> => {
|
||||
if (isRecordLiteral(node)) {
|
||||
return node;
|
||||
const visitedNode = ts.visitEachChild(node, visitorHelp, ctx);
|
||||
if (!isRecordLiteral(visitedNode)) {
|
||||
return visitedNode;
|
||||
}
|
||||
|
||||
return node;
|
||||
const recordClassName = registry.register(visitedNode);
|
||||
console.log(recordClassName);
|
||||
|
||||
return visitedNode;
|
||||
}
|
||||
|
||||
return visitorHelp;
|
||||
}
|
||||
|
||||
function isRecordLiteral(node: ts.Node): boolean {
|
||||
return ts.isObjectLiteralExpression(node);
|
||||
return ts.isObjectLiteralExpression(node) &&
|
||||
node.properties.length > 0 &&
|
||||
node.properties[0].name.text !== '$';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user