96 releases (43 breaking)

1.0.1 Jan 8, 2024
0.44.0 Nov 21, 2024
0.41.2 Jul 31, 2024
0.34.2 Mar 6, 2024
0.5.0 Oct 29, 2021

#66 in Parser implementations

Download history 9199/week @ 2024-08-13 13867/week @ 2024-08-20 16480/week @ 2024-08-27 14231/week @ 2024-09-03 13404/week @ 2024-09-10 12439/week @ 2024-09-17 15358/week @ 2024-09-24 20359/week @ 2024-10-01 9491/week @ 2024-10-08 18362/week @ 2024-10-15 12874/week @ 2024-10-22 15925/week @ 2024-10-29 6377/week @ 2024-11-05 35852/week @ 2024-11-12 27777/week @ 2024-11-19 10834/week @ 2024-11-26

82,660 downloads per month
Used in 75 crates (45 directly)

MIT license

390KB
11K SLoC

deno_ast

Discord Chat

Source text parsing, lexing, and AST related functionality for Deno.

use deno_ast::parse_module;
use deno_ast::MediaType;
use deno_ast::ParseParams;
use deno_ast::SourceTextInfo;

let source_text = "class MyClass {}";
let text_info = SourceTextInfo::new(source_text.into());
let parsed_source = parse_module(ParseParams {
  specifier: deno_ast::ModuleSpecifier::parse("file:///my_file.ts").unwrap(),
  media_type: MediaType::TypeScript,
  text_info,
  capture_tokens: true,
  maybe_syntax: None,
  scope_analysis: false,
}).expect("should parse");

// returns the comments
parsed_source.comments();
// returns the tokens if captured
parsed_source.tokens();
// returns the module (AST)
parsed_source.module();
// returns the `SourceTextInfo`
parsed_source.text_info();

swc upgrades

We upgrade swc about once a month. Upgrading swc is a very involved process that often requires many changes in downstream Deno crates. We also test the new version of swc in all downstream crates before merging a PR into deno_ast that updates swc.

Please do not open a PR for upgrading swc unless you have stated you are going to work on it in the issue tracker and have run the tests on all downstream crates.

To upgrade swc:

  1. Checkout the following repositories in sibling directories to this repository (ex. /home/david/dev/deno_graph, /home/david/dev/deno_ast):
  2. Ensure they all have upstream remotes set for the urls specified above. For example, your deno_graph repo should have git remote add upstream https://github.com/denoland/deno_graph.
  3. Run ./scripts/update_swc_deps.ts
  4. Run ./scripts/01_setup.ts
  5. Run ./scripts/02_build.ts and fix any build errors.
  6. Run ./scripts/03_test.ts and fix any failing tests.
    • At this point, all the tests should be passing in all the repositories.
  7. Open a PR for upgrading deno_ast.
  8. Merge the PR and publish a new version of deno_ast using the release workflow.
  9. At this point, bump the version of deno_ast and open PRs for deno_graph, deno_lint, and dprint-plugin-typescript (note: ./scripts/04_confirm.ts might be helpful to automate some of this. Read its source code to understand it so that you can deal with any problems that may arise).
  10. Merge the PR deno_graph and publish using its release workflow.
  11. Open PRs to deno_emit, deno_doc, and eszip.
  12. Merge those PRs and do releases. Also merge and release deno_lint and dprint-plugin-typescript (Bartek and David have access to publish dprint-plugin-typescript).
  13. Open a PR to Deno with the versions bumped and merge the PR.

Dependencies

~9–20MB
~310K SLoC