Skip to content

Commit

Permalink
chore: 🤖 update env
Browse files Browse the repository at this point in the history
  • Loading branch information
IWANABETHATGUY committed Sep 21, 2023
1 parent 99afe64 commit e55b2be
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 3 additions & 1 deletion crates/rspack/tests/fixtures.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::path::PathBuf;
use std::sync::atomic::Ordering;

use cargo_rst::git_diff;
use rspack_core::{BoxPlugin, CompilerOptions, TreeShaking, UsedExportsOption};
use rspack_core::{BoxPlugin, CompilerOptions, TreeShaking, UsedExportsOption, IS_NEW_TREESHAKING};
use rspack_plugin_javascript::{FlagDependencyExportsPlugin, FlagDependencyUsagePlugin};
use rspack_testing::test_fixture;
use testing_macros::fixture;
Expand All @@ -27,6 +28,7 @@ fn tree_shaking(fixture_path: PathBuf) {
// First test is old version tree shaking snapshot test
test_fixture(&fixture_path, Box::new(|_, _| {}), None);
// second test is webpack based tree shaking
IS_NEW_TREESHAKING.store(true, Ordering::SeqCst);
test_fixture(
&fixture_path,
Box::new(
Expand Down
7 changes: 3 additions & 4 deletions crates/rspack_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
#![feature(box_patterns)]
#![feature(anonymous_lifetime_in_impl_trait)]

use std::sync::atomic::AtomicBool;
use std::{fmt, sync::Arc};
mod fake_namespace_object;
pub use fake_namespace_object::*;
mod module_profile;
pub use module_profile::*;
use once_cell::sync::Lazy;
use rkyv::with::Atomic;
use rspack_database::Database;
pub mod external_module;
pub use external_module::*;
Expand Down Expand Up @@ -253,7 +255,4 @@ pub type ChunkByUkey = Database<Chunk>;
pub type ChunkGroupByUkey = Database<ChunkGroup>;
pub(crate) type SharedPluginDriver = Arc<PluginDriver>;

pub static IS_NEW_TREESHAKING: Lazy<bool> = Lazy::new(|| -> bool {
// std::env::set_var(key, value);
std::env::var("IS_NEW_TREESHAKING").is_ok()
});
pub static IS_NEW_TREESHAKING: AtomicBool = AtomicBool::new(false);
2 changes: 1 addition & 1 deletion crates/rspack_core/src/module_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl ModuleGraph {
) -> Result<()> {
let is_module_dependency = dependency.as_module_dependency().is_some();
let dependency_id = *dependency.id();
let condition = if *IS_NEW_TREESHAKING {
let condition = if IS_NEW_TREESHAKING.load(std::sync::atomic::Ordering::Relaxed) {
dependency
.as_module_dependency()
.and_then(|dep| dep.get_condition())
Expand Down
2 changes: 1 addition & 1 deletion crates/rspack_core/src/module_graph_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl ModuleGraphModule {
// }

pub fn depended_modules<'a>(&self, module_graph: &'a ModuleGraph) -> Vec<&'a ModuleIdentifier> {
if *IS_NEW_TREESHAKING {
if IS_NEW_TREESHAKING.load(std::sync::atomic::Ordering::Relaxed) {
self
.outgoing_connections_unordered(module_graph)
.expect("should have outgoing connections")
Expand Down

0 comments on commit e55b2be

Please sign in to comment.