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
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function createJestConfig(_, rootDir = __dirname) {
moduleFileExtensions: ['ts', 'js'],
collectCoverageFrom: ['src/**/*.{ts,tsx,js,jsx}'],
testMatch: ['<rootDir>/test/*.(spec|test).ts'],
testURL: 'http://localhost',
testEnvironmentOptions: { url: 'http://localhost' },
rootDir,
watchPlugins: [
require.resolve('jest-watch-typeahead/filename'),
Expand Down
6,352 changes: 2,880 additions & 3,472 deletions package-lock.json

Large diffs are not rendered by default.

23 changes: 11 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,33 +44,32 @@
"module": "dist/lib.esm.js",
"devDependencies": {
"@gfx/zopfli": "^1.0.15",
"@types/commander": "^2.12.2",
"@types/selenium-webdriver": "^4.35.5",
"chromedriver": "^97.0.4",
"@types/selenium-webdriver": "^4.0.14",
"copyfiles": "^2.4.1",
"geckodriver": "^1.20.0",
"husky": "^4.2.5",
"jest": "^27.3.1",
"jest-watch-typeahead": "^1.0.0",
"jest": "^29.7.0",
"jest-watch-typeahead": "^2.2.2",
"node-gyp": "^9.0.0",
"prepack": "^0.2.54",
"selenium-webdriver": "^4.0.0-beta.4",
"selenium-webdriver": "^4.41.0",
"terser": "^5.1.0",
"tree-sitter": "^0.20.0",
"tree-sitter-elm": "^4.5.0",
"ts-jest": "^27.1.4",
"ts-node": "^8.10.2",
"ts-jest": "^29.4.6",
"ts-node": "^10.9.2",
"tslib": "^2.0.0",
"uglify-js": "^3.10.0",
"v8-natives": "^1.2.5",
"node-gyp": "^9.0.0"
"v8-natives": "^1.2.5"
},
"dependencies": {
"@types/jest": "^27.0.3",
"@types/jest": "^29.5.14",
"chalk": "^4.1.0",
"commander": "^6.0.0",
"commander": "^12.1.0",
"node-elm-compiler": "^5.0.4",
"ts-union": "^2.2.1",
"typescript": "^4.5.5"
"typescript": "^5.9.3"
},
"volta": {
"node": "16.14.2"
Expand Down
4 changes: 2 additions & 2 deletions src/benchmark/visit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ const visitBrowser = async (
const safariOptions = new safari.Options();

if (options.headless) {
firefoxOptions.headless();
chromeOptions.headless();
firefoxOptions.addArguments('--headless');
chromeOptions.addArguments('--headless');
// safariOptions.headless();
}
// Should probably make this configurable...
Expand Down
2 changes: 1 addition & 1 deletion src/bin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import program from 'commander';
import { program } from 'commander';
import chalk from 'chalk';
import { run } from './run';
const { version } = require('../package.json');
Expand Down
16 changes: 8 additions & 8 deletions src/transforms/adjustVirtualDom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export const replaceVDomNode = (): ts.TransformerFactory<ts.SourceFile> => conte
node.expression.text == '_VirtualDom_node' &&
node.arguments.length == 1
) {
return ts.createCall(ts.createIdentifier('A2'), undefined, [
ts.createIdentifier('_VirtualDom_nodeNS'),
ts.createIdentifier('undefined'),
return ts.factory.createCallExpression(ts.factory.createIdentifier('A2'), undefined, [
ts.factory.createIdentifier('_VirtualDom_nodeNS'),
ts.factory.createIdentifier('undefined'),
node.arguments[0],
]);
}
Expand All @@ -66,7 +66,7 @@ export const replaceVDomNode = (): ts.TransformerFactory<ts.SourceFile> => conte
return ts.visitEachChild(node, visitor, context);
};

return ts.visitNode(sourceFile, visitor);
return ts.visitNode(sourceFile, visitor) as ts.SourceFile;
};
};

Expand All @@ -84,10 +84,10 @@ function replaceVDomWithNSInline(node: ts.Node): ts.Node | undefined {
ts.isIdentifier(firstArg) &&
firstArg.text === '$elm$virtual_dom$VirtualDom$node'
) {
return ts.createCall(ts.createIdentifier('A4'), undefined, [
ts.createIdentifier('_VirtualDom_nodeNS'),
ts.createIdentifier('undefined'),
ts.createCall(ts.createIdentifier('_VirtualDom_noScript'), undefined, [
return ts.factory.createCallExpression(ts.factory.createIdentifier('A4'), undefined, [
ts.factory.createIdentifier('_VirtualDom_nodeNS'),
ts.factory.createIdentifier('undefined'),
ts.factory.createCallExpression(ts.factory.createIdentifier('_VirtualDom_noScript'), undefined, [
node.arguments[1],
]),
node.arguments[2],
Expand Down
5 changes: 2 additions & 3 deletions src/transforms/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export const v8Debug: ts.TransformerFactory<ts.SourceFile> = context => {
}
return ts.visitEachChild(node, visitor, context);
};
return ts.visitNode(sourceFile, visitor);
return ts.visitNode(sourceFile, visitor) as ts.SourceFile;
};
};

Expand All @@ -205,7 +205,6 @@ export const reportFunctionStatusInBenchmarks: ts.TransformerFactory<ts.SourceFi
}
return ts.visitEachChild(node, visitor, context);
};
return ts.visitNode(sourceFile, visitor);
return ts.visitNode(sourceFile, visitor) as ts.SourceFile;
};
};

2 changes: 1 addition & 1 deletion src/transforms/createTSprogram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const createProgramFromSource = (
if (name === sourceCopy.fileName) {
return sourceCopy;
} else {
return serveLibFile(name, languageVersion);
return serveLibFile(name, languageVersion as ts.ScriptTarget);
}
},
writeFile: () => {},
Expand Down
5 changes: 3 additions & 2 deletions src/transforms/inlineEquality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ export const inlineEquality = (): ts.TransformerFactory<ts.SourceFile> => contex
if (inferredPrimitive) {
// Documentation for creating nodes using the typescript compiler:
// https://github.com/microsoft/TypeScript/blob/2c08affa0d0d7fc55f15ab22e0326b93326d21d8/src/compiler/factory/nodeFactory.ts
return ts.createStrictEquality(
return ts.factory.createBinaryExpression(
node.arguments[0],
ts.SyntaxKind.EqualsEqualsEqualsToken,
node.arguments[1]
);
}
Expand All @@ -53,7 +54,7 @@ export const inlineEquality = (): ts.TransformerFactory<ts.SourceFile> => contex
return ts.visitEachChild(node, visitor, context);
};

return ts.visitNode(sourceFile, visitor);
return ts.visitNode(sourceFile, visitor) as ts.SourceFile;
};
};

Expand Down
22 changes: 11 additions & 11 deletions src/transforms/inlineListFromArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ import { Mode } from '../types';

const listElementMarker = (mode: Mode): ts.Expression =>
mode === Mode.Dev
? ts.createStringLiteral('::')
: ts.createNumericLiteral('1');
? ts.factory.createStringLiteral('::')
: ts.factory.createNumericLiteral('1');

export const InlineMode = Union({
UsingConsFunc: of(null),
Expand All @@ -75,8 +75,8 @@ const LIST_FROM_ARRAY_F_NAME = '_List_fromArray';
const LIST_NIL_NAME = '_List_Nil';
const LIST_CONS_F_NAME = '_List_cons';

const listNil = ts.createIdentifier(LIST_NIL_NAME);
const listConsCall = ts.createIdentifier(LIST_CONS_F_NAME);
const listNil = ts.factory.createIdentifier(LIST_NIL_NAME);
const listConsCall = ts.factory.createIdentifier(LIST_CONS_F_NAME);

export const createInlineListFromArrayTransformer = (
inlineMode: InlineMode
Expand All @@ -100,16 +100,16 @@ export const createInlineListFromArrayTransformer = (
(list: ts.Expression, element: ts.Expression): ts.Expression => {
return InlineMode.match(inlineMode, {
UsingConsFunc: (): ts.Expression =>
ts.createCall(listConsCall, undefined, [
ts.visitNode(element, visitor),
ts.factory.createCallExpression(listConsCall, undefined, [
ts.visitNode(element, visitor) as ts.Expression,
list,
]),

UsingLiteralObjects: mode =>
ts.createObjectLiteral([
ts.createPropertyAssignment('$', listElementMarker(mode)),
ts.createPropertyAssignment('a', element),
ts.createPropertyAssignment('b', list),
ts.factory.createObjectLiteralExpression([
ts.factory.createPropertyAssignment('$', listElementMarker(mode)),
ts.factory.createPropertyAssignment('a', element),
ts.factory.createPropertyAssignment('b', list),
]),
});
},
Expand All @@ -122,6 +122,6 @@ export const createInlineListFromArrayTransformer = (
return ts.visitEachChild(node, visitor, context);
};

return ts.visitNode(sourceFile, visitor);
return ts.visitNode(sourceFile, visitor) as ts.SourceFile;
};
};
4 changes: 2 additions & 2 deletions src/transforms/inlineNumberToString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ export const inlineNumberToString = (): ts.TransformerFactory<ts.SourceFile> =>
expression.text === INT_2_STRING) &&
node.arguments.length == 1
) {
return ts.createAdd(node.arguments[0], ts.createIdentifier('""'));
return ts.factory.createBinaryExpression(node.arguments[0], ts.SyntaxKind.PlusToken, ts.factory.createIdentifier('""'));
}
}
return ts.visitEachChild(node, visitor, context);
};

return ts.visitNode(sourceFile, visitor);
return ts.visitNode(sourceFile, visitor) as ts.SourceFile;
};
};
56 changes: 30 additions & 26 deletions src/transforms/inlineWrappedFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ export const createFunctionInlineTransformer = (
ignoreTopLevel === 'for tests',
arityBasedFunctionNames
);
const splittedNode = ts.visitNode(sourceFile, splitter);
const splittedNode = ts.visitNode(sourceFile, splitter) as ts.SourceFile;

const inliner = createInlinerVisitor(inlineContext, context);
const result = ts.visitNode(splittedNode, inliner);
const result = ts.visitNode(splittedNode, inliner) as ts.SourceFile;

if (logOverview) {
reportInlineTransformResult(inlineContext);
Expand Down Expand Up @@ -220,18 +220,20 @@ const createSplitterVisitor = (
type: 'raw_func',
});

const lambdaDeclaration = ts.createVariableDeclaration(
const lambdaDeclaration = ts.factory.createVariableDeclaration(
rawLambdaName,
undefined,
undefined,
maybeFuncExpression
);

const newDeclaration = ts.updateVariableDeclaration(
const newDeclaration = ts.factory.updateVariableDeclaration(
node,
node.name,
undefined,
ts.createCall(callExpression, undefined, [
ts.createIdentifier(rawLambdaName),
undefined,
ts.factory.createCallExpression(callExpression, undefined, [
ts.factory.createIdentifier(rawLambdaName),
])
);

Expand Down Expand Up @@ -302,28 +304,29 @@ const createSplitterVisitor = (
});

const argsIdentifiers = appliedArgs.map((name) =>
ts.createIdentifier(name)
ts.factory.createIdentifier(name)
);

return [
...appliedArgsNodes.map((argExpression, i) =>
ts.createVariableDeclaration(
ts.factory.createVariableDeclaration(
nameOfArg(i),
undefined,
undefined,
argExpression
)
),

ts.updateVariableDeclaration(
ts.factory.updateVariableDeclaration(
node,
node.name,
undefined,
ts.updateCall(
node.initializer,
undefined,
ts.factory.createCallExpression(
callExpression,
undefined,
isWrappedWithA
? [ts.createIdentifier(funcName), ...argsIdentifiers]
? [ts.factory.createIdentifier(funcName), ...argsIdentifiers]
: argsIdentifiers
)
),
Expand Down Expand Up @@ -376,10 +379,11 @@ const createSplitterVisitor = (

return [
node,
ts.createVariableDeclaration(
ts.createIdentifier(rawFunName),
ts.factory.createVariableDeclaration(
ts.factory.createIdentifier(rawFunName),
undefined,
undefined,
ts.createPropertyAccess(node.name, ts.createIdentifier(inner_fn_name))
ts.factory.createPropertyAccessExpression(node.name, ts.factory.createIdentifier(inner_fn_name))
),
];
}
Expand Down Expand Up @@ -423,10 +427,10 @@ const createInlinerVisitor = (

if (split && split.arity === arity) {
reportInlinining(split, inlineContext);
return ts.createCall(
ts.createIdentifier(split.rawLambdaName),
return ts.factory.createCallExpression(
ts.factory.createIdentifier(split.rawLambdaName),
undefined,
args.map((arg) => ts.visitNode(arg, inliner))
args.map((arg) => ts.visitNode(arg, inliner) as ts.Expression)
);
}

Expand All @@ -440,14 +444,14 @@ const createInlinerVisitor = (
) {
inlineContext.inlined.partialApplications += 1;

return ts.createCall(
ts.createIdentifier(partialApplication.split.rawLambdaName),
return ts.factory.createCallExpression(
ts.factory.createIdentifier(partialApplication.split.rawLambdaName),
undefined,
[
...partialApplication.appliedArgs.map((name) =>
ts.createIdentifier(name)
ts.factory.createIdentifier(name)
),
...args.map((arg) => ts.visitNode(arg, inliner)),
...args.map((arg) => ts.visitNode(arg, inliner) as ts.Expression),
]
);
}
Expand All @@ -464,14 +468,14 @@ const createInlinerVisitor = (
) {
inlineContext.inlined.partialApplications += 1;

return ts.createCall(
ts.createIdentifier(partialApplication.split.rawLambdaName),
return ts.factory.createCallExpression(
ts.factory.createIdentifier(partialApplication.split.rawLambdaName),
undefined,
[
...partialApplication.appliedArgs.map((name) =>
ts.createIdentifier(name)
ts.factory.createIdentifier(name)
),
...node.arguments.map((arg) => ts.visitNode(arg, inliner)),
...node.arguments.map((arg) => ts.visitNode(arg, inliner) as ts.Expression),
]
);
}
Expand Down
Loading
Loading