File tree Expand file tree Collapse file tree 6 files changed +14
-0
lines changed Expand file tree Collapse file tree 6 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -37,4 +37,5 @@ pub struct Flags {
3737 pub scramitize : bool ,
3838 pub do_sourcemaps : bool ,
3939 pub strict_rewrites : bool ,
40+ pub destructure_rewrites : bool ,
4041}
Original file line number Diff line number Diff line change @@ -414,6 +414,10 @@ where
414414 }
415415
416416 fn visit_binding_pattern ( & mut self , it : & BindingPattern < ' data > ) {
417+ if !self . flags . destructure_rewrites {
418+ return ;
419+ }
420+
417421 match & it. kind {
418422 BindingPatternKind :: BindingIdentifier ( p) => {
419423 // let a = 0;
@@ -498,6 +502,10 @@ where
498502 walk:: walk_expression ( self , & s. expression ) ;
499503 }
500504 AssignmentTarget :: ObjectAssignmentTarget ( o) => {
505+ if !self . flags . destructure_rewrites {
506+ return ;
507+ }
508+
501509 let mut restids: Vec < Atom < ' data > > = Vec :: new ( ) ;
502510 self . recurse_object_assignment_target ( o, & mut restids) ;
503511
Original file line number Diff line number Diff line change @@ -57,6 +57,8 @@ pub struct RewriterOptions {
5757 scramitize : bool ,
5858 #[ clap( long, default_value_t = false ) ]
5959 strict_rewrites : bool ,
60+ #[ clap( long, default_value_t = false ) ]
61+ destructure_rewrites : bool ,
6062}
6163
6264impl Default for RewriterOptions {
Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ impl NativeRewriter {
9090 do_sourcemaps : cfg. do_sourcemaps ,
9191 scramitize : cfg. scramitize ,
9292 strict_rewrites : cfg. strict_rewrites ,
93+ destructure_rewrites : cfg. destructure_rewrites ,
9394 } ,
9495 )
9596 . context ( "failed to rewrite file" )
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ export class ScramjetController {
4343 cleanErrors : false ,
4444 scramitize : false ,
4545 sourcemaps : true ,
46+ destructureRewrites : false ,
4647 } ,
4748 siteFlags : { } ,
4849 codec : {
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ export type ScramjetFlags = {
1313 cleanErrors : boolean ;
1414 scramitize : boolean ;
1515 sourcemaps : boolean ;
16+ destructureRewrites : boolean ;
1617} ;
1718
1819export interface ScramjetConfig {
You can’t perform that action at this time.
0 commit comments