@@ -9,24 +9,24 @@ use path_absolutize::Absolutize;
9
9
use qwik_core:: { transform_fs, EmitMode , EntryStrategy , MinifyMode , TransformFsOptions } ;
10
10
11
11
struct OptimizerInput {
12
- glob : Option < String > ,
13
- manifest : Option < String > ,
14
- core_module : Option < String > ,
15
- scope : Option < String > ,
16
- src : PathBuf ,
17
- dest : PathBuf ,
18
- mode : EmitMode ,
19
- strategy : EntryStrategy ,
20
- transpile_ts : bool ,
21
- transpile_jsx : bool ,
22
- preserve_filenames : bool ,
23
- minify : MinifyMode ,
24
- sourcemaps : bool ,
25
- explicit_extensions : bool ,
12
+ glob : Option < String > ,
13
+ manifest : Option < String > ,
14
+ core_module : Option < String > ,
15
+ scope : Option < String > ,
16
+ src : PathBuf ,
17
+ dest : PathBuf ,
18
+ mode : EmitMode ,
19
+ strategy : EntryStrategy ,
20
+ transpile_ts : bool ,
21
+ transpile_jsx : bool ,
22
+ preserve_filenames : bool ,
23
+ minify : MinifyMode ,
24
+ sourcemaps : bool ,
25
+ explicit_extensions : bool ,
26
26
}
27
27
28
28
fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
29
- let matches = Command :: new ( "qwik" )
29
+ let matches = Command :: new ( "qwik" )
30
30
. version ( "1.0" )
31
31
. arg_required_else_help ( true )
32
32
. subcommand_required ( true )
@@ -85,85 +85,85 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
85
85
)
86
86
. get_matches ( ) ;
87
87
88
- // You can check for the existence of subcommands, and if found use their
89
- // matches just as you would the top level app
90
- if let Some ( matches) = matches. subcommand_matches ( "optimize" ) {
91
- // "$ myapp test" was run
92
- let strategy = match matches. value_of ( "strategy" ) {
93
- Some ( "inline" ) => EntryStrategy :: Inline ,
94
- Some ( "hook" ) => EntryStrategy :: Hook ,
95
- Some ( "single" ) => EntryStrategy :: Single ,
96
- Some ( "component" ) => EntryStrategy :: Component ,
97
- Some ( "smart" ) | None => EntryStrategy :: Smart ,
98
- _ => panic ! ( "Invalid strategy option" ) ,
99
- } ;
88
+ // You can check for the existence of subcommands, and if found use their
89
+ // matches just as you would the top level app
90
+ if let Some ( matches) = matches. subcommand_matches ( "optimize" ) {
91
+ // "$ myapp test" was run
92
+ let strategy = match matches. value_of ( "strategy" ) {
93
+ Some ( "inline" ) => EntryStrategy :: Inline ,
94
+ Some ( "hook" ) => EntryStrategy :: Hook ,
95
+ Some ( "single" ) => EntryStrategy :: Single ,
96
+ Some ( "component" ) => EntryStrategy :: Component ,
97
+ Some ( "smart" ) | None => EntryStrategy :: Smart ,
98
+ _ => panic ! ( "Invalid strategy option" ) ,
99
+ } ;
100
100
101
- let minify = match matches. value_of ( "minify" ) {
102
- Some ( "none" ) => MinifyMode :: None ,
103
- Some ( "simplify" ) | None => MinifyMode :: Simplify ,
104
- _ => panic ! ( "Invalid minify option" ) ,
105
- } ;
101
+ let minify = match matches. value_of ( "minify" ) {
102
+ Some ( "none" ) => MinifyMode :: None ,
103
+ Some ( "simplify" ) | None => MinifyMode :: Simplify ,
104
+ _ => panic ! ( "Invalid minify option" ) ,
105
+ } ;
106
106
107
- let mode = match matches. value_of ( "mode" ) {
108
- Some ( "dev" ) => EmitMode :: Dev ,
109
- Some ( "prod" ) => EmitMode :: Prod ,
110
- Some ( "lib" ) | None => EmitMode :: Lib ,
111
- _ => panic ! ( "Invalid mode option" ) ,
112
- } ;
113
- optimize ( OptimizerInput {
114
- src : matches. value_of_t_or_exit ( "src" ) ,
115
- dest : matches. value_of_t_or_exit ( "dest" ) ,
116
- manifest : matches. value_of ( "manifest" ) . map ( |s| s. into ( ) ) ,
117
- core_module : matches. value_of ( "core_module" ) . map ( |s| s. into ( ) ) ,
118
- scope : matches. value_of ( "scope" ) . map ( |s| s. into ( ) ) ,
119
- mode,
120
- glob : None ,
121
- strategy,
122
- minify,
123
- explicit_extensions : matches. is_present ( "extensions" ) ,
124
- transpile_jsx : !matches. is_present ( "no-jsx" ) ,
125
- transpile_ts : !matches. is_present ( "no-ts" ) ,
126
- preserve_filenames : matches. is_present ( "preserve-filenames" ) ,
127
- sourcemaps : matches. is_present ( "sourcemaps" ) ,
128
- } ) ?;
129
- }
130
- Ok ( ( ) )
107
+ let mode = match matches. value_of ( "mode" ) {
108
+ Some ( "dev" ) => EmitMode :: Dev ,
109
+ Some ( "prod" ) => EmitMode :: Prod ,
110
+ Some ( "lib" ) | None => EmitMode :: Lib ,
111
+ _ => panic ! ( "Invalid mode option" ) ,
112
+ } ;
113
+ optimize ( OptimizerInput {
114
+ src : matches. value_of_t_or_exit ( "src" ) ,
115
+ dest : matches. value_of_t_or_exit ( "dest" ) ,
116
+ manifest : matches. value_of ( "manifest" ) . map ( |s| s. into ( ) ) ,
117
+ core_module : matches. value_of ( "core_module" ) . map ( |s| s. into ( ) ) ,
118
+ scope : matches. value_of ( "scope" ) . map ( |s| s. into ( ) ) ,
119
+ mode,
120
+ glob : None ,
121
+ strategy,
122
+ minify,
123
+ explicit_extensions : matches. is_present ( "extensions" ) ,
124
+ transpile_jsx : !matches. is_present ( "no-jsx" ) ,
125
+ transpile_ts : !matches. is_present ( "no-ts" ) ,
126
+ preserve_filenames : matches. is_present ( "preserve-filenames" ) ,
127
+ sourcemaps : matches. is_present ( "sourcemaps" ) ,
128
+ } ) ?;
129
+ }
130
+ Ok ( ( ) )
131
131
}
132
132
133
133
fn optimize (
134
- optimizer_input : OptimizerInput ,
134
+ optimizer_input : OptimizerInput ,
135
135
) -> Result < qwik_core:: TransformOutput , Box < dyn std:: error:: Error > > {
136
- let current_dir = std:: env:: current_dir ( ) ?;
137
- let src_dir = current_dir. join ( optimizer_input. src ) . canonicalize ( ) ?;
136
+ let current_dir = std:: env:: current_dir ( ) ?;
137
+ let src_dir = current_dir. join ( optimizer_input. src ) . canonicalize ( ) ?;
138
138
139
- let result = transform_fs ( TransformFsOptions {
140
- src_dir : src_dir. to_string_lossy ( ) . to_string ( ) ,
141
- vendor_roots : vec ! [ ] ,
142
- glob : optimizer_input. glob ,
143
- source_maps : optimizer_input. sourcemaps ,
144
- minify : optimizer_input. minify ,
145
- transpile_jsx : optimizer_input. transpile_jsx ,
146
- transpile_ts : optimizer_input. transpile_ts ,
147
- preserve_filenames : optimizer_input. preserve_filenames ,
148
- entry_strategy : optimizer_input. strategy ,
149
- explicit_extensions : optimizer_input. explicit_extensions ,
150
- core_module : optimizer_input. core_module ,
151
- root_dir : None ,
139
+ let result = transform_fs ( TransformFsOptions {
140
+ src_dir : src_dir. to_string_lossy ( ) . to_string ( ) ,
141
+ vendor_roots : vec ! [ ] ,
142
+ glob : optimizer_input. glob ,
143
+ source_maps : optimizer_input. sourcemaps ,
144
+ minify : optimizer_input. minify ,
145
+ transpile_jsx : optimizer_input. transpile_jsx ,
146
+ transpile_ts : optimizer_input. transpile_ts ,
147
+ preserve_filenames : optimizer_input. preserve_filenames ,
148
+ entry_strategy : optimizer_input. strategy ,
149
+ explicit_extensions : optimizer_input. explicit_extensions ,
150
+ core_module : optimizer_input. core_module ,
151
+ root_dir : None ,
152
152
153
- mode : optimizer_input. mode ,
154
- scope : optimizer_input. scope ,
153
+ mode : optimizer_input. mode ,
154
+ scope : optimizer_input. scope ,
155
155
156
- manual_chunks : None ,
157
- strip_exports : None ,
158
- strip_ctx_name : None ,
159
- strip_event_handlers : false ,
160
- reg_ctx_name : None ,
161
- is_server : None ,
162
- } ) ?;
156
+ manual_chunks : None ,
157
+ strip_exports : None ,
158
+ strip_ctx_name : None ,
159
+ strip_event_handlers : false ,
160
+ reg_ctx_name : None ,
161
+ is_server : None ,
162
+ } ) ?;
163
163
164
- result. write_to_fs (
165
- & current_dir. join ( optimizer_input. dest ) . absolutize ( ) ?,
166
- optimizer_input. manifest ,
167
- ) ?;
168
- Ok ( result)
164
+ result. write_to_fs (
165
+ & current_dir. join ( optimizer_input. dest ) . absolutize ( ) ?,
166
+ optimizer_input. manifest ,
167
+ ) ?;
168
+ Ok ( result)
169
169
}
0 commit comments