-
-
Notifications
You must be signed in to change notification settings - Fork 553
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add build unique id for detecting (#6865)
* feat: add build unique id for detecting * feat: add build unique id for detecting
- Loading branch information
1 parent
fc2e737
commit 7215fa8
Showing
42 changed files
with
455 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
crates/rspack_plugin_runtime/src/runtime_module/rspack_unique_id.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use rspack_core::{ | ||
impl_runtime_module, | ||
rspack_sources::{BoxSource, RawSource, SourceExt}, | ||
Compilation, RuntimeModule, RuntimeModuleStage, | ||
}; | ||
use rspack_identifier::Identifier; | ||
|
||
#[impl_runtime_module] | ||
#[derive(Debug)] | ||
pub struct RspackUniqueIdRuntimeModule { | ||
id: Identifier, | ||
bundler_name: String, | ||
bundler_version: String, | ||
} | ||
|
||
impl RspackUniqueIdRuntimeModule { | ||
pub fn new(bundler_name: String, bundler_version: String) -> Self { | ||
Self::with_default( | ||
Identifier::from("webpack/runtime/rspack_unique_id"), | ||
bundler_name, | ||
bundler_version, | ||
) | ||
} | ||
} | ||
|
||
impl RuntimeModule for RspackUniqueIdRuntimeModule { | ||
fn stage(&self) -> RuntimeModuleStage { | ||
RuntimeModuleStage::Attach | ||
} | ||
fn name(&self) -> Identifier { | ||
self.id | ||
} | ||
|
||
fn generate(&self, _: &Compilation) -> rspack_error::Result<BoxSource> { | ||
Ok( | ||
RawSource::from( | ||
include_str!("runtime/get_unique_id.js") | ||
.replace("$BUNDLER_NAME$", &self.bundler_name) | ||
.replace("$BUNDLER_VERSION$", &self.bundler_version), | ||
) | ||
.boxed(), | ||
) | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
crates/rspack_plugin_runtime/src/runtime_module/runtime/get_unique_id.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__webpack_require__.ruid = "bundler=$BUNDLER_NAME$@$BUNDLER_VERSION$"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
7215fa8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Ran ecosystem CI: Open
7215fa8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Benchmark detail: Open