Skip to content

Commit

Permalink
Merge branch 'main' into chore/diagnose-windows
Browse files Browse the repository at this point in the history
  • Loading branch information
h-a-n-a authored Sep 4, 2023
2 parents 9ea75c6 + 3dfaee5 commit 62704eb
Show file tree
Hide file tree
Showing 19 changed files with 553 additions and 155 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,36 @@ jobs:
uses: ./.github/workflows/reusable-build.yml
with:
target: x86_64-unknown-linux-gnu
profile: 'debug'
profile: "debug"

test-windows:
name: Test Windows
uses: ./.github/workflows/reusable-build.yml
with:
target: x86_64-pc-windows-msvc
profile: 'debug'
profile: "debug"

test-mac:
name: Test Mac
if: github.ref_name == 'main'
uses: ./.github/workflows/reusable-build.yml
with:
target: x86_64-apple-darwin
profile: 'debug'
profile: "debug"
cargo-deny:
name: Check license of dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install cargo-deny
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-deny
version: "0.11.3"

- name: Check licenses
run: |
cargo deny check license
spell:
name: Spell check
runs-on: ubuntu-latest
Expand Down
13 changes: 13 additions & 0 deletions crates/rspack_core/src/compiler/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ impl Compilation {
diagnostics,
dependencies,
current_profile,
exports_info_related,
} = task_result;
let module_identifier = factory_result.module.identifier();

Expand All @@ -638,6 +639,18 @@ impl Compilation {
self
.missing_dependencies
.extend(factory_result.missing_dependencies);
self.module_graph.exports_info_map.insert(
exports_info_related.exports_info.id,
exports_info_related.exports_info,
);
self.module_graph.export_info_map.insert(
exports_info_related.side_effects_info.id,
exports_info_related.side_effects_info,
);
self.module_graph.export_info_map.insert(
exports_info_related.other_exports_info.id,
exports_info_related.other_exports_info,
);

add_queue.add_task(AddTask {
original_module_identifier,
Expand Down
15 changes: 13 additions & 2 deletions crates/rspack_core/src/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,23 @@ where
.module_graph
.module_identifier_to_module_graph_module,
);
let mut export_info_map =
std::mem::take(&mut self.compilation.module_graph.export_info_map);
for mgm in mi_to_mgm.values_mut() {
// merge exports info
if let Some(exports_map) = exports_info_map.remove(&mgm.module_identifier) {
mgm.exports.exports.extend(exports_map.into_iter());
let exports = self
.compilation
.module_graph
.exports_info_map
.get_mut(&mgm.exports)
.expect("should have exports info");
for (name, export_info) in exports_map {
exports.exports.insert(name, export_info.id);
export_info_map.insert(export_info.id, export_info);
}
}
}
self.compilation.module_graph.export_info_map = export_info_map;
self
.compilation
.module_graph
Expand Down
24 changes: 23 additions & 1 deletion crates/rspack_core/src/compiler/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::{
ModuleProfile, ModuleType, NormalModuleFactory, NormalModuleFactoryContext, Resolve,
ResolverFactory, SharedPluginDriver, WorkerQueue,
};
use crate::{ExportInfo, ExportsInfo, UsageState};

#[derive(Debug)]
pub enum TaskResult {
Expand Down Expand Up @@ -41,6 +42,13 @@ pub struct FactorizeTask {
pub current_profile: Option<Box<ModuleProfile>>,
}

/// a struct temporarily used creating ExportsInfo
#[derive(Debug)]
pub struct ExportsInfoRelated {
pub exports_info: ExportsInfo,
pub other_exports_info: ExportInfo,
pub side_effects_info: ExportInfo,
}
#[derive(Debug)]
pub struct FactorizeTaskResult {
pub original_module_identifier: Option<ModuleIdentifier>,
Expand All @@ -50,6 +58,7 @@ pub struct FactorizeTaskResult {
pub diagnostics: Vec<Diagnostic>,
pub is_entry: bool,
pub current_profile: Option<Box<ModuleProfile>>,
pub exports_info_related: ExportsInfoRelated,
}

#[async_trait::async_trait]
Expand Down Expand Up @@ -108,7 +117,15 @@ impl WorkerTask for FactorizeTask {
}
};

let mgm = ModuleGraphModule::new(result.module.identifier(), *result.module.module_type());
let other_exports_info = ExportInfo::new("null".into(), UsageState::Unknown, None);
let side_effects_only_info =
ExportInfo::new("*side effects only*".into(), UsageState::Unknown, None);
let exports_info = ExportsInfo::new(other_exports_info.id, side_effects_only_info.id);
let mgm = ModuleGraphModule::new(
result.module.identifier(),
*result.module.module_type(),
exports_info.id,
);

if let Some(current_profile) = &self.current_profile {
current_profile.mark_factory_end();
Expand All @@ -122,6 +139,11 @@ impl WorkerTask for FactorizeTask {
dependencies: self.dependencies,
diagnostics,
current_profile: self.current_profile,
exports_info_related: ExportsInfoRelated {
exports_info,
other_exports_info,
side_effects_info: side_effects_only_info,
},
})))
}
}
Expand Down
Loading

0 comments on commit 62704eb

Please sign in to comment.