From afe2d3bda4b15438c5d3781cb878d2acdf43a318 Mon Sep 17 00:00:00 2001 From: IWANABETHATGUY Date: Sun, 24 Sep 2023 11:35:16 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20remove=20temp=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ' | 99 --------------------------------------------------------------- 1 file changed, 99 deletions(-) delete mode 100644 ' diff --git a/' b/' deleted file mode 100644 index 5702291e7b6..00000000000 --- a/' +++ /dev/null @@ -1,99 +0,0 @@ -use rspack_core::{ - get_dependency_used_by_exports_condition, module_id, Dependency, DependencyCategory, - DependencyCondition, DependencyId, DependencyTemplate, DependencyType, ErrorSpan, - ModuleDependency, RuntimeGlobals, TemplateContext, TemplateReplaceSource, UsedByExports, -}; -use swc_core::ecma::atoms::JsWord; - -#[derive(Debug, Clone)] -pub struct URLDependency { - start: u32, - end: u32, - id: DependencyId, - request: JsWord, - span: Option, - used_by_exports: Option, -} - -impl URLDependency { - pub fn new(start: u32, end: u32, request: JsWord, span: Option) -> Self { - Self { - start, - end, - id: DependencyId::new(), - request, - span, - used_by_exports: None, - } - } -} - -impl Dependency for URLDependency { - fn id(&self) -> &DependencyId { - &self.id - } - - fn category(&self) -> &DependencyCategory { - &DependencyCategory::Url - } - - fn dependency_type(&self) -> &DependencyType { - &DependencyType::NewUrl - } -} - -impl ModuleDependency for URLDependency { - fn request(&self) -> &str { - &self.request - } - - fn user_request(&self) -> &str { - &self.request - } - - fn span(&self) -> Option<&ErrorSpan> { - self.span.as_ref() - } - - fn set_request(&mut self, request: String) { - self.request = request.into(); - } - - fn get_condition(&self) -> Option { - get_dependency_used_by_exports_condition(self.id, self.used_by_exports.as_ref()) - } - - fn dependency_debug_name(&self) -> &'static str { - "URLDependency" - } -} - -impl DependencyTemplate for URLDependency { - fn apply( - &self, - source: &mut TemplateReplaceSource, - code_generatable_context: &mut TemplateContext, - ) { - let TemplateContext { - compilation, - runtime_requirements, - .. - } = code_generatable_context; - - runtime_requirements.insert(RuntimeGlobals::BASE_URI); - runtime_requirements.insert(RuntimeGlobals::REQUIRE); - - source.replace( - self.start, - self.end, - format!( - "/* asset import */{}({}), {}", - RuntimeGlobals::REQUIRE, - module_id(compilation, &self.id, &self.request, false), - RuntimeGlobals::BASE_URI - ) - .as_str(), - None, - ); - } -}