nuke typescript again

This commit is contained in:
Toshit Chawda 2024-12-17 15:29:58 -08:00
parent 7b881c0013
commit e366d4b029
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
3 changed files with 52 additions and 9 deletions

View file

@ -386,7 +386,8 @@ impl JsChanges {
macro_rules! tryget { macro_rules! tryget {
($range:expr) => { ($range:expr) => {
js.get($range).ok_or_else(|| RewriterError::Oob($range))? js.get($range)
.ok_or_else(|| RewriterError::Oob(($range).start, ($range).end))?
}; };
} }

View file

@ -1,5 +1,3 @@
use std::ops::Range;
use cfg::Config; use cfg::Config;
use changes::{JsChangeResult, JsChanges}; use changes::{JsChangeResult, JsChanges};
use oxc::{ use oxc::{
@ -18,10 +16,10 @@ mod visitor;
#[derive(Error, Debug)] #[derive(Error, Debug)]
pub enum RewriterError { pub enum RewriterError {
#[error("oxc panicked in parser: {0:?}")] #[error("oxc panicked in parser: {0}")]
OxcPanicked(Vec<OxcDiagnostic>), OxcPanicked(String),
#[error("out of bounds while applying range: {0:?})")] #[error("out of bounds while applying range: {0}..{1})")]
Oob(Range<usize>), Oob(usize, usize),
} }
#[derive(Debug)] #[derive(Debug)]
@ -49,7 +47,12 @@ where
.parse(); .parse();
if ret.panicked { if ret.panicked {
return Err(RewriterError::OxcPanicked(ret.errors)); let mut errors = String::new();
for error in ret.errors {
errors.push_str(&format!("{}", error));
errors.push('\n');
}
return Err(RewriterError::OxcPanicked(errors));
} }
let mut visitor = Visitor { let mut visitor = Visitor {

View file

@ -29,7 +29,46 @@ sed -i 's/import.meta.url/""/g' out/wasm.js
cd ../../ cd ../../
wasm-snip rewriter/wasm/out/wasm_bg.wasm -o rewriter/wasm/out/wasm_snipped.wasm -p 'oxc_regular_expression::.*' wasm-snip rewriter/wasm/out/wasm_bg.wasm -o rewriter/wasm/out/wasm_snipped.wasm \
-p 'oxc_regular_expression::.*' \
'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_non_array_type' \
'oxc_parser::ts::statement::<impl oxc_parser::ParserImpl>::parse_declaration' \
'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_ts_import_type' \
'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_type_operator_or_higher' \
'oxc_parser::ts::statement::<impl oxc_parser::ParserImpl>::parse_ts_interface_declaration' \
'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_mapped_type' \
'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_index_signature_declaration' \
'oxc_parser::ts::statement::<impl oxc_parser::ParserImpl>::parse_ts_import_equals_declaration' \
'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_type_or_type_predicate' \
'oxc_parser::ts::statement::<impl oxc_parser::ParserImpl>::parse_ts_namespace_or_module_declaration_body' \
'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_ts_implements_clause' \
'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_intersection_type_or_higher' \
'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_ts_type_name' \
'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_literal_type_node' \
'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_asserts_type_predicate' \
'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_tuple_element_type' \
'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_type_arguments_of_type_reference' \
'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_ts_call_signature_member' \
'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::is_start_of_type' \
'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_this_type_predicate' \
'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_type_query' \
'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_type_reference' \
'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_type_operator' \
'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_type_literal' \
'oxc_parser::ts::statement::<impl oxc_parser::ParserImpl>::is_at_enum_declaration'
#
# these are confirmed to break oxc
# 'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_ts_type' \
# 'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_type_arguments_in_expression' \
# 'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_ts_type_parameters' \
# 'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_class_element_modifiers' \
# 'oxc_parser::ts::statement::<impl oxc_parser::ParserImpl>::eat_decorators' \
# 'oxc_parser::ts::statement::<impl oxc_parser::ParserImpl>::is_nth_at_modifier' \
# 'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::try_parse_type_arguments' \
# 'oxc_parser::ts::statement::<impl oxc_parser::ParserImpl>::is_at_ts_index_signature_member' \
# 'oxc_parser::ts::types::<impl oxc_parser::ParserImpl>::parse_ts_return_type_annotation' \
# 'oxc_parser::ts::statement::<impl oxc_parser::ParserImpl>::parse_ts_type_annotation' \
# shellcheck disable=SC2086 # shellcheck disable=SC2086
time wasm-opt $WASMOPTFLAGS --converge -tnh -O4 --vacuum --dce --enable-threads --enable-bulk-memory --enable-simd rewriter/wasm/out/wasm_snipped.wasm -o rewriter/wasm/out/optimized.wasm time wasm-opt $WASMOPTFLAGS --converge -tnh -O4 --vacuum --dce --enable-threads --enable-bulk-memory --enable-simd rewriter/wasm/out/wasm_snipped.wasm -o rewriter/wasm/out/optimized.wasm