Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Experimenting with integrating https://github.com/zth/rescript-embed-lang into the compiler.
Instructions
Pass whatever extension points you want to treat as embeds to
bscvia-embedwhen producing the.astfile via-bs-ast:./bsc tst.res -bs-ast -embed sql.one -embed sql.manySome examples. Imagine this ReScript file:
Running
./bsc tst.res -bs-ast -embed sql.one -embed sql.manywill do 2 things:First, it'll produce a JSON file
tst.embeds.jsonright next to thetst.astfile, with all embeds + info needed for them from the file:[ { "tag": "sql.one", "filename": "Tst__sql_one_1.res", "contents": "\n SELECT * FROM tst.res\n WHERE id = 1\n", "loc": {"start": {"line": 1, "col": 22}, "end": {"line": 4, "col": 64}} }, { "tag": "sql.many", "filename": "Tst__sql_many_1.res", "contents": "\n SELECT * FROM tst.res\n WHERE id > 1\n", "loc": {"start": {"line": 6, "col": 86}, "end": {"line": 9, "col": 128}} }, { "tag": "sql.one", "filename": "Tst__sql_one_2.res", "contents": "\n SELECT * FROM tst.res\n WHERE id = 2\n", "loc": {"start": {"line": 11, "col": 149}, "end": {"line": 14, "col": 191}} }, { "tag": "sql.many", "filename": "Tst__sql_many_2.res", "contents": "\n SELECT * FROM tst.res\n WHERE id > 2\n", "loc": {"start": {"line": 16, "col": 219}, "end": {"line": 19, "col": 261}} } ]Second, it'll rewrite the source to point to the generated file it expects:
.defaultinside of the generated module.TODO