-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build and publish the lexer to npm #20778
Conversation
2896925
to
c6c1464
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, although I'm not super familiar with some of these build scripts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Structure looks great! Just a few nits on the specifics within!
I've updated the PR to capture the above changes. |
@benesch between approval and merge we'll need to set the |
Done: https://github.com/MaterializeInc/i2/pull/1016 |
LGTM, modulo the debugging |
In an effort to ensure we're not maintaing two concurrent Lexer implementations, make the existing lexer available to more platforms. By building a WASM module, we can re-use it in JavaScript contexts. `wasm-pack` does most of the heavy lifting, but we need to ensure we're emitting types that can be serialized across the WASM interface, hence the flattening of the token array.
Certain crates, such as 'sql-lexer', can be compiled to WASM using the 'wasm-pack' tool. This commit: 1. Adds the relevant WASM libraries and tooling to the ci-builder. 2. Exposes additional CLI surface area to allow xcompile to run in the ci-builder image.
Add CI hooks to build WASM packages alongside the crates in CI, and tooling to publish built artifacts to npm with the appropriate tags and version information. This will publish packages for _all_ builds on the deploy pipeline. Stable/official builds will not have a `-dev` suffix, and will receive the `latest` dist tag. Unstable builds will have a `dev` suffix that includes a build number, and will receive the `dev` dist tag.
Motivation
Following #20345, let's publish the lexer to npm! This PR contains the three phases of the change, each in its own commit with details in the message. To summarize, they:
mz-sql-lexer
. Perform the necessary updates to be able to compile the lexer to WASM targets as well as make it ergonomic for JS/TS callers. This includes a special allocator that reduces the bundle size.wasm-pack
tool. It also includes a wrapper script to codify invocation parameters.@materializinc
namespace` be added to the Buildkite environment. A sample npm listing is here (please ignore the incorrect package name held over from testing).CI updates
Two additional CI jobs are added to the PR and deploy pipelines:
main
. For dev builds, this uses pre-release versioning with a build identifier derived from the Buildkite build ID.cargo-deny exemption
The custom allocator (
lol_alloc
) depends on spin 0.9, whilering
(a dependency ofaws-config
) depends on 0.5. This is fixed onring
's main branch, but it has not yet made it to a stable release. The last stable release forring
is 2+ years old, and the last unstable release is 8 months old. The ring dep may disappear altogether in a future version of aws-config. Given the alternate version of this crate is only used when targeting WASM, I believe this exemption is fine to carve out.Tips for reviewer
These are grouped by commit, and each commit message includes additional information.
Unfortunately, I had to disable TypeScript definition autogeneration for the
lex
function asjs-sys
does not provide adequate support for container types (i.e., it would returnArray
instead ofToken[]
).Checklist
$T ⇔ Proto$T
mapping (possibly in a backwards-incompatible way), then it is tagged with aT-proto
label.