Crates.io | deno_ast |
lib.rs | deno_ast |
version | 0.43.3 |
source | src |
created_at | 2021-09-02 20:44:04.550581 |
updated_at | 2024-10-31 17:18:02.847837 |
description | Source text parsing, lexing, and AST related functionality for Deno |
homepage | https://deno.land/ |
repository | https://github.com/denoland/deno_ast |
max_upload_size | |
id | 446177 |
size | 405,550 |
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();
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:
/home/david/dev/deno_graph
, /home/david/dev/deno_ast
):
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
../scripts/update_swc_deps.ts
./scripts/01_setup.ts
./scripts/02_build.ts
and fix any build errors../scripts/03_test.ts
and fix any failing tests.
./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).