Closed hildjj closed 8 months ago
There's a timing bug in the watchfile tests as well. Will deal with it if we end up using this.
I think the sourcemap thing isn't an issue. This works surprisingly well already. Still needs a compiler pass that checks if output type is "es" and looks for import lines to move to the top.
Still needs docs, a changelog entry, and some thought about how this affects the version number.
Being able to specify a URL in the CLI would be pretty cool. In order to do this, I'd look for filenames starting with https?://
, use fetch to pull down the contents, and cache it, like deno. This would up the minimum version of node required to be v18 -- That's fine with me because:
a) we're taking a breaking change in this release for node version anyway. b) Node 16 is no longer supported.
This would make importing rules from a central repository easier, I think.
Tested combining grammars from two repositories successfully: https://github.com/frostburn/peggy-string-concat
Another patch coming with other issues fixed.
OK, I think I fixed all of the outstanding issues. I've left this as two patches since review to make it easier to see the changes, but I'll reorder and clean up the patch before merging.
This is ready to squash and merge.
ready to go if anyone wants to take a last look. Next step is to merge the imports grammar back into the main grammar, and give it two entry points. Then, I'll use the imports grammar to add imports syntax before toplevel initializers.
This is a PR draft exploring another part of #292.
What if you could just pass multiple files in on the command line, and have Peggy stitch them together into a single output?
This points out a few issues:
topLevelInitializer
andinitializer
in the AST should be arrays. This is so that when they get copied into the output, each initializer section would be marked up with the correct source-map info.import
s in the top-level initializers of multiple files. They should probably all be moved to the top, but this is a JS-specific transform that should be in a compiler pass.