mirror of
https://github.com/mdgriffith/elm-optimize-level-2.git
synced 2024-12-01 19:35:08 +03:00
not really known
.vscode | ||
elm-packages/elm/parser | ||
src | ||
test | ||
testcases | ||
.gitignore | ||
.gitmodules | ||
add-benchmark.sh | ||
jest.config.js | ||
LICENSE | ||
LINKS.md | ||
package-lock.json | ||
package.json | ||
README.md | ||
transformations.md | ||
tsconfig.json |
Elm Optimize
This project is meant to explore different optimizations that are specific to elm-generated code.
I'd like to avoid aspects that can handled by terser, uglify or prepack just because it seems like this is a huge area and there's already a ton of work done. We should focus on things specific to Elm, and possibly make it easier for these tools to be even more effective.
The first focus is to implement transformations that were explored by Robin in this dev.to post
Needed work
- - Set up a basic test example (e.g. fold through a list of maybe Ints and sum them).
- - Set up complation pipeline
- We want to be able to compare different JS outputs to get a handle of who does what transformation. So let's set up a pipeline that will generate multiple
js
files in a folder at different stages of the pipeline (e.g.elm.js
,elm.optimized.js
,elm.optimized.prepack.js
. This will allow us todiff
stages and ultimately compare how our tool can potentially allow other tools to function more effectively.
- We want to be able to compare different JS outputs to get a handle of who does what transformation. So let's set up a pipeline that will generate multiple
Choose AST tool We need some tool(s) that will allow us to do the following:
- Parse Elm code and extract information such as a type definition (i.e. what are all the variant names and their structures).
- Parse JS code and transform bits of the AST.
Options
- SWC
- In Rust, plugin in typescript
- Codemod
- Treesitter
Opimization exploration
- 1. Parse Elm code and prepare a summary that matches custom type variant names to their type definition
- 2. Fill out variant constructors with nulls so that the shapes of the objects are the same. (See V8 fast properties reference. Is there some way to check how V8 is implementing a specific object?)
- 3. Transform
A2(author$project$Main$add, 1, 2)
toauthor$project$Main$add.f(1, 2)
when appropriate