@@ -35,12 +35,12 @@ void GodotJSExportPlugin::export_raw_files(const PackedStringArray &p_paths, boo
3535
3636 if (!file_path.ends_with (" ." JSB_TYPESCRIPT_EXT))
3737 {
38- export_raw_file (file_path);
38+ export_raw_file (file_path, false );
3939 }
4040 else if (p_permit_typescript)
4141 {
4242 const String compiled_script_path = jsb::internal::PathUtil::convert_typescript_path (file_path);
43- export_raw_file (compiled_script_path);
43+ export_raw_file (compiled_script_path, true );
4444 }
4545 }
4646}
@@ -103,7 +103,7 @@ void GodotJSExportPlugin::_export_begin(const HashSet<String>& p_features, bool
103103 }
104104}
105105
106- bool GodotJSExportPlugin::export_raw_file (const String& p_path)
106+ bool GodotJSExportPlugin::export_raw_file (const String& p_path, bool p_remap )
107107{
108108 if (exported_paths_.has (p_path))
109109 {
@@ -116,14 +116,14 @@ bool GodotJSExportPlugin::export_raw_file(const String& p_path)
116116 return false ;
117117 }
118118 exported_paths_.insert (p_path);
119- add_file (p_path, content, false );
119+ add_file (p_path, content, p_remap );
120120 JSB_EXPORTER_LOG (Verbose, " include raw: %s" , p_path);
121121 return true ;
122122}
123123
124- bool GodotJSExportPlugin::export_module_files (const jsb::JavaScriptModule& p_module)
124+ bool GodotJSExportPlugin::export_module_files (const jsb::JavaScriptModule& p_module, bool p_remap )
125125{
126- if (!export_raw_file (p_module.source_info .source_filepath ))
126+ if (!export_raw_file (p_module.source_info .source_filepath , p_remap ))
127127 {
128128 JSB_EXPORTER_LOG (Error, " can't read JS source from %s, please ensure that 'tsc' has being executed properly." , p_module.source_info .source_filepath );
129129 return false ;
@@ -132,21 +132,21 @@ bool GodotJSExportPlugin::export_module_files(const jsb::JavaScriptModule& p_mod
132132 if (jsb::internal::Settings::is_packaging_with_source_map ())
133133 {
134134 const String source_map_path = p_module.source_info .source_filepath + " .map" ;
135- if (!export_raw_file (source_map_path))
135+ if (!export_raw_file (source_map_path, false ))
136136 {
137137 JSB_EXPORTER_LOG (Verbose, " can't read the sourcemap from %s, please ensure that 'tsc' has being executed properly." , source_map_path);
138138 }
139139 }
140140
141- if (!p_module.source_info .package_filepath .is_empty () && !export_raw_file (p_module.source_info .package_filepath ))
141+ if (!p_module.source_info .package_filepath .is_empty () && !export_raw_file (p_module.source_info .package_filepath , false ))
142142 {
143143 JSB_EXPORTER_LOG (Error, " can't read the package.json from %s" , p_module.source_info .package_filepath );
144144 return false ;
145145 }
146146 return true ;
147147}
148148
149- bool GodotJSExportPlugin::export_compiled_script (const String& p_path)
149+ bool GodotJSExportPlugin::export_compiled_script (const String& p_path, bool p_remap )
150150{
151151 static constexpr char kNodeModulesPrefix [] = u8" res://node_modules/" ;
152152
@@ -198,7 +198,7 @@ bool GodotJSExportPlugin::export_compiled_script(const String& p_path)
198198 const v8::Local<v8::Context> context = env_->get_context ();
199199 v8::Context::Scope context_scope (context);
200200
201- export_module_files (*module );
201+ export_module_files (*module , p_remap );
202202 jsb::Environment* environment = jsb::Environment::wrap (isolate);
203203 const v8::Local<v8::Object> module_obj = module ->module .Get (isolate);
204204 if (v8::Local<v8::Value> temp; module_obj->Get (context, jsb_name (environment, children)).ToLocal (&temp) && temp->IsArray ())
@@ -213,7 +213,7 @@ bool GodotJSExportPlugin::export_compiled_script(const String& p_path)
213213 if (child->Get (context, jsb_name (environment, filename)).ToLocal (&temp))
214214 {
215215 const String filename = jsb::impl::Helper::to_string (isolate, temp);
216- if (export_compiled_script (filename))
216+ if (export_compiled_script (filename, false ))
217217 {
218218 JSB_EXPORTER_LOG (Verbose, " export dependent source: %s" , filename);
219219 }
@@ -236,10 +236,9 @@ void GodotJSExportPlugin::_export_file(const String& p_path, const String& p_typ
236236 if (p_path.ends_with (" ." JSB_TYPESCRIPT_EXT))
237237 {
238238 const String compiled_script_path = jsb::internal::PathUtil::convert_typescript_path (p_path);
239- export_compiled_script (compiled_script_path);
239+ export_compiled_script (compiled_script_path, true );
240240
241241 // always skip the typescript source from packing
242- skip ();
243242 JSB_EXPORTER_LOG (Verbose, " export source: %s => %s" , p_path, compiled_script_path);
244243 }
245244 else
0 commit comments