@@ -5,7 +5,10 @@ use std::rc::Rc;
55use std:: sync:: Arc ;
66
77use async_trait:: async_trait;
8+ use deno_core:: FromV8 ;
89use deno_core:: OpState ;
10+ use deno_core:: ToV8 ;
11+ use deno_core:: convert:: Uint8Array ;
912use deno_core:: error:: AnyError ;
1013use deno_core:: op2;
1114use deno_error:: JsErrorBox ;
@@ -53,38 +56,31 @@ pub trait BundleProvider: Send + Sync {
5356 ) -> Result < BuildResponse , AnyError > ;
5457}
5558
56- #[ derive( Clone , Debug , Eq , PartialEq , Default , serde:: Deserialize ) ]
57- #[ serde( rename_all = "camelCase" ) ]
59+ #[ derive( Clone , Debug , Eq , PartialEq , Default , FromV8 ) ]
5860pub struct BundleOptions {
5961 pub entrypoints : Vec < String > ,
60- #[ serde( default ) ]
6162 pub output_path : Option < String > ,
62- #[ serde( default ) ]
6363 pub output_dir : Option < String > ,
64- #[ serde ( default ) ]
64+ #[ from_v8 ( default ) ]
6565 pub external : Vec < String > ,
66- #[ serde ( default ) ]
66+ #[ from_v8 ( serde , default ) ]
6767 pub format : BundleFormat ,
68- #[ serde ( default ) ]
68+ #[ from_v8 ( default ) ]
6969 pub minify : bool ,
70- #[ serde ( default ) ]
70+ #[ from_v8 ( default ) ]
7171 pub code_splitting : bool ,
72- #[ serde ( default = "tru" ) ]
72+ #[ from_v8 ( default = true ) ]
7373 pub inline_imports : bool ,
74- #[ serde ( default ) ]
74+ #[ from_v8 ( serde , default ) ]
7575 pub packages : PackageHandling ,
76- #[ serde ( default ) ]
76+ #[ from_v8 ( serde ) ]
7777 pub sourcemap : Option < SourceMapType > ,
78- #[ serde ( default ) ]
78+ #[ from_v8 ( serde , default ) ]
7979 pub platform : BundlePlatform ,
80- #[ serde ( default = "tru" ) ]
80+ #[ from_v8 ( default = true ) ]
8181 pub write : bool ,
8282}
8383
84- fn tru ( ) -> bool {
85- true
86- }
87-
8884#[ derive( Clone , Debug , Eq , PartialEq , Copy , Default , serde:: Deserialize ) ]
8985#[ serde( rename_all = "camelCase" ) ]
9086pub enum BundlePlatform {
@@ -147,16 +143,14 @@ impl std::fmt::Display for PackageHandling {
147143 }
148144 }
149145}
150- #[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize ) ]
151- #[ serde( rename_all = "camelCase" ) ]
146+ #[ derive( Debug , Clone , FromV8 , ToV8 ) ]
152147pub struct Message {
153148 pub text : String ,
154149 pub location : Option < Location > ,
155150 pub notes : Vec < Note > ,
156151}
157152
158- #[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize ) ]
159- #[ serde( rename_all = "camelCase" ) ]
153+ #[ derive( Debug , Clone , FromV8 , ToV8 ) ]
160154pub struct PartialMessage {
161155 pub id : Option < String > ,
162156 pub plugin_name : Option < String > ,
@@ -166,28 +160,24 @@ pub struct PartialMessage {
166160 pub detail : Option < u32 > ,
167161}
168162
169- #[ derive( Debug , Clone , serde:: Serialize ) ]
170- #[ serde( rename_all = "camelCase" ) ]
163+ #[ derive( Debug , Clone , ToV8 ) ]
171164pub struct BuildOutputFile {
172165 pub path : String ,
173- pub contents : Option < Vec < u8 > > ,
166+ pub contents : Option < Uint8Array > ,
174167 pub hash : String ,
175168}
176- #[ derive( Debug , Clone , serde:: Serialize ) ]
177- #[ serde( rename_all = "camelCase" ) ]
169+ #[ derive( Debug , Clone , ToV8 ) ]
178170pub struct BuildResponse {
179171 pub errors : Vec < Message > ,
180172 pub warnings : Vec < Message > ,
181173 pub output_files : Option < Vec < BuildOutputFile > > ,
182174}
183- #[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize ) ]
184- #[ serde( rename_all = "camelCase" ) ]
175+ #[ derive( Debug , Clone , FromV8 , ToV8 ) ]
185176pub struct Note {
186177 pub text : String ,
187178 pub location : Option < Location > ,
188179}
189- #[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize ) ]
190- #[ serde( rename_all = "camelCase" ) ]
180+ #[ derive( Debug , Clone , FromV8 , ToV8 ) ]
191181pub struct Location {
192182 pub file : String ,
193183 pub namespace : Option < String > ,
@@ -222,11 +212,10 @@ pub struct OnLoadOptions {
222212 pub namespace : Option < String > ,
223213}
224214
225- #[ op2( async ) ]
226- #[ serde]
215+ #[ op2]
227216pub async fn op_bundle (
228217 state : Rc < RefCell < OpState > > ,
229- #[ serde ] options : BundleOptions ,
218+ #[ scoped ] options : BundleOptions ,
230219) -> Result < BuildResponse , JsErrorBox > {
231220 // eprintln!("op_bundle: {:?}", options);
232221 let provider = {
0 commit comments