diff --git a/.github/pr-labeler.yml b/.github/pr-labeler.yml index 03912b631e2..68f966524b0 100644 --- a/.github/pr-labeler.yml +++ b/.github/pr-labeler.yml @@ -6,3 +6,5 @@ - "/^perf/" "release: bug fix": - "/^fix/" +"release: document": + - "/^docs/" diff --git a/.github/release.yml b/.github/release.yml index 358a60c56aa..e8a3c0b811a 100644 --- a/.github/release.yml +++ b/.github/release.yml @@ -20,6 +20,9 @@ changelog: - title: Bug Fixes 🐞 labels: - "release: bug fix" + - title: Document Updates 📖 + labels: + - "release: document" - title: Other Changes labels: - "*" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3964200cde7..5e829333ae5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -316,7 +316,7 @@ jobs: owner: ${{ github.repository_owner }} repo: "rspack-ecosystem-benchmark" workflow_file_name: "bench_rspack_commit.yml" - github_token: ${{ secrets.RSPACK_BOT_ACCESS_TOKEN }} + github_token: ${{ secrets.RSPACK_ACCESS_TOKEN }} ref: "main" client_payload: '{"commit_sha":"${{ github.sha }}"}' @@ -333,7 +333,7 @@ jobs: owner: ${{ github.repository_owner }} repo: "rspack-ecosystem-ci" workflow_file_name: "ecosystem-ci-from-commit.yml" - github_token: ${{ secrets.ECOSYSTEM_CI_ACCESS_TOKEN }} + github_token: ${{ secrets.RSPACK_ACCESS_TOKEN }} ref: "main" client_payload: '{"commitSHA":"${{ github.sha }}","repo":"web-infra-dev/rspack","suite":"-","suiteRefType":"precoded","suiteRef":"precoded"}' diff --git a/.github/workflows/diff.yml b/.github/workflows/diff.yml.bak similarity index 98% rename from .github/workflows/diff.yml rename to .github/workflows/diff.yml.bak index ff135e318fb..f6c3922fe94 100644 --- a/.github/workflows/diff.yml +++ b/.github/workflows/diff.yml.bak @@ -61,7 +61,7 @@ jobs: - name: Upload Report shell: bash env: - API_TOKEN_GITHUB: ${{ secrets.RSPACK_REPORT_ACCESS_TOKEN }} + API_TOKEN_GITHUB: ${{ secrets.RSPACK_ACCESS_TOKEN }} run: | cache_dir="$HOME/.cache/diff_upload" clone_dir="$cache_dir/${{ github.run_id }}" diff --git a/.github/workflows/ecosystem-ci-trigger.yml b/.github/workflows/ecosystem-ci-trigger.yml index 59ed85abb4d..e2cc78d13c0 100644 --- a/.github/workflows/ecosystem-ci-trigger.yml +++ b/.github/workflows/ecosystem-ci-trigger.yml @@ -65,7 +65,7 @@ jobs: env: COMMENT: ${{ github.event.comment.body }} with: - github-token: ${{ secrets.ECOSYSTEM_CI_ACCESS_TOKEN }} + github-token: ${{ secrets.RSPACK_ACCESS_TOKEN }} result-encoding: string script: | const comment = process.env.COMMENT.trim() diff --git a/.github/workflows/github-issue-sync.yml b/.github/workflows/github-issue-sync.yml index f7ad3855d67..387e7607dfe 100644 --- a/.github/workflows/github-issue-sync.yml +++ b/.github/workflows/github-issue-sync.yml @@ -19,7 +19,7 @@ jobs: # This is a Personal Access Token and it needs to have the following permissions # - "read:org": used to read the project's board # - "write:org": used to assign issues to the project's board - PROJECT_TOKEN: ${{ secrets.PROJECT_TOKEN }} + PROJECT_TOKEN: ${{ secrets.RSPACK_ACCESS_TOKEN }} # The number of the project which the issues will be synced to # You can find this in https://github.com/orgs/@ORGANIZATION/projects/ project: 12 diff --git a/.github/workflows/release-canary.yml b/.github/workflows/release-canary.yml.bak similarity index 100% rename from .github/workflows/release-canary.yml rename to .github/workflows/release-canary.yml.bak diff --git a/.github/workflows/release-nightly.yml b/.github/workflows/release-nightly.yml index 9649e1b4e8c..18841feda91 100644 --- a/.github/workflows/release-nightly.yml +++ b/.github/workflows/release-nightly.yml @@ -94,7 +94,7 @@ jobs: steps: - uses: actions/github-script@v7 with: - github-token: ${{ secrets.ECOSYSTEM_CI_ACCESS_TOKEN }} + github-token: ${{ secrets.RSPACK_ACCESS_TOKEN }} script: | const result = await github.rest.actions.createWorkflowDispatch({ owner: context.repo.owner, diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml index 6fd63bd12df..be1573d8df3 100644 --- a/.github/workflows/reusable-build.yml +++ b/.github/workflows/reusable-build.yml @@ -299,6 +299,10 @@ jobs: echo "====================================" pnpm api-extractor:ci + - name: Documentation coverage check + if: ${{ inputs.target == 'x86_64-unknown-linux-gnu' && !inputs.skipable }} + run: pnpm doc-coverage + ### write the latest metric into branch gh-pages ### Note that, We can't merge this script, because this script only runs on main branch - name: Update main branch test compatibility metric diff --git a/.gitignore b/.gitignore index 31fd07b9991..b6d5152d390 100644 --- a/.gitignore +++ b/.gitignore @@ -111,7 +111,10 @@ out # Nuxt.js build / generate output .nuxt + +# Dist files dist +compiled webpack-dist # Gatsby files diff --git a/Cargo.lock b/Cargo.lock index 08415992a13..e9426da82ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -777,9 +777,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" [[package]] name = "debugid" @@ -3187,7 +3187,6 @@ dependencies = [ "rspack_util", "rustc-hash", "serde_json", - "sugar_path", "swc_core", "tracing", "urlencoding", @@ -3662,6 +3661,7 @@ dependencies = [ name = "rspack_util" version = "0.1.0" dependencies = [ + "bitflags 2.5.0", "concat-string", "dashmap", "indexmap 2.2.6", @@ -4018,9 +4018,9 @@ checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043" [[package]] name = "smol_str" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74212e6bbe9a4352329b2f68ba3130c15a3f26fe88ff22dbdc6cdd58fa85e99c" +checksum = "e6845563ada680337a52d43bb0b29f396f2d911616f6573012645b9e3d048a49" dependencies = [ "serde", ] diff --git a/crates/node_binding/package.json b/crates/node_binding/package.json index 31fdbb25670..5538d371179 100644 --- a/crates/node_binding/package.json +++ b/crates/node_binding/package.json @@ -1,6 +1,6 @@ { "name": "@rspack/binding", - "version": "0.6.3", + "version": "0.6.4", "license": "MIT", "description": "Node binding for rspack", "main": "binding.js", diff --git a/crates/rspack_binding_options/src/options/raw_builtins/mod.rs b/crates/rspack_binding_options/src/options/raw_builtins/mod.rs index 3a8ba6e5ae3..1b1ace1fb8a 100644 --- a/crates/rspack_binding_options/src/options/raw_builtins/mod.rs +++ b/crates/rspack_binding_options/src/options/raw_builtins/mod.rs @@ -355,6 +355,7 @@ impl BuiltinPlugin { plugins.push( SourceMapDevToolModuleOptionsPlugin::new(SourceMapDevToolModuleOptionsPluginOptions { module: options.module, + cheap: !options.columns, }) .boxed(), ); @@ -366,6 +367,7 @@ impl BuiltinPlugin { plugins.push( SourceMapDevToolModuleOptionsPlugin::new(SourceMapDevToolModuleOptionsPluginOptions { module: options.module, + cheap: !options.columns, }) .boxed(), ); diff --git a/crates/rspack_binding_values/src/compilation.rs b/crates/rspack_binding_values/src/compilation.rs index 94b7503db83..f8ae66a72fb 100644 --- a/crates/rspack_binding_values/src/compilation.rs +++ b/crates/rspack_binding_values/src/compilation.rs @@ -463,13 +463,6 @@ impl JsCompilation { original_module_context: Option, callback: JsFunction, ) -> Result<()> { - let options = self.0.options.clone(); - let plugin_driver = self.0.plugin_driver.clone(); - let resolver_factory = self.0.resolver_factory.clone(); - let loader_resolver_factory = self.0.loader_resolver_factory.clone(); - let cache = self.0.cache.clone(); - let dependency_factories = self.0.dependency_factories.clone(); - callbackify(env, callback, async { let module_executor = self .0 @@ -478,12 +471,6 @@ impl JsCompilation { .expect("should have module executor"); let result = module_executor .import_module( - options, - plugin_driver, - resolver_factory, - loader_resolver_factory, - cache, - dependency_factories, request, public_path, base_uri, diff --git a/crates/rspack_core/src/compiler/compilation.rs b/crates/rspack_core/src/compiler/compilation.rs index 29366ac2605..2cc3c6d47b5 100644 --- a/crates/rspack_core/src/compiler/compilation.rs +++ b/crates/rspack_core/src/compiler/compilation.rs @@ -609,6 +609,13 @@ impl Compilation { #[instrument(name = "compilation:make", skip_all)] pub async fn make(&mut self, mut params: Vec) -> Result<()> { + // run module_executor + if let Some(module_executor) = &mut self.module_executor { + let mut module_executor = std::mem::take(module_executor); + module_executor.hook_before_make(self, ¶ms).await; + self.module_executor = Some(module_executor); + } + let make_failed_module = MakeParam::ForceBuildModules(std::mem::take(&mut self.make_failed_module)); let make_failed_dependencies = @@ -1042,13 +1049,10 @@ impl Compilation { logger.time_end(start); // sync assets to compilation from module_executor - let assets = self - .module_executor - .as_mut() - .map(|module_executor| std::mem::take(&mut module_executor.assets)) - .unwrap_or_default(); - for (filename, asset) in assets { - self.emit_asset(filename, asset) + if let Some(module_executor) = &mut self.module_executor { + let mut module_executor = std::mem::take(module_executor); + module_executor.hook_before_process_assets(self).await; + self.module_executor = Some(module_executor); } let start = logger.time("process assets"); diff --git a/crates/rspack_core/src/compiler/hmr.rs b/crates/rspack_core/src/compiler/hmr.rs index d6eca817681..ad3868e00ec 100644 --- a/crates/rspack_core/src/compiler/hmr.rs +++ b/crates/rspack_core/src/compiler/hmr.rs @@ -9,7 +9,9 @@ use rspack_sources::Source; use rustc_hash::FxHashSet as HashSet; use super::MakeParam; -use crate::{fast_set, get_chunk_from_ukey, ChunkKind, Compilation, Compiler, RuntimeSpec}; +use crate::{ + fast_set, get_chunk_from_ukey, ChunkKind, Compilation, Compiler, ModuleExecutor, RuntimeSpec, +}; impl Compiler where @@ -73,8 +75,7 @@ where self.loader_resolver_factory.clone(), Some(records), self.cache.clone(), - // reuse module executor - std::mem::take(&mut self.compilation.module_executor), + Some(ModuleExecutor::default()), ); if let Some(state) = self.options.get_incremental_rebuild_make_state() { @@ -118,6 +119,9 @@ where new_compilation.code_splitting_cache = std::mem::take(&mut self.compilation.code_splitting_cache); + // reuse module executor + new_compilation.module_executor = std::mem::take(&mut self.compilation.module_executor); + new_compilation.has_module_import_export_change = false; } diff --git a/crates/rspack_core/src/compiler/make/mod.rs b/crates/rspack_core/src/compiler/make/mod.rs index fa0cc36356f..e59a90ecad9 100644 --- a/crates/rspack_core/src/compiler/make/mod.rs +++ b/crates/rspack_core/src/compiler/make/mod.rs @@ -1,5 +1,5 @@ mod cutout; -mod repair; +pub mod repair; use std::{hash::BuildHasherDefault, path::PathBuf}; @@ -19,16 +19,16 @@ use crate::{ #[derive(Debug, Default)] pub struct MakeArtifact { module_graph_partial: ModuleGraphPartial, - make_failed_dependencies: HashSet, - make_failed_module: HashSet, - diagnostics: Vec, + pub make_failed_dependencies: HashSet, + pub make_failed_module: HashSet, + pub diagnostics: Vec, entry_module_identifiers: IdentifierSet, optimize_analyze_result_map: IdentifierMap, - file_dependencies: IndexSet>, - context_dependencies: IndexSet>, - missing_dependencies: IndexSet>, - build_dependencies: IndexSet>, + pub file_dependencies: IndexSet>, + pub context_dependencies: IndexSet>, + pub missing_dependencies: IndexSet>, + pub build_dependencies: IndexSet>, has_module_graph_change: bool, } @@ -76,7 +76,7 @@ impl MakeArtifact { } } -#[derive(Debug)] +#[derive(Debug, Clone)] pub enum MakeParam { ModifiedFiles(HashSet), DeletedFiles(HashSet), @@ -99,10 +99,8 @@ pub async fn update_module_graph( let mut artifact = MakeArtifact::default(); compilation.swap_make_artifact(&mut artifact); artifact.move_data_from_compilation(compilation); - let mut cutout = Cutout::default(); - let build_dependencies = cutout.cutout_artifact(&mut artifact, params); - artifact = repair(compilation, artifact, build_dependencies)?; - cutout.fix_artifact(&mut artifact); + + artifact = update_module_graph_with_artifact(compilation, artifact, params).await?; // Avoid to introduce too much overhead, // until we find a better way to align with webpack hmr behavior @@ -149,3 +147,16 @@ pub async fn update_module_graph( compilation.swap_make_artifact(&mut artifact); Ok(()) } + +pub async fn update_module_graph_with_artifact( + compilation: &Compilation, + mut artifact: MakeArtifact, + params: Vec, +) -> Result { + let mut cutout = Cutout::default(); + let build_dependencies = cutout.cutout_artifact(&mut artifact, params); + artifact = repair(compilation, artifact, build_dependencies)?; + cutout.fix_artifact(&mut artifact); + + Ok(artifact) +} diff --git a/crates/rspack_core/src/compiler/make/repair/build.rs b/crates/rspack_core/src/compiler/make/repair/build.rs index af4a8658c4f..dc3f7ef84ec 100644 --- a/crates/rspack_core/src/compiler/make/repair/build.rs +++ b/crates/rspack_core/src/compiler/make/repair/build.rs @@ -55,7 +55,7 @@ impl Task for BuildTask { resolver_factory: resolver_factory.clone(), module: module.identifier(), module_context: module.as_normal_module().and_then(|m| m.get_context()), - module_source_map_kind: module.get_source_map_kind().clone(), + module_source_map_kind: *module.get_source_map_kind(), plugin_driver: plugin_driver.clone(), cache: cache.clone(), }, diff --git a/crates/rspack_core/src/compiler/make/repair/factorize.rs b/crates/rspack_core/src/compiler/make/repair/factorize.rs index fcbe67a6739..497fe759742 100644 --- a/crates/rspack_core/src/compiler/make/repair/factorize.rs +++ b/crates/rspack_core/src/compiler/make/repair/factorize.rs @@ -147,7 +147,7 @@ pub struct ExportsInfoRelated { } #[derive(Debug)] -struct FactorizeResultTask { +pub struct FactorizeResultTask { // pub dependency: DependencyId, pub original_module_identifier: Option, /// Result will be available if [crate::ModuleFactory::create] returns `Ok`. diff --git a/crates/rspack_core/src/compiler/make/repair/mod.rs b/crates/rspack_core/src/compiler/make/repair/mod.rs index e34aa16038f..369f60a3801 100644 --- a/crates/rspack_core/src/compiler/make/repair/mod.rs +++ b/crates/rspack_core/src/compiler/make/repair/mod.rs @@ -1,7 +1,7 @@ -mod add; -mod build; -mod factorize; -mod process_dependencies; +pub mod add; +pub mod build; +pub mod factorize; +pub mod process_dependencies; use std::{hash::BuildHasherDefault, path::PathBuf, sync::Arc}; @@ -21,14 +21,14 @@ use crate::{ NormalModuleSource, ResolverFactory, SharedPluginDriver, }; -struct MakeTaskContext { +pub struct MakeTaskContext { // compilation info - plugin_driver: SharedPluginDriver, - compiler_options: Arc, - resolver_factory: Arc, - loader_resolver_factory: Arc, - cache: Arc, - dependency_factories: HashMap>, + pub plugin_driver: SharedPluginDriver, + pub compiler_options: Arc, + pub resolver_factory: Arc, + pub loader_resolver_factory: Arc, + pub cache: Arc, + pub dependency_factories: HashMap>, // TODO move outof context logger: CompilationLogger, @@ -41,7 +41,7 @@ struct MakeTaskContext { /// Collecting all module that need to skip in tree-shaking ast modification phase // bailout_module_identifiers: IdentifierMap, // TODO change to artifact - module_graph_partial: ModuleGraphPartial, + pub module_graph_partial: ModuleGraphPartial, make_failed_dependencies: HashSet, make_failed_module: HashSet, @@ -56,7 +56,7 @@ struct MakeTaskContext { } impl MakeTaskContext { - fn new(compilation: &Compilation, artifact: MakeArtifact) -> Self { + pub fn new(compilation: &Compilation, artifact: MakeArtifact) -> Self { let logger = compilation.get_logger("rspack.Compilation"); let mut build_cache_counter = None; let mut factorize_cache_counter = None; @@ -97,7 +97,7 @@ impl MakeTaskContext { } } - fn transform_to_make_artifact(self) -> MakeArtifact { + pub fn transform_to_make_artifact(self) -> MakeArtifact { let Self { module_graph_partial, make_failed_dependencies, @@ -137,9 +137,43 @@ impl MakeTaskContext { } // TODO use module graph with make artifact - fn get_module_graph_mut(partial: &mut ModuleGraphPartial) -> ModuleGraph { + pub fn get_module_graph_mut(partial: &mut ModuleGraphPartial) -> ModuleGraph { ModuleGraph::new(vec![], Some(partial)) } + + // TODO remove it after incremental rebuild cover all stage + pub fn transform_to_temp_compilation(&mut self) -> Compilation { + let mut compilation = Compilation::new( + self.compiler_options.clone(), + self.plugin_driver.clone(), + self.resolver_factory.clone(), + self.loader_resolver_factory.clone(), + None, + self.cache.clone(), + None, + ); + compilation.dependency_factories = self.dependency_factories.clone(); + let mut make_artifact = MakeArtifact { + module_graph_partial: std::mem::take(&mut self.module_graph_partial), + file_dependencies: std::mem::take(&mut self.file_dependencies), + context_dependencies: std::mem::take(&mut self.context_dependencies), + missing_dependencies: std::mem::take(&mut self.missing_dependencies), + build_dependencies: std::mem::take(&mut self.build_dependencies), + ..Default::default() + }; + compilation.swap_make_artifact(&mut make_artifact); + compilation + } + + pub fn recovery_from_temp_compilation(&mut self, mut compilation: Compilation) { + let mut make_artifact = Default::default(); + compilation.swap_make_artifact(&mut make_artifact); + self.module_graph_partial = make_artifact.module_graph_partial; + self.file_dependencies = make_artifact.file_dependencies; + self.context_dependencies = make_artifact.context_dependencies; + self.missing_dependencies = make_artifact.missing_dependencies; + self.build_dependencies = make_artifact.build_dependencies; + } } pub fn repair( diff --git a/crates/rspack_core/src/compiler/module_executor/ctrl.rs b/crates/rspack_core/src/compiler/module_executor/ctrl.rs new file mode 100644 index 00000000000..f2d97e66b3e --- /dev/null +++ b/crates/rspack_core/src/compiler/module_executor/ctrl.rs @@ -0,0 +1,291 @@ +use std::collections::VecDeque; + +use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; +use tokio::sync::mpsc::{error::TryRecvError, UnboundedReceiver}; + +use super::{ + entry::{EntryParam, EntryTask}, + execute::ExecuteTask, +}; +use crate::{ + compiler::make::repair::MakeTaskContext, + utils::task_loop::{Task, TaskResult, TaskType}, + Dependency, DependencyId, ModuleIdentifier, +}; + +#[derive(Debug)] +struct UnfinishCounter { + is_building: bool, + unfinished_child_module_count: usize, +} + +impl UnfinishCounter { + fn new() -> Self { + UnfinishCounter { + is_building: true, + unfinished_child_module_count: 0, + } + } + + fn set_unfinished_child_module_count(&mut self, count: usize) { + self.is_building = false; + self.unfinished_child_module_count = count; + } + + fn minus_one(&mut self) { + if self.is_building || self.unfinished_child_module_count == 0 { + panic!("UnfinishDepCount Error") + } + self.unfinished_child_module_count -= 1; + } + + fn is_finished(&self) -> bool { + !self.is_building && self.unfinished_child_module_count == 0 + } +} + +// send event can only use in sync task +#[derive(Debug)] +pub enum Event { + StartBuild(ModuleIdentifier), + // origin_module_identifier and current dependency id and target_module_identifier + FinishDeps( + Option, + DependencyId, + Option, + ), + // current_module_identifier and sub dependency count + FinishModule(ModuleIdentifier, usize), + ExecuteModule(EntryParam, ExecuteTask), + Stop(), +} + +#[derive(Debug)] +pub struct CtrlTask { + pub event_receiver: UnboundedReceiver, + execute_task_map: HashMap, + running_module_map: HashMap, +} + +impl CtrlTask { + pub fn new(event_receiver: UnboundedReceiver) -> Self { + Self { + event_receiver, + execute_task_map: Default::default(), + running_module_map: Default::default(), + } + } +} + +#[async_trait::async_trait] +impl Task for CtrlTask { + fn get_task_type(&self) -> TaskType { + TaskType::Async + } + + async fn async_run(mut self: Box) -> TaskResult { + while let Some(event) = self.event_receiver.recv().await { + tracing::info!("CtrlTask async receive {:?}", event); + match event { + Event::StartBuild(module_identifier) => { + self + .running_module_map + .insert(module_identifier, UnfinishCounter::new()); + } + Event::FinishDeps(origin_module_identifier, dep_id, target_module_graph) => { + if let Some(target_module_graph) = target_module_graph { + if self.running_module_map.contains_key(&target_module_graph) + && Some(target_module_graph) != origin_module_identifier + { + continue; + } + } + + // target module finished + let Some(origin_module_identifier) = origin_module_identifier else { + // origin_module_identifier is none means entry dep + let execute_task = self + .execute_task_map + .remove(&dep_id) + .expect("should have execute task"); + return Ok(vec![Box::new(execute_task), self]); + }; + + let value = self + .running_module_map + .get_mut(&origin_module_identifier) + .expect("should have counter"); + value.minus_one(); + if value.is_finished() { + return Ok(vec![Box::new(FinishModuleTask { + ctrl_task: self, + module_identifier: origin_module_identifier, + })]); + } + } + Event::FinishModule(mid, size) => { + let value = self + .running_module_map + .get_mut(&mid) + .expect("should have counter"); + value.set_unfinished_child_module_count(size); + if value.is_finished() { + return Ok(vec![Box::new(FinishModuleTask { + ctrl_task: self, + module_identifier: mid, + })]); + } + } + Event::ExecuteModule(param, execute_task) => { + let dep_id = match ¶m { + EntryParam::DependencyId(id, _) => *id, + EntryParam::EntryDependency(dep) => *dep.id(), + }; + self.execute_task_map.insert(dep_id, execute_task); + return Ok(vec![Box::new(EntryTask { param }), self]); + } + Event::Stop() => { + return Ok(vec![]); + } + } + } + // if channel has been closed, finish this task + Ok(vec![]) + } +} + +#[derive(Debug)] +struct FinishModuleTask { + ctrl_task: Box, + module_identifier: ModuleIdentifier, +} + +impl Task for FinishModuleTask { + fn get_task_type(&self) -> TaskType { + TaskType::Sync + } + + fn sync_run(self: Box, context: &mut MakeTaskContext) -> TaskResult { + let Self { + mut ctrl_task, + module_identifier, + } = *self; + let mut res: Vec>> = vec![]; + let module_graph = MakeTaskContext::get_module_graph_mut(&mut context.module_graph_partial); + let mut queue = VecDeque::new(); + queue.push_back(module_identifier); + + // clean ctrl task events + loop { + let event = ctrl_task.event_receiver.try_recv(); + tracing::info!("CtrlTask sync receive {:?}", event); + let Ok(event) = event else { + if matches!(event, Err(TryRecvError::Empty)) { + break; + } else { + panic!("clean ctrl_task event failed"); + } + }; + + match event { + Event::StartBuild(module_identifier) => { + ctrl_task + .running_module_map + .insert(module_identifier, UnfinishCounter::new()); + } + Event::FinishDeps(origin_module_identifier, dep_id, target_module_graph) => { + if let Some(target_module_graph) = target_module_graph { + if ctrl_task + .running_module_map + .contains_key(&target_module_graph) + && Some(target_module_graph) != origin_module_identifier + { + continue; + } + } + + // target module finished + let Some(origin_module_identifier) = origin_module_identifier else { + // origin_module_identifier is none means entry dep + let execute_task = ctrl_task + .execute_task_map + .remove(&dep_id) + .expect("should have execute task"); + res.push(Box::new(execute_task)); + continue; + }; + + let value = ctrl_task + .running_module_map + .get_mut(&origin_module_identifier) + .expect("should have counter"); + value.minus_one(); + if value.is_finished() { + queue.push_back(origin_module_identifier); + } + } + Event::FinishModule(mid, size) => { + let value = ctrl_task + .running_module_map + .get_mut(&mid) + .expect("should have counter"); + value.set_unfinished_child_module_count(size); + if value.is_finished() { + queue.push_back(mid); + } + } + Event::ExecuteModule(param, execute_task) => { + let dep_id = match ¶m { + EntryParam::DependencyId(id, _) => *id, + EntryParam::EntryDependency(dep) => *dep.id(), + }; + ctrl_task.execute_task_map.insert(dep_id, execute_task); + res.push(Box::new(EntryTask { param })); + } + Event::Stop() => { + return Ok(vec![]); + } + } + } + + while let Some(module_identifier) = queue.pop_front() { + tracing::info!("finish build module {:?}", module_identifier); + ctrl_task.running_module_map.remove(&module_identifier); + + let mgm = module_graph + .module_graph_module_by_identifier(&module_identifier) + .expect("should have mgm"); + + let mut original_module_identifiers = HashSet::default(); + for connection_id in mgm.incoming_connections() { + let connection = module_graph + .connection_by_connection_id(connection_id) + .expect("should have connection"); + if let Some(original_module_identifier) = &connection.original_module_identifier { + original_module_identifiers.insert(*original_module_identifier); + } else { + // entry + let execute_task = ctrl_task + .execute_task_map + .remove(&connection.dependency_id) + .expect("should have execute task"); + res.push(Box::new(execute_task)); + } + } + + for id in original_module_identifiers { + let value = ctrl_task + .running_module_map + .get_mut(&id) + .expect("should have counter"); + value.minus_one(); + if value.is_finished() { + queue.push_back(id); + } + } + } + + res.push(ctrl_task); + Ok(res) + } +} diff --git a/crates/rspack_core/src/compiler/module_executor/entry.rs b/crates/rspack_core/src/compiler/module_executor/entry.rs new file mode 100644 index 00000000000..b3bc357d358 --- /dev/null +++ b/crates/rspack_core/src/compiler/module_executor/entry.rs @@ -0,0 +1,71 @@ +use tokio::sync::mpsc::UnboundedSender; + +use super::ctrl::Event; +use crate::{ + compiler::make::repair::{factorize::FactorizeTask, MakeTaskContext}, + utils::task_loop::{Task, TaskResult, TaskType}, + Dependency, DependencyId, EntryDependency, ModuleProfile, +}; + +#[derive(Debug)] +pub enum EntryParam { + DependencyId(DependencyId, UnboundedSender), + EntryDependency(Box), +} + +#[derive(Debug)] +pub struct EntryTask { + pub param: EntryParam, +} + +impl Task for EntryTask { + fn get_task_type(&self) -> TaskType { + TaskType::Sync + } + + fn sync_run(self: Box, context: &mut MakeTaskContext) -> TaskResult { + let Self { param } = *self; + let mut module_graph = MakeTaskContext::get_module_graph_mut(&mut context.module_graph_partial); + + match param { + EntryParam::DependencyId(dep_id, sender) => { + if let Some(module_identifier) = module_graph.module_identifier_by_dependency_id(&dep_id) { + sender + .send(Event::FinishDeps(None, dep_id, Some(*module_identifier))) + .expect("should success"); + } else { + // no module_identifier means the factorize task not run, do nothing + } + Ok(vec![]) + } + EntryParam::EntryDependency(dep) => { + let dep_id = *dep.id(); + module_graph.add_dependency(dep.clone()); + Ok(vec![Box::new(FactorizeTask { + module_factory: context + .dependency_factories + .get(dep.dependency_type()) + .expect("should have dependency_factories") + .clone(), + original_module_identifier: None, + original_module_source: None, + issuer: None, + original_module_context: None, + dependency: dep, + dependencies: vec![dep_id], + is_entry: true, + resolve_options: None, + resolver_factory: context.resolver_factory.clone(), + loader_resolver_factory: context.loader_resolver_factory.clone(), + options: context.compiler_options.clone(), + plugin_driver: context.plugin_driver.clone(), + cache: context.cache.clone(), + current_profile: context + .compiler_options + .profile + .then(Box::::default), + })]) + } + } + } +} diff --git a/crates/rspack_core/src/compiler/module_executor.rs b/crates/rspack_core/src/compiler/module_executor/execute.rs similarity index 69% rename from crates/rspack_core/src/compiler/module_executor.rs rename to crates/rspack_core/src/compiler/module_executor/execute.rs index 0990a54e098..7c46627f183 100644 --- a/crates/rspack_core/src/compiler/module_executor.rs +++ b/crates/rspack_core/src/compiler/module_executor/execute.rs @@ -1,20 +1,19 @@ -use std::sync::{atomic::AtomicU32, Arc}; -use std::{hash::BuildHasherDefault, iter::once}; +use std::{iter::once, sync::atomic::AtomicU32}; -use dashmap::DashMap; use rayon::prelude::*; use rspack_error::Result; -use rspack_identifier::{Identifiable, IdentifierSet}; -use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet, FxHasher}; +use rspack_identifier::IdentifierSet; +use rustc_hash::FxHashSet as HashSet; +use tokio::{runtime::Handle, sync::oneshot::Sender}; -use crate::cache::Cache; +// use tokio::sync::Sender use crate::{ + compiler::make::repair::MakeTaskContext, + utils::task_loop::{Task, TaskResult, TaskType}, Chunk, ChunkGraph, ChunkKind, CodeGenerationDataAssetInfo, CodeGenerationDataFilename, - CodeGenerationResult, Dependency, DependencyType, EntryDependency, EntryOptions, Entrypoint, - ModuleFactory, RuntimeSpec, SourceType, + CodeGenerationResult, CompilationAsset, CompilationAssets, DependencyId, EntryOptions, + Entrypoint, RuntimeSpec, SourceType, }; -use crate::{Compilation, CompilationAsset, MakeParam}; -use crate::{CompilerOptions, Context, ResolverFactory, SharedPluginDriver}; static EXECUTE_MODULE_ID: AtomicU32 = AtomicU32::new(0); pub type ExecuteModuleId = u32; @@ -29,65 +28,38 @@ pub struct ExecuteModuleResult { pub id: ExecuteModuleId, } -#[derive(Debug, Default)] -pub struct ModuleExecutor { - pub assets: DashMap, +#[derive(Debug)] +pub struct ExecuteTask { + pub entry_dep_id: DependencyId, + pub public_path: Option, + pub base_uri: Option, + pub result_sender: Sender<(Result, CompilationAssets)>, } -impl ModuleExecutor { - #[allow(clippy::too_many_arguments)] - pub async fn import_module( - &self, - options: Arc, - plugin_driver: SharedPluginDriver, - resolver_factory: Arc, - loader_resolver_factory: Arc, - cache: Arc, - dependency_factories: HashMap>, - - request: String, - public_path: Option, - base_uri: Option, - original_module_context: Option, - ) -> Result { - let mut compilation = Compilation::new( - options, - plugin_driver, - resolver_factory, - loader_resolver_factory, - None, - cache, - None, - ); - compilation.dependency_factories = dependency_factories; +impl Task for ExecuteTask { + fn get_task_type(&self) -> TaskType { + TaskType::Sync + } - let mut mg = compilation.get_module_graph_mut(); - let dep_id = { - let dep = EntryDependency::new( - request, - original_module_context.unwrap_or(Context::from("")), - ); - let dep_id = *dep.id(); - mg.add_dependency(Box::new(dep)); - dep_id - }; + fn sync_run(self: Box, context: &mut MakeTaskContext) -> TaskResult { + let Self { + entry_dep_id, + public_path, + base_uri, + result_sender, + } = *self; - compilation - .make(vec![MakeParam::new_force_build_dep_param(dep_id, None)]) - .await?; + let mut compilation = context.transform_to_temp_compilation(); let id = EXECUTE_MODULE_ID.fetch_add(1, std::sync::atomic::Ordering::Relaxed); let mg = compilation.get_module_graph_mut(); - let module = mg - .get_module_by_dependency_id(&dep_id) + let entry_module_identifier = mg + .get_module_by_dependency_id(&entry_dep_id) .expect("should have module") .identifier(); - let mut queue = vec![module]; - let mut modules: std::collections::HashSet< - rspack_identifier::Identifier, - BuildHasherDefault, - > = HashSet::default(); + let mut queue = vec![entry_module_identifier]; + let mut modules = HashSet::default(); while let Some(m) = queue.pop() { modules.insert(m); @@ -137,7 +109,11 @@ impl ModuleExecutor { let chunk = compilation.chunk_by_ukey.add(chunk); let chunk_ukey = chunk.ukey; - chunk_graph.connect_chunk_and_entry_module(chunk.ukey, module, entrypoint.ukey); + chunk_graph.connect_chunk_and_entry_module( + chunk.ukey, + entry_module_identifier, + entrypoint.ukey, + ); entrypoint.connect_chunk(chunk); entrypoint.set_runtime_chunk(chunk.ukey); entrypoint.set_entry_point_chunk(chunk.ukey); @@ -168,14 +144,16 @@ impl ModuleExecutor { compilation.code_generation_modules(&mut None, false, modules.par_iter().copied())?; - compilation - .process_runtime_requirements( - modules.clone(), - once(chunk_ukey), - once(chunk_ukey), - compilation.plugin_driver.clone(), - ) - .await?; + Handle::current().block_on(async { + compilation + .process_runtime_requirements( + modules.clone(), + once(chunk_ukey), + once(chunk_ukey), + compilation.plugin_driver.clone(), + ) + .await + })?; let runtime_modules = compilation .chunk_graph @@ -215,7 +193,12 @@ impl ModuleExecutor { .plugin_driver .compilation_hooks .execute_module - .call(&module, &runtime_modules, &codegen_results, &id); + .call( + &entry_module_identifier, + &runtime_modules, + &codegen_results, + &id, + ); let module_graph = compilation.get_module_graph(); let mut execute_result = match exports { @@ -265,18 +248,14 @@ impl ModuleExecutor { Err(e) => Err(e), }; + let assets = std::mem::take(compilation.assets_mut()); if let Ok(ref mut result) = execute_result { - let assets = std::mem::take(compilation.assets_mut()); - for (key, value) in assets { - result.assets.insert(key.clone()); - self.assets.insert(key, value); - } + result.assets = assets.keys().cloned().collect::>(); } - - for error in compilation.get_errors() { - error.render_report(true)?; - } - - execute_result + context.recovery_from_temp_compilation(compilation); + result_sender + .send((execute_result, assets)) + .expect("should send result success"); + Ok(vec![]) } } diff --git a/crates/rspack_core/src/compiler/module_executor/mod.rs b/crates/rspack_core/src/compiler/module_executor/mod.rs new file mode 100644 index 00000000000..28344df5cc2 --- /dev/null +++ b/crates/rspack_core/src/compiler/module_executor/mod.rs @@ -0,0 +1,178 @@ +mod ctrl; +mod entry; +mod execute; +mod overwrite; + +use dashmap::mapref::entry::Entry; +use dashmap::DashMap; +pub use execute::ExecuteModuleId; +use rspack_error::Result; +use tokio::sync::{ + mpsc::{unbounded_channel, UnboundedSender}, + oneshot, +}; + +use self::{ + ctrl::{CtrlTask, Event}, + entry::EntryParam, + execute::{ExecuteModuleResult, ExecuteTask}, + overwrite::OverwriteTask, +}; +use super::make::{repair::MakeTaskContext, update_module_graph_with_artifact, MakeArtifact}; +use crate::{ + task_loop::run_task_loop_with_event, Compilation, CompilationAsset, Context, Dependency, + DependencyId, EntryDependency, MakeParam, +}; + +#[derive(Debug, Default)] +pub struct ModuleExecutor { + request_dep_map: DashMap, + make_artifact: MakeArtifact, + + event_sender: Option>, + stop_receiver: Option>, + assets: DashMap, +} + +impl ModuleExecutor { + pub async fn hook_before_make( + &mut self, + compilation: &Compilation, + global_params: &Vec, + ) { + let mut make_artifact = std::mem::take(&mut self.make_artifact); + let mut params = vec![]; + for param in global_params { + if matches!(param, MakeParam::DeletedFiles(_)) { + params.push(param.clone()); + } + if matches!(param, MakeParam::ModifiedFiles(_)) { + params.push(param.clone()); + } + } + if !make_artifact.make_failed_dependencies.is_empty() { + let deps = std::mem::take(&mut make_artifact.make_failed_dependencies); + params.push(MakeParam::ForceBuildDeps(deps)); + } + if !make_artifact.make_failed_module.is_empty() { + let modules = std::mem::take(&mut make_artifact.make_failed_module); + params.push(MakeParam::ForceBuildModules(modules)); + } + + make_artifact = if let Ok(artifact) = + update_module_graph_with_artifact(compilation, make_artifact, params).await + { + artifact + } else { + MakeArtifact::default() + }; + + let mut ctx = MakeTaskContext::new(compilation, make_artifact); + let (event_sender, event_receiver) = unbounded_channel(); + let (stop_sender, stop_receiver) = oneshot::channel(); + self.event_sender = Some(event_sender.clone()); + self.stop_receiver = Some(stop_receiver); + + tokio::spawn(async move { + let _ = run_task_loop_with_event( + &mut ctx, + vec![Box::new(CtrlTask::new(event_receiver))], + |_, task| { + Box::new(OverwriteTask { + origin_task: task, + event_sender: event_sender.clone(), + }) + }, + ); + + stop_sender + .send(ctx.transform_to_make_artifact()) + .expect("should success"); + }); + } + + pub async fn hook_before_process_assets(&mut self, compilation: &mut Compilation) { + let sender = std::mem::take(&mut self.event_sender); + sender + .expect("should have sender") + .send(Event::Stop()) + .expect("should success"); + + let stop_receiver = std::mem::take(&mut self.stop_receiver); + if let Ok(make_artifact) = stop_receiver.expect("should have receiver").await { + self.make_artifact = make_artifact; + } else { + panic!("receive make artifact failed"); + } + + let assets = std::mem::take(&mut self.assets); + for (filename, asset) in assets { + compilation.emit_asset(filename, asset); + } + + let diagnostics = std::mem::take(&mut self.make_artifact.diagnostics); + compilation.push_batch_diagnostic(diagnostics); + + compilation + .file_dependencies + .extend(self.make_artifact.file_dependencies.iter().cloned()); + compilation + .context_dependencies + .extend(self.make_artifact.context_dependencies.iter().cloned()); + compilation + .missing_dependencies + .extend(self.make_artifact.missing_dependencies.iter().cloned()); + compilation + .build_dependencies + .extend(self.make_artifact.build_dependencies.iter().cloned()); + } + + #[allow(clippy::too_many_arguments)] + pub async fn import_module( + &self, + request: String, + public_path: Option, + base_uri: Option, + original_module_context: Option, + ) -> Result { + let sender = self + .event_sender + .as_ref() + .expect("should have event sender"); + let (param, dep_id) = match self.request_dep_map.entry(request.clone()) { + Entry::Vacant(v) => { + let dep = EntryDependency::new( + request.clone(), + original_module_context.unwrap_or(Context::from("")), + ); + let dep_id = *dep.id(); + v.insert(dep_id); + (EntryParam::EntryDependency(Box::new(dep)), dep_id) + } + Entry::Occupied(v) => { + let dep_id = *v.get(); + (EntryParam::DependencyId(dep_id, sender.clone()), dep_id) + } + }; + + let (tx, rx) = oneshot::channel(); + sender + .send(Event::ExecuteModule( + param, + ExecuteTask { + entry_dep_id: dep_id, + public_path, + base_uri, + result_sender: tx, + }, + )) + .expect("should success"); + let (execute_result, assets) = rx.await.expect("should receiver success"); + + for (key, value) in assets { + self.assets.insert(key, value); + } + + execute_result + } +} diff --git a/crates/rspack_core/src/compiler/module_executor/overwrite.rs b/crates/rspack_core/src/compiler/module_executor/overwrite.rs new file mode 100644 index 00000000000..14bb424ac45 --- /dev/null +++ b/crates/rspack_core/src/compiler/module_executor/overwrite.rs @@ -0,0 +1,92 @@ +use tokio::sync::mpsc::UnboundedSender; + +use super::ctrl::Event; +use crate::{ + compiler::make::repair::{ + add::AddTask, factorize::FactorizeResultTask, process_dependencies::ProcessDependenciesTask, + MakeTaskContext, + }, + utils::task_loop::{Task, TaskResult, TaskType}, +}; + +pub struct OverwriteTask { + pub origin_task: Box>, + pub event_sender: UnboundedSender, +} + +#[async_trait::async_trait] +impl Task for OverwriteTask { + fn get_task_type(&self) -> TaskType { + self.origin_task.get_task_type() + } + + fn sync_run(self: Box, context: &mut MakeTaskContext) -> TaskResult { + let Self { + origin_task, + event_sender, + } = *self; + // process dependencies + if let Some(process_dependencies_task) = origin_task + .as_any() + .downcast_ref::() + { + let original_module_identifier = process_dependencies_task.original_module_identifier; + let res = origin_task.sync_run(context)?; + event_sender + .send(Event::FinishModule(original_module_identifier, res.len())) + .expect("should success"); + return Ok(res); + } + + // factorize result task + if let Some(factorize_result_task) = origin_task.as_any().downcast_ref::() + { + let dep_id = factorize_result_task + .dependencies + .first() + .cloned() + .expect("should have dep_id"); + let original_module_identifier = factorize_result_task.original_module_identifier; + let res = origin_task.sync_run(context)?; + if res.is_empty() { + event_sender + .send(Event::FinishDeps(original_module_identifier, dep_id, None)) + .expect("should success"); + } + return Ok(res); + } + // add task + if let Some(add_task) = origin_task.as_any().downcast_ref::() { + let dep_id = add_task + .dependencies + .first() + .cloned() + .expect("should have dep_id"); + let original_module_identifier = add_task.original_module_identifier; + let target_module_identifier = add_task.module.identifier(); + + let res = origin_task.sync_run(context)?; + if res.is_empty() { + event_sender + .send(Event::FinishDeps( + original_module_identifier, + dep_id, + Some(target_module_identifier), + )) + .expect("should success"); + } else { + event_sender + .send(Event::StartBuild(target_module_identifier)) + .expect("should success"); + } + return Ok(res); + } + + // other task + origin_task.sync_run(context) + } + + async fn async_run(self: Box) -> TaskResult { + self.origin_task.async_run().await + } +} diff --git a/crates/rspack_core/src/concatenated_module.rs b/crates/rspack_core/src/concatenated_module.rs index 9545b2c0c7d..1a881c94704 100644 --- a/crates/rspack_core/src/concatenated_module.rs +++ b/crates/rspack_core/src/concatenated_module.rs @@ -395,7 +395,7 @@ impl ConcatenatedModule { diagnostics: Mutex::new(vec![]), cached_hash: OnceCell::default(), build_info: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), } } diff --git a/crates/rspack_core/src/context_module.rs b/crates/rspack_core/src/context_module.rs index ae61628f82e..661fba4e13c 100644 --- a/crates/rspack_core/src/context_module.rs +++ b/crates/rspack_core/src/context_module.rs @@ -198,7 +198,7 @@ impl ContextModule { factory_meta: None, build_info: None, build_meta: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), } } diff --git a/crates/rspack_core/src/external_module.rs b/crates/rspack_core/src/external_module.rs index 628bd6f7a9c..dab673e22c5 100644 --- a/crates/rspack_core/src/external_module.rs +++ b/crates/rspack_core/src/external_module.rs @@ -110,7 +110,7 @@ impl ExternalModule { factory_meta: None, build_info: None, build_meta: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), } } diff --git a/crates/rspack_core/src/normal_module.rs b/crates/rspack_core/src/normal_module.rs index c2eccfe1ab8..dc094c89e3e 100644 --- a/crates/rspack_core/src/normal_module.rs +++ b/crates/rspack_core/src/normal_module.rs @@ -225,7 +225,7 @@ impl NormalModule { build_meta: None, parsed: false, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), } } @@ -503,11 +503,12 @@ impl Module for NormalModule { .parser_and_generator .parse(ParseContext { source: original_source.clone(), + module_context: &self.context, module_identifier: self.identifier(), module_parser_options: self.parser_options.as_ref(), module_type: &self.module_type, module_user_request: &self.user_request, - module_source_map_kind: self.get_source_map_kind().clone(), + module_source_map_kind: *self.get_source_map_kind(), loaders: &self.loaders, resource_data: &self.resource_data, compiler_options: build_context.compiler_options, @@ -754,7 +755,7 @@ impl NormalModule { return Ok(RawSource::Buffer(content.into_bytes()).boxed()); } let source_map_kind = self.get_source_map_kind(); - if !matches!(source_map_kind, SourceMapKind::None) + if source_map_kind.enabled() && let Some(source_map) = source_map { let content = content.into_string_lossy(); @@ -767,7 +768,7 @@ impl NormalModule { .boxed(), ); } - if !matches!(source_map_kind, SourceMapKind::None) + if source_map_kind.enabled() && let Content::String(content) = content { return Ok(OriginalSource::new(content, self.request()).boxed()); diff --git a/crates/rspack_core/src/parser_and_generator.rs b/crates/rspack_core/src/parser_and_generator.rs index e7de0a5e2e9..e661e76c18b 100644 --- a/crates/rspack_core/src/parser_and_generator.rs +++ b/crates/rspack_core/src/parser_and_generator.rs @@ -14,12 +14,13 @@ use crate::{ DependencyTemplate, GeneratorOptions, Module, ModuleDependency, ModuleIdentifier, ModuleType, ParserOptions, RuntimeGlobals, RuntimeSpec, SourceType, }; -use crate::{ChunkGraph, ConcatenationScope, ModuleGraph}; +use crate::{ChunkGraph, ConcatenationScope, Context, ModuleGraph}; #[derive(Derivative)] #[derivative(Debug)] pub struct ParseContext<'a> { pub source: BoxSource, + pub module_context: &'a Context, pub module_identifier: ModuleIdentifier, pub module_type: &'a ModuleType, pub module_user_request: &'a str, diff --git a/crates/rspack_core/src/raw_module.rs b/crates/rspack_core/src/raw_module.rs index 01d75b0149e..dbec11e6346 100644 --- a/crates/rspack_core/src/raw_module.rs +++ b/crates/rspack_core/src/raw_module.rs @@ -49,7 +49,7 @@ impl RawModule { factory_meta: None, build_info: None, build_meta: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), } } } diff --git a/crates/rspack_core/src/self_module.rs b/crates/rspack_core/src/self_module.rs index b1240fca54f..cdaac59f82c 100644 --- a/crates/rspack_core/src/self_module.rs +++ b/crates/rspack_core/src/self_module.rs @@ -39,7 +39,7 @@ impl SelfModule { factory_meta: None, build_info: None, build_meta: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), } } } diff --git a/crates/rspack_core/src/utils/task_loop.rs b/crates/rspack_core/src/utils/task_loop.rs index d285ef637dd..17357deeb9d 100644 --- a/crates/rspack_core/src/utils/task_loop.rs +++ b/crates/rspack_core/src/utils/task_loop.rs @@ -1,4 +1,5 @@ use std::{ + any::Any, collections::VecDeque, sync::{ atomic::{AtomicBool, Ordering}, @@ -7,7 +8,11 @@ use std::{ }; use rspack_error::Result; -use tokio::sync::mpsc::{self, error::TryRecvError}; +use rspack_util::ext::AsAny; +use tokio::{ + runtime::Handle, + sync::mpsc::{self, error::TryRecvError}, +}; /// Result returned by task /// @@ -26,11 +31,11 @@ pub enum TaskType { /// /// See test for more example #[async_trait::async_trait] -pub trait Task: Send { +pub trait Task: Send + Any + AsAny { /// Return the task type /// - /// return `TaskType::Sync` will run `self::sync_run` - /// return `TaskType::Async` will run `self::async_run` + /// Return `TaskType::Sync` will run `self::sync_run` + /// Return `TaskType::Async` will run `self::async_run` fn get_task_type(&self) -> TaskType; /// Sync task process @@ -50,6 +55,15 @@ pub trait Task: Send { pub fn run_task_loop( ctx: &mut Ctx, init_tasks: Vec>>, +) -> Result<()> { + run_task_loop_with_event(ctx, init_tasks, |_, task| task) +} + +/// Run task loop with event +pub fn run_task_loop_with_event( + ctx: &mut Ctx, + init_tasks: Vec>>, + before_task_run: impl Fn(&mut Ctx, Box>) -> Box>, ) -> Result<()> { // create channel to receive async task result let (tx, mut rx) = mpsc::unbounded_channel::>(); @@ -65,6 +79,7 @@ pub fn run_task_loop( } if let Some(task) = task { + let task = before_task_run(ctx, task); match task.get_task_type() { TaskType::Async => { let tx = tx.clone(); @@ -90,7 +105,16 @@ pub fn run_task_loop( } } - match rx.try_recv() { + let data = if queue.is_empty() && active_task_count != 0 { + Handle::current().block_on(async { + let res = rx.recv().await.expect("should recv success"); + Ok(res) + }) + } else { + rx.try_recv() + }; + + match data { Ok(r) => { active_task_count -= 1; // merge async task result diff --git a/crates/rspack_hash/Cargo.toml b/crates/rspack_hash/Cargo.toml index 44087b289d5..2dda0caa1d2 100644 --- a/crates/rspack_hash/Cargo.toml +++ b/crates/rspack_hash/Cargo.toml @@ -7,7 +7,7 @@ version = "0.1.0" [dependencies] -data-encoding = { version = "2.5.0" } +data-encoding = { version = "2.6.0" } md4 = "0.10.2" smol_str = { version = "*" } xxhash-rust = { workspace = true, features = ["xxh3"] } diff --git a/crates/rspack_hash/src/lib.rs b/crates/rspack_hash/src/lib.rs index 1ebbe599151..d73d7c7f380 100644 --- a/crates/rspack_hash/src/lib.rs +++ b/crates/rspack_hash/src/lib.rs @@ -78,7 +78,9 @@ impl RspackHash { pub fn with_salt(function: &HashFunction, salt: &HashSalt) -> Self { let mut this = Self::new(function); - salt.hash(&mut this); + if !matches!(salt, HashSalt::None) { + salt.hash(&mut this); + } this } diff --git a/crates/rspack_loader_runner/src/content.rs b/crates/rspack_loader_runner/src/content.rs index 96078d10ed8..421c3aeb171 100644 --- a/crates/rspack_loader_runner/src/content.rs +++ b/crates/rspack_loader_runner/src/content.rs @@ -87,7 +87,10 @@ impl Debug for Content { }; content - .field(ty, &s[0..usize::min(s.len(), 20)].to_owned()) + .field( + ty, + &s[0..usize::min(s.len(), s.ceil_char_boundary(20))].to_owned(), + ) .finish() } } diff --git a/crates/rspack_loader_runner/src/lib.rs b/crates/rspack_loader_runner/src/lib.rs index 1d8e3c6c40a..a3a0987c4c7 100644 --- a/crates/rspack_loader_runner/src/lib.rs +++ b/crates/rspack_loader_runner/src/lib.rs @@ -1,4 +1,5 @@ #![feature(let_chains)] +#![feature(round_char_boundary)] mod content; mod loader; diff --git a/crates/rspack_loader_swc/src/lib.rs b/crates/rspack_loader_swc/src/lib.rs index 83fcff5659b..67ede9862af 100644 --- a/crates/rspack_loader_swc/src/lib.rs +++ b/crates/rspack_loader_swc/src/lib.rs @@ -80,9 +80,9 @@ impl Loader for SwcLoader { swc_options }; - let source_map_kind: &SourceMapKind = match swc_options.config.source_maps { - Some(SourceMapsConfig::Bool(false)) => &SourceMapKind::None, - _ => &loader_context.context.module_source_map_kind, + let source_map_kind: SourceMapKind = match swc_options.config.source_maps { + Some(SourceMapsConfig::Bool(false)) => SourceMapKind::empty(), + _ => loader_context.context.module_source_map_kind, }; let source = content.try_into_string()?; @@ -122,9 +122,9 @@ impl Loader for SwcLoader { .as_ref() .map(|v| matches!(v, OutputCharset::Ascii)), source_map_config: SourceMapConfig { - enable: !matches!(source_map_kind, SourceMapKind::None), - inline_sources_content: true, - emit_columns: matches!(source_map_kind, SourceMapKind::SourceMap), + enable: source_map_kind.source_map(), + inline_sources_content: source_map_kind.source_map(), + emit_columns: !source_map_kind.cheap(), names: Default::default(), }, inline_script: Some(false), diff --git a/crates/rspack_plugin_css/Cargo.toml b/crates/rspack_plugin_css/Cargo.toml index 9500693fdca..67ebe57b105 100644 --- a/crates/rspack_plugin_css/Cargo.toml +++ b/crates/rspack_plugin_css/Cargo.toml @@ -22,7 +22,6 @@ rspack_plugin_runtime = { path = "../rspack_plugin_runtime" } rspack_util = { path = "../rspack_util" } rustc-hash = { workspace = true } serde_json = { workspace = true } -sugar_path = { workspace = true } swc_core = { workspace = true, features = [ "css_ast", "css_codegen", diff --git a/crates/rspack_plugin_css/src/parser_and_generator/mod.rs b/crates/rspack_plugin_css/src/parser_and_generator/mod.rs index bd6a65c527f..3d629ee08c9 100644 --- a/crates/rspack_plugin_css/src/parser_and_generator/mod.rs +++ b/crates/rspack_plugin_css/src/parser_and_generator/mod.rs @@ -18,7 +18,6 @@ use rspack_core::{ }; use rspack_core::{ModuleInitFragments, RuntimeGlobals}; use rspack_error::{IntoTWithDiagnosticArray, Result, TWithDiagnosticArray}; -use rspack_util::source_map::SourceMapKind; use rustc_hash::FxHashSet; use swc_core::{ css::{parser::parser::ParserConfig, visit::VisitWith}, @@ -154,9 +153,9 @@ impl ParserAndGenerator for CssParserAndGenerator { let (code, map) = swc_compiler.codegen( &stylesheet, SwcCssSourceMapGenConfig { - enable: !matches!(module_source_map_kind, SourceMapKind::None), - inline_sources_content: false, - emit_columns: matches!(module_source_map_kind, SourceMapKind::SourceMap), + enable: module_source_map_kind.enabled(), + inline_sources_content: module_source_map_kind.source_map(), + emit_columns: !module_source_map_kind.cheap(), }, )?; source_code = code; @@ -249,7 +248,7 @@ impl ParserAndGenerator for CssParserAndGenerator { dependencies }; - let new_source = if !matches!(module_source_map_kind, SourceMapKind::None) { + let new_source = if module_source_map_kind.enabled() { if let Some(source_map) = source_map { SourceMapSource::new(SourceMapSourceOptions { value: source_code, diff --git a/crates/rspack_plugin_css/src/runtime/mod.rs b/crates/rspack_plugin_css/src/runtime/mod.rs index 5a94b142b2e..20ec867c0f6 100644 --- a/crates/rspack_plugin_css/src/runtime/mod.rs +++ b/crates/rspack_plugin_css/src/runtime/mod.rs @@ -21,7 +21,7 @@ impl Default for CssLoadingRuntimeModule { Self { id: Identifier::from("webpack/runtime/css_loading"), chunk: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_css/src/utils.rs b/crates/rspack_plugin_css/src/utils.rs index 86a7892990b..b1c1db395a3 100644 --- a/crates/rspack_plugin_css/src/utils.rs +++ b/crates/rspack_plugin_css/src/utils.rs @@ -1,4 +1,5 @@ -use std::{fmt::Write, hash::Hash}; +use std::fmt::Write; +use std::hash::Hasher; use heck::{ToKebabCase, ToLowerCamelCase}; use once_cell::sync::Lazy; @@ -14,7 +15,6 @@ use rspack_hash::{HashDigest, HashFunction, HashSalt, RspackHash}; use rspack_util::identifier::make_paths_relative; use rspack_util::infallible::ResultInfallibleExt; use rustc_hash::FxHashSet as HashSet; -use sugar_path::SugarPath; use swc_core::common::Spanned; use swc_core::css::modules::CssClassName; use swc_core::ecma::atoms::Atom; @@ -24,6 +24,8 @@ use crate::parser_and_generator::{CssExport, CssExportsType}; pub const AUTO_PUBLIC_PATH_PLACEHOLDER: &str = "__RSPACK_PLUGIN_CSS_AUTO_PUBLIC_PATH__"; pub static AUTO_PUBLIC_PATH_PLACEHOLDER_REGEX: Lazy = Lazy::new(|| Regex::new(AUTO_PUBLIC_PATH_PLACEHOLDER).expect("Invalid regexp")); +pub static LEADING_DIGIT_REGEX: Lazy = + Lazy::new(|| Regex::new(r"^\d+").expect("Invalid regexp")); pub struct ModulesTransformConfig<'a> { resource_data: &'a ResourceData, @@ -60,10 +62,13 @@ impl<'a> ModulesTransformConfig<'a> { impl swc_core::css::modules::TransformConfig for ModulesTransformConfig<'_> { fn new_name_for(&self, local: &Atom) -> Atom { - let relative_path = self.resource_data.resource_path.relative(self.context); + let relative_path = make_paths_relative( + self.context, + &self.resource_data.resource_path.to_string_lossy(), + ); let hash = { let mut hasher = RspackHash::with_salt(self.hash_function, self.hash_salt); - relative_path.hash(&mut hasher); + hasher.write(relative_path.as_bytes()); let contains_local = self .local_name_ident .template @@ -71,21 +76,18 @@ impl swc_core::css::modules::TransformConfig for ModulesTransformConfig<'_> { .map(|t| t.contains("[local]")) .unwrap_or_default(); if !contains_local { - local.hash(&mut hasher); + hasher.write(local.as_bytes()); } let hash = hasher.digest(self.hash_digest); - let hash = hash.rendered(self.hash_digest_length); - if hash.as_bytes()[0].is_ascii_digit() { - format!("_{hash}") - } else { - hash.into() - } + LEADING_DIGIT_REGEX + .replace_all(hash.rendered(self.hash_digest_length), "") + .into_owned() }; let relative_resource = make_paths_relative(self.context.as_str(), &self.resource_data.resource); LocalIdentNameRenderOptions { path_data: PathData::default() - .filename(&relative_path.to_string_lossy()) + .filename(&relative_path) .hash(&hash) // TODO: should be moduleId, but we don't have it at parse, // and it's lots of work to move css module compile to generator, @@ -120,6 +122,7 @@ impl LocalIdentNameRenderOptions<'_> { .always_ok(); s = s.replace("[local]", self.local); s = s.replace("[uniqueName]", self.unique_name); + s = ESCAPE_LOCAL_IDENT_REGEX.replace_all(&s, "_").into_owned(); s } diff --git a/crates/rspack_plugin_devtool/src/lib.rs b/crates/rspack_plugin_devtool/src/lib.rs index 3259907641d..676b94e9e8b 100644 --- a/crates/rspack_plugin_devtool/src/lib.rs +++ b/crates/rspack_plugin_devtool/src/lib.rs @@ -941,17 +941,19 @@ impl Plugin for EvalSourceMapDevToolPlugin { pub struct SourceMapDevToolModuleOptionsPluginOptions { pub module: bool, + pub cheap: bool, } #[plugin] #[derive(Debug)] pub struct SourceMapDevToolModuleOptionsPlugin { module: bool, + cheap: bool, } impl SourceMapDevToolModuleOptionsPlugin { pub fn new(options: SourceMapDevToolModuleOptionsPluginOptions) -> Self { - Self::new_inner(options.module) + Self::new_inner(options.module, options.cheap) } } @@ -962,6 +964,9 @@ async fn build_module(&self, module: &mut BoxModule) -> Result<()> { } else { module.set_source_map_kind(SourceMapKind::SimpleSourceMap); } + if self.cheap { + module.set_source_map_kind(*module.get_source_map_kind() | SourceMapKind::Cheap) + } Ok(()) } @@ -980,6 +985,9 @@ async fn runtime_module( } else { module.set_source_map_kind(SourceMapKind::SimpleSourceMap); } + if self.cheap { + module.set_source_map_kind(*module.get_source_map_kind() | SourceMapKind::Cheap) + } Ok(()) } diff --git a/crates/rspack_plugin_extract_css/src/css_module.rs b/crates/rspack_plugin_extract_css/src/css_module.rs index 1b7b61a5d04..fbd4e364f7e 100644 --- a/crates/rspack_plugin_extract_css/src/css_module.rs +++ b/crates/rspack_plugin_extract_css/src/css_module.rs @@ -78,7 +78,7 @@ impl CssModule { factory_meta: None, build_info: None, build_meta: None, - source_map_kind: rspack_util::source_map::SourceMapKind::None, + source_map_kind: rspack_util::source_map::SourceMapKind::empty(), identifier__, filepath: dep.filepath, } diff --git a/crates/rspack_plugin_extract_css/src/runtime.rs b/crates/rspack_plugin_extract_css/src/runtime.rs index 417a2a2d240..34179e83635 100644 --- a/crates/rspack_plugin_extract_css/src/runtime.rs +++ b/crates/rspack_plugin_extract_css/src/runtime.rs @@ -41,7 +41,7 @@ impl CssLoadingRuntimeModule { insert, loading, hmr, - source_map_kind: rspack_util::source_map::SourceMapKind::None, + source_map_kind: rspack_util::source_map::SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_hmr/src/hot_module_replacement.rs b/crates/rspack_plugin_hmr/src/hot_module_replacement.rs index 55bebb784cb..a32d95019b5 100644 --- a/crates/rspack_plugin_hmr/src/hot_module_replacement.rs +++ b/crates/rspack_plugin_hmr/src/hot_module_replacement.rs @@ -19,7 +19,7 @@ impl Default for HotModuleReplacementRuntimeModule { fn default() -> Self { Self { id: Identifier::from("webpack/runtime/hot_module_replacement"), - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_javascript/src/ast/stringify.rs b/crates/rspack_plugin_javascript/src/ast/stringify.rs index 85b1000889e..547b8b25603 100644 --- a/crates/rspack_plugin_javascript/src/ast/stringify.rs +++ b/crates/rspack_plugin_javascript/src/ast/stringify.rs @@ -36,9 +36,9 @@ impl CodegenOptions { pub fn new(source_map_kind: &SourceMapKind, keep_comments: Option) -> Self { Self { source_map_config: SourceMapConfig { - enable: !matches!(source_map_kind, SourceMapKind::None), - inline_sources_content: true, - emit_columns: matches!(source_map_kind, SourceMapKind::SourceMap), + enable: source_map_kind.enabled(), + inline_sources_content: source_map_kind.source_map(), + emit_columns: !source_map_kind.cheap(), names: Default::default(), }, keep_comments, @@ -92,11 +92,7 @@ pub fn print( source_map.clone(), "\n", &mut buf, - if source_map_config.enable { - Some(&mut src_map_buf) - } else { - None - }, + source_map_config.enable.then_some(&mut src_map_buf), )) as Box; if minify { diff --git a/crates/rspack_plugin_javascript/src/parser_and_generator/mod.rs b/crates/rspack_plugin_javascript/src/parser_and_generator/mod.rs index 25da337c08f..dafb6997e04 100644 --- a/crates/rspack_plugin_javascript/src/parser_and_generator/mod.rs +++ b/crates/rspack_plugin_javascript/src/parser_and_generator/mod.rs @@ -16,7 +16,6 @@ use rspack_core::{ }; use rspack_error::miette::Diagnostic; use rspack_error::{DiagnosticExt, IntoTWithDiagnosticArray, Result, TWithDiagnosticArray}; -use rspack_util::source_map::SourceMapKind; use swc_core::common::{Span, SyntaxContext}; use swc_core::ecma::parser::{EsConfig, Syntax}; @@ -106,8 +105,8 @@ impl ParserAndGenerator for JavaScriptParserAndGenerator { allow_super_outside_method: true, ..Default::default() }); - let use_source_map = matches!(module_source_map_kind, SourceMapKind::SourceMap); - let enable_source_map = !matches!(module_source_map_kind, SourceMapKind::None); + let use_source_map = module_source_map_kind.source_map(); + let enable_source_map = module_source_map_kind.enabled(); let original_map = source.map(&MapOptions::new(use_source_map)); let source = source.source(); diff --git a/crates/rspack_plugin_javascript/src/plugin/module_concatenation_plugin.rs b/crates/rspack_plugin_javascript/src/plugin/module_concatenation_plugin.rs index 2c92e100077..b06be0fee50 100644 --- a/crates/rspack_plugin_javascript/src/plugin/module_concatenation_plugin.rs +++ b/crates/rspack_plugin_javascript/src/plugin/module_concatenation_plugin.rs @@ -912,7 +912,7 @@ impl ModuleConcatenationPlugin { resolver_factory: compilation.resolver_factory.clone(), module: new_module.id(), module_context: None, - module_source_map_kind: rspack_util::source_map::SourceMapKind::None, + module_source_map_kind: rspack_util::source_map::SourceMapKind::empty(), cache: compilation.cache.clone(), plugin_driver: compilation.plugin_driver.clone(), }, diff --git a/crates/rspack_plugin_javascript/src/utils/eval/eval_tpl_expr.rs b/crates/rspack_plugin_javascript/src/utils/eval/eval_tpl_expr.rs index e9c92097f2f..0af9040cd08 100644 --- a/crates/rspack_plugin_javascript/src/utils/eval/eval_tpl_expr.rs +++ b/crates/rspack_plugin_javascript/src/utils/eval/eval_tpl_expr.rs @@ -29,8 +29,7 @@ fn get_simplified_template_result( TemplateStringKind::Raw => &quasi_expr.raw, }; if i > 0 { - let len = parts.len(); - let prev_expr = &mut parts[len - 1]; + let prev_expr = parts.last_mut().expect("should not empty"); let expr = scanner.evaluate_expression(&node.exprs[i - 1]); if !expr.could_have_side_effects() && let Some(str) = expr.as_string() @@ -41,7 +40,7 @@ fn get_simplified_template_result( // prev_expr.set_expression(None); // also merge for quasis - let prev_expr = &mut quasis[len - 1]; + let prev_expr = quasis.last_mut().expect("should not empty"); prev_expr.set_string(format!("{}{}{}", prev_expr.string(), str, quasi)); prev_expr.set_range(prev_expr.range().0, quasi_expr.span_hi().0); diff --git a/crates/rspack_plugin_javascript/src/visitors/mod.rs b/crates/rspack_plugin_javascript/src/visitors/mod.rs index d46ac14ca69..3a0e1b1143b 100644 --- a/crates/rspack_plugin_javascript/src/visitors/mod.rs +++ b/crates/rspack_plugin_javascript/src/visitors/mod.rs @@ -62,11 +62,11 @@ pub fn run_before_pass(ast: &mut Ast, options: &CompilerOptions) -> Result<()> { let comments = program.comments.take(); { let mut pass = chain!( + dropped_comments_preserver(comments.clone()), swc_visitor::resolver(unresolved_mark, top_level_mark, false), builtins_webpack_plugin(options, unresolved_mark), swc_visitor::hygiene(false, top_level_mark), swc_visitor::fixer(Some(&comments as &dyn Comments)), - dropped_comments_preserver(comments.clone()), ); program.fold_with(&mut pass); } diff --git a/crates/rspack_plugin_mf/src/container/container_entry_module.rs b/crates/rspack_plugin_mf/src/container/container_entry_module.rs index 62895feb922..52b98c632dd 100644 --- a/crates/rspack_plugin_mf/src/container/container_entry_module.rs +++ b/crates/rspack_plugin_mf/src/container/container_entry_module.rs @@ -59,7 +59,7 @@ impl ContainerEntryModule { factory_meta: None, build_info: None, build_meta: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), enhanced, } } diff --git a/crates/rspack_plugin_mf/src/container/expose_runtime_module.rs b/crates/rspack_plugin_mf/src/container/expose_runtime_module.rs index de9dc3d65fc..d87ee5c35fb 100644 --- a/crates/rspack_plugin_mf/src/container/expose_runtime_module.rs +++ b/crates/rspack_plugin_mf/src/container/expose_runtime_module.rs @@ -21,7 +21,7 @@ impl ExposeRuntimeModule { Self { id: Identifier::from("webpack/runtime/initialize_exposes"), chunk: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_mf/src/container/fallback_module.rs b/crates/rspack_plugin_mf/src/container/fallback_module.rs index 20eca227b52..59c85c3ec62 100644 --- a/crates/rspack_plugin_mf/src/container/fallback_module.rs +++ b/crates/rspack_plugin_mf/src/container/fallback_module.rs @@ -52,7 +52,7 @@ impl FallbackModule { factory_meta: None, build_info: None, build_meta: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), } } } diff --git a/crates/rspack_plugin_mf/src/container/module_federation_runtime_plugin.rs b/crates/rspack_plugin_mf/src/container/module_federation_runtime_plugin.rs index 37c38e23365..86e57fa852e 100644 --- a/crates/rspack_plugin_mf/src/container/module_federation_runtime_plugin.rs +++ b/crates/rspack_plugin_mf/src/container/module_federation_runtime_plugin.rs @@ -22,7 +22,7 @@ impl Default for FederationRuntimeModule { Self { id: Identifier::from("module_federation/runtime"), chunk: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_mf/src/container/remote_module.rs b/crates/rspack_plugin_mf/src/container/remote_module.rs index e8297b0a156..967ead5b05d 100644 --- a/crates/rspack_plugin_mf/src/container/remote_module.rs +++ b/crates/rspack_plugin_mf/src/container/remote_module.rs @@ -69,7 +69,7 @@ impl RemoteModule { factory_meta: None, build_info: None, build_meta: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), } } } diff --git a/crates/rspack_plugin_mf/src/container/remote_runtime_module.rs b/crates/rspack_plugin_mf/src/container/remote_runtime_module.rs index 00268eeef33..42decc40523 100644 --- a/crates/rspack_plugin_mf/src/container/remote_runtime_module.rs +++ b/crates/rspack_plugin_mf/src/container/remote_runtime_module.rs @@ -25,7 +25,7 @@ impl RemoteRuntimeModule { id: Identifier::from("webpack/runtime/remotes_loading"), chunk: None, enhanced, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_mf/src/sharing/consume_shared_module.rs b/crates/rspack_plugin_mf/src/sharing/consume_shared_module.rs index 0181f3d471c..726d4215206 100644 --- a/crates/rspack_plugin_mf/src/sharing/consume_shared_module.rs +++ b/crates/rspack_plugin_mf/src/sharing/consume_shared_module.rs @@ -78,7 +78,7 @@ impl ConsumeSharedModule { factory_meta: None, build_info: None, build_meta: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), } } } diff --git a/crates/rspack_plugin_mf/src/sharing/consume_shared_runtime_module.rs b/crates/rspack_plugin_mf/src/sharing/consume_shared_runtime_module.rs index bd47304275b..45d8e210962 100644 --- a/crates/rspack_plugin_mf/src/sharing/consume_shared_runtime_module.rs +++ b/crates/rspack_plugin_mf/src/sharing/consume_shared_runtime_module.rs @@ -25,7 +25,7 @@ impl ConsumeSharedRuntimeModule { id: Identifier::from("webpack/runtime/consumes_loading"), chunk: None, enhanced, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_mf/src/sharing/provide_shared_module.rs b/crates/rspack_plugin_mf/src/sharing/provide_shared_module.rs index 8800dbe005d..72b6ce7f7b9 100644 --- a/crates/rspack_plugin_mf/src/sharing/provide_shared_module.rs +++ b/crates/rspack_plugin_mf/src/sharing/provide_shared_module.rs @@ -65,7 +65,7 @@ impl ProvideSharedModule { factory_meta: None, build_info: None, build_meta: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), } } } diff --git a/crates/rspack_plugin_mf/src/sharing/share_runtime_module.rs b/crates/rspack_plugin_mf/src/sharing/share_runtime_module.rs index 66a29f79556..898a2bd0a91 100644 --- a/crates/rspack_plugin_mf/src/sharing/share_runtime_module.rs +++ b/crates/rspack_plugin_mf/src/sharing/share_runtime_module.rs @@ -26,7 +26,7 @@ impl ShareRuntimeModule { id: Identifier::from("webpack/runtime/sharing"), chunk: None, enhanced, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/async_module.rs b/crates/rspack_plugin_runtime/src/runtime_module/async_module.rs index a70d6983e2b..7bedd97a5ec 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/async_module.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/async_module.rs @@ -15,7 +15,7 @@ impl Default for AsyncRuntimeModule { fn default() -> Self { AsyncRuntimeModule { id: Identifier::from("webpack/runtime/async_module"), - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/auto_public_path.rs b/crates/rspack_plugin_runtime/src/runtime_module/auto_public_path.rs index 780b9cf1114..3a4a6382946 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/auto_public_path.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/auto_public_path.rs @@ -21,7 +21,7 @@ impl Default for AutoPublicPathRuntimeModule { Self { id: Identifier::from("webpack/runtime/auto_public_path"), chunk: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/base_uri.rs b/crates/rspack_plugin_runtime/src/runtime_module/base_uri.rs index 2c3ae563855..16fe64d0041 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/base_uri.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/base_uri.rs @@ -17,7 +17,7 @@ impl Default for BaseUriRuntimeModule { BaseUriRuntimeModule { id: Identifier::from("webpack/runtime/base_uri"), chunk: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/chunk_name.rs b/crates/rspack_plugin_runtime/src/runtime_module/chunk_name.rs index 7ce00bbdadb..6e07be0f306 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/chunk_name.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/chunk_name.rs @@ -18,7 +18,7 @@ impl Default for ChunkNameRuntimeModule { Self { id: Identifier::from("webpack/runtime/chunk_name"), chunk: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_preload_function.rs b/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_preload_function.rs index 082b0f4aa2f..2fb1abc9c3d 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_preload_function.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_preload_function.rs @@ -27,7 +27,7 @@ impl ChunkPrefetchPreloadFunctionRuntimeModule { )), runtime_function, runtime_handlers, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_startup.rs b/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_startup.rs index 9b39e9123a3..b025efa1654 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_startup.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_startup.rs @@ -21,7 +21,7 @@ impl ChunkPrefetchStartupRuntimeModule { id: Identifier::from("webpack/runtime/chunk_prefetch_startup"), startup_chunks, chunk: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_trigger.rs b/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_trigger.rs index ed64174ab39..03e34e7d81d 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_trigger.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_trigger.rs @@ -22,7 +22,7 @@ impl ChunkPrefetchTriggerRuntimeModule { Self { id: Identifier::from("webpack/runtime/chunk_prefetch_trigger"), chunk_map, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/chunk_preload_trigger.rs b/crates/rspack_plugin_runtime/src/runtime_module/chunk_preload_trigger.rs index 69c887fc2e4..1d9b4dd17cd 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/chunk_preload_trigger.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/chunk_preload_trigger.rs @@ -22,7 +22,7 @@ impl ChunkPreloadTriggerRuntimeModule { Self { id: Identifier::from("webpack/runtime/chunk_preload_trigger"), chunk_map, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/compat_get_default_export.rs b/crates/rspack_plugin_runtime/src/runtime_module/compat_get_default_export.rs index 148ee44f833..f4d064dad6f 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/compat_get_default_export.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/compat_get_default_export.rs @@ -16,7 +16,7 @@ impl Default for CompatGetDefaultExportRuntimeModule { fn default() -> Self { Self { id: Identifier::from("webpack/runtime/compat_get_default_export"), - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/create_fake_namespace_object.rs b/crates/rspack_plugin_runtime/src/runtime_module/create_fake_namespace_object.rs index b6f26d41cb0..8d95ff9fa03 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/create_fake_namespace_object.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/create_fake_namespace_object.rs @@ -16,7 +16,7 @@ impl Default for CreateFakeNamespaceObjectRuntimeModule { fn default() -> Self { Self { id: Identifier::from("webpack/runtime/create_fake_namespace_object"), - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/create_script_url.rs b/crates/rspack_plugin_runtime/src/runtime_module/create_script_url.rs index b3f3fc21f26..40dba3a9423 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/create_script_url.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/create_script_url.rs @@ -16,7 +16,7 @@ impl Default for CreateScriptUrlRuntimeModule { fn default() -> Self { Self { id: Identifier::from("webpack/runtime/create_script_url"), - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/define_property_getters.rs b/crates/rspack_plugin_runtime/src/runtime_module/define_property_getters.rs index cbc80f351b6..6b9e4a4025e 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/define_property_getters.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/define_property_getters.rs @@ -16,7 +16,7 @@ impl Default for DefinePropertyGettersRuntimeModule { fn default() -> Self { Self { id: Identifier::from("webpack/runtime/define_property_getters"), - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/ensure_chunk.rs b/crates/rspack_plugin_runtime/src/runtime_module/ensure_chunk.rs index 58f3533d594..840a81ec018 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/ensure_chunk.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/ensure_chunk.rs @@ -20,7 +20,7 @@ impl Default for EnsureChunkRuntimeModule { Self { id: Identifier::from("webpack/runtime/ensure_chunk"), chunk: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/export_webpack_require.rs b/crates/rspack_plugin_runtime/src/runtime_module/export_webpack_require.rs index 2bcce0e2e1c..174a306eb15 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/export_webpack_require.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/export_webpack_require.rs @@ -16,7 +16,7 @@ impl ExportWebpackRequireRuntimeModule { pub fn new() -> Self { Self { id: Identifier::from("webpack/runtime/export_webpack_runtime"), - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/get_chunk_filename.rs b/crates/rspack_plugin_runtime/src/runtime_module/get_chunk_filename.rs index 3e458263c66..61c6c920f31 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/get_chunk_filename.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/get_chunk_filename.rs @@ -68,7 +68,7 @@ impl GetChunkFilenameRuntimeModule { global, all_chunks: Box::new(all_chunks), filename_for_chunk: Box::new(filename_for_chunk), - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/get_chunk_update_filename.rs b/crates/rspack_plugin_runtime/src/runtime_module/get_chunk_update_filename.rs index 5608f00f446..5b74f5dc361 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/get_chunk_update_filename.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/get_chunk_update_filename.rs @@ -19,7 +19,7 @@ impl Default for GetChunkUpdateFilenameRuntimeModule { Self { chunk: None, id: Identifier::from("webpack/runtime/get_chunk_update_filename"), - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/get_full_hash.rs b/crates/rspack_plugin_runtime/src/runtime_module/get_full_hash.rs index 5e5339d6c09..44f16a2548f 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/get_full_hash.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/get_full_hash.rs @@ -16,7 +16,7 @@ impl Default for GetFullHashRuntimeModule { fn default() -> Self { Self { id: Identifier::from("webpack/runtime/get_full_hash"), - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/get_main_filename.rs b/crates/rspack_plugin_runtime/src/runtime_module/get_main_filename.rs index 3cd18259c68..023ff079cd0 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/get_main_filename.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/get_main_filename.rs @@ -24,7 +24,7 @@ impl GetMainFilenameRuntimeModule { id: Identifier::from(format!("webpack/runtime/get_main_filename/{content_type}")), global, filename, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/get_trusted_types_policy.rs b/crates/rspack_plugin_runtime/src/runtime_module/get_trusted_types_policy.rs index f54047a1f4b..df1a3b42202 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/get_trusted_types_policy.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/get_trusted_types_policy.rs @@ -20,7 +20,7 @@ impl Default for GetTrustedTypesPolicyRuntimeModule { Self { id: Identifier::from("webpack/runtime/get_trusted_types_policy"), chunk: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/global.rs b/crates/rspack_plugin_runtime/src/runtime_module/global.rs index 9e24eddc99f..54365e21f61 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/global.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/global.rs @@ -16,7 +16,7 @@ impl Default for GlobalRuntimeModule { fn default() -> Self { Self { id: Identifier::from("webpack/runtime/global"), - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/harmony_module_decorator.rs b/crates/rspack_plugin_runtime/src/runtime_module/harmony_module_decorator.rs index 3a825a87ce1..99cbf02f94b 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/harmony_module_decorator.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/harmony_module_decorator.rs @@ -16,7 +16,7 @@ impl Default for HarmonyModuleDecoratorRuntimeModule { fn default() -> Self { Self { id: Identifier::from("webpack/runtime/harmony_module_decorator"), - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/has_own_property.rs b/crates/rspack_plugin_runtime/src/runtime_module/has_own_property.rs index dbeedf71d00..ff30985bd78 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/has_own_property.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/has_own_property.rs @@ -16,7 +16,7 @@ impl Default for HasOwnPropertyRuntimeModule { fn default() -> Self { Self { id: Identifier::from("webpack/runtime/has_own_property"), - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/import_scripts_chunk_loading.rs b/crates/rspack_plugin_runtime/src/runtime_module/import_scripts_chunk_loading.rs index 3b7b01a8b64..2f0c15e5ce7 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/import_scripts_chunk_loading.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/import_scripts_chunk_loading.rs @@ -29,7 +29,7 @@ impl ImportScriptsChunkLoadingRuntimeModule { id: Identifier::from("webpack/runtime/import_scripts_chunk_loading"), chunk: None, with_create_script_url, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/jsonp_chunk_loading.rs b/crates/rspack_plugin_runtime/src/runtime_module/jsonp_chunk_loading.rs index 14ab0d819ed..1cf67cebe00 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/jsonp_chunk_loading.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/jsonp_chunk_loading.rs @@ -25,7 +25,7 @@ impl Default for JsonpChunkLoadingRuntimeModule { Self { id: Identifier::from("webpack/runtime/jsonp_chunk_loading"), chunk: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/load_script.rs b/crates/rspack_plugin_runtime/src/runtime_module/load_script.rs index d7cf13a11f4..14cc9871594 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/load_script.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/load_script.rs @@ -20,7 +20,7 @@ impl LoadScriptRuntimeModule { id: Identifier::from("webpack/runtime/load_script"), unique_name, with_create_script_url, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/make_namespace_object.rs b/crates/rspack_plugin_runtime/src/runtime_module/make_namespace_object.rs index c4f20caff76..53ac866c344 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/make_namespace_object.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/make_namespace_object.rs @@ -16,7 +16,7 @@ impl Default for MakeNamespaceObjectRuntimeModule { fn default() -> Self { Self { id: Identifier::from("webpack/runtime/make_namespace_object"), - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/module_chunk_loading.rs b/crates/rspack_plugin_runtime/src/runtime_module/module_chunk_loading.rs index acc975bd67a..11b241e5b06 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/module_chunk_loading.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/module_chunk_loading.rs @@ -24,7 +24,7 @@ impl Default for ModuleChunkLoadingRuntimeModule { Self { id: Identifier::from("webpack/runtime/module_chunk_loading"), chunk: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/node_module_decorator.rs b/crates/rspack_plugin_runtime/src/runtime_module/node_module_decorator.rs index f2514b04d0d..95640457530 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/node_module_decorator.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/node_module_decorator.rs @@ -16,7 +16,7 @@ impl Default for NodeModuleDecoratorRuntimeModule { fn default() -> Self { Self { id: Identifier::from("webpack/runtime/node_module_decorator"), - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/nonce.rs b/crates/rspack_plugin_runtime/src/runtime_module/nonce.rs index e05e9060fc4..4e2e7d15a37 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/nonce.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/nonce.rs @@ -16,7 +16,7 @@ impl Default for NonceRuntimeModule { fn default() -> Self { Self { id: Identifier::from("webpack/runtime/nonce"), - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/normal.rs b/crates/rspack_plugin_runtime/src/runtime_module/normal.rs index 0daf1e4bb88..112ae33fb77 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/normal.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/normal.rs @@ -18,7 +18,7 @@ impl NormalRuntimeModule { Self { identifier: Identifier::from(identifier.name()), sources, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/on_chunk_loaded.rs b/crates/rspack_plugin_runtime/src/runtime_module/on_chunk_loaded.rs index f5550254dc3..6a6b5e4ec2a 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/on_chunk_loaded.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/on_chunk_loaded.rs @@ -16,7 +16,7 @@ impl Default for OnChunkLoadedRuntimeModule { fn default() -> Self { Self { id: Identifier::from("webpack/runtime/on_chunk_loaded"), - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/public_path.rs b/crates/rspack_plugin_runtime/src/runtime_module/public_path.rs index e3c7fcdff3b..cbfdc2bbef9 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/public_path.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/public_path.rs @@ -18,7 +18,7 @@ impl PublicPathRuntimeModule { Self { id: Identifier::from("webpack/runtime/public_path"), public_path, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/readfile_chunk_loading.rs b/crates/rspack_plugin_runtime/src/runtime_module/readfile_chunk_loading.rs index 27ecafa975d..80cff0574d6 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/readfile_chunk_loading.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/readfile_chunk_loading.rs @@ -27,7 +27,7 @@ impl Default for ReadFileChunkLoadingRuntimeModule { Self { id: Identifier::from("webpack/runtime/readfile_chunk_loading"), chunk: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/relative_url.rs b/crates/rspack_plugin_runtime/src/runtime_module/relative_url.rs index 87efa8f77d6..a0d340d6443 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/relative_url.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/relative_url.rs @@ -16,7 +16,7 @@ impl Default for RelativeUrlRuntimeModule { fn default() -> Self { Self { id: Identifier::from("webpack/runtime/relative_url"), - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/require_js_chunk_loading.rs b/crates/rspack_plugin_runtime/src/runtime_module/require_js_chunk_loading.rs index a701931d3a3..51d059a7319 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/require_js_chunk_loading.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/require_js_chunk_loading.rs @@ -27,7 +27,7 @@ impl Default for RequireChunkLoadingRuntimeModule { Self { id: Identifier::from("webpack/runtime/require_chunk_loading"), chunk: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/rspack_version.rs b/crates/rspack_plugin_runtime/src/runtime_module/rspack_version.rs index fea4fdbbdf7..dcdc9b8dcb1 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/rspack_version.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/rspack_version.rs @@ -18,7 +18,7 @@ impl RspackVersionRuntimeModule { Self { id: Identifier::from("webpack/runtime/rspack_version"), version, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime_id.rs b/crates/rspack_plugin_runtime/src/runtime_module/runtime_id.rs index ed4e94943d7..71ac2053354 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime_id.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime_id.rs @@ -19,7 +19,7 @@ impl Default for RuntimeIdRuntimeModule { Self { id: Identifier::from("webpack/runtime/runtime_id"), chunk: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/startup_chunk_dependencies.rs b/crates/rspack_plugin_runtime/src/runtime_module/startup_chunk_dependencies.rs index d52c206c268..27b1ce6cf3f 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/startup_chunk_dependencies.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/startup_chunk_dependencies.rs @@ -23,7 +23,7 @@ impl StartupChunkDependenciesRuntimeModule { id: Identifier::from("webpack/runtime/startup_chunk_dependencies"), async_chunk_loading, chunk: None, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/startup_entry_point.rs b/crates/rspack_plugin_runtime/src/runtime_module/startup_entry_point.rs index 90ea19290e5..c7e285c95cd 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/startup_entry_point.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/startup_entry_point.rs @@ -18,7 +18,7 @@ impl StartupEntrypointRuntimeModule { Self { id: Identifier::from("webpack/runtime/startup_entrypoint"), async_chunk_loading, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/system_context.rs b/crates/rspack_plugin_runtime/src/runtime_module/system_context.rs index 87044b16b46..bca80026225 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/system_context.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/system_context.rs @@ -16,7 +16,7 @@ impl Default for SystemContextRuntimeModule { fn default() -> Self { Self { id: Identifier::from("webpack/runtime/start_entry_point"), - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_plugin_wasm/src/runtime.rs b/crates/rspack_plugin_wasm/src/runtime.rs index 742ed688847..da292d77136 100644 --- a/crates/rspack_plugin_wasm/src/runtime.rs +++ b/crates/rspack_plugin_wasm/src/runtime.rs @@ -27,7 +27,7 @@ impl AsyncWasmLoadingRuntimeModule { id: Identifier::from("webpack/runtime/async_wasm_loading"), supports_streaming, chunk, - source_map_kind: SourceMapKind::None, + source_map_kind: SourceMapKind::empty(), custom_source: None, } } diff --git a/crates/rspack_util/Cargo.toml b/crates/rspack_util/Cargo.toml index 537b65c33a3..949db49ab82 100644 --- a/crates/rspack_util/Cargo.toml +++ b/crates/rspack_util/Cargo.toml @@ -8,6 +8,7 @@ version = "0.1.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +bitflags = { workspace = true } concat-string = { workspace = true } dashmap = { workspace = true } indexmap = { workspace = true } diff --git a/crates/rspack_util/src/source_map.rs b/crates/rspack_util/src/source_map.rs index baf4796f641..bffad9a7584 100644 --- a/crates/rspack_util/src/source_map.rs +++ b/crates/rspack_util/src/source_map.rs @@ -1,9 +1,36 @@ -#[derive(Debug, PartialEq, Eq, Default, Clone)] -pub enum SourceMapKind { - #[default] - None, - SourceMap, - SimpleSourceMap, +use bitflags::bitflags; + +bitflags! { + #[derive(Debug, PartialEq, Eq, Clone, Copy)] + pub struct SourceMapKind: u8 { + const SourceMap = 1 << 0; + const SimpleSourceMap = 1 << 1; + const Cheap = 1 << 2; + } +} + +impl Default for SourceMapKind { + fn default() -> Self { + SourceMapKind::empty() + } +} + +impl SourceMapKind { + pub fn enabled(&self) -> bool { + !self.is_empty() + } + + pub fn source_map(&self) -> bool { + self.contains(SourceMapKind::SourceMap) + } + + pub fn simple_source_map(&self) -> bool { + self.contains(SourceMapKind::SimpleSourceMap) + } + + pub fn cheap(&self) -> bool { + self.contains(SourceMapKind::Cheap) + } } pub trait ModuleSourceMapConfig { diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index ea2fd8acce7..cbd00c7a39d 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "@rspack/binding-darwin-arm64", - "version": "0.6.3", + "version": "0.6.4", "license": "MIT", "description": "Node binding for rspack", "main": "rspack.darwin-arm64.node", diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index d35656593af..a78c8cae850 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "@rspack/binding-darwin-x64", - "version": "0.6.3", + "version": "0.6.4", "license": "MIT", "description": "Node binding for rspack", "main": "rspack.darwin-x64.node", diff --git a/npm/linux-x64-gnu/package.json b/npm/linux-x64-gnu/package.json index f6db0c8df1b..b9b62c0cc08 100644 --- a/npm/linux-x64-gnu/package.json +++ b/npm/linux-x64-gnu/package.json @@ -1,6 +1,6 @@ { "name": "@rspack/binding-linux-x64-gnu", - "version": "0.6.3", + "version": "0.6.4", "license": "MIT", "description": "Node binding for rspack", "main": "rspack.linux-x64-gnu.node", diff --git a/npm/win32-x64-msvc/package.json b/npm/win32-x64-msvc/package.json index 179c1d27a72..81f7e00a0f2 100644 --- a/npm/win32-x64-msvc/package.json +++ b/npm/win32-x64-msvc/package.json @@ -1,6 +1,6 @@ { "name": "@rspack/binding-win32-x64-msvc", - "version": "0.6.3", + "version": "0.6.4", "license": "MIT", "description": "Node binding for rspack", "main": "rspack.win32-x64-msvc.node", diff --git a/package.json b/package.json index 0bd72a6b43c..3be34c3f357 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "monorepo", - "version": "0.6.3", + "version": "0.6.4", "license": "MIT", "description": "A Fast Rust-based web bundler", "private": true, @@ -9,7 +9,7 @@ "x": "zx x.mjs", "dev": "pnpm --filter @rspack/cli run dev", "clean": "pnpm --filter @rspack/cli run clean", - "build:js": "pnpm --filter \"@rspack/core\" build --force && pnpm --filter \"@rspack/*\" --filter \"!@rspack/core\" build --force", + "build:js": "pnpm --filter \"@rspack/core\" build:force && pnpm --filter \"@rspack/*\" --filter \"!@rspack/core\" build", "build:cli:debug": "npm run build:binding:debug && npm run build:js", "build:cli:release": "npm run build:binding:release && npm run build:js", "build:cli:release:all": "pnpm --filter @rspack/binding build:release:all && npm run build:js", @@ -36,6 +36,7 @@ "test:ci": "cross-env NODE_OPTIONS=--max_old_space_size=8192 pnpm run build:js && pnpm run test:unit && npm run test:plugin && pnpm test:webpack", "test:plugin": "pnpm --filter \"plugin-test\" test", "test:webpack": "pnpm --filter \"webpack-test\" test:metric", + "doc-coverage": "pnpm --filter '@rspack/core' doc-coverage", "api-extractor:local": "pnpm --filter '@rspack/*' api-extractor --local", "api-extractor:ci": "pnpm --filter '@rspack/*' api-extractor:ci" }, diff --git a/packages/create-rspack/package.json b/packages/create-rspack/package.json index 4b9bec4af55..22f72940876 100644 --- a/packages/create-rspack/package.json +++ b/packages/create-rspack/package.json @@ -1,6 +1,6 @@ { "name": "create-rspack", - "version": "0.6.3", + "version": "0.6.4", "license": "MIT", "main": "index.js", "bin": { diff --git a/packages/rspack-cli/package.json b/packages/rspack-cli/package.json index c541148c37a..e1addf502c6 100644 --- a/packages/rspack-cli/package.json +++ b/packages/rspack-cli/package.json @@ -1,6 +1,6 @@ { "name": "@rspack/cli", - "version": "0.6.3", + "version": "0.6.4", "license": "MIT", "description": "CLI for rspack", "bin": { diff --git a/packages/rspack-cli/src/commands/preview.ts b/packages/rspack-cli/src/commands/preview.ts index 404bac8e565..3875a61d4e5 100644 --- a/packages/rspack-cli/src/commands/preview.ts +++ b/packages/rspack-cli/src/commands/preview.ts @@ -1,5 +1,4 @@ import type { RspackCLI } from "../rspack-cli"; -import { RspackDevServer } from "@rspack/dev-server"; import { RspackCommand, RspackPreviewCLIOptions } from "../types"; import { previewOptions } from "../utils/options"; import { @@ -26,6 +25,7 @@ export class PreviewCommand implements RspackCommand { ...options } }; + const { RspackDevServer } = await import("@rspack/dev-server"); let config = await cli.loadConfig(rspackOptions); config = await getPreviewConfig(config, options); diff --git a/packages/rspack-cli/src/commands/serve.ts b/packages/rspack-cli/src/commands/serve.ts index 0081db0c7c0..2be261b542f 100644 --- a/packages/rspack-cli/src/commands/serve.ts +++ b/packages/rspack-cli/src/commands/serve.ts @@ -1,5 +1,5 @@ import type { RspackCLI } from "../rspack-cli"; -import { RspackDevServer } from "@rspack/dev-server"; +import type { RspackDevServer as RspackDevServerType } from "@rspack/dev-server"; import { RspackCommand } from "../types"; import { commonOptions, @@ -22,6 +22,17 @@ export class ServeCommand implements RspackCommand { ...options } }; + /** + * webpack-dev-server will set `process.env.WEBPACK_SERVE` to true + * when its module is imported, so we have to lazy load the package + * to make sure the envvar is not set on build mode. + * when run in serve mode, we have to load the package before config + * module is imported so that the envvar `process.env.WEBPACK_SERVE` + * got in config module could be `true`. + * related issue: https://github.com/web-infra-dev/rspack/issues/6359 + */ + const { RspackDevServer } = await import("@rspack/dev-server"); + const compiler = await cli.createCompiler(rspackOptions, "serve"); if (!compiler) return; const compilers = cli.isMultipleCompiler(compiler) @@ -32,7 +43,7 @@ export class ServeCommand implements RspackCommand { ); const usedPorts: number[] = []; - const servers: RspackDevServer[] = []; + const servers: RspackDevServerType[] = []; /** * Webpack uses an Array of compilerForDevServer, diff --git a/packages/rspack-cli/tests/build/issue-6359/entry.js b/packages/rspack-cli/tests/build/issue-6359/entry.js new file mode 100644 index 00000000000..d2d81e24730 --- /dev/null +++ b/packages/rspack-cli/tests/build/issue-6359/entry.js @@ -0,0 +1 @@ +log(DEFINE_ME); diff --git a/packages/rspack-cli/tests/build/issue-6359/index.test.ts b/packages/rspack-cli/tests/build/issue-6359/index.test.ts new file mode 100644 index 00000000000..152cb5ce416 --- /dev/null +++ b/packages/rspack-cli/tests/build/issue-6359/index.test.ts @@ -0,0 +1,16 @@ +import { readFile, run, runWatch } from "../../utils/test-utils"; +import { resolve } from "path"; + +it("should not have `process.env.WEBPACK_SERVE` set on build mode", async () => { + await run(__dirname, []); + const mainJs = await readFile(resolve(__dirname, "dist/main.js"), "utf-8"); + + expect(mainJs).toContain("WEBPACK_SERVE="); +}); + +it("should have `process.env.WEBPACK_SERVE` set on serve mode", async () => { + await runWatch(__dirname, ["serve"], { killString: /rspack compiled/i }); + const mainJs = await readFile(resolve(__dirname, "dist/main.js"), "utf-8"); + + expect(mainJs).toContain("WEBPACK_SERVE=true"); +}); diff --git a/packages/rspack-cli/tests/build/issue-6359/rspack.config.js b/packages/rspack-cli/tests/build/issue-6359/rspack.config.js new file mode 100644 index 00000000000..ef0d639ed64 --- /dev/null +++ b/packages/rspack-cli/tests/build/issue-6359/rspack.config.js @@ -0,0 +1,22 @@ +const { WEBPACK_SERVE } = process.env; +module.exports = /** @type {import('@rspack/cli').Configuration} */ { + mode: "production", + entry: "./entry.js", + output: { clean: true }, + plugins: [ + { + apply(compiler) { + new compiler.webpack.DefinePlugin({ + DEFINE_ME: JSON.stringify( + `WEBPACK_SERVE=${WEBPACK_SERVE ?? ""}` + ) + }).apply(compiler); + } + } + ], + devServer: { + devMiddleware: { + writeToDisk: true + } + } +}; diff --git a/packages/rspack-dev-server/package.json b/packages/rspack-dev-server/package.json index 2087de422af..146428af115 100644 --- a/packages/rspack-dev-server/package.json +++ b/packages/rspack-dev-server/package.json @@ -1,6 +1,6 @@ { "name": "@rspack/dev-server", - "version": "0.6.3", + "version": "0.6.4", "license": "MIT", "description": "Development server for rspack", "main": "./dist/index.js", diff --git a/packages/rspack-plugin-minify/package.json b/packages/rspack-plugin-minify/package.json index 2ff4c7965aa..61f760cf741 100644 --- a/packages/rspack-plugin-minify/package.json +++ b/packages/rspack-plugin-minify/package.json @@ -1,6 +1,6 @@ { "name": "@rspack/plugin-minify", - "version": "0.6.3", + "version": "0.6.4", "license": "MIT", "description": "Minify plugin for rspack", "main": "src/index.js", diff --git a/packages/rspack-plugin-react-refresh/package.json b/packages/rspack-plugin-react-refresh/package.json index cbdae4785d2..1afbaa4edfa 100644 --- a/packages/rspack-plugin-react-refresh/package.json +++ b/packages/rspack-plugin-react-refresh/package.json @@ -1,6 +1,6 @@ { "name": "@rspack/plugin-react-refresh", - "version": "0.6.3", + "version": "0.6.4", "license": "MIT", "description": "React refresh plugin for rspack", "main": "dist/index.js", diff --git a/packages/rspack-test-tools/package.json b/packages/rspack-test-tools/package.json index b0d048e512b..2d5d0d0cd2a 100644 --- a/packages/rspack-test-tools/package.json +++ b/packages/rspack-test-tools/package.json @@ -1,6 +1,6 @@ { "name": "@rspack/test-tools", - "version": "0.6.3", + "version": "0.6.4", "license": "MIT", "description": "Test tools for rspack", "main": "dist/index.js", diff --git a/packages/rspack-test-tools/tests/__snapshots__/Config.test.js.snap b/packages/rspack-test-tools/tests/__snapshots__/Config.test.js.snap index a45c95dba2b..64219112159 100644 --- a/packages/rspack-test-tools/tests/__snapshots__/Config.test.js.snap +++ b/packages/rspack-test-tools/tests/__snapshots__/Config.test.js.snap @@ -2,200 +2,200 @@ exports[`config config/builtins/css-auto exported tests css/auto can handle css module correctly 1`] = ` Object { - "style": "-_921b05f8c9c16ca9ea84-style", + "style": "-ca56f23580d7bbb484-style", } `; exports[`config config/builtins/css-modules-composes exported tests css modules composes 1`] = ` Object { - "simple-bar": "-_273d87445e861b3031dc-simple-bar -_9d368fc847854456bea3-imported-simple", - "simple-foo": "-_273d87445e861b3031dc-simple-foo -_9d368fc847854456bea3-imported-simple", + "simple-bar": "-a7200a43b5c2530b1414-simple-bar -f27007fff641a72c371d-imported-simple", + "simple-foo": "-a7200a43b5c2530b1414-simple-foo -f27007fff641a72c371d-imported-simple", } `; exports[`config config/builtins/css-modules-composes-preprocessers exported tests css modules with css preprocessers 1`] = ` Object { - "class": "-_273d87445e861b3031dc-class -_11a6d6ffb863bd538fe5-lessClass", - "ghi": "-_273d87445e861b3031dc-ghi", - "other": "-_273d87445e861b3031dc-other -_1f71e04288dddc43d27d-scssClass", - "otherClassName": "-_273d87445e861b3031dc-otherClassName globalClassName", + "class": "-a7200a43b5c2530b1414-class -feb80f2fe6d30-lessClass", + "ghi": "-a7200a43b5c2530b1414-ghi", + "other": "-a7200a43b5c2530b1414-other -ebd90a48d100efd-scssClass", + "otherClassName": "-a7200a43b5c2530b1414-otherClassName globalClassName", } `; exports[`config config/builtins/css-modules-composes-sass exported tests css modules in scss 1`] = ` Object { - "bar": "-_735885c5e37059075f0c-bar -_3dd446eb32b4cceede74-foo", + "bar": "-f1f00e6e62b9a7fadb02-bar -a3b1929b59eeacf15a4-foo", } `; exports[`config config/builtins/css-modules-dedupe exported tests css modules dedupe 1`] = ` Object { - "backButton": "-d4f5f65e6ec5e3abc2cc-backButton -_0f182db74b24b91ce53c-secondaryButton -ed3ce9538ce4b9c8f8ab-button", - "nextButton": "-d4f5f65e6ec5e3abc2cc-nextButton -_73af08fa9da07d8b8412-primaryButton -ed3ce9538ce4b9c8f8ab-button", + "backButton": "-baa5c4d806a1671b-backButton -e683a459bd7b289e1b8d-secondaryButton -d8686a334ddc6bdd0-button", + "nextButton": "-baa5c4d806a1671b-nextButton -a510fa2734ece860e70-primaryButton -d8686a334ddc6bdd0-button", } `; exports[`config config/builtins/css-modules-exports-only exported tests css modules exportsOnly 1`] = ` Object { - "simple-bar": "-_273d87445e861b3031dc-simple-bar -_9d368fc847854456bea3-imported-simple", - "simple-foo": "-_273d87445e861b3031dc-simple-foo -_9d368fc847854456bea3-imported-simple", + "simple-bar": "-a7200a43b5c2530b1414-simple-bar -f27007fff641a72c371d-imported-simple", + "simple-foo": "-a7200a43b5c2530b1414-simple-foo -f27007fff641a72c371d-imported-simple", } `; exports[`config config/builtins/css-modules-local-ident-name-hash exported tests css modules localIdentName with hash 1`] = ` Object { - "#": "_2d1f13069a34dadb8112", - "##": "ae8301fd6f3598539bfd", - "#.#.#": "_1c997a569a07f2420708", - "#fake-id": "d3e8bdca9f976f125db0", - "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.": "cf064fddad4f1ee12a13", - "-a-b-c-": "_3009825ac55fd922e1d4", - "-a0-34a___f": "_2470cf17671bc0f04fb9", - ".": "_45953b92c963cd9365ee", - "123": "b83ce8234973aca76caf", - "1a2b3c": "eca4a6468c54eaabda5f", - ":)": "_9cd9dacf371a665c5e39", - ":\`(": "_849c0b45e753bfe7e332", - ":hover": "_0eec8dbaeb3d52c7e318", - ":hover:focus:active": "cebbf8d9d82b804826ba", - "<><<<>><>": "d0504329c86bf6aaf83f", - "

": "_1f3da2d9abca032e8688", - "?": "d53002e1233f2049f1d4", - "@": "_3604bb5089512604fd6d", - "B&W?": "_29a1f492830adeef54f9", - "[attr=value]": "eb2787a6b2019adfdf12", - "_": "e0c21379fbaec4cf8e76", - "_test": "_701db8dd042b793cda43", - "className": "d42832db1967a6f6161f", - "f!o!o": "_1a4bc095be932bd43d82", - "f'o'o": "b419c7cea20ab4e4c57f", - "f*o*o": "bc01ebf6803f206edbdc", - "f+o+o": "a330ce191c89fbe8ef59", - "f/o/o": "a507c95c5be333d80af6", - "f\\\\o\\\\o": "_8ae0554ce544e3013a32", - "foo.bar": "abed3de09fc05d3400f8", - "foo/bar": "_57fbbed34c6039e5045b", - "foo/bar/baz": "_66e03c108771225ae79a", - "foo\\\\bar": "_48beb53984c701be5645", - "foo\\\\bar\\\\baz": "f9e76b11c67b5115ebdb", - "f~o~o": "_451cb3cda3d4bf8ea8f3", - "m_x_@": "_9a7665e6cf83142e1b3c", - "someId": "_9d834034f45a6a2c699b", - "subClass": "fe69f3ebba3ba63e167e", - "test": "b7fc104110738641f152", - "{}": "a7a93ea70d691fba54a2", - "©": "d9e5b239186637532208", - "“‘’”": "_56e0bf6b2fa8a18ff54e", - "⌘⌥": "_6f25eff10f3aecf1d2de", - "☺☃": "c00a0e3463f69bf799ae", - "♥": "_4d9b71f741c330bc24d0", - "𝄞♪♩♫♬": "a01c68c82acee141b0b9", - "💩": "e3663ae314f6186e799a", - "😍": "bfb8a2d9978df6976636", + "#": "b8b048cfa675ca7e9b4f", + "##": "a8e816d5d9b299b2c0d", + "#.#.#": "c6d1911da4c507e78", + "#fake-id": "d71ffe1702e9e5f648a4", + "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.": "f085385047c8494d66a2", + "-a-b-c-": "e171381fc62026ffe05b", + "-a0-34a___f": "e6419db424263d77191e", + ".": "e1742279a9b31ae95d46", + "123": "e3e235fe2ac5b10a03fa", + "1a2b3c": "e510ae3725659c886e", + ":)": "a7752c5da475e25c37", + ":\`(": "ec4ad64c1cd22a195fb2", + ":hover": "aabfd498fc2f10c7", + ":hover:focus:active": "ea9f2b2a3c0d8b6f20f6", + "<><<<>><>": "b9dc5ecfad4841cf835", + "

": "d66e45a3f7eba1bd2ff3", + "?": "db855a2cb1936bcecdd8", + "@": "b7c53c5c915459fb9703", + "B&W?": "b24426e6382e4f90c52", + "[attr=value]": "cebfe9ac1785240b1f84", + "_": "ffc4dae298ad4c338544", + "_test": "acd3c0528ed3c3330", + "className": "a20f38af3e2122251", + "f!o!o": "dfe9da10af7d0818e5e", + "f'o'o": "b91ad92cc62c88a93dc8", + "f*o*o": "c8706122491802a", + "f+o+o": "fb4386a15ebce1ce30f", + "f/o/o": "c6b959b8b545952c7fcf", + "f\\\\o\\\\o": "c9c9fd2189f4eef61", + "foo.bar": "fa92bf8dea4a5a2ea13", + "foo/bar": "e27d59ba2484ded530e7", + "foo/bar/baz": "fb5155c99d0c07a91", + "foo\\\\bar": "c4b0876e6a72fa1da88", + "foo\\\\bar\\\\baz": "d0641bf036f0db5b0fb7", + "f~o~o": "cb1e1a38751d777913bc", + "m_x_@": "acf01e983cc34242b09", + "someId": "f7dad309581ff59a8c1", + "subClass": "f904cf1d95567c868707", + "test": "c8e76de9832d60b206c2", + "{}": "a273624fc967254e4ad3", + "©": "d4c6ea8dbaf492a7e42e", + "“‘’”": "d3df6d853c11234b8", + "⌘⌥": "bbb74fa7684d2b07", + "☺☃": "d09672ed2a23417fa543", + "♥": "f5682d5025ab700972a0", + "𝄞♪♩♫♬": "b7e928b15b6057d2f8", + "💩": "bb34b4e107a01390e3fb", + "😍": "e5439193d7906536aeac", } `; exports[`config config/builtins/css-modules-local-ident-name-path exported tests css modules localIdentName with path 1`] = ` Object { - "#": "src_index__#", - "##": "src_index__##", - "#.#.#": "src_index__#_#_#", - "#fake-id": "src_index__#fake-id", - "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.": "src_index__++++++++++[_+++++++_++++++++++_+++_+____-]_++__+_+++++++__+++__++___+++++++++++++++___+++_------_--------__+___", - "-a-b-c-": "src_index__-a-b-c-", - "-a0-34a___f": "src_index__-a0-34a___f", - ".": "src_index___", - "123": "src_index__123", - "1a2b3c": "src_index__1a2b3c", - ":)": "src_index___)", - ":\`(": "src_index___\`(", - ":hover": "src_index___hover", - ":hover:focus:active": "src_index___hover_focus_active", - "<><<<>><>": "src_index___________", - "

": "src_index___p_", - "?": "src_index___", - "@": "src_index__@", - "B&W?": "src_index__B&W_", - "[attr=value]": "src_index__[attr=value]", - "_": "src_index___", - "_test": "src_index___test", - "className": "src_index__className", - "f!o!o": "src_index__f!o!o", - "f'o'o": "src_index__f'o'o", - "f*o*o": "src_index__f_o_o", - "f+o+o": "src_index__f+o+o", - "f/o/o": "src_index__f_o_o", - "f\\\\o\\\\o": "src_index__f_o_o", - "foo.bar": "src_index__foo_bar", - "foo/bar": "src_index__foo_bar", - "foo/bar/baz": "src_index__foo_bar_baz", - "foo\\\\bar": "src_index__foo_bar", - "foo\\\\bar\\\\baz": "src_index__foo_bar_baz", - "f~o~o": "src_index__f~o~o", - "m_x_@": "src_index__m_x_@", - "someId": "src_index__someId", - "subClass": "src_index__subClass", - "test": "src_index__test", - "{}": "src_index__{}", - "©": "src_index__©", - "“‘’”": "src_index__“‘’”", - "⌘⌥": "src_index__⌘⌥", - "☺☃": "src_index__☺☃", - "♥": "src_index__♥", - "𝄞♪♩♫♬": "src_index__𝄞♪♩♫♬", - "💩": "src_index__💩", - "😍": "src_index__😍", + "#": "__src_index__#", + "##": "__src_index__##", + "#.#.#": "__src_index__#_#_#", + "#fake-id": "__src_index__#fake-id", + "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.": "__src_index__++++++++++[_+++++++_++++++++++_+++_+____-]_++__+_+++++++__+++__++___+++++++++++++++___+++_------_--------__+___", + "-a-b-c-": "__src_index__-a-b-c-", + "-a0-34a___f": "__src_index__-a0-34a___f", + ".": "__src_index___", + "123": "__src_index__123", + "1a2b3c": "__src_index__1a2b3c", + ":)": "__src_index___)", + ":\`(": "__src_index___\`(", + ":hover": "__src_index___hover", + ":hover:focus:active": "__src_index___hover_focus_active", + "<><<<>><>": "__src_index___________", + "

": "__src_index___p_", + "?": "__src_index___", + "@": "__src_index__@", + "B&W?": "__src_index__B&W_", + "[attr=value]": "__src_index__[attr=value]", + "_": "__src_index___", + "_test": "__src_index___test", + "className": "__src_index__className", + "f!o!o": "__src_index__f!o!o", + "f'o'o": "__src_index__f'o'o", + "f*o*o": "__src_index__f_o_o", + "f+o+o": "__src_index__f+o+o", + "f/o/o": "__src_index__f_o_o", + "f\\\\o\\\\o": "__src_index__f_o_o", + "foo.bar": "__src_index__foo_bar", + "foo/bar": "__src_index__foo_bar", + "foo/bar/baz": "__src_index__foo_bar_baz", + "foo\\\\bar": "__src_index__foo_bar", + "foo\\\\bar\\\\baz": "__src_index__foo_bar_baz", + "f~o~o": "__src_index__f~o~o", + "m_x_@": "__src_index__m_x_@", + "someId": "__src_index__someId", + "subClass": "__src_index__subClass", + "test": "__src_index__test", + "{}": "__src_index__{}", + "©": "__src_index__©", + "“‘’”": "__src_index__“‘’”", + "⌘⌥": "__src_index__⌘⌥", + "☺☃": "__src_index__☺☃", + "♥": "__src_index__♥", + "𝄞♪♩♫♬": "__src_index__𝄞♪♩♫♬", + "💩": "__src_index__💩", + "😍": "__src_index__😍", } `; exports[`config config/builtins/css-modules-locals-convention-camelCase exported tests css modules localsConvention with camelCase 1`] = ` Object { - "btn--info_is-disabled_1": "-_273d87445e861b3031dc-btn--info_is-disabled_1", - "btn-info_is-disabled": "-_273d87445e861b3031dc-btn-info_is-disabled", - "btnInfoIsDisabled": "-_273d87445e861b3031dc-btn-info_is-disabled", - "btnInfoIsDisabled1": "-_273d87445e861b3031dc-btn--info_is-disabled_1", - "fooBar": "-_273d87445e861b3031dc-foo_bar", - "foo_bar": "-_273d87445e861b3031dc-foo_bar", - "simple": "-_273d87445e861b3031dc-simple", + "btn--info_is-disabled_1": "-a7200a43b5c2530b1414-btn--info_is-disabled_1", + "btn-info_is-disabled": "-a7200a43b5c2530b1414-btn-info_is-disabled", + "btnInfoIsDisabled": "-a7200a43b5c2530b1414-btn-info_is-disabled", + "btnInfoIsDisabled1": "-a7200a43b5c2530b1414-btn--info_is-disabled_1", + "fooBar": "-a7200a43b5c2530b1414-foo_bar", + "foo_bar": "-a7200a43b5c2530b1414-foo_bar", + "simple": "-a7200a43b5c2530b1414-simple", } `; exports[`config config/builtins/css-modules-locals-convention-camelCaseOnly exported tests css modules localsConvention with camelCaseOnly 1`] = ` Object { - "btnInfoIsDisabled": "-_273d87445e861b3031dc-btn-info_is-disabled", - "btnInfoIsDisabled1": "-_273d87445e861b3031dc-btn--info_is-disabled_1", - "fooBar": "-_273d87445e861b3031dc-foo_bar", - "simple": "-_273d87445e861b3031dc-simple", + "btnInfoIsDisabled": "-a7200a43b5c2530b1414-btn-info_is-disabled", + "btnInfoIsDisabled1": "-a7200a43b5c2530b1414-btn--info_is-disabled_1", + "fooBar": "-a7200a43b5c2530b1414-foo_bar", + "simple": "-a7200a43b5c2530b1414-simple", } `; exports[`config config/builtins/css-modules-locals-convention-dashes exported tests css modules localsConvention with dashes 1`] = ` Object { - "btn--info_is-disabled_1": "-_273d87445e861b3031dc-btn--info_is-disabled_1", - "btn-info-is-disabled": "-_273d87445e861b3031dc-btn-info_is-disabled", - "btn-info-is-disabled-1": "-_273d87445e861b3031dc-btn--info_is-disabled_1", - "btn-info_is-disabled": "-_273d87445e861b3031dc-btn-info_is-disabled", - "foo-bar": "-_273d87445e861b3031dc-foo_bar", - "foo_bar": "-_273d87445e861b3031dc-foo_bar", - "simple": "-_273d87445e861b3031dc-simple", + "btn--info_is-disabled_1": "-a7200a43b5c2530b1414-btn--info_is-disabled_1", + "btn-info-is-disabled": "-a7200a43b5c2530b1414-btn-info_is-disabled", + "btn-info-is-disabled-1": "-a7200a43b5c2530b1414-btn--info_is-disabled_1", + "btn-info_is-disabled": "-a7200a43b5c2530b1414-btn-info_is-disabled", + "foo-bar": "-a7200a43b5c2530b1414-foo_bar", + "foo_bar": "-a7200a43b5c2530b1414-foo_bar", + "simple": "-a7200a43b5c2530b1414-simple", } `; exports[`config config/builtins/css-modules-pseudo exported tests css modules pseudo syntax 1`] = ` Object { - "bar": "-_273d87445e861b3031dc-bar", - "bav": "-_273d87445e861b3031dc-bav", - "foo": "-_273d87445e861b3031dc-foo", - "four": "-_273d87445e861b3031dc-four", - "one": "-_273d87445e861b3031dc-one", - "three": "-_273d87445e861b3031dc-three", - "two": "-_273d87445e861b3031dc-two", + "bar": "-a7200a43b5c2530b1414-bar", + "bav": "-a7200a43b5c2530b1414-bav", + "foo": "-a7200a43b5c2530b1414-foo", + "four": "-a7200a43b5c2530b1414-four", + "one": "-a7200a43b5c2530b1414-one", + "three": "-a7200a43b5c2530b1414-three", + "two": "-a7200a43b5c2530b1414-two", } `; exports[`config config/builtins/css-modules-simple exported tests css modules simple test 1`] = ` Object { - "style": "-_921b05f8c9c16ca9ea84-style", + "style": "-ca56f23580d7bbb484-style", } `; @@ -245,17 +245,17 @@ exports[`config config/css/export-selector exported tests should have correct cs " `; -exports[`config config/css/rewrite-url exported tests should rewrite the css url() 1`] = `"eb587e4780c414fe3a22.png"`; +exports[`config config/css/rewrite-url exported tests should rewrite the css url() 1`] = `"95988e500e4d2ddfeeb7.png"`; exports[`config config/css/rewrite-url exported tests should rewrite the css url() 2`] = `"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAOCAYAAAAbvf3sAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAEWSURBVHgBjZFRSsNAEIb/3fQAOUK9gfpe6YIovjU3UE+gJ2g8gTcw3sC+itUFrW+BeAN7ATFSKAjbHWcSC+mSlszLDrvfzvzzj0LHmNpZBtBQd4Gf7fuYgHPPueoCe1DK1UsHd7Dzw+P0daQj/SC5h09OzdGktw221vZXUBlVMN0ILPd6O9yzBBXX8CBdv6kWOGa4YLivQJNjM0ia73oTLsBwJjCB5gu4i7CgbsIey5ThEcOfKziTGFOGHypJeZ7jZ/Gbst4x2/fN9h2eGTNvgk92VrDEWLNmfJXLpIYrRy5b4Fs+9v2/pL0oUncI7FuHLI6PK5lJZGoe8qXNvrry27DesoRLpLPmNkTw9yEcxPWJMR+S/AFbfpAZqxwUNQAAAABJRU5ErkJggg=="`; -exports[`config config/css/rewrite-url-css-variables exported tests should rewrite the css url() in css variables 1`] = `"eb587e4780c414fe3a22.png"`; +exports[`config config/css/rewrite-url-css-variables exported tests should rewrite the css url() in css variables 1`] = `"95988e500e4d2ddfeeb7.png"`; -exports[`config config/css/rewrite-url-css-variables exported tests should rewrite the css url() in css variables 2`] = `"eb587e4780c414fe3a22.png"`; +exports[`config config/css/rewrite-url-css-variables exported tests should rewrite the css url() in css variables 2`] = `"95988e500e4d2ddfeeb7.png"`; -exports[`config config/css/rewrite-url-with-css-filename exported tests should rewrite the css url() with publicPath and ~@ prefix 1`] = `"/image/logo.eb587e47.png"`; +exports[`config config/css/rewrite-url-with-css-filename exported tests should rewrite the css url() with publicPath and ~@ prefix 1`] = `"/image/logo.95988e50.png"`; -exports[`config config/css/rewrite-url-with-css-filename exported tests should rewrite the css url() with publicPath when output.cssFilename is set 1`] = `"/image/logo.eb587e47.png"`; +exports[`config config/css/rewrite-url-with-css-filename exported tests should rewrite the css url() with publicPath when output.cssFilename is set 1`] = `"/image/logo.95988e50.png"`; exports[`config config/css/urls exported tests css urls should works 1`] = ` "/* @supports (background-image: url(\\"unknown.png\\")) { @@ -302,7 +302,7 @@ div { div { a1: url(); - a114: url(ebb93b9cb62e55bcbc35.png); + a114: url(4d3b8fdfbe46b279f223.png); } div { @@ -387,10 +387,10 @@ exports[`config config/schemes/data-imports exported tests data imports 1`] = ` .class { - a: url(bd595024fc7e226eea64.svg); - b: url(bd595024fc7e226eea64.svg); - c: url(bd595024fc7e226eea64); - d: url(bd595024fc7e226eea64); + a: url(3a4d6b1f7ae9358a676b.svg); + b: url(3a4d6b1f7ae9358a676b.svg); + c: url(3a4d6b1f7ae9358a676b); + d: url(3a4d6b1f7ae9358a676b); } " diff --git a/packages/rspack-test-tools/tests/__snapshots__/StatsAPI.test.js.snap b/packages/rspack-test-tools/tests/__snapshots__/StatsAPI.test.js.snap index 6f3f4683518..142957a81c4 100644 --- a/packages/rspack-test-tools/tests/__snapshots__/StatsAPI.test.js.snap +++ b/packages/rspack-test-tools/tests/__snapshots__/StatsAPI.test.js.snap @@ -102,7 +102,7 @@ Object { "errors": Array [], "errorsCount": 0, "filteredModules": undefined, - "hash": "57e46af248a1c1fe076f", + "hash": "ee9a5ee8da42dac2c2aa", "logging": Object {}, "modules": Array [ Object { @@ -402,7 +402,7 @@ Object { "errors": Array [], "errorsCount": 0, "filteredModules": undefined, - "hash": "4b5e3314a79376e83a18", + "hash": "36dd148024fa89ee453a", "logging": Object {}, "modules": Array [ Object { @@ -968,7 +968,7 @@ exports.c = require(\\"./c?c=3\\"); "errors": Array [], "errorsCount": 0, "filteredModules": undefined, - "hash": "aa85e38b2dc3e3f7dbda", + "hash": "4fed4a0fec64e42d02f8", "logging": Object {}, "modules": Array [ Object { diff --git a/packages/rspack-test-tools/tests/__snapshots__/StatsOutput.test.js.snap b/packages/rspack-test-tools/tests/__snapshots__/StatsOutput.test.js.snap index f7aefb1c36a..97114eeefb4 100644 --- a/packages/rspack-test-tools/tests/__snapshots__/StatsOutput.test.js.snap +++ b/packages/rspack-test-tools/tests/__snapshots__/StatsOutput.test.js.snap @@ -2,8 +2,8 @@ exports[`statsOutput statsOutput/auxiliary-files-test should print correct stats for auxiliary-files-test 1`] = ` "PublicPath: auto +asset a09d8e0f399c215faa79.png 7 bytes {909} [emitted] [from: raw.png] (name: main) asset bundle.js 2.4 KiB {909} [emitted] (name: main) -asset f7f4f00355f310234f70.png 7 bytes {909} [emitted] [from: raw.png] (name: main) Entrypoint main 2.4 KiB = bundle.js chunk {909} bundle.js (main) [entry] ./raw.png [193] {909} @@ -33,7 +33,7 @@ webpack/runtime/auto_public_path {909} [no exports] [used exports unknown] -Rspack compiled successfully (ad3050f7790e51415050)" +Rspack compiled successfully (96c9a0233f5bdeaa93e8)" `; exports[`statsOutput statsOutput/builtin-swc-loader-parse-error should print correct stats for builtin-swc-loader-parse-error 1`] = ` @@ -60,7 +60,7 @@ Entrypoint main 654 bytes = main.js ERROR in × Resolve error: Can't resolve './src' in 'Xdir/css-concat-error' -Rspack x.x.x compiled with 1 error in X s (6a173f34164e1af948e4)" +Rspack x.x.x compiled with 1 error in X s (8808376bbd25437de260)" `; exports[`statsOutput statsOutput/filename should print correct stats for filename 1`] = ` @@ -71,7 +71,7 @@ Entrypoint main 8.73 KiB = 909.xxxx.js runtime modules 11 modules ./index.js ./dynamic.js -Rspack x.x.x compiled successfully in X s (185b80456c181897fcd5)" +Rspack x.x.x compiled successfully in X s (a41322d0088be2cf18dc)" `; exports[`statsOutput statsOutput/hot+production should print correct stats for hot+production 1`] = ` @@ -80,7 +80,7 @@ asset main.js 32.1 KiB [emitted] (name: main) Entrypoint main 32.1 KiB = main.js runtime modules 11 modules ./index.js -Rspack x.x.x compiled successfully in X s (db903683225d0fe50e7b)" +Rspack x.x.x compiled successfully in X s (bda0662c38188eca4d63)" `; exports[`statsOutput statsOutput/ignore-plugin should print correct stats for ignore-plugin 1`] = ` @@ -133,7 +133,7 @@ exports[`statsOutput statsOutput/limit-chunk-count-plugin should print correct s ./d.js ./e.js ./index.js - 1 chunks (Rspack x.x.x) compiled successfully in X s (0d76b7dadd0c657ad341) + 1 chunks (Rspack x.x.x) compiled successfully in X s (9343a795eebf86cac89a) 2 chunks: PublicPath: auto @@ -147,7 +147,7 @@ exports[`statsOutput statsOutput/limit-chunk-count-plugin should print correct s chunk bundle2.js (main) >{76}< [entry] ./b.js ./index.js - 2 chunks (Rspack x.x.x) compiled successfully in X s (a80080d4a166d3a145b2) + 2 chunks (Rspack x.x.x) compiled successfully in X s (58d446010942300c8786) 3 chunks: PublicPath: auto @@ -163,7 +163,7 @@ exports[`statsOutput statsOutput/limit-chunk-count-plugin should print correct s chunk bundle3.js (main) >{76}< [entry] ./b.js ./index.js - 3 chunks (Rspack x.x.x) compiled successfully in X s (0e854af4043d4cced12b) + 3 chunks (Rspack x.x.x) compiled successfully in X s (e1f702c28a1f7745f19e) 4 chunks: PublicPath: auto @@ -181,7 +181,7 @@ exports[`statsOutput statsOutput/limit-chunk-count-plugin should print correct s chunk bundle4.js (main) >{76}< [entry] ./b.js ./index.js - 4 chunks (Rspack x.x.x) compiled successfully in X s (4525b2f4f1626b91a6f4)" + 4 chunks (Rspack x.x.x) compiled successfully in X s (799760b5db8d720723c3)" `; exports[`statsOutput statsOutput/logging-loader should print correct stats for logging-loader 1`] = ` @@ -311,7 +311,7 @@ ERROR in ./index.js ╰──── help: maybe it had cyclic aliases -Rspack x.x.x compiled with 1 error in X s (59974c3941ac297dceb3)" +Rspack x.x.x compiled with 1 error in X s (1610bb37730c587998bd)" `; exports[`statsOutput statsOutput/resolve-unexpected-exports-in-pkg-error should print correct stats for resolve-unexpected-exports-in-pkg-error 1`] = ` @@ -324,7 +324,7 @@ runtime modules 1 module ERROR in ./index.js × Invalid \\"exports\\" target \\"../../index.js\\" defined for '.' in the package config Xdir/resolve-unexpected-exports-in-pkg-error/node_modules/pkg-a/package.json -Rspack x.x.x compiled with 1 error in X s (c1888f6bacf659a49dc3)" +Rspack x.x.x compiled with 1 error in X s (b45f1a2adf9c9eae762e)" `; exports[`statsOutput statsOutput/runtime-modules should print correct stats for runtime-modules 1`] = ` @@ -347,7 +347,7 @@ Entrypoint main 1.66 KiB = main.js ./increment.js [exports: decrement, increment, incrementBy2] [only some exports used: increment] -Rspack x.x.x compiled successfully in X s (962310b17150e819242d)" +Rspack x.x.x compiled successfully in X s (9efe9f85d71294bf4e5f)" `; exports[`statsOutput statsOutput/side-effects-bailouts should print correct stats for side-effects-bailouts 1`] = ` @@ -382,7 +382,7 @@ webpack/runtime/define_property_getters {909} [no exports] [used exports unknown] -1970-04-20 12:42:42: Rspack x.x.x compiled successfully in X s (6407ed847eb679304311)" +1970-04-20 12:42:42: Rspack x.x.x compiled successfully in X s (c4f7bcbb8ec6a06a4661)" `; exports[`statsOutput statsOutput/simple-export should print correct stats for simple-export 1`] = ` @@ -391,7 +391,7 @@ asset bundle.js 1.79 KiB [emitted] (name: main) Entrypoint main 1.79 KiB = bundle.js runtime modules 3 modules ./index.js -Rspack x.x.x compiled successfully in X s (28af2d7a47e4039ec00e)" +Rspack x.x.x compiled successfully in X s (a3d8bfb29f0f2ccec405)" `; exports[`statsOutput statsOutput/simple-module-source should print correct stats for simple-module-source 1`] = ` @@ -402,7 +402,7 @@ runtime modules 3 modules orphan modules [orphan] 1 module ./raw.png ./index.js -Rspack compiled successfully (de1220b5052bdbe79250)" +Rspack compiled successfully (d0ce130488abf5f87f64)" `; exports[`statsOutput statsOutput/stats-hooks should print correct stats for stats-hooks 1`] = ` @@ -410,7 +410,7 @@ exports[`statsOutput statsOutput/stats-hooks should print correct stats for stat asset main.js 764 bytes [emitted111] (name: main) [testA: aaaaaa] Entrypoint main 764 bytes = main.js ./index.js -Rspack compiled successfully (baea1f1033101ca9fde6)" +Rspack compiled successfully (d55a67420c97eab0f0a6)" `; exports[`statsOutput statsOutput/try-require-module should print correct stats for try-require-module 1`] = ` diff --git a/packages/rspack-test-tools/tests/builtinCases/plugin-asset/asset-simple/snapshot/output.snap.txt b/packages/rspack-test-tools/tests/builtinCases/plugin-asset/asset-simple/snapshot/output.snap.txt index 078cd8d499f..6d3d378e46a 100644 --- a/packages/rspack-test-tools/tests/builtinCases/plugin-asset/asset-simple/snapshot/output.snap.txt +++ b/packages/rspack-test-tools/tests/builtinCases/plugin-asset/asset-simple/snapshot/output.snap.txt @@ -40,7 +40,7 @@ function createImageElement(title, src) { module.exports = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QCMRXhpZgAATU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAIdpAAQAAAABAAAAWgAAAAAAAABIAAAAAQAAAEgAAAABAAOgAQADAAAAAQABAACgAgAEAAAAAQAAAJagAwAEAAAAAQAAAJYAAAAA/+0AOFBob3Rvc2hvcCAzLjAAOEJJTQQEAAAAAAAAOEJJTQQlAAAAAAAQ1B2M2Y8AsgTpgAmY7PhCfv/CABEIAJYAlgMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAADAgQBBQAGBwgJCgv/xADDEAABAwMCBAMEBgQHBgQIBnMBAgADEQQSIQUxEyIQBkFRMhRhcSMHgSCRQhWhUjOxJGIwFsFy0UOSNIII4VNAJWMXNfCTc6JQRLKD8SZUNmSUdMJg0oSjGHDiJ0U3ZbNVdaSVw4Xy00Z2gONHVma0CQoZGigpKjg5OkhJSldYWVpnaGlqd3h5eoaHiImKkJaXmJmaoKWmp6ipqrC1tre4ubrAxMXGx8jJytDU1dbX2Nna4OTl5ufo6erz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAECAAMEBQYHCAkKC//EAMMRAAICAQMDAwIDBQIFAgQEhwEAAhEDEBIhBCAxQRMFMCIyURRABjMjYUIVcVI0gVAkkaFDsRYHYjVT8NElYMFE4XLxF4JjNnAmRVSSJ6LSCAkKGBkaKCkqNzg5OkZHSElKVVZXWFlaZGVmZ2hpanN0dXZ3eHl6gIOEhYaHiImKkJOUlZaXmJmaoKOkpaanqKmqsLKztLW2t7i5usDCw8TFxsfIycrQ09TV1tfY2drg4uPk5ebn6Onq8vP09fb3+Pn6/9sAQwAEBAQEBAQEBAQEBgYFBgYIBwcHBwgMCQkJCQkMEwwODAwODBMRFBAPEBQRHhcVFRceIh0bHSIqJSUqNDI0RERc/9sAQwEEBAQEBAQEBAQEBgYFBgYIBwcHBwgMCQkJCQkMEwwODAwODBMRFBAPEBQRHhcVFRceIh0bHSIqJSUqNDI0RERc/9oADAMBAAIRAxEAAAH3/bVttW21baKnVRdMbDMXyabbBttq22rbattq22rYHP6891zzLej5UdFzvRA89aVe25+zccNc8HqdBkL4+/baO21bbUije0vZ57JOV6PkJJbUePVfMfJK3pz94p/PvTcXZa0qziW+5y2x6Oklk98v2ttg221cY/rwez890jA3P8vfwVF6d5z7fjt9t1cu2sVN76hzbzwvdvqnMLG06fmOn5O/bbl7dtq4sBwe581d+J+2eJu7n0fyHdfP3XF9L6by9XJOOGpdM3fSch1++PfsLCv87otOn5jp/P8AV225e3bauLAcHufNXfiftvj7a0m29by49b8k9c8/0PJNt6Hn7r+Q7zm6uzr37Dzui06fmOn8/wBXbbl7dtq4yytec9LyLUVHtMWPm/r1nsvgnrlN0bN41ad/1GmNJdVA+TbpK6ss0eenbuOD0ttsujbatX2GZOOa91Ud3mc5ii7fPedDyPRcndSg26+HZ10OPRS9A63nerttj07bVttW21bbUijv9pjwvQWUdHLyV9aEV4nbl7dtq22rbattq22rbattq22rbattq22rbattq//aAAgBAQABBQL/AFXLdIQ5JSiKOdEn8/JOiNyTrk7T/wCLOO6WhokRIP5pciIxJdKV9yf/ABbsCQY7thQUPvFQSJLtkknslClkW8cSU7rt8y5LRkEd0LUgx3aVfeVyZ3Jbrj7AEmO0d1vNtbC5u7i7U7TcrmzdvuFlfuS1WnvHaqU0KiSfuSfvY7pSWYYZ3d3cO2ou9xubz71nvFzbOIwX8P0Fs5LhcjtP3v3Jf3jsuKN4gVJdbJHIJIpIV97a0nu1Q7ZZbei23YXd5c/vnafvfuS/vHZcbn/GbW+uLMxX1huibzZJoWiNci7TYwBc7zb26Zp5rhex/wCP3P752n737kv7x2XG5/xntZ7vcWruLqK2tru/ubw9tj/x+5/fO0/e/cl/eOy43P8AjPY8Nz/2j99j/wAfuf3ztP3v3Jf3jsuN/bzQXHY8Nz/2j99jt5vebn987T979yQEyx2jVcRxAXEcqbvYkLcsMsCzw3P/AGju2s7i7VbbPa2oVdsLhuBJbLQ7T979whMQknXJ3RKuNlVtdovNikS76CaXa7TY442q4RGlSlLPaK5WlhCa/dkt0SOSFcf3I51xuSXCJci5PuR2y1uOJEf8zJaJU1oUg9p/8W7RwrkcduiP+cKQoSWjIIc/+LJQpZjtEj/UC40SBUSVISkJH+q//9oACAEDEQE/Aez38X3/AHXsFmmM4zG6Bsd+bqMeH8R5/IeXN1eTLx+GP5B6f+H1X/WNhknjNwlTh66MuMv2n8/R88js6rJn23hrZ6yjyXkn8yjpxCPudTP24/l/aKevjj+3p8I2eu7kyY/pup/hS9vJ/iS8H/A5Mc8Rqcaemn1AlWHkeoPhjLcPI/rX56+7PFlmYSr7ijJi9uOT7MWXJYEq4sPVYuohPdnuV/2vIOkYykRGIJJ9A9OJ4xHF1mQHdxHGeS588gZYYfZCJIoer0H8D/go6z/HP/CXqv8AJOm/wy/2rh6vJhGz8eP1hLwx6fpOpEsuOZxiPM4kXX+Bl1cMIOPo4bR6zP4i9KTLqsJJsmYc/wDGy/7/AJeg/gf8FHWf45/4S9SCej6cgcAyv/X06L+F13/WLTowT1OGhf3Bz/xsv+/5eg/gf8FHWePD08jLN98ybEfR/WZt18bf8WuGWHpup/AfZyfl/ZL0/T5sMOthOBs4+P6/4GHQiAE+qnsH+KPxFPUbBs6aHtx/2JRmxZ/tzxqX+PH/AHy9PiOHHsJvm9ZwjkG2cbDm6Aj7sJsfkUgg0RRemy5Biz/cfthY/okmRuRsuHpcmbkCo/mXD02LDyBcvzPdlwY8w++P+f1YdJLGM8RIETjQcPRY8fM/ul/sPr//2gAIAQIRAT8B7Payfb9v4jQZRlE1IUe/Hhnl8Dj83F08MfPmX5lzfj6f/f8AZwjMVIW5eklHnHyPy9e3BDFf8z8X5Hw+H3ZZJbOnhvl+foGPxxmN2fMd/pt8RZw6jpvxj3Mf+NHz/nYTjMXE2544SLycH8/VkKPr/n19uGSERIegRjyHJKFSy48dExvmi9Nl6ecNuCo1/Z8EaSlGAMpEAD1L1GzKZZekxEbOZZBwHFijUcsvukRfL1f8X/MNY/hj/gD0X+VdT/gi5ukxZjv/AAZPScfKc/V9MY4skBlMuISBqz/Vj0k8xGTrJ7vygPwh6kCPS5gBQEC4v4WP/f0PV/xf8w1j+GP+APRyA6vqATyRGtOs/jdD/wBZdOsIHTZrNfaQ4v4WP/f0PV/xf8w1jPJmG3H9sRwZer+mx163/jXyw6nqOn4yfzcf5/2g5+ow5Z9FOExQy83xX+FydfZMOljvP+Mfwh9o5Dv6iZnL/YB9vJi5wm4/4pc2T3J7qrjWMpQNxNFxdWDxk4/qgg8gufHD3MP2/ilRQABQFBydRDH62fyDkzzyeTQ/Id2PLPGftP8AmZdTGZxEitsrLl6qc+I/aP8AY/X/AP/aAAgBAQAGPwL/AFXRPUf1NMnyfofT+f11Po/QenZH+T2orqH630n+bqouiOkfr+4j/J71B1dJPxdUmo+/VRoHSP8AF1Jqe9EirMlwsUHHyDMGdBwBUKJPydYjUejoe9UmjovQ/q+8UE9QdeKfXtQDV5Smg9GY7VIkV8PZH2+bynkr6DyH2dgEKyj/AGFcPs9GEK6Jf2VcfsLqnqH6+9V6D9b5SPur/tF0XqP1vJB/Bj6JRKuFB/CXSRdEfsJ4f6P3gmT6WP0VxH2tMyUqTX1FC/VX63Tgl/5J+7J/aPaT7HNbXsYCc1Jy4pIBpq+dYLGuuFek/IsxyoKVeh+5jBHX1PkPmXz72RKlD9r2R8h5sQRR0ixUaniaNX2dv8k/dk/tHtJ9juP92r/4M6wr6fNB9ksQ3SAmTyCvX+SWV230qPT8w/uvloQVL/ZA1fNvlaccAf4S+RYISaaV/IPl6vmTSFSvj/U0/wC61tX2dv8AJP3ZP7R7SfY7n/dq/wDg3cJX9LF6K4j5F++iGpWE/AmvCr+lV0fsD2e6f91ravs7f5J+7J/aPaT7Hc/7tX/wbuXD/wAI/cT/ALrW1fZ2/wAk/dk/tHtJ9jlMsZAVIopPkanuXD/wj9wXHLPKwUMj8fRq+zt/kn7qwP2i6y6fB4RD+4zHcIFDx8w+ZZKp/IPD7C+XMgoV6Flw/wDCPakEdR5q4JH2sSXJEi/j7I+x/Rp0+LxUKKdU9Q/W/wDJP3VLSip+D14enfpP2PlXMY+3+pqXZqzH7B4/YXDDHGTJ9Fp8nzL1eX8gez9vqxHAgUHD0dVGvcJPUP1vmY0VT71eCvV6jT1+56j0LElONP1vqP3KnpD6R9v8zVGh/U6KFO6P8nv0jT1deKvX+cooVDrH+DoRq0f5LokVdZNT6eX+oKKDCDwFP1OiRQf6s//EADMQAQADAAICAgICAwEBAAACCwERACExQVFhcYGRobHB8NEQ4fEgMEBQYHCAkKCwwNDg/9oACAEBAAE/If8A9LkP6VQsCuz5uePtf1/+flr0ubPi+l/f/wCBIj+lWcT+Ts//AC8w/B22b/sX/wCD9L/oEoHZXIGfX+ylieQ//G0IHbecfv8A0VUpO3/sw6odJTJh+Wr3gyxe3VQPMJc/TUUETp/7Lmv02IH3f4yiOn/4ZOgp4T4s8D1P7/4CUrouGI2D/LQDPJw3v+iyARZ4fi/4/PKf9lG6DhI/tWZ/pX/PRYz4bt/qkX0FzY+//wAOVP8ABsZ8t/jbwU3f9yv/AMGC+3CtPgeX3/2//FKKPsy9f7XpDl/+8e7Ay8Pyv9WeHxH9t/zPj/8AD/iPP/P0KB8DwlAR6+eLmwEFL+CpQ/yMPz7P/wAElkXXLBDYk4b9ixPrudCIOjb+v/D/AJz/AOHH/wCH/Eef+foV/n/K91KdH0dfJUqrkfl5f3Z7PLcGurGj7HX3RQwajB/n1cG3AkfAKdeUuB6HRf8AEer+v/D/AJz/AOHH/wCH/Eef+foV/k/L/sukO7L/AAxrvjBI8ieqqxlmY+fL8/8Af8R6v6/8P+c/+HH/AOH/ABHn/n6Ff5Py/wC/oN/S/p/+D/Eer+v/AA/5z/4cf/h/xHn/AJ+hXXYdoiQ+fX/f0G/pf0//AATyI4ELCNc39f8Ah/zn/wAOP/wgYqwB81naHhz9tjDU8cP91skokS/JQEbdll/wVh4Nefjz9X9Bv6X9P+T6Awn5H+lJOtzDeu33Y0Aj+X+qO8IHn6bOf0q8/wD+EZKjLyd/q5ajxcf9ZnPvo2dCPXGfK6abgLrB/Q/dyWZ1TEzPEUQIjZIHy5/hRxCiBB+Cyjr3/wBbA9R/StIka6d8/wD4p6Hqf3ezvBx/+DHH/EywhNwFpyZ/B0f/AIIv5F5fgo/Z2uf/AMhBxswvq/xllzX6f/xIn+Q4scj3P6//ADGxE6a5Kz7/ANNZVA6f+JNuv4sSn+R90AIOP/z9w/D2VF39ygxPAf8A6Z//2gAMAwEAAhEDEQAAEAAABDigAAAAABwvg5QwAAHQ1gOR/ogACa6AB62QAAKawFmNIQQAKZgEgFCQQAIAVRCMlCwAEbyvYAEwAAAAA+iAAAAAAAAAAAAAAP/EADMRAQEBAAMAAQIFBQEBAAEBCQEAESExEEFRYSBx8JGBobHRweHxMEBQYHCAkKCwwNDg/9oACAEDEQE/EPwOxD9QgIuFvk/GMmvx5v8Ai0w/1b835v1352/y+c6fzPmzyPou3+IQCCPInX4NTR1Rgne/S+6R/NWBB+Fc/kEoF9esff6XwR/k5vutbl8b0/kxgnb6D+f0i1ETjTQHZvooy5D4efkhccWdhM/jZcnwN/wH/XnAzYDVuBr+A14FfiK06ReDnL97p9P1r6+PNFiccjH2+kAPeuH1X0tKMZy/8BKWQKuq783679fwJ+tfWe46YODeG+fpPs+b4YZw3Ae2/Xfr+BNwkgmHX5fmeIzjOLj9MuSJfn3fb6QgWPPJ27HdsG+Tm/wQ5wfk5y+qwB8NC5/h82QPKE40fVoG+H/Vt/uC/h+ZU4OETEjEy5nnX22eNTtXWwv2Ffx9bE/dF/H0/FhNH4HA/m15JXh372Jn97p/Hz/P/wB//9oACAECEQE/EPwGTUdjxrImh8P43ty+a6/7Y6P6R+RfrPysdx/U/K0G/pH+ZEUTE7H8GebO4eL6Z9bgfAB+QEIM+YcfnMgVx9FPtvdvOd8XA+yx3H9T8yeufAP02XJAPJjFPr6g29T8nHw3CDR5X9zI99QZ/kH+/OQmymBPNWeQ85QPlmIo2uebzwXf7fr30v0b6WQaHPAD9/rODv8AjgFqTnK8/wAkYYGAYBnxfqH0u/2/XvpFFMIvLh8efp/y8xz0TXNU6PvfqH0u/wBj+JBHPA+CDy63v1H1soEvj1ff6zsWrbXXo9XHC8PF/kn7KE8flBO35ovx/DFlXAI/U9EP+oWIevp6/kgQCPSckxMfC8afxChB0BhbY/onP0t8/YT+fr+LTcfyuR/iYasA54+1ofxvb+f/AL//2gAIAQEAAT8Q/wD0pQ1uIxnh09vfwWXj5pBjseLHee5v27//ADx3wXf7ePutS/34/Ll/ivD8X9b+N4hOS7DDJXD0vP3YFIcmfIf/AJcCEvZ8B3Y9KZI4e3r6rKqsrr/x4b/mfH/ePIiQlyHcQ7/h2VoI4ST/APHzIQSCs45xDv8Ah23myAkr/wBD9gwYfLwXIGqwnkiaUeVF4oFjHSxPVaTIghj8D93AuyEJ9P8A3yLCN+Q4bFNxx5f480AQRJE0f/wlMB8mUML0S5IXToenX8f848iBK1CBBIAgfQHxZcpyoTwavt7aJy4vx7B9svu+ffNTgt1ET2/gz1UfCQMz6M+Jvksq0NgID2d/VRFEhMR6oKgKrABKvqz7eeNBhlaOEImfLf8A8LUiIwjCPhY5vHHh8/4aMT6JwJ8icNDk+Cgbxvo5eiy7l5Mf7r8PX/4f/v4o78Mwk88yB1P5KAaGpKfOeISPTQlZMLHwjpZkTd+p+z4vJ/hv/wCMh/hfLcU1tyh5VBuu2WAvmHHxz8Bk+LugfEPDr2Cn/wCBZgz8zmD6JfVWloAgdB5fCsvgKxdHzgUHPe30X/IeH/P8B5//ABkP8L5biG6HULQ+dPc+h8zcb8QxIiHCeBnpYQ5KcBejA/EPprZ4TQownJDtgHdPL+ARzxZ5IHtovo435wF/EHuoU8wmL0M9QfP/AD//ACHh/wA/wHn/APGQ/wAL5f8Au1BEQR5EkaWCetQeeXOpD4oNI6DUYHOS3mOqaR8puySHJefoF55/7/8A5Dw/5/gPP/4yH+F8v/4Nv+C8f/ic/wD8h4f8/wAB5/8AxkP8L5aq75ExtMmHVvr/AL/gvH/4HPPra0y3Dj1gnOTPd/yHh/z/AAHn/wDCJG0CV9AoRFdm4fo+q1xZOG+e1wJqsL5JimdiD/yp9Rk+KOETwIHbJD7SX/BeP+uaAoGR7Mn1J9VrJgwDSeZnmXoK4+UJEQOgOFNFBogP7vi7qHcMPZ39X/AeT/8AC3n0aVU6vHwqL4fn9vP3/wBmoEym/Mf2VpwMCfqL4nGq0dIwkcwHwQfbVVgYgjwAENnija4S/wAd9hno3EFqSnRxWvkFceg6P+pCDHIfl38NkO0JMIMAyc//ABRJI6eX04f5rq7Ob/fx9/8A4IuG90n25KwuDgg+SeLJ4Dhz4j/8Ea5dhw/w1sK3kaH9/wBH/wCQAgIkI6JYpuefL/Hi+DYLvwPD/wAeG/rfx/6SxnuZ+PP1cwLpwfTr+f8A8zmogElyHcy7/h5vL8QIS/rfxvnIEcfJ4LEpzQ4fNAgAEAEAf/nwpQ4M+BKhz0GHol990aI4CD/9M//Z";}), "./images/file.png": (function (module, __unused_webpack_exports, __webpack_require__) { "use strict"; -module.exports = __webpack_require__.p + "7baf20ff2eb011d3.png";}), +module.exports = __webpack_require__.p + "cee6b2eecb9ff70a.png";}), "./images/file.svg": (function (module) { "use strict"; module.exports = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2MDAgNjAwIj48dGl0bGU+aWNvbi1zcXVhcmUtc21hbGw8L3RpdGxlPjxwYXRoIGZpbGw9IiNGRkYiIGQ9Ik0zMDAgLjFMNTY1IDE1MHYyOTkuOUwzMDAgNTk5LjggMzUgNDQ5LjlWMTUweiIvPjxwYXRoIGZpbGw9IiM4RUQ2RkIiIGQ9Ik01MTcuNyA0MzkuNUwzMDguOCA1NTcuOHYtOTJMNDM5IDM5NC4xbDc4LjcgNDUuNHptMTQuMy0xMi45VjE3OS40bC03Ni40IDQ0LjF2MTU5bDc2LjQgNDQuMXpNODEuNSA0MzkuNWwyMDguOSAxMTguMnYtOTJsLTEzMC4yLTcxLjYtNzguNyA0NS40em0tMTQuMy0xMi45VjE3OS40bDc2LjQgNDQuMXYxNTlsLTc2LjQgNDQuMXptOC45LTI2My4yTDI5MC40IDQyLjJ2ODlsLTEzNy4zIDc1LjUtMS4xLjYtNzUuOS00My45em00NDYuOSAwTDMwOC44IDQyLjJ2ODlMNDQ2IDIwNi44bDEuMS42IDc1LjktNDR6Ii8+PHBhdGggZmlsbD0iIzFDNzhDMCIgZD0iTTI5MC40IDQ0NC44TDE2MiAzNzQuMVYyMzQuMmwxMjguNCA3NC4xdjEzNi41em0xOC40IDBsMTI4LjQtNzAuNnYtMTQwbC0xMjguNCA3NC4xdjEzNi41ek0yOTkuNiAzMDN6bS0xMjktODVsMTI5LTcwLjlMNDI4LjUgMjE4bC0xMjguOSA3NC40LTEyOS03NC40eiIvPjwvc3ZnPgo=";}), diff --git a/packages/rspack-test-tools/tests/builtinCases/plugin-css-modules/modules-composes/snapshot/output.snap.txt b/packages/rspack-test-tools/tests/builtinCases/plugin-css-modules/modules-composes/snapshot/output.snap.txt index e165812b439..55dd6c2480c 100644 --- a/packages/rspack-test-tools/tests/builtinCases/plugin-css-modules/modules-composes/snapshot/output.snap.txt +++ b/packages/rspack-test-tools/tests/builtinCases/plugin-css-modules/modules-composes/snapshot/output.snap.txt @@ -1,23 +1,23 @@ ```css title=main.css -._f_module__f-1--____33039942d115f59c__33 { +.___f_module____f-1--___af10a85c64a6b515_af1 { color: black; } -._f_module__f--____33039942d115f59c__33 {} -._d_module__d-1--____3adea2b80c7f9bb9__3a { +.___f_module____f--___af10a85c64a6b515_af1 {} +.___d_module____d-1--___a41e34edaa1ca3c_a41 { color: green; } -._d_module__d--____3adea2b80c7f9bb9__3a {} -._b_module__b-1--____42eb20d659c9bbbb__42 { +.___d_module____d--___a41e34edaa1ca3c_a41 {} +.___b_module____b-1--___eca6dd2253f6b569_eca { color: red; } -._b_module__b--____42eb20d659c9bbbb__42 {} -._style_module__chain2--____7dc7309cdb55212a__7d { +.___b_module____b--___eca6dd2253f6b569_eca {} +.___style_module____chain2--___afc435275e612570_afc { background: blue; } -._style_module__chain1--____7dc7309cdb55212a__7d { +.___style_module____chain1--___afc435275e612570_afc { background: green; } -._style_module__root-class--____7dc7309cdb55212a__7d { +.___style_module____root-class--___afc435275e612570_afc { background: red; } @@ -34,30 +34,30 @@ __webpack_require__.r(__webpack_exports__); "./b.module.css": (function (module, __unused_webpack_exports, __webpack_require__) { "use strict"; __webpack_require__.r(module.exports = { - "b": "_b_module__b--____42eb20d659c9bbbb__42" + " " + "_b_module__b-1--____42eb20d659c9bbbb__42", - "b-1": "_b_module__b-1--____42eb20d659c9bbbb__42", + "b": "___b_module____b--___eca6dd2253f6b569_eca" + " " + "___b_module____b-1--___eca6dd2253f6b569_eca", + "b-1": "___b_module____b-1--___eca6dd2253f6b569_eca", }); }), "./d.module.css": (function (module, __unused_webpack_exports, __webpack_require__) { "use strict"; __webpack_require__.r(module.exports = { - "d": "_d_module__d--____3adea2b80c7f9bb9__3a" + " " + "_d_module__d-1--____3adea2b80c7f9bb9__3a", - "d-1": "_d_module__d-1--____3adea2b80c7f9bb9__3a", + "d": "___d_module____d--___a41e34edaa1ca3c_a41" + " " + "___d_module____d-1--___a41e34edaa1ca3c_a41", + "d-1": "___d_module____d-1--___a41e34edaa1ca3c_a41", }); }), "./f.module.css": (function (module, __unused_webpack_exports, __webpack_require__) { "use strict"; __webpack_require__.r(module.exports = { - "f": "_f_module__f--____33039942d115f59c__33" + " " + "_f_module__f-1--____33039942d115f59c__33", - "f-1": "_f_module__f-1--____33039942d115f59c__33", + "f": "___f_module____f--___af10a85c64a6b515_af1" + " " + "___f_module____f-1--___af10a85c64a6b515_af1", + "f-1": "___f_module____f-1--___af10a85c64a6b515_af1", }); }), "./style.module.css": (function (module, __unused_webpack_exports, __webpack_require__) { "use strict"; __webpack_require__.r(module.exports = { - "chain1": "_style_module__chain1--____7dc7309cdb55212a__7d" + " " + "_style_module__chain2--____7dc7309cdb55212a__7d" + " " + "c" + " " + __webpack_require__("./d.module.css")["d"] + " " + "e" + " " + __webpack_require__("./f.module.css")["f"], - "chain2": "_style_module__chain2--____7dc7309cdb55212a__7d" + " " + "e" + " " + __webpack_require__("./f.module.css")["f"], - "root-class": "_style_module__root-class--____7dc7309cdb55212a__7d" + " " + "_style_module__chain1--____7dc7309cdb55212a__7d" + " " + "a" + " " + __webpack_require__("./b.module.css")["b"] + " " + "_style_module__chain2--____7dc7309cdb55212a__7d" + " " + "c" + " " + __webpack_require__("./d.module.css")["d"] + " " + "e" + " " + __webpack_require__("./f.module.css")["f"], + "chain1": "___style_module____chain1--___afc435275e612570_afc" + " " + "___style_module____chain2--___afc435275e612570_afc" + " " + "c" + " " + __webpack_require__("./d.module.css")["d"] + " " + "e" + " " + __webpack_require__("./f.module.css")["f"], + "chain2": "___style_module____chain2--___afc435275e612570_afc" + " " + "e" + " " + __webpack_require__("./f.module.css")["f"], + "root-class": "___style_module____root-class--___afc435275e612570_afc" + " " + "___style_module____chain1--___afc435275e612570_afc" + " " + "a" + " " + __webpack_require__("./b.module.css")["b"] + " " + "___style_module____chain2--___afc435275e612570_afc" + " " + "c" + " " + __webpack_require__("./d.module.css")["d"] + " " + "e" + " " + __webpack_require__("./f.module.css")["f"], }); }), diff --git a/packages/rspack-test-tools/tests/builtinCases/plugin-css-modules/modules-ident-name/snapshot/output.snap.txt b/packages/rspack-test-tools/tests/builtinCases/plugin-css-modules/modules-ident-name/snapshot/output.snap.txt index 7801d3245c3..b038d1133ea 100644 --- a/packages/rspack-test-tools/tests/builtinCases/plugin-css-modules/modules-ident-name/snapshot/output.snap.txt +++ b/packages/rspack-test-tools/tests/builtinCases/plugin-css-modules/modules-ident-name/snapshot/output.snap.txt @@ -1,5 +1,5 @@ ```css title=main.css -._style_module__foo--____7dc7309cdb55212a__7d { +.___style_module____foo--___afc435275e612570_afc { color: hotpink; } @@ -17,7 +17,7 @@ console.log(_style_module_css__WEBPACK_IMPORTED_MODULE_0__); "./style.module.css": (function (module, __unused_webpack_exports, __webpack_require__) { "use strict"; __webpack_require__.r(module.exports = { - "foo": "_style_module__foo--____7dc7309cdb55212a__7d", + "foo": "___style_module____foo--___afc435275e612570_afc", }); }), diff --git a/packages/rspack-test-tools/tests/builtinCases/plugin-html/filename/snapshot/output.snap.txt b/packages/rspack-test-tools/tests/builtinCases/plugin-html/filename/snapshot/output.snap.txt index 3768c4159d7..b38fe8fc5b7 100644 --- a/packages/rspack-test-tools/tests/builtinCases/plugin-html/filename/snapshot/output.snap.txt +++ b/packages/rspack-test-tools/tests/builtinCases/plugin-html/filename/snapshot/output.snap.txt @@ -1,4 +1,4 @@ -```html title=default.248cbd4291badac0.html +```html title=default.ef8306b113a7b5d7.html @@ -10,7 +10,7 @@ ``` -```html title=index.248cbd4291badac0.html +```html title=index.ef8306b113a7b5d7.html diff --git a/packages/rspack-test-tools/tests/builtinCases/plugin-javascript/new-url-source/snapshot/output.snap.txt b/packages/rspack-test-tools/tests/builtinCases/plugin-javascript/new-url-source/snapshot/output.snap.txt index e5ec389d255..1568a39ffe6 100644 --- a/packages/rspack-test-tools/tests/builtinCases/plugin-javascript/new-url-source/snapshot/output.snap.txt +++ b/packages/rspack-test-tools/tests/builtinCases/plugin-javascript/new-url-source/snapshot/output.snap.txt @@ -9,10 +9,10 @@ img.src = imgSrc2; }), "./react.svg": (function (module, __unused_webpack_exports, __webpack_require__) { "use strict"; -module.exports = __webpack_require__.p + "ef0c5aab88bb335e.svg";}), +module.exports = __webpack_require__.p + "ef805cb3080d4db4.svg";}), "./vue.svg": (function (module, __unused_webpack_exports, __webpack_require__) { "use strict"; -module.exports = __webpack_require__.p + "7908863e290b1fc6.svg";}), +module.exports = __webpack_require__.p + "adc3645d19cb2dbe.svg";}), },function(__webpack_require__) { var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId) } diff --git a/packages/rspack-test-tools/tests/builtinCases/plugin-wasm/imports-multiple/snapshot/output.snap.txt b/packages/rspack-test-tools/tests/builtinCases/plugin-wasm/imports-multiple/snapshot/output.snap.txt index 80391e585b9..dd02754f2da 100644 --- a/packages/rspack-test-tools/tests/builtinCases/plugin-wasm/imports-multiple/snapshot/output.snap.txt +++ b/packages/rspack-test-tools/tests/builtinCases/plugin-wasm/imports-multiple/snapshot/output.snap.txt @@ -55,7 +55,7 @@ __webpack_async_result__(); "./wasm.wasm": (function (module, exports, __webpack_require__) { "use strict"; var __webpack_instantiate__ = function ([WEBPACK_IMPORTED_MODULE_0, WEBPACK_IMPORTED_MODULE_1]) { -return __webpack_require__.v(exports, module.id, "7ff106a99b84c158" , { +return __webpack_require__.v(exports, module.id, "99f401a36b8fee81" , { "./module": { "getNumber": WEBPACK_IMPORTED_MODULE_0["getNumber"] }, @@ -71,7 +71,7 @@ var WEBPACK_IMPORTED_MODULE_1 = __webpack_require__("./module2.js"); var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([WEBPACK_IMPORTED_MODULE_0, WEBPACK_IMPORTED_MODULE_1]); var [WEBPACK_IMPORTED_MODULE_0, WEBPACK_IMPORTED_MODULE_1] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__; - await __webpack_require__.v(exports, module.id, "7ff106a99b84c158" , { + await __webpack_require__.v(exports, module.id, "99f401a36b8fee81" , { "./module": { "getNumber": WEBPACK_IMPORTED_MODULE_0["getNumber"] }, diff --git a/packages/rspack-test-tools/tests/builtinCases/plugin-wasm/v128/snapshot/output.snap.txt b/packages/rspack-test-tools/tests/builtinCases/plugin-wasm/v128/snapshot/output.snap.txt index af4a0c1edce..e73655adfb5 100644 --- a/packages/rspack-test-tools/tests/builtinCases/plugin-wasm/v128/snapshot/output.snap.txt +++ b/packages/rspack-test-tools/tests/builtinCases/plugin-wasm/v128/snapshot/output.snap.txt @@ -13,7 +13,7 @@ __webpack_async_result__(); } catch(e) { __webpack_async_result__(e); } });}), "./v128.wasm": (function (module, exports, __webpack_require__) { "use strict"; - module.exports = __webpack_require__.v(exports, module.id, "1a19b30af21700aa" );}), + module.exports = __webpack_require__.v(exports, module.id, "83b6564dd2e8778e" );}), },function(__webpack_require__) { var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId) } diff --git a/packages/rspack-test-tools/tests/configCases/concatenate-modules/with-css/index.js b/packages/rspack-test-tools/tests/configCases/concatenate-modules/with-css/index.js index 55e36ab9f26..44d2c13b0f0 100644 --- a/packages/rspack-test-tools/tests/configCases/concatenate-modules/with-css/index.js +++ b/packages/rspack-test-tools/tests/configCases/concatenate-modules/with-css/index.js @@ -4,7 +4,7 @@ test; it("should concatenate css", () => { expect(styles).toMatchObject({ - foo: "foo_css__foo", - test: "foo_css__test" + foo: "__foo_css__foo", + test: "__foo_css__test" }); }); diff --git a/packages/rspack-test-tools/tests/configCases/container-1-0/init-sharing-without-config/index.js b/packages/rspack-test-tools/tests/configCases/container-1-0/init-sharing-without-config/index.js new file mode 100644 index 00000000000..4ba156ad866 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/container-1-0/init-sharing-without-config/index.js @@ -0,0 +1,4 @@ +it("should have single runtime chunk", () => { + __webpack_init_sharing__("default"); + expect(typeof __webpack_require__.I).toBe("function") +}); diff --git a/packages/rspack-test-tools/tests/configCases/container-1-0/init-sharing-without-config/webpack.config.js b/packages/rspack-test-tools/tests/configCases/container-1-0/init-sharing-without-config/webpack.config.js new file mode 100644 index 00000000000..3588b01b231 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/container-1-0/init-sharing-without-config/webpack.config.js @@ -0,0 +1,8 @@ +const { ModuleFederationPluginV1: ModuleFederationPlugin } = require("@rspack/core").container; + +/** @type {import("@rspack/core").Configuration} */ +module.exports = { + plugins: [ + new ModuleFederationPlugin({}), + ] +}; diff --git a/packages/rspack-test-tools/tests/configCases/css/deep-dir-local-path/deep/index.module.css b/packages/rspack-test-tools/tests/configCases/css/deep-dir-local-path/deep/index.module.css new file mode 100644 index 00000000000..5512dae453d --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/css/deep-dir-local-path/deep/index.module.css @@ -0,0 +1 @@ +.a {} diff --git a/packages/rspack-test-tools/tests/configCases/css/deep-dir-local-path/index.js b/packages/rspack-test-tools/tests/configCases/css/deep-dir-local-path/index.js new file mode 100644 index 00000000000..683c14cd667 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/css/deep-dir-local-path/index.js @@ -0,0 +1,7 @@ +import * as styles1 from "./index.module.css" +import * as styles2 from "./deep/index.module.css" + +it("should have different local ident name", async () => { + expect(styles1.a).toBe("__index_module-a"); + expect(styles2.a).toBe("__deep_index_module-a"); +}) \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/configCases/css/deep-dir-local-path/index.module.css b/packages/rspack-test-tools/tests/configCases/css/deep-dir-local-path/index.module.css new file mode 100644 index 00000000000..5512dae453d --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/css/deep-dir-local-path/index.module.css @@ -0,0 +1 @@ +.a {} diff --git a/packages/rspack-test-tools/tests/configCases/css/deep-dir-local-path/webpack.config.js b/packages/rspack-test-tools/tests/configCases/css/deep-dir-local-path/webpack.config.js new file mode 100644 index 00000000000..5013083269a --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/css/deep-dir-local-path/webpack.config.js @@ -0,0 +1,14 @@ +/** @type {import("@rspack/core").Configuration} */ +module.exports = { + module: { + generator: { + "css/auto": { + localIdentName: "[path][name]-[local]", + } + } + }, + mode: "development", + experiments: { + css: true + } +}; diff --git a/packages/rspack-test-tools/tests/configCases/css/rspack-issue-6435/a.module.css b/packages/rspack-test-tools/tests/configCases/css/rspack-issue-6435/a.module.css new file mode 100644 index 00000000000..38323d70965 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/css/rspack-issue-6435/a.module.css @@ -0,0 +1,3 @@ +.a-main { + color: green; +} \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/configCases/css/rspack-issue-6435/index.js b/packages/rspack-test-tools/tests/configCases/css/rspack-issue-6435/index.js new file mode 100644 index 00000000000..de15f3b57c5 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/css/rspack-issue-6435/index.js @@ -0,0 +1,7 @@ +import * as classes from "./style.module.css"; +import legacyClasses from "./legacy/index.css"; + +it("should have consistent hash", () => { + expect(classes["container-main"]).toBe(`${/* md4("./style.module.css") */ "ea850e6088d2566f677"}-container-main`) + expect(legacyClasses["legacy-main"]).toBe(`${/* md4("./legacy/index.css") */ "c15d43fe622e87bbf5d"}-legacy-main`) +}); diff --git a/packages/rspack-test-tools/tests/configCases/css/rspack-issue-6435/legacy/index.css b/packages/rspack-test-tools/tests/configCases/css/rspack-issue-6435/legacy/index.css new file mode 100644 index 00000000000..d863b4d5038 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/css/rspack-issue-6435/legacy/index.css @@ -0,0 +1,3 @@ +.legacy-main { + color: blue; +} diff --git a/packages/rspack-test-tools/tests/configCases/css/rspack-issue-6435/style.module.css b/packages/rspack-test-tools/tests/configCases/css/rspack-issue-6435/style.module.css new file mode 100644 index 00000000000..3fff4e9e7e2 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/css/rspack-issue-6435/style.module.css @@ -0,0 +1,3 @@ +.container-main { + color: red; +} diff --git a/packages/rspack-test-tools/tests/configCases/css/rspack-issue-6435/webpack.config.js b/packages/rspack-test-tools/tests/configCases/css/rspack-issue-6435/webpack.config.js new file mode 100644 index 00000000000..6d8022bbc41 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/css/rspack-issue-6435/webpack.config.js @@ -0,0 +1,41 @@ +const path = require("path"); + +/** @type {import('@rspack/core').Configuration} */ +module.exports = { + mode: "development", + entry: "./index.js", + output: { + hashFunction: "md4", + cssFilename: "main.css" + }, + module: { + parser: { + "css/auto": { + namedExports: true, + }, + }, + generator: { + "css/auto": { + exportsConvention: "as-is", + localIdentName: "[hash]-[local]", + }, + }, + rules: [ + { + include: path.resolve(__dirname, "legacy"), + test: /\.css$/, + type: "css/module", + parser: { + namedExports: false, + }, + generator: { + exportsConvention: "camel-case", + localIdentName: "[hash]-[local]", + } + }, + ] + }, + experiments: { + css: true, + } +}; diff --git a/packages/rspack-test-tools/tests/configCases/mangle-exports/skipping-mangle-css-modules/index.js b/packages/rspack-test-tools/tests/configCases/mangle-exports/skipping-mangle-css-modules/index.js index fbbd4af5aff..a6d2a8a9f7d 100644 --- a/packages/rspack-test-tools/tests/configCases/mangle-exports/skipping-mangle-css-modules/index.js +++ b/packages/rspack-test-tools/tests/configCases/mangle-exports/skipping-mangle-css-modules/index.js @@ -1,11 +1,10 @@ import test from "./index.module.css"; import { res } from "./lib.js"; - it("should not mangle css module", () => { res; // Using this to trigger a none provided export test.res; - expect(test.test).toBe("-_921b05f8c9c16ca9ea84-test"); + expect(test.test).toBe("-ca56f23580d7bbb484-test"); }); diff --git a/packages/rspack-test-tools/tests/configCases/parsing/preserve-all-comments-define/index.js b/packages/rspack-test-tools/tests/configCases/parsing/preserve-all-comments-define/index.js new file mode 100644 index 00000000000..e49a69d2c74 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/parsing/preserve-all-comments-define/index.js @@ -0,0 +1,14 @@ +const fs = require("fs"); + +async function renderInBrowser() { + const jsx = () => {}; + const RootApp = {}; + if (process.env.__IS_REACT_18__) { + /* @__PURE__ */ jsx(RootApp, {}); + } else { + /* @__PURE__ */ jsx(RootApp, {}); + } +} +renderInBrowser(); + +it("should only contain a single pure annotation after being minimized", () => {}) diff --git a/packages/rspack-test-tools/tests/configCases/parsing/preserve-all-comments-define/webpack.config.js b/packages/rspack-test-tools/tests/configCases/parsing/preserve-all-comments-define/webpack.config.js new file mode 100644 index 00000000000..3f825bb9733 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/parsing/preserve-all-comments-define/webpack.config.js @@ -0,0 +1,19 @@ +const { DefinePlugin } = require("@rspack/core") + +module.exports = { + plugins: [ + new DefinePlugin({ + "process.env.__IS_REACT_18__": "true" + }), + { + apply(compiler) { + compiler.hooks.compilation.tap("Test", (compilation) => { + compilation.hooks.processAssets.tap("Test", (assets) => { + let source = assets["bundle0.js"].source(); + expect(source.match(/\/\* @__PURE__ \*\//g) || []).toHaveLength(1); + }) + }) + } + } + ] +} diff --git a/packages/rspack-test-tools/tests/hotCases/chunk/asset/snapshot/web/2.snap.txt b/packages/rspack-test-tools/tests/hotCases/chunk/asset/snapshot/web/2.snap.txt index ce5e15ff5f8..a9b35f40ec2 100644 --- a/packages/rspack-test-tools/tests/hotCases/chunk/asset/snapshot/web/2.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/chunk/asset/snapshot/web/2.snap.txt @@ -38,7 +38,7 @@ module.exports = 3; }), "./raw.png": (function (module, __unused_webpack_exports, __webpack_require__) { "use strict"; -module.exports = __webpack_require__.p + "f7f4f00355f310234f70.png";}), +module.exports = __webpack_require__.p + "a09d8e0f399c215faa79.png";}), },function(__webpack_require__) { // webpack/runtime/get_full_hash diff --git a/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/index.js b/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/index.js index 840ed57f0da..f3a2a8bb9ec 100644 --- a/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/index.js +++ b/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/index.js @@ -1,9 +1,9 @@ import style from './index.module.css'; it("should store and resume css parser and generator states", (done) => { - expect(style['btnInfoIsDisabled']).toBe('index_module_css__btn-info_is-disabled'); + expect(style['btnInfoIsDisabled']).toBe('__index_module_css__btn-info_is-disabled'); module.hot.accept("./index.module.css", () => { - expect(style['btnInfoIsDisabled']).toBe('index_module_css__btn-info_is-disabled'); + expect(style['btnInfoIsDisabled']).toBe('__index_module_css__btn-info_is-disabled'); done(); }); NEXT(require("../../update")(done)); diff --git a/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/snapshot/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/snapshot/web/1.snap.txt index 2d369a03756..0bd69a4c7e7 100644 --- a/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/snapshot/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/snapshot/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 487 +- Update: main.LAST_HASH.hot-update.js, size: 491 ## Manifest @@ -34,8 +34,8 @@ self["webpackHotUpdate"]('main', { "./index.module.css": (function (module, __unused_webpack_exports, __webpack_require__) { "use strict"; __webpack_require__.r(module.exports = { - "btn-info_is-disabled": "index_module_css__btn-info_is-disabled", - "btnInfoIsDisabled": "index_module_css__btn-info_is-disabled", + "btn-info_is-disabled": "__index_module_css__btn-info_is-disabled", + "btnInfoIsDisabled": "__index_module_css__btn-info_is-disabled", }); }), diff --git a/packages/rspack-test-tools/tests/statsAPICases/basic.js b/packages/rspack-test-tools/tests/statsAPICases/basic.js index 0dcc2373005..7baa730c6c8 100644 --- a/packages/rspack-test-tools/tests/statsAPICases/basic.js +++ b/packages/rspack-test-tools/tests/statsAPICases/basic.js @@ -34,7 +34,7 @@ module.exports = { Statement with side_effects in source code at ./fixtures/a.js:1:0-3:2 entry ./fixtures/a - Rspack compiled successfully (57e46af248a1c1fe076f)" + Rspack compiled successfully (ee9a5ee8da42dac2c2aa)" `); } }; diff --git a/packages/rspack-test-tools/tests/statsAPICases/exports.js b/packages/rspack-test-tools/tests/statsAPICases/exports.js index 253d5c1e765..a2a14e75b79 100644 --- a/packages/rspack-test-tools/tests/statsAPICases/exports.js +++ b/packages/rspack-test-tools/tests/statsAPICases/exports.js @@ -44,7 +44,7 @@ module.exports = { ./fixtures/esm/abc.js [no exports] [no exports used] - Rspack compiled successfully (4b5e3314a79376e83a18)" + Rspack compiled successfully (36dd148024fa89ee453a)" `); } }; diff --git a/packages/rspack-test-tools/tests/statsAPICases/to-string.js b/packages/rspack-test-tools/tests/statsAPICases/to-string.js index a24991a0fe3..eb0efed65fa 100644 --- a/packages/rspack-test-tools/tests/statsAPICases/to-string.js +++ b/packages/rspack-test-tools/tests/statsAPICases/to-string.js @@ -31,7 +31,7 @@ module.exports = { help: You may need an appropriate loader to handle this file type. - Rspack compiled with 1 error (3fa2fc6e23dccdd9a108)" + Rspack compiled with 1 error (2269ff26c17a6bb04d0e)" `); } }; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/tree-shaking-interop/snapshot/new_treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/tree-shaking-interop/snapshot/new_treeshaking.snap.txt index 9106960fa49..02ab1e708e8 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/tree-shaking-interop/snapshot/new_treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/tree-shaking-interop/snapshot/new_treeshaking.snap.txt @@ -30,7 +30,8 @@ exports.test = 30; { const res = __webpack_require__("./a.js"); module.exports = res; -}}), +} // export default function () {} +}), "./index.js": (function (__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */var _foo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./foo.js"); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/tree-shaking-interop/snapshot/output.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/tree-shaking-interop/snapshot/output.snap.txt index d859f18d6bc..f1622e0b6de 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/tree-shaking-interop/snapshot/output.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/tree-shaking-interop/snapshot/output.snap.txt @@ -30,7 +30,8 @@ exports.test = 30; { const res = __webpack_require__("./a.js"); module.exports = res; -}}), +} // export default function () {} +}), "./index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); diff --git a/packages/rspack/api-extractor.json b/packages/rspack/api-extractor.json index 1e0238cd9f0..66be3218c38 100644 --- a/packages/rspack/api-extractor.json +++ b/packages/rspack/api-extractor.json @@ -3,5 +3,9 @@ */ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", - "extends": "../../api-extractor.json" -} + "extends": "../../api-extractor.json", + "docModel": { + "enabled": true, + "includeForgottenExports": true + } +} \ No newline at end of file diff --git a/packages/rspack/etc/api.md b/packages/rspack/etc/api.md index c1ac2479174..baffad7715c 100644 --- a/packages/rspack/etc/api.md +++ b/packages/rspack/etc/api.md @@ -16,11 +16,13 @@ import CacheFacade = require('./lib/CacheFacade'); import { Callback as Callback_2 } from 'tapable'; import { Compiler as Compiler_2 } from '../Compiler'; import { RawEvalDevToolModulePluginOptions as EvalDevToolModulePluginOptions } from '@rspack/binding'; +import { EventEmitter } from 'events'; import { cleanupGlobalTrace as experimental_cleanupGlobalTrace } from '@rspack/binding'; import { registerGlobalTrace as experimental_registerGlobalTrace } from '@rspack/binding'; import { exports as exports_2 } from './exports'; import type { ExternalObject } from '@rspack/binding'; import { fs } from 'fs'; +import { default as fs_2 } from 'graceful-fs'; import Hash = require('../util/hash'); import { HookMap as HookMap_2 } from 'tapable'; import { JsAssetInfo } from '@rspack/binding'; @@ -29,8 +31,7 @@ import { JsChunkGroup } from '@rspack/binding'; import { JsCodegenerationResult } from '@rspack/binding'; import { JsCompilation } from '@rspack/binding'; import { JsCreateData } from '@rspack/binding'; -import { JsLoaderContext } from '@rspack/binding'; -import { JsLoaderResult } from '@rspack/binding'; +import type { JsLoaderContext } from '@rspack/binding'; import { JsModule } from '@rspack/binding'; import { JsPathData } from '@rspack/binding'; import type { JsRuntimeModule } from '@rspack/binding'; @@ -44,18 +45,14 @@ import { Logger as Logger_2 } from './logging/Logger'; import { MultiHook } from 'tapable'; import { PathWithInfo } from '@rspack/binding'; import { RawBannerPluginOptions } from '@rspack/binding'; -import { RawBuiltins } from '@rspack/binding'; -import { RawBundlerInfoPluginOptions } from '@rspack/binding'; import { RawCopyPattern } from '@rspack/binding'; import { RawCopyRspackPluginOptions } from '@rspack/binding'; import type { RawCssExtractPluginOption } from '@rspack/binding'; import { RawDynamicEntryPluginOptions } from '@rspack/binding'; -import { RawEntryOptions } from '@rspack/binding'; import { RawEntryPluginOptions } from '@rspack/binding'; import { RawExternalsPluginOptions } from '@rspack/binding'; import { RawFuncUseCtx } from '@rspack/binding'; import { RawHtmlRspackPluginOptions } from '@rspack/binding'; -import { RawHttpExternalsRspackPluginOptions } from '@rspack/binding'; import { RawIgnorePluginOptions } from '@rspack/binding'; import type { RawLibraryOptions } from '@rspack/binding'; import { RawLimitChunkCountPluginOptions } from '@rspack/binding'; @@ -77,12 +74,7 @@ import { SyncWaterfallHook } from 'tapable'; import * as tapable from 'tapable'; import Template = require('./Template'); import { UnsetAdditionalOptions as UnsetAdditionalOptions_2 } from 'tapable'; -import type { WatchOptions as WatchOptions_2 } from 'watchpack'; import type * as webpackDevServer from 'webpack-dev-server'; -import { z } from 'zod'; - -// @public (undocumented) -const ABSOLUTE_PUBLIC_PATH = "webpack:///mini-css-extract-plugin/"; // @public (undocumented) interface AdditionalData { @@ -110,17 +102,6 @@ const amdContainer: z.ZodString; // @public (undocumented) type Any = any; -// @public (undocumented) -const APIPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) type Append = { 0: [U]; @@ -143,17 +124,6 @@ export const applyRspackOptionsDefaults: (options: RspackOptionsNormalized) => v // @public (undocumented) type ArgumentNames = FixedSizeArray; -// @public (undocumented) -const ArrayPushCallbackChunkFormatPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) type AsArray = T extends any[] ? T : [T]; @@ -340,17 +310,6 @@ export type AssetModuleFilename = z.infer; // @public (undocumented) const assetModuleFilename: z.ZodString; -// @public (undocumented) -const AssetModulesPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) export type AssetParserDataUrl = z.infer; @@ -454,20 +413,6 @@ class AsyncSeriesHook extends Hoo tapPromise(options: Options, fn: Fn): void; } -// @public (undocumented) -const AsyncWebAssemblyModulesPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - -// @public (undocumented) -const AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__"; - // @public (undocumented) export type AuxiliaryComment = z.infer; @@ -495,42 +440,6 @@ export type Bail = z.infer; // @public (undocumented) const bail: z.ZodBoolean; -// @public (undocumented) -type BannerContent = z.infer; - -// @public (undocumented) -const bannerContent: z.ZodUnion<[z.ZodString, z.ZodFunction; - filename: z.ZodString; -}, "strip", z.ZodTypeAny, { - hash: string; - chunk: JsChunk; - filename: string; -}, { - hash: string; - chunk: JsChunk; - filename: string; -}>], z.ZodUnknown>, z.ZodString>]>; - -// @public (undocumented) -type BannerFunction = z.infer; - -// @public (undocumented) -const bannerFunction: z.ZodFunction; - filename: z.ZodString; -}, "strip", z.ZodTypeAny, { - hash: string; - chunk: JsChunk; - filename: string; -}, { - hash: string; - chunk: JsChunk; - filename: string; -}>], z.ZodUnknown>, z.ZodString>; - // @public (undocumented) export const BannerPlugin: { new (args: string | ((args_0: { @@ -632,67 +541,6 @@ const bannerPluginArgument: z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodFunction]>; -// @public (undocumented) -type BannerPluginOptions = z.infer; - -// @public (undocumented) -const bannerPluginOptions: z.ZodObject<{ - banner: z.ZodUnion<[z.ZodString, z.ZodFunction; - filename: z.ZodString; - }, "strip", z.ZodTypeAny, { - hash: string; - chunk: JsChunk; - filename: string; - }, { - hash: string; - chunk: JsChunk; - filename: string; - }>], z.ZodUnknown>, z.ZodString>]>; - entryOnly: z.ZodOptional; - exclude: z.ZodOptional]>, z.ZodArray]>, "many">]>>; - include: z.ZodOptional]>, z.ZodArray]>, "many">]>>; - raw: z.ZodOptional; - footer: z.ZodOptional; - test: z.ZodOptional]>, z.ZodArray]>, "many">]>>; -}, "strict", z.ZodTypeAny, { - banner: (string | ((args_0: { - hash: string; - chunk: JsChunk; - filename: string; - }, ...args_1: unknown[]) => string)) & (string | ((args_0: { - hash: string; - chunk: JsChunk; - filename: string; - }, ...args_1: unknown[]) => string) | undefined); - entryOnly?: boolean | undefined; - exclude?: string | RegExp | (string | RegExp)[] | undefined; - include?: string | RegExp | (string | RegExp)[] | undefined; - raw?: boolean | undefined; - footer?: boolean | undefined; - test?: string | RegExp | (string | RegExp)[] | undefined; -}, { - banner: (string | ((args_0: { - hash: string; - chunk: JsChunk; - filename: string; - }, ...args_1: unknown[]) => string)) & (string | ((args_0: { - hash: string; - chunk: JsChunk; - filename: string; - }, ...args_1: unknown[]) => string) | undefined); - entryOnly?: boolean | undefined; - exclude?: string | RegExp | (string | RegExp)[] | undefined; - include?: string | RegExp | (string | RegExp)[] | undefined; - raw?: boolean | undefined; - footer?: boolean | undefined; - test?: string | RegExp | (string | RegExp)[] | undefined; -}>; - -// @public (undocumented) -const BASE_URI = "webpack://"; - // @public (undocumented) interface BaseModuleConfig { // (undocumented) @@ -926,7 +774,7 @@ const baseUri: z.ZodString; export type Builtins = z.infer; // @public (undocumented) -const builtins: z.ZodType; +const builtins: z.ZodType; // @public (undocumented) interface Builtins_2 { @@ -934,23 +782,6 @@ interface Builtins_2 { treeShaking?: boolean | "module"; } -// @public (undocumented) -type BundleInfoOptions = { - version?: string; - force?: boolean | string[]; -}; - -// @public (undocumented) -const BundlerInfoRspackPlugin: { - new (options: BundleInfoOptions): { - name: BuiltinPluginName; - _options: RawBundlerInfoPluginOptions; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) type CacheHookMap = Map[]>; @@ -970,7 +801,7 @@ type CallFn = (...args: any[]) => any; type CallFn_2 = (args: D[]) => void; // @public (undocumented) -class Chunk { +export class Chunk { constructor(chunk: JsChunk, compilation: JsCompilation); // (undocumented) static __from_binding(chunk: JsChunk, compilation: Compilation): Chunk; @@ -1084,17 +915,6 @@ export type ChunkLoadingType = z.infer; // @public (undocumented) const chunkLoadingType: z.ZodUnion<[z.ZodEnum<["jsonp", "import-scripts", "require", "async-node", "import"]>, z.ZodString]>; -// @public (undocumented) -const ChunkPrefetchPreloadPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) export type Clean = z.infer; @@ -1108,17 +928,6 @@ class CodeGenerationResult { get(sourceType: string): string; } -// @public (undocumented) -const CommonJsChunkFormatPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) interface CommonJsConfig extends BaseModuleConfig { // (undocumented) @@ -1450,7 +1259,7 @@ export class Compiler { // (undocumented) running: boolean; // (undocumented) - watch(watchOptions: WatchOptions_2, handler: Callback_2): Watching; + watch(watchOptions: Watchpack.WatchOptions, handler: Callback_2): Watching; // (undocumented) watchFileSystem: WatchFileSystem; // (undocumented) @@ -1798,17 +1607,6 @@ const cssModuleParserOptions: z.ZodObject<{ namedExports?: boolean | undefined; }>; -// @public (undocumented) -const CssModulesPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) export type CssParserNamedExports = z.infer; @@ -1827,17 +1625,6 @@ const cssParserOptions: z.ZodObject<{ namedExports?: boolean | undefined; }>; -// @public (undocumented) -const DataUriPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) export const DefinePlugin: { new (define: DefinePluginOptions): { @@ -1858,31 +1645,6 @@ export type Dependencies = z.infer; // @public (undocumented) const dependencies: z.ZodArray; -// @public (undocumented) -function deprecated_resolveBuiltins(builtins: Builtins_2, options: RspackOptionsNormalized): RawBuiltins; - -// @public (undocumented) -const DeterministicChunkIdsPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - -// @public (undocumented) -const DeterministicModuleIdsPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) export interface DevServer extends webpackDevServer.Configuration { } @@ -1911,6 +1673,67 @@ export type DevtoolNamespace = z.infer; // @public (undocumented) const devtoolNamespace: z.ZodString; +// @public (undocumented) +class DirectoryWatcher extends EventEmitter { + constructor(directoryPath: string, options: Watchpack.WatcherOptions); + // (undocumented) + close(): void; + // (undocumented) + createNestedWatcher(directoryPath: string): void; + // (undocumented) + directories: { + [path: string]: Watcher_2 | true; + }; + // (undocumented) + doInitialScan(): void; + // (undocumented) + files: { + [path: string]: [number, number]; + }; + // (undocumented) + getTimes(): { + [path: string]: number; + }; + // (undocumented) + initialScan: boolean; + // (undocumented) + initialScanRemoved: string[]; + // (undocumented) + nestedWatching: boolean; + // (undocumented) + onChange(filePath: string, stat: fs_2.Stats): void; + // (undocumented) + onDirectoryAdded(directoryPath: string): void; + // (undocumented) + onDirectoryUnlinked(directoryPath: string): void; + // (undocumented) + onFileAdded(filePath: string, stat: fs_2.Stats): void; + // (undocumented) + onFileUnlinked(filePath: string): void; + // (undocumented) + onWatcherError(): void; + // (undocumented) + options: Watchpack.WatcherOptions; + // (undocumented) + path: string; + // (undocumented) + refs: number; + // (undocumented) + setDirectory(directoryPath: string, exist: boolean, initial: boolean): void; + // (undocumented) + setFileTime(filePath: string, mtime: number, initial: boolean, type?: string | boolean): void; + // (undocumented) + setNestedWatching(flag: boolean): void; + // (undocumented) + watch(filePath: string, startTime: number): Watcher_2; + // (undocumented) + watcher: fs_2.FSWatcher; + // (undocumented) + watchers: { + [path: string]: Watcher_2[]; + }; +} + // @public (undocumented) export const DynamicEntryPlugin: { new (context: string, entry: EntryDynamicNormalized): { @@ -2015,17 +1838,6 @@ const EnableWasmLoadingPlugin: { }; }; -// @public (undocumented) -const EnsureChunkConditionsPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) export type Entry = z.infer; @@ -2294,6 +2106,12 @@ const entry: z.ZodUnion<[z.ZodUnion<[z.ZodRecord]>>, z.ZodUnion<[z.ZodString, z.ZodArray]>]>>]>; +// @public (undocumented) +interface Entry_2 { + safeTime: number; + timestamp: number; +} + // @public (undocumented) export type EntryDependOn = z.infer; @@ -3210,17 +3028,6 @@ interface FileSystemInfoEntry_2 { timestamp?: number; } -// @public (undocumented) -const FileUriPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) export type FilterItemTypes = z.infer; @@ -3231,34 +3038,12 @@ const filterItemTypes: z.ZodUnion<[z.ZodUnion<[z.ZodType; // @public (undocumented) -const filterTypes: z.ZodUnion<[z.ZodArray, z.ZodString]>, z.ZodFunction, z.ZodBoolean>]>, "many">, z.ZodUnion<[z.ZodUnion<[z.ZodType, z.ZodString]>, z.ZodFunction, z.ZodBoolean>]>]>; - -// @public (undocumented) -type FixedSizeArray = T extends 0 ? void[] : ReadonlyArray & { - 0: U; - length: T; -}; - -// @public (undocumented) -const FlagDependencyExportsPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - -// @public (undocumented) -const FlagDependencyUsagePlugin: { - new (global: boolean): { - name: BuiltinPluginName; - _options: boolean; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; +const filterTypes: z.ZodUnion<[z.ZodArray, z.ZodString]>, z.ZodFunction, z.ZodBoolean>]>, "many">, z.ZodUnion<[z.ZodUnion<[z.ZodType, z.ZodString]>, z.ZodFunction, z.ZodBoolean>]>]>; + +// @public (undocumented) +type FixedSizeArray = T extends 0 ? void[] : ReadonlyArray & { + 0: U; + length: T; }; // @public (undocumented) @@ -3730,9 +3515,6 @@ export const getNormalizedRspackOptions: (config: RspackOptions) => RspackOption // @public (undocumented) export function getRawChunkLoading(chunkLoading: ChunkLoading): string; -// @public (undocumented) -function getRawEntryOptions(entry: EntryOptions): RawEntryOptions; - // @public (undocumented) export function getRawLibrary(library: LibraryOptions): RawLibraryOptions; @@ -4014,17 +3796,6 @@ const htmlRspackPluginOptions: z.ZodObject<{ meta?: Record> | undefined; }>; -// @public (undocumented) -const HttpExternalsRspackPlugin: { - new (css: boolean, webAsync: boolean): { - name: BuiltinPluginName; - _options: RawHttpExternalsRspackPluginOptions; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) type IfSet = X extends UnsetAdditionalOptions ? {} : X; @@ -4068,17 +3839,6 @@ export type ImportFunctionName = z.infer; // @public (undocumented) const importFunctionName: z.ZodString; -// @public (undocumented) -const InferAsyncModulesPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) export type InfrastructureLogging = z.infer; @@ -4118,17 +3878,6 @@ interface JavaScript { // @public (undocumented) export const javascript: JavaScript; -// @public (undocumented) -const JavascriptModulesPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) export type JavascriptParserOptions = z.infer; @@ -4185,28 +3934,6 @@ interface JsFormatOptions { wrapIife?: boolean; } -// @public (undocumented) -const JsLoaderRspackPlugin: { - new (compiler: Compiler): { - name: BuiltinPluginName; - _options: (rawContext: JsLoaderContext) => Promise; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler): void; - }; -}; - -// @public (undocumented) -const JsonModulesPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) interface KnownCreateStatsOptionsContext { // (undocumented) @@ -4728,18 +4455,6 @@ interface LoaderObject { request: string; } -// @public (undocumented) -interface LoaderOptions { - // (undocumented) - emit?: boolean; - // (undocumented) - esModule?: boolean; - // (undocumented) - layer?: boolean; - // (undocumented) - publicPath?: string | ((resourcePath: string, context: string) => string); -} - // @public export class LoaderOptionsPlugin { constructor(options?: LoaderOptionsPluginOptions); @@ -4850,17 +4565,6 @@ const LogType: Readonly<{ // @public (undocumented) type LogTypeEnum = (typeof LogType)[keyof typeof LogType]; -// @public (undocumented) -const MangleExportsPlugin: { - new (deterministic: boolean): { - name: BuiltinPluginName; - _options: boolean; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) type Matcher = string | RegExp | (string | RegExp)[]; @@ -4893,17 +4597,6 @@ class MergeCaller { push(...data: D[]): void; } -// @public (undocumented) -const MergeDuplicateChunksPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) type MinifyCondition = string | RegExp; @@ -4920,7 +4613,7 @@ export type Mode = z.infer; const mode: z.ZodEnum<["development", "production", "none"]>; // @public (undocumented) -class Module { +export class Module { constructor(module: JsModule); // (undocumented) static __from_binding(module: JsModule): Module; @@ -4940,31 +4633,6 @@ class Module { get resource(): string | undefined; } -// @public (undocumented) -const MODULE_TYPE = "css/mini-extract"; - -// @public (undocumented) -const ModuleChunkFormatPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - -// @public (undocumented) -const ModuleConcatenationPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) class ModuleFederationPlugin { constructor(_options: ModuleFederationPluginOptions); @@ -5791,28 +5459,6 @@ export type Name = z.infer; // @public (undocumented) const name_2: z.ZodString; -// @public (undocumented) -const NamedChunkIdsPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - -// @public (undocumented) -const NamedModuleIdsPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) export const node: Node_3; @@ -5938,105 +5584,6 @@ export class NormalModuleReplacementPlugin { readonly resourceRegExp: RegExp; } -declare namespace oldBuiltins { - export { - deprecated_resolveBuiltins, - RspackBuiltinPlugin, - Builtins_2 as Builtins, - DefinePluginOptions, - DefinePlugin, - ProvidePluginOptions, - ProvidePlugin, - Rule, - Rules, - BannerFunction, - BannerContent, - BannerPluginOptions, - BannerPluginArgument, - BannerPlugin, - IgnorePluginOptions, - IgnorePlugin, - ProgressPluginArgument, - ProgressPlugin, - getRawEntryOptions, - EntryOptions, - EntryPlugin, - DynamicEntryPlugin, - ExternalsPlugin, - NodeTargetPlugin, - ElectronTargetPlugin, - HttpExternalsRspackPlugin, - EnableChunkLoadingPlugin, - EnableLibraryPlugin, - EnableWasmLoadingPlugin, - ChunkPrefetchPreloadPlugin, - ArrayPushCallbackChunkFormatPlugin, - CommonJsChunkFormatPlugin, - ModuleChunkFormatPlugin, - HotModuleReplacementPlugin, - WebWorkerTemplatePlugin, - WorkerPlugin, - LimitChunkCountOptions, - LimitChunkCountPlugin, - MergeDuplicateChunksPlugin, - SplitChunksPlugin, - NamedModuleIdsPlugin, - DeterministicModuleIdsPlugin, - NamedChunkIdsPlugin, - DeterministicChunkIdsPlugin, - RealContentHashPlugin, - RemoveEmptyChunksPlugin, - EnsureChunkConditionsPlugin, - WarnCaseSensitiveModulesPlugin, - DataUriPlugin, - FileUriPlugin, - RuntimePlugin, - JsonModulesPlugin, - InferAsyncModulesPlugin, - JavascriptModulesPlugin, - AsyncWebAssemblyModulesPlugin, - AssetModulesPlugin, - SourceMapDevToolPluginOptions, - SourceMapDevToolPlugin, - EvalSourceMapDevToolPlugin, - EvalDevToolModulePluginOptions, - EvalDevToolModulePlugin, - SideEffectsFlagPlugin, - FlagDependencyExportsPlugin, - FlagDependencyUsagePlugin, - MangleExportsPlugin, - BundleInfoOptions, - BundlerInfoRspackPlugin, - ModuleConcatenationPlugin, - CssModulesPlugin, - APIPlugin, - RuntimeChunkPluginOptions, - RuntimeChunkPlugin, - HtmlRspackPluginOptions, - HtmlRspackPlugin, - CopyRspackPluginOptions, - CopyRspackPlugin, - SwcJsMinimizerRspackPluginOptions, - JsFormatOptions, - TerserEcmaVersion, - TerserCompressOptions, - TerserMangleOptions, - TerserManglePropertiesOptions, - SwcJsMinimizerRspackPlugin, - SwcCssMinimizerRspackPlugin, - JsLoaderRspackPlugin, - PluginOptions, - CssExtractRspackPlugin, - MODULE_TYPE, - AUTO_PUBLIC_PATH, - ABSOLUTE_PUBLIC_PATH, - BASE_URI, - SINGLE_DOT_PATH_SEGMENT, - LoaderOptions, - pitch - } -} - // @public (undocumented) export type Optimization = z.infer; @@ -6633,6 +6180,8 @@ interface Optimize { LimitChunkCountPlugin: typeof LimitChunkCountPlugin; // (undocumented) RuntimeChunkPlugin: typeof RuntimeChunkPlugin; + // (undocumented) + SplitChunksPlugin: typeof SplitChunksPlugin; } // @public (undocumented) @@ -7525,9 +7074,6 @@ export type Pathinfo = z.infer; // @public (undocumented) const pathinfo: z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"verbose">]>; -// @public (undocumented) -const pitch: LoaderDefinition["pitch"]; - // @public (undocumented) interface PitchLoaderDefinitionFunction { // (undocumented) @@ -7711,17 +7257,6 @@ const rawPublicPath: z.ZodString; // @public (undocumented) type ReactOptions = RawReactOptions | undefined; -// @public (undocumented) -const RealContentHashPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) type RelayOptions = boolean | RawRelayConfig | undefined; @@ -7745,17 +7280,6 @@ export type RemotesObject = { [k: string]: RemotesConfig | RemotesItem | RemotesItems; }; -// @public (undocumented) -const RemoveEmptyChunksPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) export type Resolve = z.infer; @@ -7875,8 +7399,10 @@ declare namespace rspackExports { StatsModule, StatsWarnings, MultiStats, + Chunk, ChunkGroup, NormalModuleFactory, + Module, NormalModule, ModuleFilenameHelpers, Template, @@ -9415,7 +8941,7 @@ export const rspackOptions: z.ZodObject<{ resolveLoader: z.ZodOptional>; plugins: z.ZodOptional, z.ZodType, z.ZodUnion<[z.ZodLiteral, z.ZodLiteral<0>, z.ZodLiteral<"">, z.ZodNull, z.ZodUndefined]>]>, "many">>; devServer: z.ZodOptional>; - builtins: z.ZodOptional>; + builtins: z.ZodOptional>; module: z.ZodOptional, z.ZodType]>, z.ZodUnion<[z.ZodLiteral, z.ZodLiteral<0>, z.ZodLiteral<"">, z.ZodNull, z.ZodUndefined]>]>, "many">>; rules: z.ZodOptional, z.ZodType]>, z.ZodUnion<[z.ZodLiteral, z.ZodLiteral<0>, z.ZodLiteral<"">, z.ZodNull, z.ZodUndefined]>]>, "many">>; @@ -10367,7 +9893,7 @@ export const rspackOptions: z.ZodObject<{ resolveLoader?: ResolveOptions | undefined; plugins?: (false | "" | 0 | RspackPluginInstance | RspackPluginFunction | null | undefined)[] | undefined; devServer?: DevServer | undefined; - builtins?: oldBuiltins.Builtins | undefined; + builtins?: Builtins_2 | undefined; module?: { defaultRules?: (false | "" | 0 | "..." | RuleSetRule | null | undefined)[] | undefined; rules?: (false | "" | 0 | "..." | RuleSetRule | null | undefined)[] | undefined; @@ -10783,7 +10309,7 @@ export const rspackOptions: z.ZodObject<{ resolveLoader?: ResolveOptions | undefined; plugins?: (false | "" | 0 | RspackPluginInstance | RspackPluginFunction | null | undefined)[] | undefined; devServer?: DevServer | undefined; - builtins?: oldBuiltins.Builtins | undefined; + builtins?: Builtins_2 | undefined; module?: { defaultRules?: (false | "" | 0 | "..." | RuleSetRule | null | undefined)[] | undefined; rules?: (false | "" | 0 | "..." | RuleSetRule | null | undefined)[] | undefined; @@ -10968,23 +10494,11 @@ export interface RspackPluginInstance { // @public (undocumented) export const rspackVersion: any; -// @public (undocumented) -type Rule = z.infer; - -// @public (undocumented) -const rule: z.ZodUnion<[z.ZodString, z.ZodType]>; - // @public -type Rule_2 = RegExp | string; - -// @public (undocumented) -type Rules = z.infer; - -// @public (undocumented) -const rules: z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodType]>, z.ZodArray]>, "many">]>; +type Rule = RegExp | string; // @public -type Rules_2 = Rule_2[] | Rule_2; +type Rules = Rule[] | Rule; // @public (undocumented) class RuleSetCompiler { @@ -11119,9 +10633,6 @@ const RuntimeChunkPlugin: { }; }; -// @public (undocumented) -type RuntimeChunkPluginOptions = RawRuntimeChunkOptions; - // @public export const RuntimeGlobals: { readonly require: "__webpack_require__"; @@ -11196,17 +10707,6 @@ export const RuntimeGlobals: { readonly asyncModule: "__webpack_require__.a"; }; -// @public (undocumented) -const RuntimePlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) type RuntimePlugins = string[]; @@ -11290,20 +10790,6 @@ export const sharing: { SharePlugin: typeof SharePlugin; }; -// @public (undocumented) -const SideEffectsFlagPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - -// @public (undocumented) -const SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__"; - // @public (undocumented) export type SnapshotOptions = z.infer; @@ -11381,11 +10867,11 @@ export const SourceMapDevToolPlugin: { // @public (undocumented) export interface SourceMapDevToolPluginOptions extends Omit { // (undocumented) - exclude?: Rules_2; + exclude?: Rules; // (undocumented) - include?: Rules_2; + include?: Rules; // (undocumented) - test?: Rules_2; + test?: Rules; } // @public (undocumented) @@ -12176,17 +11662,6 @@ export const util: { // @public (undocumented) export const version: any; -// @public (undocumented) -const WarnCaseSensitiveModulesPlugin: { - new (): { - name: BuiltinPluginName; - _options: void; - affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; - raw(): BuiltinPlugin; - apply(compiler: Compiler_2): void; - }; -}; - // @public (undocumented) interface Wasm { // (undocumented) @@ -12232,6 +11707,23 @@ interface Watcher { pause(): void; } +// @public (undocumented) +class Watcher_2 extends EventEmitter { + constructor(directoryWatcher: DirectoryWatcher, filePath: string, startTime: number); + // (undocumented) + checkStartTime(mtime: number, initial: boolean): boolean; + // (undocumented) + close(): void; + // (undocumented) + data: number; + // (undocumented) + directoryWatcher: DirectoryWatcher; + // (undocumented) + path: string; + // (undocumented) + startTime: number; +} + // @public (undocumented) interface WatcherInfo { // (undocumented) @@ -12319,6 +11811,99 @@ const watchOptions: z.ZodObject<{ stdin?: boolean | undefined; }>; +// @public (undocumented) +class Watchpack extends EventEmitter { + constructor(options: Watchpack.WatchOptions); + // (undocumented) + aggregatedChanges: Set; + // (undocumented) + aggregatedRemovals: Set; + // (undocumented) + aggregateTimeout: NodeJS.Timer; + close(): void; + collectTimeInfoEntries(fileInfoEntries: Map, directoryInfoEntries: Map): void; + // (undocumented) + _dirWatcher(item: string, watcher: Watcher_2): Watcher_2; + // (undocumented) + dirWatchers: Watcher_2[]; + // (undocumented) + _fileWatcher(file: string, watcher: Watcher_2): Watcher_2; + // (undocumented) + fileWatchers: Watcher_2[]; + getAggregated(): { + changes: Set; + removals: Set; + }; + getTimeInfoEntries(): Map; + // @deprecated + getTimes(): { + [path: string]: number; + }; + mtimes: { + [path: string]: number; + }; + // (undocumented) + on( + eventName: "change", + listener: ( + filePath: string, + modifiedTime: number, + explanation: string, + ) => void, + ): this; + // (undocumented) + on( + eventName: "remove", + listener: ( + filePath: string, + explanation: string, + ) => void, + ): this; + // (undocumented) + on( + eventName: "aggregated", + listener: ( + changes: Set, + removals: Set, + ) => void, + ): this; + // (undocumented) + _onChange(item: string, mtime: number, file?: string): void; + // (undocumented) + _onTimeout(): void; + // (undocumented) + options: Watchpack.WatchOptions; + pause(): void; + // (undocumented) + paused: boolean; + watch(options: { + files?: Iterable; + directories?: Iterable; + missing?: Iterable; + startTime?: number; + }): void; + // (undocumented) + watcherOptions: Watchpack.WatcherOptions; +} + +// @public (undocumented) +namespace Watchpack { + // (undocumented) + interface WatcherOptions { + // (undocumented) + followSymlinks?: boolean; + // (undocumented) + ignored?: string[] | string | RegExp | ((path: string) => boolean) | undefined; + // (undocumented) + poll?: boolean | number | undefined; + } + // (undocumented) + interface WatchOptions extends WatcherOptions { + // (undocumented) + aggregateTimeout?: number | undefined; + } +} + // @public (undocumented) export type WebassemblyModuleFilename = z.infer; @@ -12348,21 +11933,17 @@ const WebWorkerTemplatePlugin: { }; }; -// @public (undocumented) -class WorkerPlugin extends RspackBuiltinPlugin { - constructor(chunkLoading: ChunkLoading, wasmLoading: WasmLoading, module: OutputModule, workerPublicPath: WorkerPublicPath); - // (undocumented) - name: BuiltinPluginName; - // (undocumented) - raw(compiler: Compiler): BuiltinPlugin; -} - // @public (undocumented) export type WorkerPublicPath = z.infer; // @public (undocumented) const workerPublicPath: z.ZodString; +// @public (undocumented) +namespace z { + { type z_AnyZodObject as AnyZodObject, type z_AnyZodTuple as AnyZodTuple, type z_ArrayCardinality as ArrayCardinality, type z_ArrayKeys as ArrayKeys, type z_AssertArray as AssertArray, type z_AsyncParseReturnType as AsyncParseReturnType, type z_BRAND as BRAND, type z_CatchallInput as CatchallInput, type z_CatchallOutput as CatchallOutput, type z_CustomErrorParams as CustomErrorParams, z_DIRTY as DIRTY, type z_DenormalizedError as DenormalizedError, z_EMPTY_PATH as EMPTY_PATH, type z_Effect as Effect, type z_EnumLike as EnumLike, type z_EnumValues as EnumValues, type z_ErrorMapCtx as ErrorMapCtx, type z_FilterEnum as FilterEnum, z_INVALID as INVALID, type z_Indices as Indices, type z_InnerTypeOfFunction as InnerTypeOfFunction, type z_InputTypeOfTuple as InputTypeOfTuple, type z_InputTypeOfTupleWithRest as InputTypeOfTupleWithRest, type z_IpVersion as IpVersion, type z_IssueData as IssueData, type z_KeySchema as KeySchema, z_NEVER as NEVER, z_OK as OK, type z_ObjectPair as ObjectPair, type z_OuterTypeOfFunction as OuterTypeOfFunction, type z_OutputTypeOfTuple as OutputTypeOfTuple, type z_OutputTypeOfTupleWithRest as OutputTypeOfTupleWithRest, type z_ParseContext as ParseContext, type z_ParseInput as ParseInput, type z_ParseParams as ParseParams, type z_ParsePath as ParsePath, type z_ParsePathComponent as ParsePathComponent, type z_ParseResult as ParseResult, type z_ParseReturnType as ParseReturnType, z_ParseStatus as ParseStatus, type z_PassthroughType as PassthroughType, type z_PreprocessEffect as PreprocessEffect, type z_Primitive as Primitive, type z_ProcessedCreateParams as ProcessedCreateParams, type z_RawCreateParams as RawCreateParams, type z_RecordType as RecordType, type z_Refinement as Refinement, type z_RefinementCtx as RefinementCtx, type z_RefinementEffect as RefinementEffect, type z_SafeParseError as SafeParseError, type z_SafeParseReturnType as SafeParseReturnType, type z_SafeParseSuccess as SafeParseSuccess, type z_Scalars as Scalars, ZodType as Schema, type z_SomeZodObject as SomeZodObject, type z_StringValidation as StringValidation, type z_SuperRefinement as SuperRefinement, type z_SyncParseReturnType as SyncParseReturnType, type z_TransformEffect as TransformEffect, type z_TypeOf as TypeOf, type z_UnknownKeysParam as UnknownKeysParam, type z_Values as Values, type z_Writeable as Writeable, z_ZodAny as ZodAny, type z_ZodAnyDef as ZodAnyDef, z_ZodArray as ZodArray, type z_ZodArrayDef as ZodArrayDef, z_ZodBigInt as ZodBigInt, type z_ZodBigIntCheck as ZodBigIntCheck, type z_ZodBigIntDef as ZodBigIntDef, z_ZodBoolean as ZodBoolean, type z_ZodBooleanDef as ZodBooleanDef, z_ZodBranded as ZodBranded, type z_ZodBrandedDef as ZodBrandedDef, z_ZodCatch as ZodCatch, type z_ZodCatchDef as ZodCatchDef, type z_ZodCustomIssue as ZodCustomIssue, z_ZodDate as ZodDate, type z_ZodDateCheck as ZodDateCheck, type z_ZodDateDef as ZodDateDef, z_ZodDefault as ZodDefault, type z_ZodDefaultDef as ZodDefaultDef, z_ZodDiscriminatedUnion as ZodDiscriminatedUnion, type z_ZodDiscriminatedUnionDef as ZodDiscriminatedUnionDef, type z_ZodDiscriminatedUnionOption as ZodDiscriminatedUnionOption, z_ZodEffects as ZodEffects, type z_ZodEffectsDef as ZodEffectsDef, z_ZodEnum as ZodEnum, type z_ZodEnumDef as ZodEnumDef, z_ZodError as ZodError, type z_ZodErrorMap as ZodErrorMap, type z_ZodFirstPartySchemaTypes as ZodFirstPartySchemaTypes, z_ZodFirstPartyTypeKind as ZodFirstPartyTypeKind, type z_ZodFormattedError as ZodFormattedError, z_ZodFunction as ZodFunction, type z_ZodFunctionDef as ZodFunctionDef, z_ZodIntersection as ZodIntersection, type z_ZodIntersectionDef as ZodIntersectionDef, type z_ZodInvalidArgumentsIssue as ZodInvalidArgumentsIssue, type z_ZodInvalidDateIssue as ZodInvalidDateIssue, type z_ZodInvalidEnumValueIssue as ZodInvalidEnumValueIssue, type z_ZodInvalidIntersectionTypesIssue as ZodInvalidIntersectionTypesIssue, type z_ZodInvalidLiteralIssue as ZodInvalidLiteralIssue, type z_ZodInvalidReturnTypeIssue as ZodInvalidReturnTypeIssue, type z_ZodInvalidStringIssue as ZodInvalidStringIssue, type z_ZodInvalidTypeIssue as ZodInvalidTypeIssue, type z_ZodInvalidUnionDiscriminatorIssue as ZodInvalidUnionDiscriminatorIssue, type z_ZodInvalidUnionIssue as ZodInvalidUnionIssue, type z_ZodIssue as ZodIssue, type z_ZodIssueBase as ZodIssueBase, type z_ZodIssueCode as ZodIssueCode, type z_ZodIssueOptionalMessage as ZodIssueOptionalMessage, z_ZodLazy as ZodLazy, type z_ZodLazyDef as ZodLazyDef, z_ZodLiteral as ZodLiteral, type z_ZodLiteralDef as ZodLiteralDef, z_ZodMap as ZodMap, type z_ZodMapDef as ZodMapDef, z_ZodNaN as ZodNaN, type z_ZodNaNDef as ZodNaNDef, z_ZodNativeEnum as ZodNativeEnum, type z_ZodNativeEnumDef as ZodNativeEnumDef, z_ZodNever as ZodNever, type z_ZodNeverDef as ZodNeverDef, type z_ZodNonEmptyArray as ZodNonEmptyArray, type z_ZodNotFiniteIssue as ZodNotFiniteIssue, type z_ZodNotMultipleOfIssue as ZodNotMultipleOfIssue, z_ZodNull as ZodNull, type z_ZodNullDef as ZodNullDef, z_ZodNullable as ZodNullable, type z_ZodNullableDef as ZodNullableDef, type z_ZodNullableType as ZodNullableType, z_ZodNumber as ZodNumber, type z_ZodNumberCheck as ZodNumberCheck, type z_ZodNumberDef as ZodNumberDef, z_ZodObject as ZodObject, type z_ZodObjectDef as ZodObjectDef, z_ZodOptional as ZodOptional, type z_ZodOptionalDef as ZodOptionalDef, type z_ZodOptionalType as ZodOptionalType, type z_ZodParsedType as ZodParsedType, z_ZodPipeline as ZodPipeline, type z_ZodPipelineDef as ZodPipelineDef, z_ZodPromise as ZodPromise, type z_ZodPromiseDef as ZodPromiseDef, type z_ZodRawShape as ZodRawShape, z_ZodReadonly as ZodReadonly, type z_ZodReadonlyDef as ZodReadonlyDef, z_ZodRecord as ZodRecord, type z_ZodRecordDef as ZodRecordDef, ZodType as ZodSchema, z_ZodSet as ZodSet, type z_ZodSetDef as ZodSetDef, z_ZodString as ZodString, type z_ZodStringCheck as ZodStringCheck, type z_ZodStringDef as ZodStringDef, z_ZodSymbol as ZodSymbol, type z_ZodSymbolDef as ZodSymbolDef, type z_ZodTooBigIssue as ZodTooBigIssue, type z_ZodTooSmallIssue as ZodTooSmallIssue, ZodEffects as ZodTransformer, z_ZodTuple as ZodTuple, type z_ZodTupleDef as ZodTupleDef, type z_ZodTupleItems as ZodTupleItems, z_ZodType as ZodType, type z_ZodTypeAny as ZodTypeAny, type z_ZodTypeDef as ZodTypeDef, z_ZodUndefined as ZodUndefined, type z_ZodUndefinedDef as ZodUndefinedDef, z_ZodUnion as ZodUnion, type z_ZodUnionDef as ZodUnionDef, type z_ZodUnionOptions as ZodUnionOptions, z_ZodUnknown as ZodUnknown, type z_ZodUnknownDef as ZodUnknownDef, type z_ZodUnrecognizedKeysIssue as ZodUnrecognizedKeysIssue, z_ZodVoid as ZodVoid, type z_ZodVoidDef as ZodVoidDef, z_addIssueToContext as addIssueToContext, anyType as any, arrayType as array, type z_arrayOutputType as arrayOutputType, type z_baseObjectInputType as baseObjectInputType, type z_baseObjectOutputType as baseObjectOutputType, bigIntType as bigint, booleanType as boolean, z_coerce as coerce, z_custom as custom, dateType as date, errorMap as defaultErrorMap, type z_deoptional as deoptional, discriminatedUnionType as discriminatedUnion, effectsType as effect, enumType as enum, functionType as function, z_getErrorMap as getErrorMap, z_getParsedType as getParsedType, type TypeOf as infer, type z_inferFlattenedErrors as inferFlattenedErrors, type z_inferFormattedError as inferFormattedError, type z_input as input, instanceOfType as instanceof, intersectionType as intersection, z_isAborted as isAborted, z_isAsync as isAsync, z_isDirty as isDirty, z_isValid as isValid, z_late as late, lazyType as lazy, literalType as literal, z_makeIssue as makeIssue, mapType as map, type z_mergeTypes as mergeTypes, nanType as nan, nativeEnumType as nativeEnum, neverType as never, type z_noUnrecognized as noUnrecognized, nullType as null, nullableType as nullable, numberType as number, objectType as object, type z_objectInputType as objectInputType, type z_objectOutputType as objectOutputType, z_objectUtil as objectUtil, z_oboolean as oboolean, z_onumber as onumber, optionalType as optional, z_ostring as ostring, type z_output as output, pipelineType as pipeline, preprocessType as preprocess, promiseType as promise, z_quotelessJson as quotelessJson, recordType as record, setType as set, z_setErrorMap as setErrorMap, strictObjectType as strictObject, stringType as string, symbolType as symbol, effectsType as transformer, tupleType as tuple, type z_typeToFlattenedError as typeToFlattenedError, type z_typecast as typecast, undefinedType as undefined, unionType as union, unknownType as unknown, z_util as util, voidType as void }; +} + // (No @packageDocumentation comment for this package) ``` diff --git a/packages/rspack/package.json b/packages/rspack/package.json index 0c62e53a56a..465ef3fd94c 100644 --- a/packages/rspack/package.json +++ b/packages/rspack/package.json @@ -1,6 +1,6 @@ { "name": "@rspack/core", - "version": "0.6.3", + "version": "0.6.4", "webpackVersion": "5.75.0", "license": "MIT", "description": "A Fast Rust-based Web Bundler", @@ -15,14 +15,17 @@ "./package.json": "./package.json" }, "scripts": { - "build": "tsc -b ./tsconfig.build.json", - "dev": "tsc -w", + "build": "prebundle && tsc -b ./tsconfig.build.json && tsc-alias -p tsconfig.build.json", + "build:force": "prebundle && tsc -b ./tsconfig.build.json --force && tsc-alias -p tsconfig.build.json", + "dev": "prebundle && tsc -w", + "doc-coverage": "node scripts/check-documentation-coverage.mjs", "api-extractor": "api-extractor run --verbose", "api-extractor:ci": "api-extractor run --verbose || diff temp/api.md etc/api.md" }, "files": [ "dist", - "hot" + "hot", + "compiled" ], "engines": { "node": ">=16.0.0" @@ -38,27 +41,33 @@ "@rspack/core": "workspace:*", "@rspack/plugin-minify": "workspace:^", "@swc/plugin-remove-console": "1.5.121", + "@types/neo-async": "^2.6.6", "@types/watchpack": "^2.4.0", "@types/webpack-sources": "3.2.3", "@types/ws": "8.5.10", "babel-loader": "^9.1.0", "babel-plugin-import": "^1.13.5", + "browserslist": "^4.21.3", "copy-webpack-plugin": "5.1.2", "cross-env": "^7.0.3", "del": "^6.0.0", "file-loader": "^6.2.0", "glob": "^10.3.10", + "graceful-fs": "4.2.10", "html-loader": "^5.0.0", "html-webpack-plugin": "^5.5.0", "identity-obj-proxy": "3.0.0", "jest-environment-jsdom": "^29", "jest-serializer-path": "^0.1.15", "jsdom": "^24.0.0", + "json-parse-even-better-errors": "^3.0.0", "less": "4.2.0", "less-loader": "^12.0.0", + "neo-async": "2.6.2", "node-polyfill-webpack-plugin": "3.0.0", "postcss-loader": "^8.0.0", "postcss-pxtorem": "^6.0.0", + "prebundle": "^1.1.0", "pug-loader": "^2.4.0", "react-relay": "^16.0.0", "sass": "1.56.2", @@ -67,21 +76,19 @@ "source-map-loader": "^5.0.0", "styled-components": "^6.0.8", "terser": "5.27.2", - "wast-loader": "^1.11.4" + "tsc-alias": "^1.8.8", + "wast-loader": "^1.11.4", + "watchpack": "^2.4.0", + "zod": "^3.21.4", + "zod-validation-error": "1.3.1" }, "dependencies": { "@module-federation/runtime-tools": "0.1.6", "@rspack/binding": "workspace:*", - "browserslist": "^4.21.3", + "caniuse-lite": "^1.0.30001616", "enhanced-resolve": "5.12.0", - "graceful-fs": "4.2.10", - "json-parse-even-better-errors": "^3.0.0", - "neo-async": "2.6.2", "tapable": "2.2.1", - "watchpack": "^2.4.0", - "webpack-sources": "3.2.3", - "zod": "^3.21.4", - "zod-validation-error": "1.3.1" + "webpack-sources": "3.2.3" }, "peerDependencies": { "@swc/helpers": ">=0.5.1" diff --git a/packages/rspack/prebundle.config.mjs b/packages/rspack/prebundle.config.mjs new file mode 100644 index 00000000000..209d1471558 --- /dev/null +++ b/packages/rspack/prebundle.config.mjs @@ -0,0 +1,26 @@ +// @ts-check + +/** @type {import('prebundle').Config} */ +export default { + dependencies: [ + "zod", + "zod-validation-error", + "json-parse-even-better-errors", + "neo-async", + "graceful-fs", + { + name: "watchpack", + externals: { + "graceful-fs": "../graceful-fs" + } + }, + { + name: "browserslist", + ignoreDts: true, + externals: { + "caniuse-lite": "caniuse-lite", + "/^caniuse-lite(/.*)/": "caniuse-lite$1" + } + } + ] +}; diff --git a/packages/rspack/scripts/check-documentation-coverage.mjs b/packages/rspack/scripts/check-documentation-coverage.mjs new file mode 100644 index 00000000000..9b3eb3b211f --- /dev/null +++ b/packages/rspack/scripts/check-documentation-coverage.mjs @@ -0,0 +1,103 @@ +import { + ApiModel, + ApiItemKind, + ApiVariable +} from "@microsoft/api-extractor-model"; +import { fileURLToPath } from "url"; +import { dirname, resolve, extname, basename } from "path"; +import { readdirSync } from "fs"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const PLUGIN_REGEX = /^[A-Z][a-zA-Z]+Plugin$/; +const PLUGIN_API_JSON = resolve(__dirname, "../temp/core.api.json"); +const PLUGIN_DOCS_DIR = resolve(__dirname, "../../../website/docs/en/plugins"); + +function getImplementedPlugins() { + const apiModel = new ApiModel(); + apiModel.loadPackage(PLUGIN_API_JSON); + + const implementedPlugins = new Set(); + + function visitApiItem(apiItem) { + if ( + [ApiItemKind.Class, ApiItemKind.Variable].includes(apiItem.kind) && + PLUGIN_REGEX.test(apiItem.displayName) && + !apiItem.isAbstract + ) { + implementedPlugins.add(apiItem.displayName); + } + for (const member of apiItem.members) { + visitApiItem(member); + } + } + visitApiItem(apiModel); + + return implementedPlugins; +} + +function toCamelCase(s) { + return s + .split(/[\s-_]+/) + .map(word => word[0].toUpperCase() + word.slice(1).toLowerCase()) + .join(""); +} + +function getDocumentedPlugins() { + const documentedPlugins = new Set(); + + function visitDir(dir) { + const items = readdirSync(dir, { withFileTypes: true }); + for (const item of items) { + const resPath = resolve(dir, item.name); + if (item.isDirectory()) { + visitDir(resPath); + } else { + const ext = extname(item.name); + if (ext === ".mdx") { + const name = toCamelCase(basename(item.name, ext)); + if (PLUGIN_REGEX.test(name)) { + documentedPlugins.add(name); + } + } + } + } + } + visitDir(PLUGIN_DOCS_DIR); + + return documentedPlugins; +} + +const implementedPlugins = getImplementedPlugins(); +const documentedPlugins = getDocumentedPlugins(); + +const undocumentedPlugins = Array.from(implementedPlugins).filter( + plugin => !documentedPlugins.has(plugin) +); +const unimplementedPlugins = Array.from(documentedPlugins).filter( + plugin => !implementedPlugins.has(plugin) +); + +if (undocumentedPlugins.length) { + console.error( + "The following plugins are implemented but not documented:", + undocumentedPlugins.join(", ") + ); +} + +if (unimplementedPlugins.length) { + if (undocumentedPlugins.length) { + console.log("\n"); + } + console.error( + "The following plugins are documented but not implemented or not properly exported:", + unimplementedPlugins.join(", ") + ); +} + +// TODO: remove the comments below once all plugins have been documented +// if (undocumentedPlugins.length || unimplementedPlugins.length) { +if (unimplementedPlugins.length) { + process.exit(1); +} diff --git a/packages/rspack/src/Compiler.ts b/packages/rspack/src/Compiler.ts index 92a3d872108..6db04a18adc 100644 --- a/packages/rspack/src/Compiler.ts +++ b/packages/rspack/src/Compiler.ts @@ -13,7 +13,7 @@ import fs from "fs"; import * as tapable from "tapable"; import * as liteTapable from "./lite-tapable"; import { Callback, SyncBailHook, SyncHook } from "tapable"; -import type { WatchOptions } from "watchpack"; +import type Watchpack from "watchpack"; import { getRawOptions, EntryNormalized, @@ -1054,7 +1054,10 @@ class Compiler { }); } - watch(watchOptions: WatchOptions, handler: Callback): Watching { + watch( + watchOptions: Watchpack.WatchOptions, + handler: Callback + ): Watching { if (this.running) { // @ts-expect-error return handler(new ConcurrentCompilationError()); diff --git a/packages/rspack/src/config/zod.ts b/packages/rspack/src/config/zod.ts index e0ee3d73138..a5f3b6a056e 100644 --- a/packages/rspack/src/config/zod.ts +++ b/packages/rspack/src/config/zod.ts @@ -1,7 +1,7 @@ import { RawFuncUseCtx, JsAssetInfo } from "@rspack/binding"; import { z } from "zod"; import { Compilation, Compiler } from ".."; -import type * as oldBuiltins from "../builtin-plugin"; +import type { Builtins as BuiltinsType } from "../builtin-plugin"; import type * as webpackDevServer from "webpack-dev-server"; import { deprecatedWarn } from "../util"; import { Module } from "../Module"; @@ -1274,7 +1274,7 @@ export type Bail = z.infer; //#endregion //#region Builtins (deprecated) -const builtins = z.custom(); +const builtins = z.custom(); export type Builtins = z.infer; //#endregion diff --git a/packages/rspack/src/container/ModuleFederationPluginV1.ts b/packages/rspack/src/container/ModuleFederationPluginV1.ts index c86c9bc7085..1bcd18c4213 100644 --- a/packages/rspack/src/container/ModuleFederationPluginV1.ts +++ b/packages/rspack/src/container/ModuleFederationPluginV1.ts @@ -9,6 +9,7 @@ import { SharePlugin, Shared } from "../sharing/SharePlugin"; import { isValidate } from "../util/validate"; import { ContainerPlugin, Exposes } from "./ContainerPlugin"; import { ContainerReferencePlugin, Remotes } from "./ContainerReferencePlugin"; +import { ShareRuntimePlugin } from "../sharing/ShareRuntimePlugin"; export interface ModuleFederationPluginV1Options { exposes?: Exposes; @@ -43,6 +44,7 @@ export class ModuleFederationPluginV1 { compiler.options.output.enabledLibraryTypes!.push(library.type); } compiler.hooks.afterPlugins.tap("ModuleFederationPlugin", () => { + new ShareRuntimePlugin(this._options.enhanced).apply(compiler); if ( options.exposes && (Array.isArray(options.exposes) diff --git a/packages/rspack/src/exports.ts b/packages/rspack/src/exports.ts index 81b62e7865c..1701cb81f2b 100644 --- a/packages/rspack/src/exports.ts +++ b/packages/rspack/src/exports.ts @@ -32,10 +32,13 @@ export type { export { MultiStats } from "./MultiStats"; +export type { Chunk } from "./Chunk"; export type { ChunkGroup } from "./ChunkGroup"; export type { NormalModuleFactory } from "./NormalModuleFactory"; +export type { Module } from "./Module"; + export { NormalModule } from "./NormalModule"; // API extractor not working with some re-exports, see: https://github.com/microsoft/fluentui/issues/20694 @@ -157,11 +160,17 @@ export const webworker: Webworker = { WebWorkerTemplatePlugin }; import { LimitChunkCountPlugin } from "./builtin-plugin"; import { RuntimeChunkPlugin } from "./builtin-plugin"; +import { SplitChunksPlugin } from "./builtin-plugin"; interface Optimize { LimitChunkCountPlugin: typeof LimitChunkCountPlugin; RuntimeChunkPlugin: typeof RuntimeChunkPlugin; + SplitChunksPlugin: typeof SplitChunksPlugin; } -export const optimize: Optimize = { LimitChunkCountPlugin, RuntimeChunkPlugin }; +export const optimize: Optimize = { + LimitChunkCountPlugin, + RuntimeChunkPlugin, + SplitChunksPlugin +}; import { ModuleFederationPlugin } from "./container/ModuleFederationPlugin"; export type { ModuleFederationPluginOptions } from "./container/ModuleFederationPlugin"; diff --git a/packages/rspack/src/global.d.ts b/packages/rspack/src/global.d.ts deleted file mode 100644 index 6e3581a6a56..00000000000 --- a/packages/rspack/src/global.d.ts +++ /dev/null @@ -1,111 +0,0 @@ -declare module "neo-async" { - interface QueueObject { - push(item: T): void; - drain: () => void; - error: (err: E) => void; - } - - export interface Dictionary { - [key: string]: T; - } - export type IterableCollection = T[] | Iterable | Dictionary; - - export interface ErrorCallback { - (err?: T): void; - } - export interface AsyncBooleanResultCallback { - (err?: E, truthValue?: boolean): void; - } - export interface AsyncResultCallback { - (err?: E, result?: T): void; - } - export interface AsyncResultArrayCallback { - (err?: E, results?: Array): void; - } - export interface AsyncResultObjectCallback { - (err: E | undefined, results: Dictionary): void; - } - - export interface AsyncFunction { - (callback: (err?: E, result?: T) => void): void; - } - export interface AsyncFunctionEx { - (callback: (err?: E, ...results: T[]) => void): void; - } - export interface AsyncIterator { - (item: T, callback: ErrorCallback): void; - } - export interface AsyncForEachOfIterator { - (item: T, key: number | string, callback: ErrorCallback): void; - } - export interface AsyncResultIterator { - (item: T, callback: AsyncResultCallback): void; - } - export interface AsyncMemoIterator { - (memo: R | undefined, item: T, callback: AsyncResultCallback): void; - } - export interface AsyncBooleanIterator { - (item: T, callback: AsyncBooleanResultCallback): void; - } - - export interface AsyncWorker { - (task: T, callback: ErrorCallback): void; - } - export interface AsyncVoidFunction { - (callback: ErrorCallback): void; - } - - export type AsyncAutoTasks, E> = { - [K in keyof R]: AsyncAutoTask; - }; - export type AsyncAutoTask, E> = - | AsyncAutoTaskFunctionWithoutDependencies - | (keyof R | AsyncAutoTaskFunction)[]; - export interface AsyncAutoTaskFunctionWithoutDependencies { - (cb: AsyncResultCallback | ErrorCallback): void; - } - export interface AsyncAutoTaskFunction, E> { - (results: R, cb: AsyncResultCallback | ErrorCallback): void; - } - - export function each( - arr: IterableCollection, - iterator: AsyncIterator, - callback?: ErrorCallback - ): void; - - export function eachLimit( - arr: IterableCollection, - limit: number, - iterator: AsyncIterator, - callback?: ErrorCallback - ): void; - - export function map( - arr: T[] | IterableIterator, - iterator: AsyncResultIterator, - callback?: AsyncResultArrayCallback - ): void; - export function map( - arr: Dictionary, - iterator: AsyncResultIterator, - callback?: AsyncResultArrayCallback - ): void; - - export function parallel( - tasks: Array>, - callback?: AsyncResultArrayCallback - ): void; - export function parallel( - tasks: Dictionary>, - callback?: AsyncResultObjectCallback - ): void; - - export function queue( - worker: AsyncIterator, - concurrency?: number - ): QueueObject; - - export const forEach: typeof each; - export const forEachLimit: typeof eachLimit; -} diff --git a/packages/rspack/src/node/NodeWatchFileSystem.ts b/packages/rspack/src/node/NodeWatchFileSystem.ts index d16d06a9961..35378a18193 100644 --- a/packages/rspack/src/node/NodeWatchFileSystem.ts +++ b/packages/rspack/src/node/NodeWatchFileSystem.ts @@ -9,12 +9,12 @@ */ import util from "util"; -import Watchpack, { WatchOptions } from "watchpack"; +import Watchpack from "watchpack"; import { FileSystemInfoEntry, Watcher, WatchFileSystem } from "../util/fs"; export default class NodeWatchFileSystem implements WatchFileSystem { inputFileSystem: any; - watcherOptions: WatchOptions; + watcherOptions: Watchpack.WatchOptions; watcher: Watchpack; constructor(inputFileSystem: any) { @@ -30,7 +30,7 @@ export default class NodeWatchFileSystem implements WatchFileSystem { directories: Iterable, missing: Iterable, startTime: number, - options: WatchOptions, + options: Watchpack.WatchOptions, callback: ( error: Error, fileTimeInfoEntries: Map, diff --git a/packages/rspack/tsconfig.json b/packages/rspack/tsconfig.json index 455f6f3c439..e45a4a595fb 100644 --- a/packages/rspack/tsconfig.json +++ b/packages/rspack/tsconfig.json @@ -3,16 +3,22 @@ "compilerOptions": { "outDir": "dist", "rootDir": "src", - "resolveJsonModule": true + "resolveJsonModule": true, + "paths": { + "zod": ["../compiled/zod"], + "neo-async": ["../compiled/neo-async"], + "watchpack": ["../compiled/watchpack"], + "graceful-fs": ["../compiled/graceful-fs"], + "browserslist": ["../compiled/browserslist"], + "zod-validation-error": ["../compiled/zod-validation-error"], + "json-parse-even-better-errors": [ + "../compiled/json-parse-even-better-errors" + ] + } }, - "include": [ - "src", - "src/**/*.json" - ], - "exclude": [ - "src/config/schema.check.js" - ], + "include": ["src", "src/**/*.json"], + "exclude": ["src/config/schema.check.js"], "ts-node": { "transpileOnly": true - }, -} \ No newline at end of file + } +} diff --git a/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/async.$a86b1707b4af75e0f088$.css b/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/async.$048dd0ea10a262087819$.css similarity index 100% rename from plugin-test/css-extract/cases/chunkFilename-fullhash/expected/async.$a86b1707b4af75e0f088$.css rename to plugin-test/css-extract/cases/chunkFilename-fullhash/expected/async.$048dd0ea10a262087819$.css diff --git a/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.$a86b1707b4af75e0f088$.css b/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.$048dd0ea10a262087819$.css similarity index 100% rename from plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.$a86b1707b4af75e0f088$.css rename to plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.$048dd0ea10a262087819$.css diff --git a/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.js b/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.js index a59b5770bff..cb12f77f8ff 100644 --- a/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.js +++ b/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.js @@ -75,7 +75,7 @@ __webpack_require__.e = function (chunkId) { // webpack/runtime/get_full_hash !function() { __webpack_require__.h = function () { - return "a86b1707b4af75e0f088"; + return "048dd0ea10a262087819"; }; }(); diff --git a/plugin-test/css-extract/cases/content-entries-with-same-import/expected/one_js.$34ea7e852b73f29ba7a5b065d4eec971$.css b/plugin-test/css-extract/cases/content-entries-with-same-import/expected/one_js.$2faf8431c36246aaa99efe65186ef7b1$.css similarity index 100% rename from plugin-test/css-extract/cases/content-entries-with-same-import/expected/one_js.$34ea7e852b73f29ba7a5b065d4eec971$.css rename to plugin-test/css-extract/cases/content-entries-with-same-import/expected/one_js.$2faf8431c36246aaa99efe65186ef7b1$.css diff --git a/plugin-test/css-extract/cases/content-entries-with-same-import/expected/two_js.$1286cc6ec04dae701cfb317f9b9aa178$.css b/plugin-test/css-extract/cases/content-entries-with-same-import/expected/two_js.$108a632b35566ba6e10f21437dc1e449$.css similarity index 100% rename from plugin-test/css-extract/cases/content-entries-with-same-import/expected/two_js.$1286cc6ec04dae701cfb317f9b9aa178$.css rename to plugin-test/css-extract/cases/content-entries-with-same-import/expected/two_js.$108a632b35566ba6e10f21437dc1e449$.css diff --git a/plugin-test/css-extract/cases/contenthash-1/expected/main.$e29a42ed09bda57bc430ed9ccfa30f63$.css b/plugin-test/css-extract/cases/contenthash-1/expected/main.$2948667d05523e0bdd4b433a8b432330$.css similarity index 100% rename from plugin-test/css-extract/cases/contenthash-1/expected/main.$e29a42ed09bda57bc430ed9ccfa30f63$.css rename to plugin-test/css-extract/cases/contenthash-1/expected/main.$2948667d05523e0bdd4b433a8b432330$.css diff --git a/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryA.$7102da6560e321434f72cdf38a5f9e22$.css b/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryA.$63eb4b2b7412624c84340d8ef2383cb3$.css similarity index 100% rename from plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryA.$7102da6560e321434f72cdf38a5f9e22$.css rename to plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryA.$63eb4b2b7412624c84340d8ef2383cb3$.css diff --git a/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryB.$ea9aedf549e60226448ece39da68f162$.css b/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryB.$7dc4057bc127528eb3d6e30affb70fc5$.css similarity index 100% rename from plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryB.$ea9aedf549e60226448ece39da68f162$.css rename to plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryB.$7dc4057bc127528eb3d6e30affb70fc5$.css diff --git a/plugin-test/css-extract/cases/contenthash/expected/1.main.$b8738e31859438bcaaf82f0e18ccb8e1$.css b/plugin-test/css-extract/cases/contenthash/expected/1.main.$fcf981e297c26c27907740d422c8fbb8$.css similarity index 100% rename from plugin-test/css-extract/cases/contenthash/expected/1.main.$b8738e31859438bcaaf82f0e18ccb8e1$.css rename to plugin-test/css-extract/cases/contenthash/expected/1.main.$fcf981e297c26c27907740d422c8fbb8$.css diff --git a/plugin-test/css-extract/cases/contenthash/expected/2.main.$22a4c275951727d855be6683d3f1b3b7$.css b/plugin-test/css-extract/cases/contenthash/expected/2.main.$a033229f200a2cfbacbc9213dd60155a$.css similarity index 100% rename from plugin-test/css-extract/cases/contenthash/expected/2.main.$22a4c275951727d855be6683d3f1b3b7$.css rename to plugin-test/css-extract/cases/contenthash/expected/2.main.$a033229f200a2cfbacbc9213dd60155a$.css diff --git a/plugin-test/css-extract/cases/devtool-source-map-from-loaders/expected/main.css.map b/plugin-test/css-extract/cases/devtool-source-map-from-loaders/expected/main.css.map index 751d41cb686..3eb623ccfa8 100644 --- a/plugin-test/css-extract/cases/devtool-source-map-from-loaders/expected/main.css.map +++ b/plugin-test/css-extract/cases/devtool-source-map-from-loaders/expected/main.css.map @@ -1 +1 @@ -{"version":3,"file":"main.css","sources":["webpack:///./style.css?aeac"],"sourcesContent":["body {\n background: red;\n}\n"],"names":[],"mappings":"AAAA;EACE,eAAe;AACjB"} \ No newline at end of file +{"version":3,"file":"main.css","sources":["webpack:///./style.css?86c4"],"sourcesContent":["body {\n background: red;\n}\n"],"names":[],"mappings":"AAAA;EACE,eAAe;AACjB"} \ No newline at end of file diff --git a/plugin-test/css-extract/cases/devtool-source-map/expected/main.css.map b/plugin-test/css-extract/cases/devtool-source-map/expected/main.css.map index 751d41cb686..3eb623ccfa8 100644 --- a/plugin-test/css-extract/cases/devtool-source-map/expected/main.css.map +++ b/plugin-test/css-extract/cases/devtool-source-map/expected/main.css.map @@ -1 +1 @@ -{"version":3,"file":"main.css","sources":["webpack:///./style.css?aeac"],"sourcesContent":["body {\n background: red;\n}\n"],"names":[],"mappings":"AAAA;EACE,eAAe;AACjB"} \ No newline at end of file +{"version":3,"file":"main.css","sources":["webpack:///./style.css?86c4"],"sourcesContent":["body {\n background: red;\n}\n"],"names":[],"mappings":"AAAA;EACE,eAAe;AACjB"} \ No newline at end of file diff --git a/plugin-test/css-extract/cases/js-hash/expected/style.$8962f7751ac742a81f8cd8ef907bc50a$.2.css b/plugin-test/css-extract/cases/js-hash/expected/style.$2ebc9424ae217f7031ea75743effd066$.2.css similarity index 100% rename from plugin-test/css-extract/cases/js-hash/expected/style.$8962f7751ac742a81f8cd8ef907bc50a$.2.css rename to plugin-test/css-extract/cases/js-hash/expected/style.$2ebc9424ae217f7031ea75743effd066$.2.css diff --git a/plugin-test/css-extract/cases/js-hash/expected/style.$59392d4d94762f990e9ea8dfa94f9c34$.1.css b/plugin-test/css-extract/cases/js-hash/expected/style.$fc35cd7d3442366ea0e20c936c0d399c$.1.css similarity index 100% rename from plugin-test/css-extract/cases/js-hash/expected/style.$59392d4d94762f990e9ea8dfa94f9c34$.1.css rename to plugin-test/css-extract/cases/js-hash/expected/style.$fc35cd7d3442366ea0e20c936c0d399c$.1.css diff --git a/plugin-test/css-extract/cases/new-url/expected/ebb93b9cb62e55bcbc35.png b/plugin-test/css-extract/cases/new-url/expected/4d3b8fdfbe46b279f223.png similarity index 100% rename from plugin-test/css-extract/cases/new-url/expected/ebb93b9cb62e55bcbc35.png rename to plugin-test/css-extract/cases/new-url/expected/4d3b8fdfbe46b279f223.png diff --git a/plugin-test/css-extract/cases/new-url/expected/main.css b/plugin-test/css-extract/cases/new-url/expected/main.css index 5a16d881ed1..ef2c3cf185c 100644 --- a/plugin-test/css-extract/cases/new-url/expected/main.css +++ b/plugin-test/css-extract/cases/new-url/expected/main.css @@ -3,6 +3,6 @@ body { } a { - background: url(ebb93b9cb62e55bcbc35.png); + background: url(4d3b8fdfbe46b279f223.png); } diff --git a/plugin-test/css-extract/cases/pathinfo-devtool-source-map/expected/main.css.map b/plugin-test/css-extract/cases/pathinfo-devtool-source-map/expected/main.css.map index d5dbd672e73..d3c9dd3454e 100644 --- a/plugin-test/css-extract/cases/pathinfo-devtool-source-map/expected/main.css.map +++ b/plugin-test/css-extract/cases/pathinfo-devtool-source-map/expected/main.css.map @@ -1 +1 @@ -{"version":3,"file":"main.css","sources":["webpack:///./style.css?aeac","webpack:///./other.css?5f00","webpack:///./extra.css?e36a"],"sourcesContent":["body {\n background: red;\n}\n","body {\n background: blue;\n}\n","body {\n background: yellow;\n}\n"],"names":[],"mappings":";;;AAAA;EACE,eAAe;AACjB;;;;;ACFA;EACE,gBAAgB;AAClB;;;;;ACFA;EACE,kBAAkB;AACpB"} \ No newline at end of file +{"version":3,"file":"main.css","sources":["webpack:///./style.css?86c4","webpack:///./other.css?264c","webpack:///./extra.css?9c40"],"sourcesContent":["body {\n background: red;\n}\n","body {\n background: blue;\n}\n","body {\n background: yellow;\n}\n"],"names":[],"mappings":";;;AAAA;EACE,eAAe;AACjB;;;;;ACFA;EACE,gBAAgB;AAClB;;;;;ACFA;EACE,kBAAkB;AACpB"} \ No newline at end of file diff --git a/plugin-test/css-extract/cases/publicpath-absolute-url-1/expected/61dc21364604d5319600.svg b/plugin-test/css-extract/cases/publicpath-absolute-url-1/expected/2b438a6f1910279f8b62.svg similarity index 100% rename from plugin-test/css-extract/cases/publicpath-absolute-url-1/expected/61dc21364604d5319600.svg rename to plugin-test/css-extract/cases/publicpath-absolute-url-1/expected/2b438a6f1910279f8b62.svg diff --git a/plugin-test/css-extract/cases/publicpath-absolute-url-1/expected/main.css b/plugin-test/css-extract/cases/publicpath-absolute-url-1/expected/main.css index f4204456377..f98bd63026c 100644 --- a/plugin-test/css-extract/cases/publicpath-absolute-url-1/expected/main.css +++ b/plugin-test/css-extract/cases/publicpath-absolute-url-1/expected/main.css @@ -1,5 +1,5 @@ body { background: red; - background-image: url(https://webpack.js.org/foo/61dc21364604d5319600.svg); + background-image: url(https://webpack.js.org/foo/2b438a6f1910279f8b62.svg); } diff --git a/plugin-test/css-extract/cases/publicpath-absolute-url-2/expected/61dc21364604d5319600.svg b/plugin-test/css-extract/cases/publicpath-absolute-url-2/expected/2b438a6f1910279f8b62.svg similarity index 100% rename from plugin-test/css-extract/cases/publicpath-absolute-url-2/expected/61dc21364604d5319600.svg rename to plugin-test/css-extract/cases/publicpath-absolute-url-2/expected/2b438a6f1910279f8b62.svg diff --git a/plugin-test/css-extract/cases/publicpath-absolute-url-3/expected/61dc21364604d5319600.svg b/plugin-test/css-extract/cases/publicpath-absolute-url-3/expected/2b438a6f1910279f8b62.svg similarity index 100% rename from plugin-test/css-extract/cases/publicpath-absolute-url-3/expected/61dc21364604d5319600.svg rename to plugin-test/css-extract/cases/publicpath-absolute-url-3/expected/2b438a6f1910279f8b62.svg diff --git a/plugin-test/css-extract/cases/publicpath-absolute-url-3/expected/main.css b/plugin-test/css-extract/cases/publicpath-absolute-url-3/expected/main.css index e12b7aadf2a..d511b18bdbc 100644 --- a/plugin-test/css-extract/cases/publicpath-absolute-url-3/expected/main.css +++ b/plugin-test/css-extract/cases/publicpath-absolute-url-3/expected/main.css @@ -1,5 +1,5 @@ body { background: red; - background-image: url(https://webpack.js.org./61dc21364604d5319600.svg); + background-image: url(https://webpack.js.org./2b438a6f1910279f8b62.svg); } diff --git a/plugin-test/css-extract/cases/publicpath-absolute-url-4/expected/61dc21364604d5319600.svg b/plugin-test/css-extract/cases/publicpath-absolute-url-4/expected/2b438a6f1910279f8b62.svg similarity index 100% rename from plugin-test/css-extract/cases/publicpath-absolute-url-4/expected/61dc21364604d5319600.svg rename to plugin-test/css-extract/cases/publicpath-absolute-url-4/expected/2b438a6f1910279f8b62.svg diff --git a/plugin-test/css-extract/cases/publicpath-absolute-url-4/expected/main.css b/plugin-test/css-extract/cases/publicpath-absolute-url-4/expected/main.css index c69bae0cdbf..2d9f549df70 100644 --- a/plugin-test/css-extract/cases/publicpath-absolute-url-4/expected/main.css +++ b/plugin-test/css-extract/cases/publicpath-absolute-url-4/expected/main.css @@ -1,5 +1,5 @@ body { background: red; - background-image: url(https://webpack.js.org../61dc21364604d5319600.svg); + background-image: url(https://webpack.js.org../2b438a6f1910279f8b62.svg); } diff --git a/plugin-test/css-extract/cases/publicpath-absolute-url-5/expected/61dc21364604d5319600.svg b/plugin-test/css-extract/cases/publicpath-absolute-url-5/expected/2b438a6f1910279f8b62.svg similarity index 100% rename from plugin-test/css-extract/cases/publicpath-absolute-url-5/expected/61dc21364604d5319600.svg rename to plugin-test/css-extract/cases/publicpath-absolute-url-5/expected/2b438a6f1910279f8b62.svg diff --git a/plugin-test/css-extract/cases/publicpath-absolute-url-5/expected/main.css b/plugin-test/css-extract/cases/publicpath-absolute-url-5/expected/main.css index c3d161fae44..d7f2a7b5c3d 100644 --- a/plugin-test/css-extract/cases/publicpath-absolute-url-5/expected/main.css +++ b/plugin-test/css-extract/cases/publicpath-absolute-url-5/expected/main.css @@ -1,5 +1,5 @@ body { background: red; - background-image: url(/61dc21364604d5319600.svg); + background-image: url(/2b438a6f1910279f8b62.svg); } diff --git a/plugin-test/css-extract/cases/publicpath-absolute-url-6/expected/61dc21364604d5319600.svg b/plugin-test/css-extract/cases/publicpath-absolute-url-6/expected/2b438a6f1910279f8b62.svg similarity index 100% rename from plugin-test/css-extract/cases/publicpath-absolute-url-6/expected/61dc21364604d5319600.svg rename to plugin-test/css-extract/cases/publicpath-absolute-url-6/expected/2b438a6f1910279f8b62.svg diff --git a/plugin-test/css-extract/cases/publicpath-absolute-url-6/expected/main.css b/plugin-test/css-extract/cases/publicpath-absolute-url-6/expected/main.css index 749772d29ae..66ce7f20c9d 100644 --- a/plugin-test/css-extract/cases/publicpath-absolute-url-6/expected/main.css +++ b/plugin-test/css-extract/cases/publicpath-absolute-url-6/expected/main.css @@ -1,5 +1,5 @@ body { background: red; - background-image: url(//cdn.example.com/assets/61dc21364604d5319600.svg); + background-image: url(//cdn.example.com/assets/2b438a6f1910279f8b62.svg); } diff --git a/plugin-test/css-extract/cases/publicpath-absolute-url/expected/61dc21364604d5319600.svg b/plugin-test/css-extract/cases/publicpath-absolute-url/expected/2b438a6f1910279f8b62.svg similarity index 100% rename from plugin-test/css-extract/cases/publicpath-absolute-url/expected/61dc21364604d5319600.svg rename to plugin-test/css-extract/cases/publicpath-absolute-url/expected/2b438a6f1910279f8b62.svg diff --git a/plugin-test/css-extract/cases/publicpath-absolute-url/expected/main.css b/plugin-test/css-extract/cases/publicpath-absolute-url/expected/main.css index d83d1fad3cb..d1bc8b5efdc 100644 --- a/plugin-test/css-extract/cases/publicpath-absolute-url/expected/main.css +++ b/plugin-test/css-extract/cases/publicpath-absolute-url/expected/main.css @@ -1,5 +1,5 @@ body { background: red; - background-image: url(https://webpack.js.org/61dc21364604d5319600.svg); + background-image: url(https://webpack.js.org/2b438a6f1910279f8b62.svg); } diff --git a/plugin-test/css-extract/cases/publicpath-default-auto/expected/61dc21364604d5319600.svg b/plugin-test/css-extract/cases/publicpath-default-auto/expected/2b438a6f1910279f8b62.svg similarity index 100% rename from plugin-test/css-extract/cases/publicpath-default-auto/expected/61dc21364604d5319600.svg rename to plugin-test/css-extract/cases/publicpath-default-auto/expected/2b438a6f1910279f8b62.svg diff --git a/plugin-test/css-extract/cases/publicpath-default-auto/expected/main.css b/plugin-test/css-extract/cases/publicpath-default-auto/expected/main.css index e1334d2985a..afa9a79cec0 100644 --- a/plugin-test/css-extract/cases/publicpath-default-auto/expected/main.css +++ b/plugin-test/css-extract/cases/publicpath-default-auto/expected/main.css @@ -1,5 +1,5 @@ body { background: red; - background-image: url(61dc21364604d5319600.svg); + background-image: url(2b438a6f1910279f8b62.svg); } diff --git a/plugin-test/css-extract/cases/publicpath-empty-string/expected/61dc21364604d5319600.svg b/plugin-test/css-extract/cases/publicpath-empty-string/expected/2b438a6f1910279f8b62.svg similarity index 100% rename from plugin-test/css-extract/cases/publicpath-empty-string/expected/61dc21364604d5319600.svg rename to plugin-test/css-extract/cases/publicpath-empty-string/expected/2b438a6f1910279f8b62.svg diff --git a/plugin-test/css-extract/cases/publicpath-empty-string/expected/main.css b/plugin-test/css-extract/cases/publicpath-empty-string/expected/main.css index e1334d2985a..afa9a79cec0 100644 --- a/plugin-test/css-extract/cases/publicpath-empty-string/expected/main.css +++ b/plugin-test/css-extract/cases/publicpath-empty-string/expected/main.css @@ -1,5 +1,5 @@ body { background: red; - background-image: url(61dc21364604d5319600.svg); + background-image: url(2b438a6f1910279f8b62.svg); } diff --git a/plugin-test/css-extract/cases/publicpath-function-2/expected/webpack-5/61dc21364604d5319600.svg b/plugin-test/css-extract/cases/publicpath-function-2/expected/webpack-5/2b438a6f1910279f8b62.svg similarity index 100% rename from plugin-test/css-extract/cases/publicpath-function-2/expected/webpack-5/61dc21364604d5319600.svg rename to plugin-test/css-extract/cases/publicpath-function-2/expected/webpack-5/2b438a6f1910279f8b62.svg diff --git a/plugin-test/css-extract/cases/publicpath-function/expected/61dc21364604d5319600.svg b/plugin-test/css-extract/cases/publicpath-function/expected/2b438a6f1910279f8b62.svg similarity index 100% rename from plugin-test/css-extract/cases/publicpath-function/expected/61dc21364604d5319600.svg rename to plugin-test/css-extract/cases/publicpath-function/expected/2b438a6f1910279f8b62.svg diff --git a/plugin-test/css-extract/cases/publicpath-function/expected/nested/again/style.css b/plugin-test/css-extract/cases/publicpath-function/expected/nested/again/style.css index 1eeff1f96ca..0b24d61dbbd 100644 --- a/plugin-test/css-extract/cases/publicpath-function/expected/nested/again/style.css +++ b/plugin-test/css-extract/cases/publicpath-function/expected/nested/again/style.css @@ -1,5 +1,5 @@ body { background: green; - background-image: url(../../61dc21364604d5319600.svg); + background-image: url(../../2b438a6f1910279f8b62.svg); } diff --git a/plugin-test/css-extract/cases/publicpath-function/expected/nested/style.css b/plugin-test/css-extract/cases/publicpath-function/expected/nested/style.css index 89722255b7b..b4b980dfd85 100644 --- a/plugin-test/css-extract/cases/publicpath-function/expected/nested/style.css +++ b/plugin-test/css-extract/cases/publicpath-function/expected/nested/style.css @@ -1,5 +1,5 @@ body { background: red; - background-image: url(../61dc21364604d5319600.svg); + background-image: url(../2b438a6f1910279f8b62.svg); } diff --git a/plugin-test/css-extract/cases/publicpath-loader-auto/expected/61dc21364604d5319600.svg b/plugin-test/css-extract/cases/publicpath-loader-auto/expected/2b438a6f1910279f8b62.svg similarity index 100% rename from plugin-test/css-extract/cases/publicpath-loader-auto/expected/61dc21364604d5319600.svg rename to plugin-test/css-extract/cases/publicpath-loader-auto/expected/2b438a6f1910279f8b62.svg diff --git a/plugin-test/css-extract/cases/publicpath-loader-auto/expected/main.css b/plugin-test/css-extract/cases/publicpath-loader-auto/expected/main.css index e1334d2985a..afa9a79cec0 100644 --- a/plugin-test/css-extract/cases/publicpath-loader-auto/expected/main.css +++ b/plugin-test/css-extract/cases/publicpath-loader-auto/expected/main.css @@ -1,5 +1,5 @@ body { background: red; - background-image: url(61dc21364604d5319600.svg); + background-image: url(2b438a6f1910279f8b62.svg); } diff --git a/plugin-test/css-extract/cases/publicpath-path-relative-1/expected/61dc21364604d5319600.svg b/plugin-test/css-extract/cases/publicpath-path-relative-1/expected/2b438a6f1910279f8b62.svg similarity index 100% rename from plugin-test/css-extract/cases/publicpath-path-relative-1/expected/61dc21364604d5319600.svg rename to plugin-test/css-extract/cases/publicpath-path-relative-1/expected/2b438a6f1910279f8b62.svg diff --git a/plugin-test/css-extract/cases/publicpath-path-relative-1/expected/main.css b/plugin-test/css-extract/cases/publicpath-path-relative-1/expected/main.css index aebe84a7122..fcd63b67dcc 100644 --- a/plugin-test/css-extract/cases/publicpath-path-relative-1/expected/main.css +++ b/plugin-test/css-extract/cases/publicpath-path-relative-1/expected/main.css @@ -1,5 +1,5 @@ body { background: red; - background-image: url(/static/img/../deep61dc21364604d5319600.svg); + background-image: url(/static/img/../deep2b438a6f1910279f8b62.svg); } diff --git a/plugin-test/css-extract/cases/publicpath-path-relative-2/expected/61dc21364604d5319600.svg b/plugin-test/css-extract/cases/publicpath-path-relative-2/expected/2b438a6f1910279f8b62.svg similarity index 100% rename from plugin-test/css-extract/cases/publicpath-path-relative-2/expected/61dc21364604d5319600.svg rename to plugin-test/css-extract/cases/publicpath-path-relative-2/expected/2b438a6f1910279f8b62.svg diff --git a/plugin-test/css-extract/cases/publicpath-path-relative-2/expected/main.css b/plugin-test/css-extract/cases/publicpath-path-relative-2/expected/main.css index 89722255b7b..b4b980dfd85 100644 --- a/plugin-test/css-extract/cases/publicpath-path-relative-2/expected/main.css +++ b/plugin-test/css-extract/cases/publicpath-path-relative-2/expected/main.css @@ -1,5 +1,5 @@ body { background: red; - background-image: url(../61dc21364604d5319600.svg); + background-image: url(../2b438a6f1910279f8b62.svg); } diff --git a/plugin-test/css-extract/cases/publicpath-path-relative-3/expected/61dc21364604d5319600.svg b/plugin-test/css-extract/cases/publicpath-path-relative-3/expected/2b438a6f1910279f8b62.svg similarity index 100% rename from plugin-test/css-extract/cases/publicpath-path-relative-3/expected/61dc21364604d5319600.svg rename to plugin-test/css-extract/cases/publicpath-path-relative-3/expected/2b438a6f1910279f8b62.svg diff --git a/plugin-test/css-extract/cases/publicpath-path-relative-3/expected/main.css b/plugin-test/css-extract/cases/publicpath-path-relative-3/expected/main.css index c3d161fae44..d7f2a7b5c3d 100644 --- a/plugin-test/css-extract/cases/publicpath-path-relative-3/expected/main.css +++ b/plugin-test/css-extract/cases/publicpath-path-relative-3/expected/main.css @@ -1,5 +1,5 @@ body { background: red; - background-image: url(/61dc21364604d5319600.svg); + background-image: url(/2b438a6f1910279f8b62.svg); } diff --git a/plugin-test/css-extract/cases/publicpath-path-relative-4/expected/61dc21364604d5319600.svg b/plugin-test/css-extract/cases/publicpath-path-relative-4/expected/2b438a6f1910279f8b62.svg similarity index 100% rename from plugin-test/css-extract/cases/publicpath-path-relative-4/expected/61dc21364604d5319600.svg rename to plugin-test/css-extract/cases/publicpath-path-relative-4/expected/2b438a6f1910279f8b62.svg diff --git a/plugin-test/css-extract/cases/publicpath-path-relative-4/expected/main.css b/plugin-test/css-extract/cases/publicpath-path-relative-4/expected/main.css index 3310cbe753f..957b734a55c 100644 --- a/plugin-test/css-extract/cases/publicpath-path-relative-4/expected/main.css +++ b/plugin-test/css-extract/cases/publicpath-path-relative-4/expected/main.css @@ -1,5 +1,5 @@ body { background: red; - background-image: url(./61dc21364604d5319600.svg); + background-image: url(./2b438a6f1910279f8b62.svg); } diff --git a/plugin-test/css-extract/cases/publicpath-path-relative-5/expected/61dc21364604d5319600.svg b/plugin-test/css-extract/cases/publicpath-path-relative-5/expected/2b438a6f1910279f8b62.svg similarity index 100% rename from plugin-test/css-extract/cases/publicpath-path-relative-5/expected/61dc21364604d5319600.svg rename to plugin-test/css-extract/cases/publicpath-path-relative-5/expected/2b438a6f1910279f8b62.svg diff --git a/plugin-test/css-extract/cases/publicpath-path-relative-5/expected/main.css b/plugin-test/css-extract/cases/publicpath-path-relative-5/expected/main.css index 392434604fc..6a2cc5a43cf 100644 --- a/plugin-test/css-extract/cases/publicpath-path-relative-5/expected/main.css +++ b/plugin-test/css-extract/cases/publicpath-path-relative-5/expected/main.css @@ -1,5 +1,5 @@ body { background: red; - background-image: url(../static/61dc21364604d5319600.svg); + background-image: url(../static/2b438a6f1910279f8b62.svg); } diff --git a/plugin-test/css-extract/cases/publicpath-path-relative-6/expected/61dc21364604d5319600.svg b/plugin-test/css-extract/cases/publicpath-path-relative-6/expected/2b438a6f1910279f8b62.svg similarity index 100% rename from plugin-test/css-extract/cases/publicpath-path-relative-6/expected/61dc21364604d5319600.svg rename to plugin-test/css-extract/cases/publicpath-path-relative-6/expected/2b438a6f1910279f8b62.svg diff --git a/plugin-test/css-extract/cases/publicpath-path-relative-6/expected/main.css b/plugin-test/css-extract/cases/publicpath-path-relative-6/expected/main.css index 77185243ce6..c41a5d80342 100644 --- a/plugin-test/css-extract/cases/publicpath-path-relative-6/expected/main.css +++ b/plugin-test/css-extract/cases/publicpath-path-relative-6/expected/main.css @@ -1,5 +1,5 @@ body { background: red; - background-image: url(./static/61dc21364604d5319600.svg); + background-image: url(./static/2b438a6f1910279f8b62.svg); } diff --git a/plugin-test/css-extract/cases/publicpath-path-relative-7/expected/61dc21364604d5319600.svg b/plugin-test/css-extract/cases/publicpath-path-relative-7/expected/2b438a6f1910279f8b62.svg similarity index 100% rename from plugin-test/css-extract/cases/publicpath-path-relative-7/expected/61dc21364604d5319600.svg rename to plugin-test/css-extract/cases/publicpath-path-relative-7/expected/2b438a6f1910279f8b62.svg diff --git a/plugin-test/css-extract/cases/publicpath-path-relative-7/expected/main.css b/plugin-test/css-extract/cases/publicpath-path-relative-7/expected/main.css index 6fdfdb4cfdf..d65456129a5 100644 --- a/plugin-test/css-extract/cases/publicpath-path-relative-7/expected/main.css +++ b/plugin-test/css-extract/cases/publicpath-path-relative-7/expected/main.css @@ -1,5 +1,5 @@ body { background: red; - background-image: url(static61dc21364604d5319600.svg); + background-image: url(static2b438a6f1910279f8b62.svg); } diff --git a/plugin-test/css-extract/cases/publicpath-path-relative/expected/61dc21364604d5319600.svg b/plugin-test/css-extract/cases/publicpath-path-relative/expected/2b438a6f1910279f8b62.svg similarity index 100% rename from plugin-test/css-extract/cases/publicpath-path-relative/expected/61dc21364604d5319600.svg rename to plugin-test/css-extract/cases/publicpath-path-relative/expected/2b438a6f1910279f8b62.svg diff --git a/plugin-test/css-extract/cases/publicpath-path-relative/expected/main.css b/plugin-test/css-extract/cases/publicpath-path-relative/expected/main.css index 281c6b8db67..1b387f01743 100644 --- a/plugin-test/css-extract/cases/publicpath-path-relative/expected/main.css +++ b/plugin-test/css-extract/cases/publicpath-path-relative/expected/main.css @@ -1,5 +1,5 @@ body { background: red; - background-image: url(/static/img/61dc21364604d5319600.svg); + background-image: url(/static/img/2b438a6f1910279f8b62.svg); } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4445fa00145..0d617ab35a7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -429,36 +429,18 @@ importers: '@swc/helpers': specifier: '>=0.5.1' version: 0.5.6 - browserslist: - specifier: ^4.21.3 - version: 4.23.0 + caniuse-lite: + specifier: ^1.0.30001616 + version: 1.0.30001616 enhanced-resolve: specifier: 5.12.0 version: 5.12.0 - graceful-fs: - specifier: 4.2.10 - version: 4.2.10 - json-parse-even-better-errors: - specifier: ^3.0.0 - version: 3.0.1 - neo-async: - specifier: 2.6.2 - version: 2.6.2 tapable: specifier: 2.2.1 version: 2.2.1 - watchpack: - specifier: ^2.4.0 - version: 2.4.1 webpack-sources: specifier: 3.2.3 version: 3.2.3 - zod: - specifier: ^3.21.4 - version: 3.22.4 - zod-validation-error: - specifier: 1.3.1 - version: 1.3.1(zod@3.22.4) devDependencies: '@rspack/core': specifier: workspace:* @@ -469,6 +451,9 @@ importers: '@swc/plugin-remove-console': specifier: 1.5.121 version: 1.5.121 + '@types/neo-async': + specifier: ^2.6.6 + version: 2.6.6 '@types/watchpack': specifier: ^2.4.0 version: 2.4.4 @@ -484,6 +469,9 @@ importers: babel-plugin-import: specifier: ^1.13.5 version: 1.13.8 + browserslist: + specifier: ^4.21.3 + version: 4.23.0 copy-webpack-plugin: specifier: 5.1.2 version: 5.1.2(webpack@5.90.1) @@ -499,6 +487,9 @@ importers: glob: specifier: ^10.3.10 version: 10.3.12 + graceful-fs: + specifier: 4.2.10 + version: 4.2.10 html-loader: specifier: ^5.0.0 version: 5.0.0(webpack@5.90.1) @@ -517,21 +508,30 @@ importers: jsdom: specifier: ^24.0.0 version: 24.0.0 + json-parse-even-better-errors: + specifier: ^3.0.0 + version: 3.0.1 less: specifier: 4.2.0 version: 4.2.0 less-loader: specifier: ^12.0.0 version: 12.2.0(@rspack/core@packages+rspack)(less@4.2.0)(webpack@5.90.1) + neo-async: + specifier: 2.6.2 + version: 2.6.2 node-polyfill-webpack-plugin: specifier: 3.0.0 version: 3.0.0(webpack@5.90.1) postcss-loader: specifier: ^8.0.0 - version: 8.1.1(@rspack/core@packages+rspack)(postcss@8.4.38)(typescript@5.0.2)(webpack@5.90.1) + version: 8.1.1(@rspack/core@packages+rspack)(postcss@8.4.38)(typescript@4.9.5)(webpack@5.90.1) postcss-pxtorem: specifier: ^6.0.0 version: 6.1.0(postcss@8.4.38) + prebundle: + specifier: ^1.1.0 + version: 1.1.0(typescript@4.9.5) pug-loader: specifier: ^2.4.0 version: 2.4.0(pug@2.0.4) @@ -556,9 +556,21 @@ importers: terser: specifier: 5.27.2 version: 5.27.2 + tsc-alias: + specifier: ^1.8.8 + version: 1.8.8 wast-loader: specifier: ^1.11.4 version: 1.12.1 + watchpack: + specifier: ^2.4.0 + version: 2.4.1 + zod: + specifier: ^3.21.4 + version: 3.22.4 + zod-validation-error: + specifier: 1.3.1 + version: 1.3.1(zod@3.22.4) packages/rspack-cli: dependencies: @@ -4228,6 +4240,134 @@ packages: resolution: {integrity: sha512-j7P6Rgr3mmtdkeDGTe0E/aYyWEWVtc5yFXtHCRHs28/jptDEWfaVOc5T7cblqy1XKPPfCxJc/8DwQ5YgLOZOVQ==} dev: false + /@rollup/rollup-android-arm-eabi@4.17.2: + resolution: {integrity: sha512-NM0jFxY8bB8QLkoKxIQeObCaDlJKewVlIEkuyYKm5An1tdVZ966w2+MPQ2l8LBZLjR+SgyV+nRkTIunzOYBMLQ==} + cpu: [arm] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-android-arm64@4.17.2: + resolution: {integrity: sha512-yeX/Usk7daNIVwkq2uGoq2BYJKZY1JfyLTaHO/jaiSwi/lsf8fTFoQW/n6IdAsx5tx+iotu2zCJwz8MxI6D/Bw==} + cpu: [arm64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-darwin-arm64@4.17.2: + resolution: {integrity: sha512-kcMLpE6uCwls023+kknm71ug7MZOrtXo+y5p/tsg6jltpDtgQY1Eq5sGfHcQfb+lfuKwhBmEURDga9N0ol4YPw==} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-darwin-x64@4.17.2: + resolution: {integrity: sha512-AtKwD0VEx0zWkL0ZjixEkp5tbNLzX+FCqGG1SvOu993HnSz4qDI6S4kGzubrEJAljpVkhRSlg5bzpV//E6ysTQ==} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-arm-gnueabihf@4.17.2: + resolution: {integrity: sha512-3reX2fUHqN7sffBNqmEyMQVj/CKhIHZd4y631duy0hZqI8Qoqf6lTtmAKvJFYa6bhU95B1D0WgzHkmTg33In0A==} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-arm-musleabihf@4.17.2: + resolution: {integrity: sha512-uSqpsp91mheRgw96xtyAGP9FW5ChctTFEoXP0r5FAzj/3ZRv3Uxjtc7taRQSaQM/q85KEKjKsZuiZM3GyUivRg==} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-arm64-gnu@4.17.2: + resolution: {integrity: sha512-EMMPHkiCRtE8Wdk3Qhtciq6BndLtstqZIroHiiGzB3C5LDJmIZcSzVtLRbwuXuUft1Cnv+9fxuDtDxz3k3EW2A==} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-arm64-musl@4.17.2: + resolution: {integrity: sha512-NMPylUUZ1i0z/xJUIx6VUhISZDRT+uTWpBcjdv0/zkp7b/bQDF+NfnfdzuTiB1G6HTodgoFa93hp0O1xl+/UbA==} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-powerpc64le-gnu@4.17.2: + resolution: {integrity: sha512-T19My13y8uYXPw/L/k0JYaX1fJKFT/PWdXiHr8mTbXWxjVF1t+8Xl31DgBBvEKclw+1b00Chg0hxE2O7bTG7GQ==} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-riscv64-gnu@4.17.2: + resolution: {integrity: sha512-BOaNfthf3X3fOWAB+IJ9kxTgPmMqPPH5f5k2DcCsRrBIbWnaJCgX2ll77dV1TdSy9SaXTR5iDXRL8n7AnoP5cg==} + cpu: [riscv64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-s390x-gnu@4.17.2: + resolution: {integrity: sha512-W0UP/x7bnn3xN2eYMql2T/+wpASLE5SjObXILTMPUBDB/Fg/FxC+gX4nvCfPBCbNhz51C+HcqQp2qQ4u25ok6g==} + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-x64-gnu@4.17.2: + resolution: {integrity: sha512-Hy7pLwByUOuyaFC6mAr7m+oMC+V7qyifzs/nW2OJfC8H4hbCzOX07Ov0VFk/zP3kBsELWNFi7rJtgbKYsav9QQ==} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-x64-musl@4.17.2: + resolution: {integrity: sha512-h1+yTWeYbRdAyJ/jMiVw0l6fOOm/0D1vNLui9iPuqgRGnXA0u21gAqOyB5iHjlM9MMfNOm9RHCQ7zLIzT0x11Q==} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-win32-arm64-msvc@4.17.2: + resolution: {integrity: sha512-tmdtXMfKAjy5+IQsVtDiCfqbynAQE/TQRpWdVataHmhMb9DCoJxp9vLcCBjEQWMiUYxO1QprH/HbY9ragCEFLA==} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-win32-ia32-msvc@4.17.2: + resolution: {integrity: sha512-7II/QCSTAHuE5vdZaQEwJq2ZACkBpQDOmQsE6D6XUbnBHW8IAhm4eTufL6msLJorzrHDFv3CF8oCA/hSIRuZeQ==} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-win32-x64-msvc@4.17.2: + resolution: {integrity: sha512-TGGO7v7qOq4CYmSBVEYpI1Y5xDuCEnbVC5Vth8mOsW0gDSzxNrVERPc790IGHsrT2dQSimgMr9Ub3Y1Jci5/8w==} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + /@rushstack/node-core-library@4.1.0(@types/node@20.12.7): resolution: {integrity: sha512-qz4JFBZJCf1YN5cAXa1dP6Mki/HrsQxc/oYGAGx29dF2cwF2YMxHoly0FBhMw3IEnxo5fMj0boVfoHVBkpkx/w==} peerDependencies: @@ -5875,6 +6015,10 @@ packages: resolution: {integrity: sha512-hov8bUuiLiyFPGyFPE1lwWhmzYbirOXQNNo40+y3zow8aFVTeyn3VWL0VFFfdNddA8S4Vf0Tc062rzyNr7Paag==} dev: true + /@types/neo-async@2.6.6: + resolution: {integrity: sha512-D22UBilfSj6IMhC5Fs6+sbZveSTgG0qPVw4mFbQaadLaU7COikojl/TJpKxX0woidAbbWJ42MJ9ANOr9ODi6Yw==} + dev: true + /@types/node-forge@1.3.11: resolution: {integrity: sha512-FQx220y22OKNTqaByeBGqHWYz4cl94tpcxeFdvBo3wjG6XPBuZ0BNgNZRV5J5TFmmcsJ4IzsLkmGRiQbnYsBEQ==} dependencies: @@ -6076,6 +6220,11 @@ packages: dependencies: '@types/yargs-parser': 21.0.3 + /@vercel/ncc@0.38.1: + resolution: {integrity: sha512-IBBb+iI2NLu4VQn3Vwldyi2QwaXt5+hTyh58ggAMoCGE6DJmPvwL3KPBWcJl1m9LYPChBLE980Jw+CS4Wokqxw==} + hasBin: true + dev: true + /@vue/compiler-core@3.2.45: resolution: {integrity: sha512-rcMj7H+PYe5wBV3iYeUgbCglC+pbpN8hBLTJvRiK2eKQiWqu+fG9F+8sW99JdL4LQi7Re178UOxn09puSXvn4A==} dependencies: @@ -7238,7 +7387,7 @@ packages: engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true dependencies: - caniuse-lite: 1.0.30001607 + caniuse-lite: 1.0.30001616 electron-to-chromium: 1.4.730 node-releases: 2.0.14 update-browserslist-db: 1.0.13(browserslist@4.23.0) @@ -7415,8 +7564,8 @@ packages: path-temp: 2.1.0 dev: true - /caniuse-lite@1.0.30001607: - resolution: {integrity: sha512-WcvhVRjXLKFB/kmOFVwELtMxyhq3iM/MvmXcyCe2PNf166c39mptscOc/45TTS96n2gpNV2z7+NakArTWZCQ3w==} + /caniuse-lite@1.0.30001616: + resolution: {integrity: sha512-RHVYKov7IcdNjVHJFNY/78RdG4oGVjbayxv8u5IO74Wv7Hlq4PnJE6mo/OjFijjVFNy5ijnCt6H3IIo4t+wfEw==} /center-align@0.1.3: resolution: {integrity: sha512-Baz3aNe2gd2LP2qk5U+sDk/m4oSuwSDcBfayTCTBoWpfIGO5XFxPmjILQII4NGiZjD6DoDI6kf7gKaxkf7s3VQ==} @@ -7772,7 +7921,6 @@ packages: engines: {node: ^12.20.0 || >=14} requiresBuild: true dev: true - optional: true /common-path-prefix@3.0.0: resolution: {integrity: sha512-QE33hToZseCH3jS0qN96O/bSh3kaw/h+Tq7ngyY9eWDUnTlTNUyqfqvCXioLe5Na5jFsL78ra/wuBU4iuEgd4w==} @@ -8018,6 +8166,22 @@ packages: typescript: 5.0.2 dev: true + /cosmiconfig@9.0.0(typescript@4.9.5): + resolution: {integrity: sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==} + engines: {node: '>=14'} + peerDependencies: + typescript: '>=4.9.5' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + env-paths: 2.2.1 + import-fresh: 3.3.0 + js-yaml: 4.1.0 + parse-json: 5.2.0 + typescript: 4.9.5 + dev: true + /cosmiconfig@9.0.0(typescript@5.0.2): resolution: {integrity: sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==} engines: {node: '>=14'} @@ -10153,7 +10317,7 @@ packages: lodash: 4.17.21 pretty-error: 4.0.0 tapable: 2.2.1 - webpack: 5.90.1(@swc/core@1.4.0)(webpack-cli@4.10.0) + webpack: 5.90.1(webpack-cli@4.10.0) dev: true /htmlescape@1.1.1: @@ -11457,7 +11621,7 @@ packages: /json-parse-even-better-errors@3.0.1: resolution: {integrity: sha512-aatBvbL26wVUCLmbWdCpeu9iF5wOyWpagiKkInA+kfws3sWdBrTnsvN2CKcyCYyUrc7rebNBlK6+kteg7ksecg==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - dev: false + dev: true /json-schema-traverse@0.4.1: resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} @@ -11597,7 +11761,7 @@ packages: dependencies: '@rspack/core': link:packages/rspack less: 4.2.0 - webpack: 5.90.1(@swc/core@1.4.0)(webpack-cli@4.10.0) + webpack: 5.90.1(webpack-cli@4.10.0) dev: true /less@4.1.3: @@ -12229,6 +12393,11 @@ packages: engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} dev: true + /mylas@2.1.13: + resolution: {integrity: sha512-+MrqnJRtxdF+xngFfUUkIMQrUUL0KsxbADUkn23Z/4ibGg192Q+z+CQyiYwvWTsYjJygmMR8+w3ZDa98Zh6ESg==} + engines: {node: '>=12.0.0'} + dev: true + /mz@2.7.0: resolution: {integrity: sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==} dependencies: @@ -12940,6 +13109,13 @@ packages: hasBin: true dev: true + /plimit-lit@1.6.1: + resolution: {integrity: sha512-B7+VDyb8Tl6oMJT9oSO2CW8XC/T4UcJGrwOVoNGwOQsQYhlpfajmrMj5xeejqaASq3V/EqThyOeATEOMuSEXiA==} + engines: {node: '>=12'} + dependencies: + queue-lit: 1.5.2 + dev: true + /point-at-length@1.1.0: resolution: {integrity: sha512-nNHDk9rNEh/91o2Y8kHLzBLNpLf80RYd2gCun9ss+V0ytRSf6XhryBTx071fesktjbachRmGuUbId+JQmzhRXw==} dependencies: @@ -13018,6 +13194,29 @@ packages: - typescript dev: true + /postcss-loader@8.1.1(@rspack/core@packages+rspack)(postcss@8.4.38)(typescript@4.9.5)(webpack@5.90.1): + resolution: {integrity: sha512-0IeqyAsG6tYiDRCYKQJLAmgQr47DX6N7sFSWvQxt6AcupX8DIdmykuk/o/tx0Lze3ErGHJEp5OSRxrelC6+NdQ==} + engines: {node: '>= 18.12.0'} + peerDependencies: + '@rspack/core': 0.x || 1.x + postcss: ^7.0.0 || ^8.0.1 + webpack: ^5.0.0 + peerDependenciesMeta: + '@rspack/core': + optional: true + webpack: + optional: true + dependencies: + '@rspack/core': link:packages/rspack + cosmiconfig: 9.0.0(typescript@4.9.5) + jiti: 1.21.0 + postcss: 8.4.38 + semver: 7.6.0 + webpack: 5.90.1(webpack-cli@4.10.0) + transitivePeerDependencies: + - typescript + dev: true + /postcss-loader@8.1.1(@rspack/core@packages+rspack)(postcss@8.4.38)(typescript@5.0.2)(webpack@5.90.1): resolution: {integrity: sha512-0IeqyAsG6tYiDRCYKQJLAmgQr47DX6N7sFSWvQxt6AcupX8DIdmykuk/o/tx0Lze3ErGHJEp5OSRxrelC6+NdQ==} engines: {node: '>= 18.12.0'} @@ -13129,6 +13328,17 @@ packages: picocolors: 1.0.0 source-map-js: 1.2.0 + /prebundle@1.1.0(typescript@4.9.5): + resolution: {integrity: sha512-yTfRjx0+xiveeb7kO77OcODVB8RSHMKIiVl/qferU7ZHw4Y8pycXkCAtPDViF8YDo0a8ViDpm4C1O9PFKCw1ig==} + hasBin: true + dependencies: + '@vercel/ncc': 0.38.1 + rollup: 4.17.2 + rollup-plugin-dts: 6.1.0(rollup@4.17.2)(typescript@4.9.5) + transitivePeerDependencies: + - typescript + dev: true + /prepend-http@2.0.0: resolution: {integrity: sha512-ravE6m9Atw9Z/jjttRUZ+clIXogdghyZAuWJ3qEzjT+jI/dL1ifAqhZeC5VHzQp1MSt1+jxKkFNemj/iO7tVUA==} engines: {node: '>=4'} @@ -13439,6 +13649,11 @@ packages: resolution: {integrity: sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==} dev: true + /queue-lit@1.5.2: + resolution: {integrity: sha512-tLc36IOPeMAubu8BkW8YDBV+WyIgKlYU7zUNs0J5Vk9skSZ4JfGlPOqplP0aHdfv7HL0B2Pg6nwiq60Qc6M2Hw==} + engines: {node: '>=12'} + dev: true + /queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} dev: true @@ -14159,6 +14374,20 @@ packages: resolution: {integrity: sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg==} dev: false + /rollup-plugin-dts@6.1.0(rollup@4.17.2)(typescript@4.9.5): + resolution: {integrity: sha512-ijSCPICkRMDKDLBK9torss07+8dl9UpY9z1N/zTeA1cIqdzMlpkV3MOOC7zukyvQfDyxa1s3Dl2+DeiP/G6DOw==} + engines: {node: '>=16'} + peerDependencies: + rollup: ^3.29.4 || ^4 + typescript: ^4.5 || ^5.0 + dependencies: + magic-string: 0.30.9 + rollup: 4.17.2 + typescript: 4.9.5 + optionalDependencies: + '@babel/code-frame': 7.24.2 + dev: true + /rollup@0.25.8: resolution: {integrity: sha512-a2S4Bh3bgrdO4BhKr2E4nZkjTvrJ2m2bWjMTzVYtoqSCn0HnuxosXnaJUHrMEziOWr3CzL9GjilQQKcyCQpJoA==} hasBin: true @@ -14168,6 +14397,32 @@ packages: source-map-support: 0.3.3 dev: false + /rollup@4.17.2: + resolution: {integrity: sha512-/9ClTJPByC0U4zNLowV1tMBe8yMEAxewtR3cUNX5BoEpGH3dQEWpJLr6CLp0fPdYRF/fzVOgvDb1zXuakwF5kQ==} + engines: {node: '>=18.0.0', npm: '>=8.0.0'} + hasBin: true + dependencies: + '@types/estree': 1.0.5 + optionalDependencies: + '@rollup/rollup-android-arm-eabi': 4.17.2 + '@rollup/rollup-android-arm64': 4.17.2 + '@rollup/rollup-darwin-arm64': 4.17.2 + '@rollup/rollup-darwin-x64': 4.17.2 + '@rollup/rollup-linux-arm-gnueabihf': 4.17.2 + '@rollup/rollup-linux-arm-musleabihf': 4.17.2 + '@rollup/rollup-linux-arm64-gnu': 4.17.2 + '@rollup/rollup-linux-arm64-musl': 4.17.2 + '@rollup/rollup-linux-powerpc64le-gnu': 4.17.2 + '@rollup/rollup-linux-riscv64-gnu': 4.17.2 + '@rollup/rollup-linux-s390x-gnu': 4.17.2 + '@rollup/rollup-linux-x64-gnu': 4.17.2 + '@rollup/rollup-linux-x64-musl': 4.17.2 + '@rollup/rollup-win32-arm64-msvc': 4.17.2 + '@rollup/rollup-win32-ia32-msvc': 4.17.2 + '@rollup/rollup-win32-x64-msvc': 4.17.2 + fsevents: 2.3.3 + dev: true + /rrweb-cssom@0.6.0: resolution: {integrity: sha512-APM0Gt1KoXBz0iIkkdB/kfvGOwC4UuJFeG/c+yV7wSc7q96cG/kJ0HiYCnzivD9SB53cLV1MlHFNfOuPaadYSw==} dev: true @@ -15570,6 +15825,18 @@ packages: yn: 3.1.1 dev: true + /tsc-alias@1.8.8: + resolution: {integrity: sha512-OYUOd2wl0H858NvABWr/BoSKNERw3N9GTi3rHPK8Iv4O1UyUXIrTTOAZNHsjlVpXFOhpJBVARI1s+rzwLivN3Q==} + hasBin: true + dependencies: + chokidar: 3.5.3 + commander: 9.5.0 + globby: 11.1.0 + mylas: 2.1.13 + normalize-path: 3.0.0 + plimit-lit: 1.6.1 + dev: true + /tslib@1.14.1: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} dev: false @@ -16772,11 +17039,11 @@ packages: zod: ^3.18.0 dependencies: zod: 3.22.4 - dev: false + dev: true /zod@3.22.4: resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==} - dev: false + dev: true /zx@7.2.3: resolution: {integrity: sha512-QODu38nLlYXg/B/Gw7ZKiZrvPkEsjPN3LQ5JFXM7h0JvwhEdPNNl+4Ao1y4+o3CLNiDUNcwzQYZ4/Ko7kKzCMA==} diff --git a/website/components/ApiMeta.tsx b/website/components/ApiMeta.tsx index 87050a9f4cc..3ecaa127655 100644 --- a/website/components/ApiMeta.tsx +++ b/website/components/ApiMeta.tsx @@ -19,29 +19,22 @@ export interface ApiMetaProps { export function ApiMeta(props: ApiMetaProps) { let lang = useLang(); + const href = `/${lang}/misc/planning/future`; return (

{props.addedVersion && ( - Added in v{props.addedVersion} + Added in v{props.addedVersion} )} {props.deprecatedVersion && ( - - Deprecated in v{props.deprecatedVersion} - + Deprecated in v{props.deprecatedVersion} )} {props.removedVersion && ( - - Removed in v{props.removedVersion} - + Removed in v{props.removedVersion} )} {props.stability && ( diff --git a/website/components/CommunityCompatibleTable.tsx b/website/components/CommunityCompatibleTable.tsx new file mode 100644 index 00000000000..df224780bca --- /dev/null +++ b/website/components/CommunityCompatibleTable.tsx @@ -0,0 +1,169 @@ +import React from 'react'; +import { Table } from '@builtIns/Table'; +import { useLang } from 'rspress/runtime'; +import S from './PluginSupportStatusTable.module.scss'; +import Markdown from 'markdown-to-jsx'; +import * as i18n from './i18n'; + +export enum CompatibleStatus { + NotCompatible, + Compatible, + Included, +} + +const SUPPORT_STATUS_LOCALIZED = { + [CompatibleStatus.NotCompatible]: { + symbol: '🔴', + en: 'Not Compatible', + zh: '不兼容', + }, + [CompatibleStatus.Compatible]: { + symbol: '🟢', + en: 'Compatible', + zh: '兼容', + }, + [CompatibleStatus.Included]: { + symbol: '🔵', + en: 'Included', + zh: '已内置', + }, +}; + +export interface PluginSupportStatus { + name: string; + status: CompatibleStatus; + url: string; + description?: string; +} + +export const CommunityPluginCompatibleTable: React.FC = () => { + const lang = useLang() as 'zh' | 'en'; + + const pluginList: PluginSupportStatus[] = [ + { + name: 'case-sensitive-paths-webpack-plugin', + url: 'https://github.com/Urthen/case-sensitive-paths-webpack-plugin', + status: CompatibleStatus.Compatible, + description: i18n[lang]['case-sensitive-paths-webpack-plugin-desc'], + }, + { + name: 'copy-webpack-plugin', + url: 'https://www.npmjs.com/package/copy-webpack-plugin', + status: CompatibleStatus.Included, + description: i18n[lang]['copy-plugin-desc'], + }, + { + name: 'css-minimizer-webpack-plugin', + url: 'https://github.com/webpack-contrib/css-minimizer-webpack-plugin', + status: CompatibleStatus.Compatible, + }, + { + name: 'eslint-webpack-plugin', + url: 'https://github.com/webpack-contrib/eslint-webpack-plugin', + status: CompatibleStatus.Compatible, + }, + { + name: 'fork-ts-checker-webpack-plugin', + url: 'https://github.com/TypeStrong/fork-ts-checker-webpack-plugin', + status: CompatibleStatus.Compatible, + }, + { + name: 'html-webpack-plugin', + url: 'https://www.npmjs.com/package/html-webpack-plugin', + status: CompatibleStatus.Compatible, + description: i18n[lang]['html-webpack-plugin-desc'], + }, + { + name: 'mini-css-extract-plugin', + url: 'https://webpack.js.org/plugins/mini-css-extract-plugin', + status: CompatibleStatus.Included, + description: i18n[lang]['mini-css-extract-plugin-desc'], + }, + { + name: 'terser-webpack-plugin', + url: 'https://webpack.js.org/plugins/terser-webpack-plugin', + status: CompatibleStatus.NotCompatible, + description: i18n[lang]['terser-webpack-plugin-desc'], + }, + { + name: 'tsconfig-paths-webpack-plugin', + url: 'https://www.npmjs.com/package/tsconfig-paths-webpack-plugin', + status: CompatibleStatus.Included, + description: i18n[lang]['tsconfig-paths-webpack-plugin-desc'], + }, + { + name: 'webpack-bundle-analyzer', + url: 'https://www.npmjs.com/package/webpack-bundle-analyzer', + status: CompatibleStatus.Compatible, + }, + { + name: 'webpack-manifest-plugin', + url: 'https://github.com/shellscape/webpack-manifest-plugin', + status: CompatibleStatus.NotCompatible, + description: i18n[lang]['webpack-manifest-plugin-desc'], + }, + { + name: 'webpack-subresource-integrity', + url: 'https://github.com/waysact/webpack-subresource-integrity', + status: CompatibleStatus.NotCompatible, + }, + { + name: '@sentry/webpack-plugin', + url: 'https://www.npmjs.com/package/@sentry/webpack-plugin', + status: CompatibleStatus.Compatible, + description: i18n[lang]['sentry_webpack-plugin-desc'], + }, + ]; + + return ( + b.status - a.status) + .map(({ name, url, status, description }) => { + const { symbol, en, zh } = SUPPORT_STATUS_LOCALIZED[status]; + const statusText = `${symbol} ${lang === 'zh' ? zh : en}`; + + const notesText = (() => { + if (description) { + return ( +
+ {description} +
+ ); + } + if (status === CompatibleStatus.NotCompatible) { + return lang === 'zh' ? '待支持' : 'To be implemented'; + } + })(); + + return { + name: ( + + {name} + + ), + status: statusText, + notes: notesText, + }; + })} + /> + ); +}; diff --git a/website/components/CompatibleCard.tsx b/website/components/CompatibleCard.tsx index 88405f6db08..87547c78536 100644 --- a/website/components/CompatibleCard.tsx +++ b/website/components/CompatibleCard.tsx @@ -34,96 +34,6 @@ const CompatibleCardItem = ({ ); }; -export const PluginCompatibleCardList = ({ lang }: { lang: 'zh' | 'en' }) => { - const pluginList: CardMeta[] = [ - { - name: 'webpack.DefinePlugin', - url: 'https://webpack.js.org/plugins/define-plugin/', - status: i18n[lang]['compatible'], - description: i18n[lang]['define-plugin-desc'], - }, - { - name: 'webpack.BannerPlugin', - url: 'https://webpack.js.org/plugins/banner-plugin', - status: i18n[lang]['compatible'], - description: i18n[lang]['banner-plugin-desc'], - }, - { - name: 'webpack.HotModuleReplacementPlugin', - url: 'https://webpack.js.org/plugins/hot-module-replacement-plugin', - status: i18n[lang]['included'], - }, - { - name: 'webpack.IgnorePlugin', - url: 'https://webpack.js.org/plugins/ignore-plugin/', - status: i18n[lang]['compatible'], - description: i18n[lang]['ignore-plugin-desc'], - }, - { - name: 'webpack.NormalModuleReplacementPlugin', - url: 'https://webpack.js.org/plugins/normal-module-replacement-plugin/', - status: i18n[lang]['included'], - }, - { - name: 'html-webpack-plugin', - url: 'https://www.npmjs.com/package/html-webpack-plugin', - status: i18n[lang]['compatible'], - description: i18n[lang]['html-webpack-plugin-desc'], - }, - { - name: '@sentry/webpack-plugin', - url: 'https://www.npmjs.com/package/@sentry/webpack-plugin', - status: i18n[lang]['compatible'], - description: i18n[lang]['sentry_webpack-plugin-desc'], - }, - { - name: 'copy-webpack-plugin', - url: 'https://www.npmjs.com/package/copy-webpack-plugin', - status: i18n[lang]['included'], - description: i18n[lang]['copy-plugin-desc'], - }, - { - name: 'mini-css-extract-plugin', - url: 'https://webpack.js.org/plugins/mini-css-extract-plugin', - status: i18n[lang]['included'], - description: i18n[lang]['mini-css-extract-plugin-desc'], - }, - { - name: 'terser-webpack-plugin', - url: 'https://webpack.js.org/plugins/terser-webpack-plugin', - status: i18n[lang]['included'], - description: i18n[lang]['terser-webpack-plugin-desc'], - }, - { - name: 'progressPlugin', - url: 'https://webpack.js.org/plugins/progress-plugin', - status: i18n[lang]['included'], - description: i18n[lang]['progress-plugin-desc'], - }, - { - name: 'webpack-bundle-analyzer', - url: 'https://www.npmjs.com/package/webpack-bundle-analyzer', - status: i18n[lang]['compatible'], - }, - { - name: 'tsconfig-paths-webpack-plugin', - url: 'https://www.npmjs.com/package/tsconfig-paths-webpack-plugin', - status: i18n[lang]['included'], - description: i18n[lang]['tsconfig-paths-webpack-plugin-desc'], - }, - { - name: 'fork-ts-checker-webpack-plugin', - url: 'https://github.com/TypeStrong/fork-ts-checker-webpack-plugin', - status: i18n[lang]['compatible'], - }, - ]; - return pluginList - .sort((item1, item2) => { - return item1.status > item2.status ? 1 : -1; - }) - .map(item => ); -}; - export const LoaderCompatibleCardList = ({ lang }: { lang: 'zh' | 'en' }) => { const loaderList: CardMeta[] = [ { diff --git a/website/components/PluginSupportStatusTable.module.scss b/website/components/PluginSupportStatusTable.module.scss index 5e50d375994..d13d36afc28 100644 --- a/website/components/PluginSupportStatusTable.module.scss +++ b/website/components/PluginSupportStatusTable.module.scss @@ -29,6 +29,17 @@ } } +.PluginLink { + color: var(--rp-c-brand); + font-weight: 500; +} + +.PluginNote { + a { + border-bottom: 1px dashed var(--rp-c-brand); + } +} + @media screen and (max-width: 600px) { .PluginSupportStatusTable { overflow-x: unset !important; diff --git a/website/components/i18n/en.json b/website/components/i18n/en.json index 562bd25d372..235397a7ded 100644 --- a/website/components/i18n/en.json +++ b/website/components/i18n/en.json @@ -4,14 +4,12 @@ "included": "included", "babel-loader-description": "SWC has been used internally to implement babel-loader with most of its conversion capabilities", "babel-loader-remark": "Be cautious of the performance impact of babel-loader", - "html-webpack-plugin-desc": "Support for this plugin was implemented in v0.3.3, please upgrade the Rspack version to use it.", + "html-webpack-plugin-desc": "Support for this plugin was implemented in v0.3.3, please upgrade the Rspack version to use it", "sentry_webpack-plugin-desc": "Support for the plugin version v1.20.1 and above has been implemented in v0.3.3", - "define-plugin-desc": "Support for this plugin was implemented in v0.3.3, before v0.3.3 you could use builtins.define instead.", - "copy-plugin-desc": "Use builtins.copy or rspack.CopyRspackPlugin instead.", - "banner-plugin-desc": "Support for this plugin was implemented in v0.3.3, before v0.3.3 you could use builtins.banner instead.", - "ignore-plugin-desc": "Recommend using rspack.IgnorePlugin instead.", - "mini-css-extract-plugin-desc": "use experiments.css or rspack.CssExtractRspackPlugin instead", - "terser-webpack-plugin-desc": "Use rspack.SwcJsMinimizerRspackPlugin instead.", - "progress-plugin-desc": "use builtins.progress instead", - "tsconfig-paths-webpack-plugin-desc": "use resolve.tsconfigPath instead" + "copy-plugin-desc": "Use [rspack.CopyRspackPlugin](/plugins/rspack/copy-rspack-plugin) instead", + "mini-css-extract-plugin-desc": "Use [experiments.css](/config/experiments#experimentscss) or [rspack.CssExtractRspackPlugin](/plugins/rspack/css-extract-rspack-plugin) instead", + "terser-webpack-plugin-desc": "Use [rspack.SwcJsMinimizerRspackPlugin](/plugins/rspack/swc-js-minimizer-rspack-plugin) instead", + "tsconfig-paths-webpack-plugin-desc": "Use [resolve.tsconfigPath](/config/resolve#resolvetsconfigpath) instead", + "case-sensitive-paths-webpack-plugin-desc": "`useBeforeEmitHook` option not supported", + "webpack-manifest-plugin-desc": "Use [rspack-manifest-plugin](https://github.com/rspack-contrib/rspack-manifest-plugin) instead" } diff --git a/website/components/i18n/zh.json b/website/components/i18n/zh.json index 1cc92d687bb..339a4bcf6f1 100644 --- a/website/components/i18n/zh.json +++ b/website/components/i18n/zh.json @@ -6,12 +6,10 @@ "babel-loader-remark": "babel-loader 对性能影响较大,请谨慎使用", "html-webpack-plugin-desc": "在 v0.3.3 已实现对该插件的支持,请升级 Rspack 版本来使用", "sentry_webpack-plugin-desc": "在 v0.3.3 已实现对该插件 v1.20.1 以上版本的支持", - "define-plugin-desc": "在 v0.3.3 已实现对该插件的支持,v0.3.3 之前可使用 builtins.define 替代", - "copy-plugin-desc": "使用 builtins.copy 或 rspack.CopyRspackPlugin 替代", - "banner-plugin-desc": "在 v0.3.3 已实现对该插件的支持,v0.3.3 之前可使用 builtins.banner 替代", - "ignore-plugin-desc": "推荐使用 rspack.IgnorePlugin 替代", - "mini-css-extract-plugin-desc": "使用 experiments.css 或 rspack.CssExtractRspackPlugin 替代", - "terser-webpack-plugin-desc": "使用 rspack.SwcJsMinimizerRspackPlugin 替代", - "progress-plugin-desc": "使用 builtins.progress 替代", - "tsconfig-paths-webpack-plugin-desc": "使用 resolve.tsconfigPath 替代" + "copy-plugin-desc": "使用 [rspack.CopyRspackPlugin](/plugins/rspack/copy-rspack-plugin) 替代", + "mini-css-extract-plugin-desc": "使用 [experiments.css](/config/experiments#experimentscss) 或 [rspack.CssExtractRspackPlugin](/plugins/rspack/css-extract-rspack-plugin) 替代", + "terser-webpack-plugin-desc": "使用 [rspack.SwcJsMinimizerRspackPlugin](/plugins/rspack/swc-js-minimizer-rspack-plugin) 替代", + "tsconfig-paths-webpack-plugin-desc": "使用 [resolve.tsconfigPath](/config/resolve#resolvetsconfigpath) 替代", + "case-sensitive-paths-webpack-plugin-desc": "不支持 `useBeforeEmitHook` 选项", + "webpack-manifest-plugin-desc": "使用 [rspack-manifest-plugin](https://github.com/rspack-contrib/rspack-manifest-plugin) 代替" } diff --git a/website/docs/en/_meta.json b/website/docs/en/_meta.json index bdf9b798aaa..935be1f70f4 100644 --- a/website/docs/en/_meta.json +++ b/website/docs/en/_meta.json @@ -21,7 +21,7 @@ }, { "text": "Blog", - "link": "/blog/announcing-0-6", + "link": "/blog/index", "activeMatch": "/blog" }, { diff --git a/website/docs/en/api/_meta.json b/website/docs/en/api/_meta.json index 5c91094e943..7e278ca4d11 100644 --- a/website/docs/en/api/_meta.json +++ b/website/docs/en/api/_meta.json @@ -1 +1,21 @@ -["index", "cli", "modules", "node-api", "hmr", "loader-api", "plugin-api"] +[ + "index", + "cli", + { + "type": "dir", + "name": "modules", + "label": "Modules" + }, + "node-api", + "hmr", + { + "type": "dir", + "name": "loader-api", + "label": "Loader API" + }, + { + "type": "dir", + "name": "plugin-api", + "label": "Plugin API" + } +] diff --git a/website/docs/en/api/index.mdx b/website/docs/en/api/index.mdx index 1d29ba8fc30..0a01f4b798e 100644 --- a/website/docs/en/api/index.mdx +++ b/website/docs/en/api/index.mdx @@ -12,7 +12,7 @@ The Command Line Interface (CLI) to configure and interact with your build. It i When processing modules with rspack, it is important to understand the different module syntaxes – specifically the methods and variables – that are supported. -[Learn more about the modules!](/api/modules) +[Learn more about the modules!](/api/modules/module-methods) ## Node @@ -30,10 +30,10 @@ The Hot Module Replacement (HMR) improves the development experience by updating Loaders are transformations that are applied to the source code of a module. They are written as functions that accept source code as a parameter and return a new version of that code with transformations applied. -[Learn more about the loaders!](/api/loader-api) +[Learn more about the loaders!](/api/loader-api/index) ## Plugins The plugin interface allows users to tap directly into the compilation process. Plugins can register handlers on lifecycle hooks that run at different points throughout a compilation. When each hook is executed, the plugin will have full access to the current state of the compilation. -[Learn more about the plugins!](/api/plugin-api) +[Learn more about the plugins!](/api/plugin-api/index) diff --git a/website/docs/en/api/loader-api.mdx b/website/docs/en/api/loader-api.mdx deleted file mode 100644 index f819502c508..00000000000 --- a/website/docs/en/api/loader-api.mdx +++ /dev/null @@ -1,335 +0,0 @@ -import WebpackLicense from '@components/webpack-license'; - - - -# Loader API - -Rspack loader is designed to reuse the webpack loader, it is compatible with most of the webpack loader API, the rest of the API is still being implemented, so most of the webpack loader can already run in Rspack. - -::: info Webpack Loader API conformance -Check out [this](https://github.com/orgs/web-infra-dev/projects/10) page to see the status of Webpack Loader API conformance. -::: - -## Synchronous Loaders - -Either `return` or `this.callback` can be used to return the transformed content synchronously: - -```js title="sync-loader.js" -module.exports = function (content, map, meta) { - return someSyncOperation(content); -}; -``` - -The `this.callback` method is more flexible as it allows multiple arguments to be passed as opposed to only the `content`. - -```js title="sync-loader-with-multiple-results.js" -module.exports = function (content, map, meta) { - this.callback(null, someSyncOperation(content), map, meta); - return; // always return undefined when calling callback() -}; -``` - -::: info -Rspack, internally, will convert loaders into asynchronous regardless of it's a synchronous loader for technical and performance reason. -::: - -## Asynchronous Loaders - -For asynchronous loaders, `this.async` is used to retrieve the callback function: - -```js title="async-loader.js" -module.exports = function (content, map, meta) { - var callback = this.async(); - someAsyncOperation(content, function (err, result) { - if (err) return callback(err); - callback(null, result, map, meta); - }); -}; -``` - -```js title="async-loader-with-multiple-results.js" -module.exports = function (content, map, meta) { - var callback = this.async(); - someAsyncOperation(content, function (err, result, sourceMaps, meta) { - if (err) return callback(err); - callback(null, result, sourceMaps, meta); - }); -}; -``` - -## Inline loaders - -It's possible to specify loaders in an import statement, or any equivalent "importing" method. Separate loaders from the resource with `!`. Each part is resolved relative to the current directory. - -```js -import Styles from 'style-loader!css-loader?modules!./styles.css'; -``` - -It's possible to override any loaders, preLoaders and postLoaders from the configuration by prefixing the inline import statement: - -Prefixing with `!` will disable all configured normal loaders - -```js -import Styles from '!style-loader!css-loader?modules!./styles.css'; -``` - -Prefixing with `!!` will disable all configured loaders (preLoaders, loaders, postLoaders) - -```js -import Styles from '!!style-loader!css-loader?modules!./styles.css'; -``` - -Prefixing with `-!` will disable all configured preLoaders and loaders but not postLoaders - -```js -import Styles from '-!style-loader!css-loader?modules!./styles.css'; -``` - -Options can be passed with a query parameter, e.g. `?key=value&foo=bar`, or a JSON object, e.g. `?{"key":"value","foo":"bar"}`. - -## Pitching loader - -Every loader has two stages: `Normal` and `Pitching`. -There are some instances where the loader only cares about the **metadata** -behind a request and can ignore the results of the previous loader. -The pitch method on loaders is called from **left to right** before the loaders are actually executed (from right to left). - -For the following configuration of use: - -```js title="rspack.config.js" -module.exports = { - //... - module: { - rules: [ - { - //... - use: ['a-loader', 'b-loader', 'c-loader'], - }, - ], - }, -}; -``` - -These steps would occur: - -``` -|- a-loader `pitch` - |- b-loader `pitch` - |- c-loader `pitch` - |- requested module is picked up as a dependency - |- c-loader normal execution - |- b-loader normal execution -|- a-loader normal execution -``` - -Normally, if it the loader is simple enough which only exports the normal stage hook: - -```js -module.exports = function (source) {}; -``` - -Then, the pitching stage will be skipped. - -So why might a loader take advantage of the "pitching" phase? - -First, the data passed to the pitch method is exposed in the execution phase as well under this.data and could be useful for capturing and sharing information from earlier in the cycle. - -```js -module.exports = function (content) { - return someSyncOperation(content, this.data.value); -}; - -module.exports.pitch = function (remainingRequest, precedingRequest, data) { - data.value = 42; -}; -``` - -Second, if a loader delivers a result in the pitch method, the process turns around and skips the remaining loaders. -In our example above, if the b-loaders pitch method returned something: - -```js -module.exports = function (content) { - return someSyncOperation(content); -}; - -module.exports.pitch = function (remainingRequest, precedingRequest, data) { - if (someCondition()) { - return ( - 'module.exports = require(' + - JSON.stringify('-!' + remainingRequest) + - ');' - ); - } -}; -``` - -The steps above would be shortened to: - -``` -|- a-loader `pitch` - |- b-loader `pitch` returns a module -|- a-loader normal execution -``` - -For a real world example, `style-loader` leverages the second advantage to dispatch requests. -Please visit [style-loader](https://github.com/webpack-contrib/style-loader/blob/eb06baeb3ac4e3107732a21170b0a7f358c5423f/src/index.js#L39) for details. - -## Inline match resource - -A new inline request syntax was introduced in webpack v4. Prefixing `!=!` to a request will set the matchResource for this request. -When a `matchResource` is set, it will be used to match with the module.rules instead of the original resource. This can be useful if further loaders should be applied to the resource, or if the module type needs to be changed. - -Example: - -```js title="file.js" -/* STYLE: body { background: red; } */ -console.log('yep'); -``` - -A loader could transform the file into the following file and use the matchResource to apply the user-specified CSS processing rules: - -```js title="file.js (transformed by loader)" -import './file.js.css!=!extract-style-loader/getStyles!./file.js'; -console.log('yep'); -``` - -This will add a dependency to `extract-style-loader/getStyles!./file.js` and treat the result as file.js.css. -Because `module.rules` has a rule matching /\.css$/ and it will apply to this dependency. - -The loader could look like this: - -```js title="extract-style-loader/index.js" -const getStylesLoader = require.resolve('./getStyles'); - -module.exports = function (source) { - if (STYLES_REGEXP.test(source)) { - source = source.replace(STYLES_REGEXP, ''); - return `import ${JSON.stringify( - this.utils.contextify( - this.context || this.rootContext, - `${this.resource}.css!=!${getStylesLoader}!${this.remainingRequest}`, - ), - )};${source}`; - } - return source; -}; -``` - -```js title="extract-style-loader/getStyles.js" -module.exports = function (source) { - const match = source.match(STYLES_REGEXP); - return match[0]; -}; -``` - -## 'Raw' Loader - -By default, resource files are converted to UTF-8 strings and passed to the loader. loaders can receive raw `Buffer` by setting `raw` to `true`. Each loader can pass its processing results as `String` or `Buffer`, and the Rspack compiler will convert them to and from the loader. - -```js -module.exports = function (content) { - assert(content instanceof Buffer); - // ... -}; -module.exports.raw = true; -``` - -## `this.addContextDependency(directory: string)` - -Add the directory as a dependency for the loader results so that any changes to the files in the directory can be listened to. - -## `this.addDependency(file: string)` - -Add a file as a dependency on the loader results so that any changes to them can be listened to. For example, `sass-loader`, `less-loader` use this trick to recompile when the imported style files change. - -## `this.dependency(file: string)` - -Alias of `this.addDependency(file: string)`. - -## `this.addMissingDependency(file: string)` - -Add a non-existent file as a dependency on the loader results to make them listenable. - -## `this.clearDependencies()` - -Removes all dependencies of the loader result. - -## `this.async()` - -Tells Rspack that this loader will be called asynchronously. Returns `this.callback`. - -## `this.callback(err: Error | null, content: string | Buffer, sourceMap?: SourceMap, meta?: any)` - -Tell Rspack the result of the Loader processing. - -The first parameter must be `Error` or `null`, which marks the current module as a compilation failure, the second parameter is a `string` or `Buffer`, which indicates the contents of the file after the module has been processed by the loader, the third parameter is a source map that can be processed by the loader, and the fourth parameter is ignored by Rspack and can be anything (e.g. some metadata). - -## `this.cacheable(flag: boolean = true)` - -By default, the processing results of the loader are marked as cacheable. Calling this method and passing `false` turns off the loader's ability to cache processing results. - -## `this.context` - -The directory where the current module is located. - -## `this.rootContext` - -The directory where the project is configured in config - -## `this.emitError(err: Error)` - -Emit an error. Unlike `throw` and `this.callback(err)` in the loader, it does not mark the current module as a compilation failure, it just adds an error to Rspack's Compilation and displays it on the command line at the end of this compilation. - -## `this.emitWarning(warning: Error)` - -Emit a warning. - -## `this.emitFile(name: string, content: Buffer | string, sourceMap: SourceMap)` - -Emit a file - -## `this.getOptions(schema)` - -Extracts the given loader option, accepting an optional JSON schema as an argument. - -## `this.getResolve(options: ResolveOptions): resolve` - -Create a resolver like `this.resolve`. - -## `this.resolve(context: string, request: string, callback: (err: Error | null, result: string) => void)` - -Resolve a request. - -- `context` must be the absolute path to a directory. This directory is used as the starting location for resolving. -- `request` is the request to be resolved. -- `callback` is a callback function that gives the resolved path. - -## `this.mode` - -The value of [`mode`](/config/mode) is read when webpack is run. - -The possible values are: `'production'`, `'development'`, `'none'` - -## `this.resource` - -The path string of the current module. For example `'/abc/resource.js?query#hash'`. - -## `this.resourcePath` - -The path string of the current module, excluding the query and fragment parameters. For example `'/abc/resource.js?query#hash'` in `'/abc/resource.js'`. - -## `this.resourceQuery` - -The query parameter for the path string of the current module. For example `'?query'` in `'/abc/resource.js?query#hash'`. - -## `this.resourceFragment` - -The fragment parameter of the current module's path string. For example `'#hash'` in `'/abc/resource.js?query#hash'`. - -## `this.sourceMap` - -Whether a source map should be generated. - -## `this.getLogger(name?: string)` - -Get the logger of this compilation, through which messages can be logged. diff --git a/website/docs/en/api/loader-api/_meta.json b/website/docs/en/api/loader-api/_meta.json new file mode 100644 index 00000000000..7a710dbf561 --- /dev/null +++ b/website/docs/en/api/loader-api/_meta.json @@ -0,0 +1,8 @@ +[ + "index", + "examples", + "context", + "rspack-specific-properties", + "inline", + "inline-match-resource" +] diff --git a/website/docs/en/api/loader-api/context.mdx b/website/docs/en/api/loader-api/context.mdx new file mode 100644 index 00000000000..69ea6451305 --- /dev/null +++ b/website/docs/en/api/loader-api/context.mdx @@ -0,0 +1,181 @@ +import WebpackLicense from '@components/webpack-license'; + + + +# The Loader Context + +The loader context represents the properties that are available inside of a loader assigned to the `this` property. + +## this.addContextDependency() + +```ts +function addContextDependency(directory: string): void; +``` + +Add the directory as a dependency for the loader results so that any changes to the files in the directory can be listened to. + +## this.addDependency() + +```ts +function addDependency(file: string): void; +``` + +Add a file as a dependency on the loader results so that any changes to them can be listened to. For example, `sass-loader`, `less-loader` use this trick to recompile when the imported style files change. + +## this.dependency() + +```ts +function dependency(file: string): void; +``` + +Alias of `this.addDependency()`. + +## this.addMissingDependency() + +```ts +function addMissingDependency(file: string): void; +``` + +Add a non-existent file as a dependency on the loader results to make them listenable. + +## this.async() + +Tells Rspack that this loader will be called asynchronously. Returns `this.callback`. + +## this.cacheable() + +A function that sets the cacheable flag: + +```ts +function cacheable(flag: boolean = true): void; +``` + +By default, the processing results of the loader are marked as cacheable. Calling this method and passing `false` turns off the loader's ability to cache processing results. + +## this.callback() + +```ts +function callback( + err: Error | null, + content: string | Buffer, + sourceMap?: SourceMap, + meta?: any, +): void; +``` + +A function that can be called synchronously or asynchronously in order to return multiple results. The expected arguments are: + +1. The first parameter must be `Error` or `null`, which marks the current module as a compilation failure. +2. The second argument is a `string` or `Buffer`, which indicates the contents of the file after the module has been processed by the loader. +3. The third parameter is a source map that can be processed by the loader. +4. The fourth parameter is ignored by Rspack and can be anything (e.g. some metadata). + +## this.clearDependencies() + +```ts +function clearDependencies(): void; +``` + +Removes all dependencies of the loader result. + +## this.context + +The directory where the current module is located. + +## this.data + +A data object shared between the pitch and the normal phase. + +## this.emitError() + +```ts +function emitError(error: Error): void; +``` + +Emit an error. Unlike `throw` and `this.callback(err)` in the loader, it does not mark the current module as a compilation failure, it just adds an error to Rspack's Compilation and displays it on the command line at the end of this compilation. + +## this.emitWarning(warning: Error) + +```ts +function emitWarning(warning: Error): void; +``` + +Emit a warning. + +## this.emitFile() + +```ts +function emitFile( + name: string, + content: Buffer | string, + sourceMap: SourceMap, +): void; +``` + +Emit a file. + +## this.getOptions(schema) + +Extracts the given loader option, accepting an optional JSON schema as an argument. + +## this.getResolve() + +```ts +function getResolve(options: ResolveOptions): resolve; +``` + +Create a resolver like `this.resolve`. + +## this.resolve() + +```ts +function resolve( + context: string, + request: string, + callback: (err: Error | null, result: string) => void, +): void; +``` + +Resolve a request. + +- `context` must be the absolute path to a directory. This directory is used as the starting location for resolving. +- `request` is the request to be resolved. +- `callback` is a callback function that gives the resolved path. + +## this.mode + +The value of [`mode`](/config/mode) is read when Rspack is run. + +The possible values are: `'production'`, `'development'`, `'none'` + +## this.resource + +The path string of the current module. For example `'/abc/resource.js?query#hash'`. + +## this.resourcePath + +The path string of the current module, excluding the query and fragment parameters. For example `'/abc/resource.js?query#hash'` in `'/abc/resource.js'`. + +## this.resourceQuery + +The query parameter for the path string of the current module. For example `'?query'` in `'/abc/resource.js?query#hash'`. + +## this.resourceFragment + +The fragment parameter of the current module's path string. For example `'#hash'` in `'/abc/resource.js?query#hash'`. + +## this.rootContext + +The directory where the project is configured in config + +## this.sourceMap + +Whether a source map should be generated. + +## this.getLogger() + +```ts +function getLogger(name?: string): void; +``` + +Get the logger of this compilation, through which messages can be logged. diff --git a/website/docs/en/api/loader-api/examples.mdx b/website/docs/en/api/loader-api/examples.mdx new file mode 100644 index 00000000000..d5b9b4d88b5 --- /dev/null +++ b/website/docs/en/api/loader-api/examples.mdx @@ -0,0 +1,150 @@ +import WebpackLicense from '@components/webpack-license'; + + + +# Examples + +The following sections provide some basic examples of the different types of loaders. Note that the `map` and `meta` parameters are optional, see [`this.callback`](#thiscallbackerr-error--null-content-string--buffer-sourcemap-sourcemap-meta-any) below. + +## Synchronous Loaders + +Either `return` or `this.callback` can be used to return the transformed `content` synchronously: + +```js title="sync-loader.js" +module.exports = function (content, map, meta) { + return someSyncOperation(content); +}; +``` + +The `this.callback` method is more flexible as it allows multiple arguments to be passed as opposed to only the `content`. + +```js title="sync-loader-with-multiple-results.js" +module.exports = function (content, map, meta) { + this.callback(null, someSyncOperation(content), map, meta); + return; // always return undefined when calling callback() +}; +``` + +::: info +Rspack, internally, will convert loaders into asynchronous regardless of it's a synchronous loader for technical and performance reason. +::: + +## Asynchronous Loaders + +For asynchronous loaders, `this.async` is used to retrieve the `callback` function: + +```js title="async-loader.js" +module.exports = function (content, map, meta) { + var callback = this.async(); + someAsyncOperation(content, function (err, result) { + if (err) return callback(err); + callback(null, result, map, meta); + }); +}; +``` + +```js title="async-loader-with-multiple-results.js" +module.exports = function (content, map, meta) { + var callback = this.async(); + someAsyncOperation(content, function (err, result, sourceMaps, meta) { + if (err) return callback(err); + callback(null, result, sourceMaps, meta); + }); +}; +``` + +## 'Raw' Loader + +By default, resource files are converted to UTF-8 strings and passed to the loader. loaders can receive raw `Buffer` by setting `raw` to `true`. Each loader can pass its processing results as `String` or `Buffer`, and the Rspack compiler will convert them to and from the loader. + +```js title="raw-loader.js" +module.exports = function (content) { + assert(content instanceof Buffer); + // ... +}; +module.exports.raw = true; +``` + +## Pitching loader + +Loaders are **always** called from right to left. There are some instances where the loader only cares about the **metadata** behind a request and can ignore the results of the previous loader. The `pitch` method on loaders is called from **left to right** before the loaders are actually executed (from right to left). + +For the following configuration of `use`: + +```js title="rspack.config.js" +module.exports = { + //... + module: { + rules: [ + { + //... + use: ['a-loader', 'b-loader', 'c-loader'], + }, + ], + }, +}; +``` + +These steps would occur: + +``` +|- a-loader `pitch` + |- b-loader `pitch` + |- c-loader `pitch` + |- requested module is picked up as a dependency + |- c-loader normal execution + |- b-loader normal execution +|- a-loader normal execution +``` + +Normally, if it the loader is simple enough which only exports the normal stage hook: + +```js +module.exports = function (source) {}; +``` + +Then, the pitching stage will be skipped. + +So why might a loader take advantage of the "pitching" phase? + +First, the data passed to the pitch method is exposed in the execution phase as well under this.data and could be useful for capturing and sharing information from earlier in the cycle. + +```js +module.exports = function (content) { + return someSyncOperation(content, this.data.value); +}; + +module.exports.pitch = function (remainingRequest, precedingRequest, data) { + data.value = 42; +}; +``` + +Second, if a loader delivers a result in the pitch method, the process turns around and skips the remaining loaders. +In our example above, if the b-loaders pitch method returned something: + +```js +module.exports = function (content) { + return someSyncOperation(content); +}; + +module.exports.pitch = function (remainingRequest, precedingRequest, data) { + if (someCondition()) { + return ( + 'module.exports = require(' + + JSON.stringify('-!' + remainingRequest) + + ');' + ); + } +}; +``` + +The steps above would be shortened to: + +``` +|- a-loader `pitch` + |- b-loader `pitch` returns a module +|- a-loader normal execution +``` + +For a real world example, `style-loader` leverages the second advantage to dispatch requests. +Please visit [style-loader](https://github.com/webpack-contrib/style-loader/blob/eb06baeb3ac4e3107732a21170b0a7f358c5423f/src/index.js#L39) for details. diff --git a/website/docs/en/api/loader-api/index.mdx b/website/docs/en/api/loader-api/index.mdx new file mode 100644 index 00000000000..0bab72a38a5 --- /dev/null +++ b/website/docs/en/api/loader-api/index.mdx @@ -0,0 +1,5 @@ +# Compatibility Status + +Rspack is committed to being compatible with the loaders within the webpack ecosystem. We ensure that Rspack is as compatible as possible with the webpack loader API, allowing more existing webpack loaders to be directly used in Rspack. + +We have already made most of the webpack loader APIs compatible. You can visit [this page](https://github.com/orgs/web-infra-dev/projects/10) to learn about the current compatibility status of webpack loader APIs. diff --git a/website/docs/en/api/loader-api/inline-match-resource.mdx b/website/docs/en/api/loader-api/inline-match-resource.mdx new file mode 100644 index 00000000000..fc8b89ffd33 --- /dev/null +++ b/website/docs/en/api/loader-api/inline-match-resource.mdx @@ -0,0 +1,52 @@ +import WebpackLicense from '@components/webpack-license'; + + + +# Inline matchResource + +Prefixing `!=!` to a request will set the `matchResource` for this request. + +When a `matchResource` is set, it will be used to match with the `module.rules` instead of the original resource. This can be useful if further loaders should be applied to the resource, or if the module type needs to be changed. + +Example: + +```js title="file.js" +/* STYLE: body { background: red; } */ +console.log('yep'); +``` + +A loader could transform the file into the following file and use the `matchResource` to apply the user-specified CSS processing rules: + +```js title="file.js (transformed by loader)" +import './file.js.css!=!extract-style-loader/getStyles!./file.js'; +console.log('yep'); +``` + +This will add a dependency to `extract-style-loader/getStyles!./file.js` and treat the result as `file.js.css`. +Because `module.rules` has a rule matching `/\.css$/` and it will apply to this dependency. + +The loader could look like this: + +```js title="extract-style-loader/index.js" +const getStylesLoader = require.resolve('./getStyles'); + +module.exports = function (source) { + if (STYLES_REGEXP.test(source)) { + source = source.replace(STYLES_REGEXP, ''); + return `import ${JSON.stringify( + this.utils.contextify( + this.context || this.rootContext, + `${this.resource}.css!=!${getStylesLoader}!${this.remainingRequest}`, + ), + )};${source}`; + } + return source; +}; +``` + +```js title="extract-style-loader/getStyles.js" +module.exports = function (source) { + const match = source.match(STYLES_REGEXP); + return match[0]; +}; +``` diff --git a/website/docs/en/api/loader-api/inline.mdx b/website/docs/en/api/loader-api/inline.mdx new file mode 100644 index 00000000000..7bfbf953060 --- /dev/null +++ b/website/docs/en/api/loader-api/inline.mdx @@ -0,0 +1,33 @@ +import WebpackLicense from '@components/webpack-license'; + + + +# Inline loaders + +It's possible to specify loaders in an `import` statement, or any equivalent "importing" method. Separate loaders from the resource with `!`. Each part is resolved relative to the current directory. + +```js +import Styles from 'style-loader!css-loader?modules!./styles.css'; +``` + +It's possible to override any loaders, preLoaders and postLoaders from the configuration by prefixing the inline `import` statement: + +- Prefixing with `!` will disable all configured normal loaders + + ```js + import Styles from '!style-loader!css-loader?modules!./styles.css'; + ``` + +- Prefixing with `!!` will disable all configured loaders (preLoaders, loaders, postLoaders) + + ```js + import Styles from '!!style-loader!css-loader?modules!./styles.css'; + ``` + +- Prefixing with `-!` will disable all configured preLoaders and loaders but not postLoaders + + ```js + import Styles from '-!style-loader!css-loader?modules!./styles.css'; + ``` + +Options can be passed with a query parameter, e.g. `?key=value&foo=bar`, or a JSON object, e.g. `?{"key":"value","foo":"bar"}`. diff --git a/website/docs/en/api/loader-api/rspack-specific-properties.mdx b/website/docs/en/api/loader-api/rspack-specific-properties.mdx new file mode 100644 index 00000000000..f85a3d5fde5 --- /dev/null +++ b/website/docs/en/api/loader-api/rspack-specific-properties.mdx @@ -0,0 +1,21 @@ +import WebpackLicense from '@components/webpack-license'; + + + +# Rspack specific properties + +The loader interface provides all module relate information. However in rare cases you might need access to the compiler api itself. + +:::warning +Please note that using these Rspack specific properties will have a negative impact on your loaders compatibility. + +Therefore you should only use them as a last resort. Using them will reduce the portability of your loader. +::: + +## this.\_compilation + +Access to the current Compilation object of Rspack. + +## this.\_compiler + +Access to the current Compiler object of Rspack. diff --git a/website/docs/en/api/modules.mdx b/website/docs/en/api/modules.mdx deleted file mode 100644 index e293c463a2d..00000000000 --- a/website/docs/en/api/modules.mdx +++ /dev/null @@ -1,142 +0,0 @@ -import WebpackLicense from '@components/webpack-license'; -import { ApiMeta } from '../../../components/ApiMeta'; - - - -# Modules - -While Rspack supports multiple module syntaxes, we recommend following a single syntax for consistency and to avoid odd behaviors/bugs. - -### ES6 (Recommended) - -Rspack support ES6 module syntax natively, you can use static `import`, `export` and `import()` syntax. - -#### Magic Comments - -By adding comments to the import, we can do things such as name our chunk or select different modes. - -```js -import( - /* webpackChunkName: "my-chunk-name" */ - /* webpackPrefetch: true */ - /* webpackPreload: true */ - 'module' -); -``` - -`webpackChunkName`: A name for the new chunk. - -`webpackPrefetch`: Tells the browser that the resource is probably needed for some navigation in the future (Available since 0.4.5). - -`webpackPreload`: Tells the browser that the resource might be needed during the current navigation (Available since 0.4.5). - -### CommonJS - -Rspack is also support `CommonJS` syntax natively, you can use `require` and `module.exports` syntax. - -### DataURI Module - -Rspack supports importing DataURI modules using the `import` and `require` syntax. - -**import** - -```js -import DataURI from 'data:text/javascript,export default 42'; -``` - -**require** - -```js -require('data:text/javascript,module.exports = 42'); -``` - -In addition, Base64 encoded requests are also supported: - -```js -const { - number, - fn, -} = require('data:text/javascript;charset=utf-8;base64,ZXhwb3J0IGNvbnN0IG51bWJlciA9IDQyOwpleHBvcnQgZnVuY3Rpb24gZm4oKSB7CiAgcmV0dXJuICJIZWxsbyB3b3JsZCI7Cn0='); -``` - -::: tip -The DataURI module can be used as a method to implement virtual modules, such as combining with a Loader to dynamically load custom modules at runtime. -::: - -### Webpack - -Aside from the module syntaxes described above, Rspack also support some webpack-specific methods. - -#### require.context - -```ts -require.context( - (directory: String), - (includeSubdirs: Boolean) /* optional, default true */, - (filter: RegExp) /* optional, default /^\.\/.*$/, any file */, - (mode: String) /* optional, 'sync' | 'eager' | 'weak' | 'lazy' | 'lazy-once', default 'sync' */ -); -``` - -Specify a whole group of dependencies using a path to the `directory`, an option to `includeSubdirs`, a filter for more fine grained control of the modules included, and a mode to define the way how loading will work. -If mode is set to 'lazy', the underlying modules will be loaded asynchronously. - -## Module Variables - -### module.hot (webpack-specific) - -Indicates whether or not Hot Module Replacement is enabled and provides an interface to the process. See the [HMR API page](/api/hmr) for details. - -### import.meta.webpackHot (webpack-specific) - -An alias for `module.hot`, however `import.meta.webpackHot` can be used in strict ESM while module.hot can't. - -### \_\_dirname (NodeJS) - -Depending on the configuration option `node.__dirname`: - -- false: Not defined -- mock: equal to '/' -- true: node.js \_\_dirname - If used inside an expression that is parsed by the Parser, the configuration option is treated as true. - -### \_\_resourceQuery (webpack-specific) - -The resource query of the current module. If the following require call was made, then the query string would be available in file.js. - -```ts -require('file.js?test'); -``` - -```ts title="file.js" -__resourceQuery === '?test'; -``` - -### \_\_webpack_modules\_\_ (webpack-specific) - -Access to the internal object of all modules. - -### \_\_webpack_hash\_\_ (webpack-specific) - -It provides access to the hash of the compilation. - -### \_\_webpack_public_path\_\_ (webpack-specific) - -Equals the configuration option's [`output.publicPath`](/config/output#outputpublicpath). - -### \_\_webpack_chunkname\_\_ (webpack-specific) - - - -Access to name of current chunk. - -### \_\_webpack_runtime_id\_\_ (webpack-specific) - - - -Access the runtime id of current entry. diff --git a/website/docs/en/api/modules/_meta.json b/website/docs/en/api/modules/_meta.json new file mode 100644 index 00000000000..e2ca1dde6e5 --- /dev/null +++ b/website/docs/en/api/modules/_meta.json @@ -0,0 +1 @@ +["module-methods", "module-variables"] diff --git a/website/docs/en/api/modules/module-methods.mdx b/website/docs/en/api/modules/module-methods.mdx new file mode 100644 index 00000000000..c5c07e4ce12 --- /dev/null +++ b/website/docs/en/api/modules/module-methods.mdx @@ -0,0 +1,167 @@ +import WebpackLicense from '@components/webpack-license'; + + + +# Module Methods + +This section covers all methods available in code compiled with Rspack. When using Rspack to bundle your application, you can pick from a variety of module syntax styles including ES6, CommonJS. + +While Rspack supports multiple module syntaxes, we recommend following a single syntax for consistency and to avoid odd behaviors/bugs. + +## ES6 (Recommended) + +Rspack support ES6 module syntax natively, you can use static `import`, `export` and `import()` syntax. + +### import + +Statically `import` the `export`s of another module. + +```js +import MyModule from './my-module.js'; +import { NamedExport } from './other-module.js'; +``` + +You can also `import` Data URI: + +```js +import 'data:text/javascript;charset=utf-8;base64,Y29uc29sZS5sb2coJ2lubGluZSAxJyk7'; +import { + number, + fn, +} from 'data:text/javascript;charset=utf-8;base64,ZXhwb3J0IGNvbnN0IG51bWJlciA9IDQyOwpleHBvcnQgY29uc3QgZm4gPSAoKSA9PiAiSGVsbG8gd29ybGQiOw=='; +``` + +### export + +Export anything as a `default` or named export. + +```js +// Named exports +export var Count = 5; +export function Multiply(a, b) { + return a * b; +} + +// Default export +export default { + // Some data... +}; +``` + +### Dynamic import() + +```ts +function(path: string): Promise +``` + +Dynamically load modules. Calls to `import()` are treated as split points, meaning the requested module and its children are split out into a separate chunk. + +```js +if (module.hot) { + import('lodash').then(_ => { + // Do something with lodash (a.k.a '_')... + }); +} +``` + +:::warning +This feature relies on `Promise` internally. If you use import() with older browsers, remember to shim `Promise` using a polyfill such as [es6-promise](https://github.com/stefanpenner/es6-promise) or [promise-polyfill](https://github.com/taylorhakes/promise-polyfill). +::: + +### Dynamic expressions in import() + +It is not possible to use a fully dynamic import statement, such as `import(foo)`. Because `foo` could potentially be any path to any file in your system or project. + +The `import()` must contain at least some information about where the module is located. Bundling can be limited to a specific directory or set of files so that when you are using a dynamic expression - every module that could potentially be requested on an `import()` call is included. +For example, `import(`./locale/$\{language}.json`)` will cause every `.json` file in the `./locale` directory to be bundled into the new chunk. At run time, when the variable `language` has been computed, any file like `english.json` or `german.json` will be available for consumption. + +```js +// imagine we had a method to get language from cookies or other storage +const language = detectVisitorLanguage(); +import(`./locale/${language}.json`).then(module => { + // do something with the translations +}); +``` + +### Magic Comments + +Inline comments to make features work. By adding comments to the import, we can do things such as name our chunk or select different modes. For a full list of these magic comments see the code below followed by an explanation of what these comments do. + +```js +import( + /* webpackChunkName: "my-chunk-name" */ + /* webpackPrefetch: true */ + /* webpackPreload: true */ + 'module' +); +``` + +`webpackChunkName`: A name for the new chunk. + +`webpackPrefetch`: Tells the browser that the resource is probably needed for some navigation in the future (Available since 0.4.5). + +`webpackPreload`: Tells the browser that the resource might be needed during the current navigation (Available since 0.4.5). + +## CommonJS + +Rspack is also support `CommonJS` syntax natively, you can use `require` and `module.exports` methods. + +## Data URI Module + +Rspack supports importing Data URI modules using the `import` and `require` syntax. + +**import** + +```js +import DataURI from 'data:text/javascript,export default 42'; +``` + +**require** + +```js +require('data:text/javascript,module.exports = 42'); +``` + +In addition, Base64 encoded requests are also supported: + +```js +const { + number, + fn, +} = require('data:text/javascript;charset=utf-8;base64,ZXhwb3J0IGNvbnN0IG51bWJlciA9IDQyOwpleHBvcnQgZnVuY3Rpb24gZm4oKSB7CiAgcmV0dXJuICJIZWxsbyB3b3JsZCI7Cn0='); +``` + +::: tip +The Data URI module can be used as a method to implement virtual modules, such as combining with a Loader to dynamically load custom modules at runtime. +::: + +## Webpack + +Aside from the module syntaxes described above, Rspack also support some webpack-specific methods. + +#### require.context + +```ts +require.context( + (directory: String), + (includeSubdirs: Boolean) /* optional, default true */, + (filter: RegExp) /* optional, default /^\.\/.*$/, any file */, + (mode: String) /* optional, 'sync' | 'eager' | 'weak' | 'lazy' | 'lazy-once', default 'sync' */ +); +``` + +Specify a whole group of dependencies using a path to the `directory`, an option to `includeSubdirs`, a `filter` for more fine grained control of the modules included, and a mode to define the way how loading will work. + +```js +const context = require.context('components', true, /\.html$/); +const componentA = context.resolve('componentA'); +``` + +If mode is set to 'lazy', the underlying modules will be loaded asynchronously. + +```js +const context = require.context('locales', true, /\.json$/, 'lazy'); +context('localeA').then(locale => { + // do something with locale +}); +``` diff --git a/website/docs/en/api/modules/module-variables.mdx b/website/docs/en/api/modules/module-variables.mdx new file mode 100644 index 00000000000..ee87d37be65 --- /dev/null +++ b/website/docs/en/api/modules/module-variables.mdx @@ -0,0 +1,62 @@ +import WebpackLicense from '@components/webpack-license'; +import { ApiMeta } from '../../../../components/ApiMeta'; + + + +# Module Variables + +This section covers all **variables** available in code compiled with webpack. Modules will have access to certain data from the compilation process through `module` and other variables. + +### module.hot (webpack-specific) + +Indicates whether or not Hot Module Replacement is enabled and provides an interface to the process. See the [HMR API page](/api/hmr) for details. + +### import.meta.webpackHot (webpack-specific) + +An alias for `module.hot`, however `import.meta.webpackHot` can be used in strict ESM while `module.hot` can't. + +### \_\_dirname (NodeJS) + +Depending on the configuration option `node.__dirname`: + +- `false`: Not defined +- `mock`: equal to `'/'` +- `true`: [node.js \_\_dirname](https://nodejs.org/api/globals.html#globals_dirname) + +If used inside an expression that is parsed by the Parser, the configuration option is treated as `true`. + +### \_\_resourceQuery (webpack-specific) + +The resource query of the current module. If the following `require` call was made, then the query string would be available in `file.js`. + +```ts +require('file.js?test'); +``` + +```ts title="file.js" +__resourceQuery === '?test'; +``` + +### \_\_webpack_modules\_\_ (webpack-specific) + +Access to the internal object of all modules. + +### \_\_webpack_hash\_\_ (webpack-specific) + +It provides access to the hash of the compilation. + +### \_\_webpack_public_path\_\_ (webpack-specific) + +Equals the configuration option's [`output.publicPath`](/config/output#outputpublicpath). + +### \_\_webpack_chunkname\_\_ (webpack-specific) + + + +Access to name of current chunk. + +### \_\_webpack_runtime_id\_\_ (webpack-specific) + + + +Access the runtime id of current entry. diff --git a/website/docs/en/api/plugin-api.mdx b/website/docs/en/api/plugin-api.mdx deleted file mode 100644 index 658a8ff7fac..00000000000 --- a/website/docs/en/api/plugin-api.mdx +++ /dev/null @@ -1,233 +0,0 @@ -import { ApiMeta, Stability } from '@components/ApiMeta'; -import WebpackLicense from '@components/webpack-license'; - - - -# Plugin API - - - -::: info Webpack Plugin API conformance -Check out [this](https://github.com/orgs/web-infra-dev/projects/9) page to see the status of Webpack Plugin API conformance. -::: - -## Compiler Hooks - -### `environment` - -`SyncHook<[]>` - -Called while preparing the compiler environment, right after initializing the plugins in the configuration file. - -### `afterEnvironment` - -`SyncHook<[]>` - -Called right after the environment hook, when the compiler environment setup is complete. - -### `afterPlugins` - -`SyncHook<[Compiler]>` - -Called after setting up initial set of internal plugins. - -### `afterResolvers` - -`SyncHook<[Compiler]>` - -Triggered after resolver setup is complete. - -### `entryOption` - -`SyncBailHook<[string, EntryNormalized]>` - -Called after the entry configuration has been processed. - -### `initialize` - -`SyncHook<[]>` - -Called when a compiler object is initialized. - -### `beforeRun` - -`AsyncSeriesHook<[Compiler]>` - -Adds a hook right before running the compiler. - -### `run` - -`AsyncSeriesHook<[Compiler]>` - -Called at the beginning of a build execution. - -### `childCompiler` - -`SyncHook[Compiler, string, number]` - -> where the version of the function type is `>=0.4.1`. - -Executed after created a childCompiler. - -### `watchRun` - -`AsyncSeriesHook<[Compiler]>` - -Executes a plugin during watch mode after a new compilation is triggered but before the compilation is actually started. - -### `compile` - -`SyncHook<[]>` - -Called right after beforeCompile, before a new compilation is created. - -### `beforeCompile` - -`AsyncSeriesHook<[]>` - -Executes a plugin after compilation parameters are created. - -### `afterCompile` - -`AsyncSeriesHook<[Compilation]>` - -Called after finishing and sealing the compilation. - -### `thisCompilation` - -`SyncHook<[Compilation]>` - -Executed while initializing the compilation, right before emitting the compilation event. - -### `compilation` - -`SyncHook<[Compilation]>` - -Runs a plugin after a compilation has been created. - -### `make` - -`AsyncParallelHook<[Compilation]>` - -Executed before the make stage. - -### `shouldEmit` - -`SyncBailHook<[Compilation]>` - -> where the version of the function type is `>=0.4.1`. - -Return a boolean telling whether to emit. - -### `emit` - -`AsyncSeriesHook<[Compilation]>` - -Executed right before emitting assets to output directory. - -### `afterEmit` - -`AsyncSeriesHook<[Compilation]>` - -Called after emitting assets to output directory. - -### `done` - -`AsyncSeriesHook` - -Executed when the compilation has completed. - -### `afterDone` - -`AsyncSeriesHook` - -Executed after `done` hook. - -### `watchClose` - -`SyncHook<[]>` - -Called when a watching compilation has stopped. - -### `failed` - -`SyncHook<[Error]>` - -Called if the compilation fails. - -## Compilation Hooks - -### `buildModule` - -`SyncHook<[JsModule]>` - -Triggered before a module build has started, can be used to modify the module (Rspack currently only support reading the module, modifying is not supported yet). - -### `processAssets` - -`AsyncSeriesHook<[CompilationAssets]>` - -Process the assets before emit. - -### `optimizeModules` - -`SyncBailHook<[JsModule[]]>` - -Called at the beginning of the module optimization phase. A plugin can tap into this hook to perform optimizations on modules. - -### `optimizeChunkModule` - -`AsyncSeriesBailHook<[JsModule[]]>` - -Called after the tree optimization, at the beginning of the chunk modules optimization. A plugin can tap into this hook to perform optimizations of chunk modules. - -### `succeedModule` - -`SyncHook<[JsModule]>` - -Executed when a module has been built successfully. - -### `finishModules` - -`AsyncSeriesHook<[JsModule[]]>` - -Called when all modules have been built without errors. - -### `chunkAsset` - -`SyncHook<[JsChunk[], string /** filename*/ ]>` - -Triggered when an asset from a chunk was added to the compilation. - -## NormalModuleFactory - -### `beforeResolve` - -`AsyncSeriesBailHook<[ResolveData]>` - -Called when a new dependency request is encountered. A dependency can be ignored by returning `false`. Otherwise, it should return `undefined` to proceed. - -### `afterResolve` - -`AsyncSeriesBailHook<[ResolveData]>` - -Called after the request is resolved. - -### `ResolveForScheme` - -`AsyncSeriesBailHook<[ResourceDataWithData]>` - -Called before a request with scheme (URI) is resolved. - -## ContextModuleFactory - -### `afterResolve` - -`AsyncSeriesBailHook<[ResolveData]>` - -Called after the requested directory resolved. diff --git a/website/docs/en/api/plugin-api/_meta.json b/website/docs/en/api/plugin-api/_meta.json new file mode 100644 index 00000000000..61c98e4028d --- /dev/null +++ b/website/docs/en/api/plugin-api/_meta.json @@ -0,0 +1,7 @@ +[ + "index", + "compiler-hooks", + "compilation-hooks", + "normal-module-factory-hooks", + "context-module-factory-hooks" +] diff --git a/website/docs/en/api/plugin-api/compilation-hooks.mdx b/website/docs/en/api/plugin-api/compilation-hooks.mdx new file mode 100644 index 00000000000..28bf67173fe --- /dev/null +++ b/website/docs/en/api/plugin-api/compilation-hooks.mdx @@ -0,0 +1,43 @@ +# Compilation Hooks + +## `buildModule` + +`SyncHook<[JsModule]>` + +Triggered before a module build has started, can be used to modify the module (Rspack currently only support reading the module, modifying is not supported yet). + +## `processAssets` + +`AsyncSeriesHook<[CompilationAssets]>` + +Process the assets before emit. + +## `optimizeModules` + +`SyncBailHook<[JsModule[]]>` + +Called at the beginning of the module optimization phase. A plugin can tap into this hook to perform optimizations on modules. + +## `optimizeChunkModule` + +`AsyncSeriesBailHook<[JsModule[]]>` + +Called after the tree optimization, at the beginning of the chunk modules optimization. A plugin can tap into this hook to perform optimizations of chunk modules. + +## `succeedModule` + +`SyncHook<[JsModule]>` + +Executed when a module has been built successfully. + +## `finishModules` + +`AsyncSeriesHook<[JsModule[]]>` + +Called when all modules have been built without errors. + +## `chunkAsset` + +`SyncHook<[JsChunk[], string /** filename*/ ]>` + +Triggered when an asset from a chunk was added to the compilation. diff --git a/website/docs/en/api/plugin-api/compiler-hooks.mdx b/website/docs/en/api/plugin-api/compiler-hooks.mdx new file mode 100644 index 00000000000..39d6a810371 --- /dev/null +++ b/website/docs/en/api/plugin-api/compiler-hooks.mdx @@ -0,0 +1,143 @@ +# Compiler Hooks + +## `environment` + +`SyncHook<[]>` + +Called while preparing the compiler environment, right after initializing the plugins in the configuration file. + +## `afterEnvironment` + +`SyncHook<[]>` + +Called right after the environment hook, when the compiler environment setup is complete. + +## `afterPlugins` + +`SyncHook<[Compiler]>` + +Called after setting up initial set of internal plugins. + +## `afterResolvers` + +`SyncHook<[Compiler]>` + +Triggered after resolver setup is complete. + +## `entryOption` + +`SyncBailHook<[string, EntryNormalized]>` + +Called after the entry configuration has been processed. + +## `initialize` + +`SyncHook<[]>` + +Called when a compiler object is initialized. + +## `beforeRun` + +`AsyncSeriesHook<[Compiler]>` + +Adds a hook right before running the compiler. + +## `run` + +`AsyncSeriesHook<[Compiler]>` + +Called at the beginning of a build execution. + +## `childCompiler` + +`SyncHook[Compiler, string, number]` + +> where the version of the function type is `>=0.4.1`. + +Executed after created a childCompiler. + +## `watchRun` + +`AsyncSeriesHook<[Compiler]>` + +Executes a plugin during watch mode after a new compilation is triggered but before the compilation is actually started. + +## `compile` + +`SyncHook<[]>` + +Called right after beforeCompile, before a new compilation is created. + +## `beforeCompile` + +`AsyncSeriesHook<[]>` + +Executes a plugin after compilation parameters are created. + +## `afterCompile` + +`AsyncSeriesHook<[Compilation]>` + +Called after finishing and sealing the compilation. + +## `thisCompilation` + +`SyncHook<[Compilation]>` + +Executed while initializing the compilation, right before emitting the compilation event. + +## `compilation` + +`SyncHook<[Compilation]>` + +Runs a plugin after a compilation has been created. + +## `make` + +`AsyncParallelHook<[Compilation]>` + +Executed before the make stage. + +## `shouldEmit` + +`SyncBailHook<[Compilation]>` + +> where the version of the function type is `>=0.4.1`. + +Return a boolean telling whether to emit. + +## `emit` + +`AsyncSeriesHook<[Compilation]>` + +Executed right before emitting assets to output directory. + +## `afterEmit` + +`AsyncSeriesHook<[Compilation]>` + +Called after emitting assets to output directory. + +## `done` + +`AsyncSeriesHook` + +Executed when the compilation has completed. + +## `afterDone` + +`AsyncSeriesHook` + +Executed after `done` hook. + +## `watchClose` + +`SyncHook<[]>` + +Called when a watching compilation has stopped. + +## `failed` + +`SyncHook<[Error]>` + +Called if the compilation fails. diff --git a/website/docs/en/api/plugin-api/context-module-factory-hooks.mdx b/website/docs/en/api/plugin-api/context-module-factory-hooks.mdx new file mode 100644 index 00000000000..dd52d6a7fc4 --- /dev/null +++ b/website/docs/en/api/plugin-api/context-module-factory-hooks.mdx @@ -0,0 +1,7 @@ +# ContextModuleFactory + +## `afterResolve` + +`AsyncSeriesBailHook<[ResolveData]>` + +Called after the requested directory resolved. diff --git a/website/docs/en/api/plugin-api/index.mdx b/website/docs/en/api/plugin-api/index.mdx new file mode 100644 index 00000000000..45fcad65f5d --- /dev/null +++ b/website/docs/en/api/plugin-api/index.mdx @@ -0,0 +1,5 @@ +# Compatibility Status + +Rspack is committed to being compatible with the plugins within the webpack ecosystem. We ensure that Rspack is as compatible as possible with the webpack plugin API, allowing more existing webpack plugins to be directly used in Rspack. + +We have already made most of the webpack plugin APIs compatible. You can visit [this page](https://github.com/orgs/web-infra-dev/projects/9) to learn about the current compatibility status of webpack plugin APIs. diff --git a/website/docs/en/api/plugin-api/normal-module-factory-hooks.mdx b/website/docs/en/api/plugin-api/normal-module-factory-hooks.mdx new file mode 100644 index 00000000000..e0535d118de --- /dev/null +++ b/website/docs/en/api/plugin-api/normal-module-factory-hooks.mdx @@ -0,0 +1,19 @@ +# NormalModuleFactory + +## `beforeResolve` + +`AsyncSeriesBailHook<[ResolveData]>` + +Called when a new dependency request is encountered. A dependency can be ignored by returning `false`. Otherwise, it should return `undefined` to proceed. + +## `afterResolve` + +`AsyncSeriesBailHook<[ResolveData]>` + +Called after the request is resolved. + +## `ResolveForScheme` + +`AsyncSeriesBailHook<[ResourceDataWithData]>` + +Called before a request with scheme (URI) is resolved. diff --git a/website/docs/en/blog/_meta.json b/website/docs/en/blog/_meta.json index 3ef23348445..d8c4340d4d9 100644 --- a/website/docs/en/blog/_meta.json +++ b/website/docs/en/blog/_meta.json @@ -1,4 +1,5 @@ [ + "index", "announcing-0-6", "announcing-0-5", "module-federation-added-to-rspack", diff --git a/website/docs/en/blog/announcing-0-2.mdx b/website/docs/en/blog/announcing-0-2.mdx index 3cf812c4caf..e787e32fa51 100644 --- a/website/docs/en/blog/announcing-0-2.mdx +++ b/website/docs/en/blog/announcing-0-2.mdx @@ -16,7 +16,7 @@ We look forward to you experiencing these new improvements in version 0.2, and w ### Loader -Version 0.2 has completed compatibility with most of the loader APIs, including: inline match resource, pitching loader, and inline loader. More APIs have further improved compatibility with webpack loaders, details of which can be found in our webpack compatibility updates [Loader API](/api/loader-api.html). +Version 0.2 has completed compatibility with most of the loader APIs, including: inline match resource, pitching loader, and inline loader. More APIs have further improved compatibility with webpack loaders, details of which can be found in our webpack compatibility updates [Loader API](/api/loader-api/index). ### Plugin Hooks @@ -24,25 +24,25 @@ New hooks for plugins have been added. Compiler hooks: -1. [beforeCompile](/api/plugin-api#beforecompile) -2. [afterCompile](/api/plugin-api#aftercompile) +1. [beforeCompile](/api/plugin-api/compiler-hooks#beforecompile) +2. [afterCompile](/api/plugin-api/compiler-hooks#aftercompile) Compilation hooks: -1. [optimizeModules](/api/plugin-api#optimizemodules) -2. [optimizeChunkModule](/api/plugin-api#optimizechunkmodules) -3. [finishModules](/api/plugin-api#finishmodules) -4. [chunkAsset](/api/plugin-api#chunkasset) +1. [optimizeModules](/api/plugin-api/compilation-hooks#optimizemodules) +2. [optimizeChunkModule](/api/plugin-api/compilation-hooks#optimizechunkmodules) +3. [finishModules](/api/plugin-api/compilation-hooks#finishmodules) +4. [chunkAsset](/api/plugin-api/compilation-hooks#chunkasset) NormalModuleFactory hooks: -1. [beforeResolve](/api/plugin-api#beforeresolve) -2. [afterResolve](/api/plugin-api#afterresolve) -3. [ResolveForScheme](/api/plugin-api#resolveforscheme) +1. [beforeResolve](/api/plugin-api/normal-module-factory-hooks#beforeresolve) +2. [afterResolve](/api/plugin-api/normal-module-factory-hooks#afterresolve) +3. [ResolveForScheme](/api/plugin-api/normal-module-factory-hooks#resolveforscheme) ContextModuleFactory hooks: -1. [beforeResolve](/api/plugin-api#beforeresolve) +1. [beforeResolve](/api/plugin-api/context-module-factory-hooks#beforeresolve) ### realContentHash diff --git a/website/docs/en/blog/index.mdx b/website/docs/en/blog/index.mdx new file mode 100644 index 00000000000..468d504d996 --- /dev/null +++ b/website/docs/en/blog/index.mdx @@ -0,0 +1,79 @@ +--- +title: Overview +--- + +# Rspack Blogs + +Check here for the latest articles and release announcements about Rspack. + +## [Deep Dive into Rspack Tree Shaking](https://github.com/orgs/web-infra-dev/discussions/17) + +> April 17, 2024 + +This article primarily focuses on understanding the concept of Rspack & Webpack tree shaking. + +## [Announcing Rspack v0.6](/blog/announcing-0-6) + +> April 10, 2024 + +Rspack v0.6 is out, with built-in support for mini-css-extract-plugin and new tree-shaking enabled by default. + +## [Webpack Chunk Graph Algorithm](https://github.com/orgs/web-infra-dev/discussions/15) + +> January 12, 2024 + +This article introduces the chunk strategy of webpack. Through this article, you can understand when a chunk will be generated in the code and how to reduce the chunk size, etc. + +## [Announcing Rspack v0.5](/blog/announcing-0-5) + +> January 09, 2024 + +Rspack v0.5 is out, supporting Module Federation and removing the default SWC transformation. + +## [Module Federation added to Rspack](/blog/module-federation-added-to-rspack) + +> January 09, 2024 + +The latest Rspack 0.5.0 introduces the highly anticipated Module Federation, which is detailed in this article. + +## [Webpack CSS Order Issue](https://github.com/orgs/web-infra-dev/discussions/12) + +> November 29, 2023 + +This article shows how the CSS order problem occurs in webpack and how to solve it. + +## [Announcing Rspack v0.4](/blog/announcing-0-4) + +> November 02, 2023 + +Rspack v0.5 is out, removing support for some builtin features. + +## [Deep Dive into Top-level await](https://github.com/orgs/web-infra-dev/discussions/9) + +> October 26, 2023 + +In this article, we will take a closer look at aspects such as the specification, toolchain support, webpack runtime, and profiling of top level await. + +## [Design Trade-offs in Bundler](https://github.com/orgs/web-infra-dev/discussions/1) + +> August 30, 2023 + +This article explains why we decided to develop Rspack and what trade-offs we made during the design process. + +## [Announcing Rspack v0.3](/blog/announcing-0-3) + +> August 24, 2023 + +Rspack v0.3 is out, adding support for web workers and the builtin:swc-loader. + +## [Announcing Rspack v0.2](/blog/announcing-0-2) + +> June 02, 2023 + +Rspack v0.2 is out, introducing many new features, such as support for realContentHash, DataURI, and the ESM format, and more. + +## [Announcing Rspack v0.1](/blog/announcing-0-1) + +> March 06, 2023 + +Rspack has officially been released! diff --git a/website/docs/en/config/entry.mdx b/website/docs/en/config/entry.mdx index 9174e9d4c36..6668ad1e923 100644 --- a/website/docs/en/config/entry.mdx +++ b/website/docs/en/config/entry.mdx @@ -207,7 +207,7 @@ The format of the chunk generated by this entry as a library, for detailed confi ## Dynamic entry -If a function is passed then it will be invoked on every [make](/api/plugin-api#make) event. +If a function is passed then it will be invoked on every [make](/api/plugin-api/compiler-hooks#make) event. > Note that the `make` event triggers when webpack starts and for every invalidation when [watching for file changes](/config/watch). diff --git a/website/docs/en/config/resolve-loader.mdx b/website/docs/en/config/resolve-loader.mdx index 05fd03270e4..cdcfb44150b 100644 --- a/website/docs/en/config/resolve-loader.mdx +++ b/website/docs/en/config/resolve-loader.mdx @@ -40,5 +40,5 @@ require('!!amazing-loader!./amazing-file.js'); ``` ::: info Inline Loaders -The loader mentioned above uses the syntax of inline loaders. For details, please refer to [here](/api/loader-api#inline-loaders). +The loader mentioned above uses the syntax of inline loaders. For details, please refer to [here](/api/loader-api/inline). ::: diff --git a/website/docs/en/guide/compatibility/plugin.mdx b/website/docs/en/guide/compatibility/plugin.mdx index 43792d6dbb4..fc362ade820 100644 --- a/website/docs/en/guide/compatibility/plugin.mdx +++ b/website/docs/en/guide/compatibility/plugin.mdx @@ -1,7 +1,9 @@ -import { PluginCompatibleCardList } from '@components/CompatibleCard.tsx'; +import { CommunityPluginCompatibleTable } from '@components/CommunityCompatibleTable.tsx'; # Plugin compat -This index lists the plugins that have been verified by compatibility tests with Rspack. +This index lists the compatibility status of some commonly community plugins in Rspack. - +The support status of Rspack for the built-in plugins in webpack can be refer to [Webpack-aligned built-in plugins](/plugins/webpack/index). + + diff --git a/website/docs/en/guide/features/loader.mdx b/website/docs/en/guide/features/loader.mdx index c3d3b892fe2..ffd700b4a4f 100644 --- a/website/docs/en/guide/features/loader.mdx +++ b/website/docs/en/guide/features/loader.mdx @@ -133,7 +133,7 @@ module.exports = { }; ``` -For details, you can refer to [loader-api](/api/loader-api) +For details, you can refer to [loader-api](/api/loader-api/index) ### Using Built-in Loader diff --git a/website/docs/en/guide/features/plugin.mdx b/website/docs/en/guide/features/plugin.mdx index 131de789797..617e5b37996 100644 --- a/website/docs/en/guide/features/plugin.mdx +++ b/website/docs/en/guide/features/plugin.mdx @@ -1,12 +1,28 @@ # Plugins -If [loaders](/guide/features/loader) are the workhorse for file transformations (preprocessing), then plugins are the workhorse for the overall Rspack build process. Most of Rspack's native implementations rely on the Rust side of the plugin system. For Node users, you don't need to worry about interoperation issues with Rust, because Rspack takes care of those details for you automatically. You can just focus on how to use the plugins. +If [loaders](/guide/features/loader) are the workhorse for file transformations (preprocessing), then plugins are the workhorse for the overall Rspack build process. Most of Rspack's native implementations rely on the Rust side of the plugin system. For Node users, you don't need to worry about compatibility issues with Rust, because Rspack takes care of those details for you automatically. You can just focus on how to use the plugins. Find out [plugins](/plugins/index) you can use with Rspack. -## Example +## Plugin usage -### Authoring plugins +Here's an example of how to use the already compatible [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer) in `rspack.config.js`: + +```js title="rspack.config.js" +const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); + +module.exports = { + plugins: [new BundleAnalyzerPlugin()], +}; +``` + +If you're looking for more Rspack plugins, have a look at the great list of [supported plugins](/plugins/index). + +You can also refer to [Plugin compat](/guide/compatibility/plugin) for the list of webpack plugins that have passed Rspack compatibility tests. + +## Write a plugin + +### Plugin structure -The structure of a plugin is very simple: just implement an `apply` method that accepts a `Compiler` instance. It will be called when the Rspack plugin is initialized. The detailed API can be found in the [Plugin API](/api/plugin-api). +As a plugin author, the structure of a plugin is very simple: just implement an `apply` method that accepts a `Compiler` instance. It will be called when the Rspack plugin is initialized. The detailed API can be found in the [Plugin API](/api/plugin-api/index). ```js const PLUGIN_NAME = 'MyPlugin'; @@ -24,22 +40,7 @@ module.exports = MyPlugin; We use CommonJS style module exports so that plugins can be imported directly using `require` in `rspack.config.js`. -### Consuming plugins - -Here's an example of how to use the already compatible [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer) in `rspack.config.js`: - -```js title="rspack.config.js" -const BundleAnalyzerPlugin = - require('webpack-bundle-analyzer').BundleAnalyzerPlugin; - -module.exports = { - plugins: [new BundleAnalyzerPlugin()], -}; -``` - -Please refer to [Plugin compat](/guide/compatibility/plugin) for the list of plugins that have passed Rspack compatibility tests. - -### Type definitions +### Write with TypeScript If you use TypeScript to write Rspack plugins, you can import `Compiler` and `RspackPluginInstance` to declare the types of your plugins: diff --git a/website/docs/en/plugins/rspack/html-rspack-plugin.mdx b/website/docs/en/plugins/rspack/html-rspack-plugin.mdx index 22acbea6c3b..fa36c5135ac 100644 --- a/website/docs/en/plugins/rspack/html-rspack-plugin.mdx +++ b/website/docs/en/plugins/rspack/html-rspack-plugin.mdx @@ -5,147 +5,256 @@ import { ApiMeta } from '@components/ApiMeta.tsx'; -This plugin can be used to create HTML files that are associated with Rspack assets. +`rspack.HtmlRspackPlugin` is a high-performance HTML plugin implemented in Rust. You can use it to generate HTML files for Rspack projects. ```js new rspack.HtmlRspackPlugin(options); ``` -- options - - - **Type:** - - ```ts - type HtmlRspackPluginOptions = { - title?: string; - filename?: string; - template?: string; - templateContent?: string; - templateParameters?: Record; - inject?: 'head' | 'body'; - publicPath?: string; - scriptLoading?: 'blocking' | 'defer' | 'module'; - chunks?: string[]; - excludedChunks?: string[]; - sri?: 'sha256' | 'sha384' | 'sha512'; - minify?: boolean; - favicon?: string; - meta?: Record>; - }; - ``` - - - **Default:** `{}` - -
`', - default: '{}', - description: 'Allows to overwrite the parameters used in the template.', - }, - { - name: '`inject`', - type: "`'head'|'body'|undefined`", - default: 'undefined', - description: 'The script and link tag inject position in `template`.', - }, - { - name: '`publicPath`', - type: '`string`', - default: "''", - description: 'The publicPath used for script and link tags.', - }, - { - name: '`scriptLoading`', - type: "`'blocking'|'defer'|'module'`", - default: "'defer'", - description: - "Modern browsers support non blocking javascript loading ('defer') to improve the page startup performance. Setting to 'module' adds attribute type='module'. This also implies 'defer', since modules are automatically deferred.", - }, - { - name: '`chunks`', - type: '`string[]|undefined`', - default: 'undefined', - description: 'Allows you to add only some chunks.', - }, - { - name: '`excludedChunks`', - type: '`string[]|undefined`', - default: 'undefined', - description: 'Allows you to skip some chunks.', - }, - { - name: '`sri`', - type: "`'sha256'|'sha384'|'sha512'|undefined`", - default: 'undefined', - description: 'The sri hash algorithm, disabled by default.', - }, - { - name: '`minify`', - type: '`boolean`', - default: 'false', - description: 'Controls whether to minify the output.', - }, - { - name: '`favicon`', - type: '`string|undefined`', - default: 'undefined', - description: 'Adds the given favicon path to the output HTML.', - }, - { - name: '`meta`', - type: '`Record>` ', - default: '{}', - description: 'Allows to inject meta-tags.', - }, - ]} - /> - -:::tip -If the configuration options provided by `rspack.HtmlRspackPlugin` cannot meet your needs, you can also directly use the community's [html-webpack-plugin](https://www.npmjs.com/package/html-webpack-plugin) plugin. -::: +## Comparison + +Before using `rspack.HtmlRspackPlugin`, please note that there are some differences between `rspack.HtmlRspackPlugin` and the community [html-webpack-plugin](https://www.npmjs.com/package/html-webpack-plugin). + +### Performance + +Because `rspack.HtmlRspackPlugin` is implemented in Rust, its build performance is significantly better than html-webpack-plugin, especially in scenarios where many HTML files are being built. + +### Features + +The features of `rspack.HtmlRspackPlugin` are a subset of `html-webpack-plugin`. To ensure the performance of the plugin, we have not implemented all the features provided by html-webpack-plugin. + +If its options do not meet your needs, you can also directly use the community [html-webpack-plugin](https://www.npmjs.com/package/html-webpack-plugin). + +## Usage + +The plugin will generate an HTML file for you that includes all your JS outputs in the head using ` + + + +``` + +If you have multiple entry points in your Rspack config, they will all be included with ` + + + +``` + +如果你的 Rspack 配置中有多个 entry points,它们的生成 `