Skip to content

Commit

Permalink
feat: upgrade swc_ecma_parser 0.141 (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Oct 13, 2023
1 parent 22089a7 commit e0eb3f2
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 28 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ jobs:
- name: Ensure code generation same
if: matrix.config.kind == 'test_debug'
run: |
cargo install cargo-clone --version 1.1.0
# lock this so it works on Rust 1.65
cargo install cargo-clone --version 1.1.0 --locked
chmod +x ./scripts/generate.ts
./scripts/generate.ts
echo Checking for git changes...
Expand Down
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions rs-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ sourcemap = ["swc_common/sourcemap"]
view = []

[dependencies]
bumpalo = "3.13.0"
bumpalo = "3.14.0"
num-bigint = "0.4"
rustc-hash = "1.1.0"
swc_atoms = "0.5.9"
swc_common = "0.32.0"
swc_ecma_ast = "0.109.0"
swc_ecma_parser = "0.139.0"
swc_atoms = "0.6.0"
swc_common = "0.33.0"
swc_ecma_ast = "0.110.0"
swc_ecma_parser = "0.141.1"
text_lines = "0.6.0"

[dev-dependencies]
Expand Down
8 changes: 4 additions & 4 deletions rs-lib/src/view/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12224,7 +12224,7 @@ fn set_parent_for_getter_prop<'a>(node: &GetterProp<'a>, parent: Node<'a>) {
/// A complete identifier with span.
///
/// Identifier of swc consists of two parts. The first one is symbol, which is
/// stored using an interned string, [JsWord] . The second
/// stored using an interned string, [Atom] . The second
/// one is [SyntaxContext][swc_common::SyntaxContext], which can be
/// used to distinguish identifier with same symbol.
///
Expand Down Expand Up @@ -12257,7 +12257,7 @@ fn set_parent_for_getter_prop<'a>(node: &GetterProp<'a>, parent: Node<'a>) {
///
/// Thanks to the `tag` we attached, we can now distinguish them.
///
/// ([JsWord], [SyntaxContext])
/// ([Atom], [SyntaxContext])
///
/// See [Id], which is a type alias for this.
///
Expand All @@ -12282,7 +12282,7 @@ impl<'a> Ident<'a> {
self.parent.get().unwrap()
}

pub fn sym(&self) -> &swc_atoms::JsWord {
pub fn sym(&self) -> &swc_atoms::Atom {
&self.inner.sym
}

Expand Down Expand Up @@ -16518,7 +16518,7 @@ impl<'a> Str<'a> {
self.parent.get().unwrap()
}

pub fn value(&self) -> &swc_atoms::JsWord {
pub fn value(&self) -> &swc_atoms::Atom {
&self.inner.value
}

Expand Down
31 changes: 23 additions & 8 deletions scripts/generate.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
#!/usr/bin/env -S deno run -A
import $ from "https://deno.land/x/[email protected]/mod.ts";
import $ from "https://deno.land/x/[email protected]/mod.ts";

$.setPrintCommand(true);

const root = $.path(import.meta).join("../../").resolve();

if (!Deno.args.some(a => a === "--quick")) {
const swcVersions = await getSwcVersions();
$.logStep("Setting up crates. Note: Provide --quick to just code generate.");
$.logStep(`Setting up swc_ecma_ast ${swcVersions.swcEcmaAst}...`);
await $.fs.emptyDir("swc_ecma_ast");
const astDir = root.join("swc_ecma_ast");
astDir.emptyDirSync();
await $`cargo clone --version`;
await $`cargo clone swc_ecma_ast@${swcVersions.swcEcmaAst}`;
// force using an old version of the regex crate that works in Rust 1.65
const cargoFile = astDir.join("Cargo.toml");
cargoFile.writeTextSync(
cargoFile.readTextSync()
+ "[dependencies.regex]\nversion = \"=1.5.5\"\n",
);
await $`cd swc_ecma_ast ; cargo rustdoc -- --output-format json -Z unstable-options`;
await $.fs.copy("swc_ecma_ast/target/doc/swc_ecma_ast.json", "swc_ecma_ast.json", { overwrite: true });
astDir.join("target/doc/swc_ecma_ast.json")
.copyFileSync(root.join("swc_ecma_ast.json"));

$.logStep(`Setting up swc_ecma_parser ${swcVersions.swcEcmaParser}...`);
await $.fs.emptyDir("swc_ecma_parser");
const parserDir = root.join("swc_ecma_parser");
parserDir.emptyDirSync();
await $`cargo clone swc_ecma_parser@${swcVersions.swcEcmaParser}`;
// generate these files to make cargo happy
await $.fs.ensureFile("swc_ecma_parser/benches/compare/main.rs");
await $.fs.ensureFile("swc_ecma_parser/benches/parser/main.rs");
await $.fs.ensureFile("swc_ecma_parser/benches/lexer/main.rs");
parserDir.join("benches/compare/main.rs").ensureFileSync();
parserDir.join("benches/parser/main.rs").ensureFileSync();
parserDir.join("benches/lexer/main.rs").ensureFileSync();
await $`cd swc_ecma_parser ; cargo rustdoc -- --output-format json -Z unstable-options`;
await $.fs.copy("swc_ecma_parser/target/doc/swc_ecma_parser.json", "swc_ecma_parser.json", { overwrite: true });
parserDir.join("target/doc/swc_ecma_parser.json")
.copyFileSync(root.join("swc_ecma_parser.json"));
}

$.logStep("Generating", "code...");
Expand Down

0 comments on commit e0eb3f2

Please sign in to comment.