-
Notifications
You must be signed in to change notification settings - Fork 569
Description
Summary
In #4226 I proposed that we remove the PureScript bundler. If we remove the bundler, then we only use language-javascript to verify that FFI declarations have a corresponding export in a .js file of the same name as the PureScript module. This library has been a notable maintenance burden on us over the past few years and I would like to move away from it.
Therefore, I propose that we drop the language-javascript dependency altogether if & when we remove the PureScript bundler.
To do this, we would need to do one of:
- No longer verify FFI declarations have a corresponding
.jsexport, instead relying on the immediate errors that would happen on application load if there was no corresponding export - Write our own minimal JavaScript lexer / parser that only looks for top-level declarations and exports for the purposes of validating FFI, but which doesn't attempt to parse all of the JavaScript.
Motivation
We've had trouble with language-javascript over the past few years. We currently pin an old version to avoid a bug parsing the async keyword, and we've supplied the majority of pull requests to the library since 2019.
While a good library, it has plenty of bugs in it and it's become a maintenance burden for the compiler team. Removing language-javascript allows us to drop this burden.
Proposal
I am proposing that we remove language-javascript if & when we remove purs bundle.
Without purs bundle, the only reason to have a JavaScript parser is to ensure that FFI declarations have a corresponding implementation. This leaves us with a decision:
- No longer verify this, leaving it to be a runtime or bundler error
- Write a "simple" JavaScript lexer / parser that only cares about exports
In the first case there is really nothing for us to do besides removing the dependency and corresponding code.
In the second case, we would need to write our own code. This code would need to be able to lex JavaScript literals like strings, brackets, export declarations, identifiers & keywords, and comments, so as to parse out exports. Everything else could be skipped over.
I think we should do (2) and maintain our own simple parser. I think this parser should only support "common sense" JavaScript rather than try to cover all edge cases. FFI files are not "do what you want" JavaScript, after all: they're a bridge between the PureScript and JavaScript worlds, and so I think we can place some restrictions on the JavaScript to make it easier for us to parse the export declarations.
It's not necessary to drop language-javascript in order to drop purs bundle, but dropping purs bundle opens the door to drop language-javascript as well.
Examples
Since this is the removal of a feature rather than an addition, I don't have any examples. However, I'm happy to edit this proposal to add them if y'all have ideas on what you'd like to see!