Skip to content

Commit

Permalink
fix: 🐛 align get provided exports with webpack (#9050)
Browse files Browse the repository at this point in the history
* fix: 🐛 align get provided exports with webpack

* test: ✅ update test case snapshot
  • Loading branch information
stormslowly authored Jan 21, 2025
1 parent c06787b commit 42cc3fd
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 30 deletions.
24 changes: 12 additions & 12 deletions crates/rspack_core/src/exports_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,20 +526,20 @@ impl ExportsInfo {

pub fn get_provided_exports(&self, mg: &ModuleGraph) -> ProvidedExports {
let info = self.as_exports_info(mg);
if let Some(_redirect_to) = info.redirect_to {
match info.other_exports_info.provided(mg) {
Some(ExportInfoProvided::Null) => {
return ProvidedExports::True;
}
Some(ExportInfoProvided::True) => {
return ProvidedExports::True;
}
None => {
return ProvidedExports::Null;
}
_ => {}

match info.other_exports_info.provided(mg) {
Some(ExportInfoProvided::Null) => {
return ProvidedExports::True;
}
Some(ExportInfoProvided::True) => {
return ProvidedExports::True;
}
None => {
return ProvidedExports::Null;
}
_ => {}
}

let mut ret = vec![];
for export_info_id in info.exports.values() {
let export_info = export_info_id.as_export_info(mg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ modules by path ./ 235 bytes (javascript) 7 bytes (asset)
[no exports used]
ModuleConcatenation bailout: Module is an entry point
./stringModule.js 1 bytes [depth 1] [orphan] [built]
[no exports]
[module unused]
ModuleConcatenation bailout: Module is not an ECMAScript module
esm import ./stringModule [686] ./index.js 1:0-41
Expand Down Expand Up @@ -414,7 +413,6 @@ webpack/runtime/make_namespace_object 280 bytes [code generated]
exports[`new code splitting stats output new code splitting stats output/runtime-specific-exports should print correct stats for: NewCodeSplittingStatsOutput 1`] = `
asset main.js 1.8 KiB [emitted] (name: main)
./example.js 70 bytes [built] [code generated]
[no exports]
[no exports used]
./increment.js 251 bytes [built] [code generated]
[exports: decrement, increment, incrementBy2]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Object {
orphan: false,
postOrderIndex: 0,
preOrderIndex: 0,
providedExports: Array [],
providedExports: null,
reasons: Array [
Object {
active: true,
Expand Down Expand Up @@ -216,7 +216,7 @@ Object {
orphan: false,
postOrderIndex: 0,
preOrderIndex: 0,
providedExports: Array [],
providedExports: null,
reasons: Array [
Object {
active: true,
Expand Down Expand Up @@ -1712,7 +1712,7 @@ Object {
orphan: false,
postOrderIndex: 1,
preOrderIndex: 3,
providedExports: Array [],
providedExports: null,
reasons: Array [
Object {
active: true,
Expand Down Expand Up @@ -1793,7 +1793,7 @@ Object {
orphan: false,
postOrderIndex: 0,
preOrderIndex: 1,
providedExports: Array [],
providedExports: null,
reasons: Array [
Object {
active: true,
Expand Down Expand Up @@ -1935,7 +1935,7 @@ exports.c = require("./c?c=3");,
orphan: false,
postOrderIndex: 2,
preOrderIndex: 2,
providedExports: Array [],
providedExports: null,
reasons: Array [
Object {
active: true,
Expand Down Expand Up @@ -2134,7 +2134,7 @@ exports.c = require("./c?c=3");,
orphan: false,
postOrderIndex: 0,
preOrderIndex: 1,
providedExports: Array [],
providedExports: null,
reasons: Array [
Object {
active: true,
Expand Down Expand Up @@ -2215,7 +2215,7 @@ exports.c = require("./c?c=3");,
orphan: false,
postOrderIndex: 2,
preOrderIndex: 2,
providedExports: Array [],
providedExports: null,
reasons: Array [
Object {
active: true,
Expand Down Expand Up @@ -2302,7 +2302,7 @@ exports.c = require("./c?c=3");,
orphan: false,
postOrderIndex: 1,
preOrderIndex: 3,
providedExports: Array [],
providedExports: null,
reasons: Array [
Object {
active: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ modules by path ./ 235 bytes (javascript) 7 bytes (asset)
[no exports used]
ModuleConcatenation bailout: Module is an entry point
./stringModule.js 1 bytes [depth 1] [orphan] [built]
[no exports]
[module unused]
ModuleConcatenation bailout: Module is not an ECMAScript module
esm import ./stringModule [686] ./index.js 1:0-41
Expand Down Expand Up @@ -414,7 +413,6 @@ webpack/runtime/make_namespace_object 280 bytes [code generated]
exports[`statsOutput statsOutput/runtime-specific-exports should print correct stats for 1`] = `
asset main.js 1.8 KiB [emitted] (name: main)
./example.js 70 bytes [built] [code generated]
[no exports]
[no exports used]
./increment.js 251 bytes [built] [code generated]
[exports: decrement, increment, incrementBy2]
Expand Down
2 changes: 0 additions & 2 deletions packages/rspack-test-tools/tests/statsAPICases/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ module.exports = {
chunk {909} (runtime: main) main.js (main) 55 bytes [entry] [rendered]
> ./fixtures/a main
./fixtures/a.js [585] 55 bytes {909} [depth 0] [built] [code generated]
[no exports]
[used exports unknown]
Statement with side_effects in source code at ./fixtures/a.js<LINE_COL_RANGE>
ModuleConcatenation bailout: Module is not an ECMAScript module
entry ./fixtures/a
cjs self exports reference self [585] ./fixtures/a.js
./fixtures/a.js [585] 55 bytes {909} [depth 0] [built] [code generated]
[no exports]
[used exports unknown]
Statement with side_effects in source code at ./fixtures/a.js<LINE_COL_RANGE>
ModuleConcatenation bailout: Module is not an ECMAScript module
Expand Down
4 changes: 2 additions & 2 deletions packages/rspack-test-tools/tests/statsAPICases/chunks.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = {
orphan: false,
postOrderIndex: 1,
preOrderIndex: 1,
providedExports: Array [],
providedExports: null,
reasons: Array [
Object {
active: true,
Expand Down Expand Up @@ -190,7 +190,7 @@ module.exports = {
orphan: false,
postOrderIndex: 0,
preOrderIndex: 0,
providedExports: Array [],
providedExports: null,
reasons: Array [
Object {
active: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,8 @@ exports[`StatsTestCases should print correct stats for concat-and-sideeffects 1`
exports[`StatsTestCases should print correct stats for custom-terser 1`] = `
"asset bundle.js 593 bytes [emitted] [minimized] (name: main)
./index.js 128 bytes [built] [code generated]
[no exports]
[no exports used]
./a.js 49 bytes [built] [code generated]
[no exports]
[used exports unknown]
Rspack x.x.x compiled successfully in X.23"
`;
Expand Down

2 comments on commit 42cc3fd

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented on 42cc3fd Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2025-01-21 c06787b) Current Change
10000_big_production-mode_disable-minimize + exec 36.7 s ± 515 ms 37.7 s ± 1.24 s +2.78 %
10000_development-mode + exec 1.86 s ± 52 ms 1.83 s ± 39 ms -1.76 %
10000_development-mode_hmr + exec 681 ms ± 9.8 ms 690 ms ± 21 ms +1.35 %
10000_production-mode + exec 2.45 s ± 138 ms 2.35 s ± 41 ms -3.93 %
10000_production-mode_persistent-cold + exec 2.61 s ± 155 ms 2.57 s ± 244 ms -1.54 %
10000_production-mode_persistent-hot + exec 1.77 s ± 116 ms 1.76 s ± 80 ms -0.49 %
arco-pro_development-mode + exec 1.76 s ± 98 ms 1.79 s ± 125 ms +1.57 %
arco-pro_development-mode_hmr + exec 388 ms ± 2.3 ms 388 ms ± 2.7 ms +0.19 %
arco-pro_production-mode + exec 3.64 s ± 257 ms 3.66 s ± 197 ms +0.60 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.75 s ± 314 ms 3.73 s ± 144 ms -0.64 %
arco-pro_production-mode_persistent-cold + exec 3.8 s ± 165 ms 3.8 s ± 134 ms +0.10 %
arco-pro_production-mode_persistent-hot + exec 2.34 s ± 79 ms 2.42 s ± 109 ms +3.51 %
arco-pro_production-mode_traverse-chunk-modules + exec 3.67 s ± 99 ms 3.59 s ± 132 ms -1.98 %
large-dyn-imports_development-mode + exec 2.11 s ± 29 ms 2.08 s ± 30 ms -1.30 %
large-dyn-imports_production-mode + exec 2.16 s ± 40 ms 2.16 s ± 56 ms -0.20 %
threejs_development-mode_10x + exec 1.53 s ± 22 ms 1.54 s ± 46 ms +0.80 %
threejs_development-mode_10x_hmr + exec 788 ms ± 39 ms 789 ms ± 20 ms +0.15 %
threejs_production-mode_10x + exec 5.25 s ± 61 ms 5.25 s ± 74 ms 0.00 %
threejs_production-mode_10x_persistent-cold + exec 5.35 s ± 65 ms 5.38 s ± 291 ms +0.62 %
threejs_production-mode_10x_persistent-hot + exec 4.5 s ± 44 ms 4.55 s ± 172 ms +1.01 %
10000_big_production-mode_disable-minimize + rss memory 8680 MiB ± 34.2 MiB 8704 MiB ± 81.3 MiB +0.28 %
10000_development-mode + rss memory 656 MiB ± 19.6 MiB 659 MiB ± 13 MiB +0.50 %
10000_development-mode_hmr + rss memory 1264 MiB ± 163 MiB 1343 MiB ± 115 MiB +6.22 %
10000_production-mode + rss memory 639 MiB ± 31 MiB 644 MiB ± 19.4 MiB +0.65 %
10000_production-mode_persistent-cold + rss memory 744 MiB ± 15.6 MiB 740 MiB ± 14 MiB -0.55 %
10000_production-mode_persistent-hot + rss memory 723 MiB ± 37.7 MiB 728 MiB ± 16.2 MiB +0.63 %
arco-pro_development-mode + rss memory 553 MiB ± 38.1 MiB 561 MiB ± 40.8 MiB +1.56 %
arco-pro_development-mode_hmr + rss memory 631 MiB ± 36 MiB 633 MiB ± 126 MiB +0.24 %
arco-pro_production-mode + rss memory 738 MiB ± 66.3 MiB 704 MiB ± 25.9 MiB -4.56 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 730 MiB ± 23.1 MiB 734 MiB ± 25.2 MiB +0.60 %
arco-pro_production-mode_persistent-cold + rss memory 844 MiB ± 36.6 MiB 846 MiB ± 37.7 MiB +0.23 %
arco-pro_production-mode_persistent-hot + rss memory 695 MiB ± 19.9 MiB 696 MiB ± 11.1 MiB +0.24 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 727 MiB ± 32.5 MiB 724 MiB ± 21.1 MiB -0.36 %
large-dyn-imports_development-mode + rss memory 642 MiB ± 4.5 MiB 647 MiB ± 5.72 MiB +0.74 %
large-dyn-imports_production-mode + rss memory 523 MiB ± 4.79 MiB 528 MiB ± 4.62 MiB +0.96 %
threejs_development-mode_10x + rss memory 551 MiB ± 32.9 MiB 551 MiB ± 8.12 MiB +0.14 %
threejs_development-mode_10x_hmr + rss memory 1145 MiB ± 125 MiB 1150 MiB ± 123 MiB +0.47 %
threejs_production-mode_10x + rss memory 865 MiB ± 36.9 MiB 865 MiB ± 59.2 MiB -0.07 %
threejs_production-mode_10x_persistent-cold + rss memory 968 MiB ± 136 MiB 949 MiB ± 142 MiB -1.93 %
threejs_production-mode_10x_persistent-hot + rss memory 870 MiB ± 25.8 MiB 859 MiB ± 47.8 MiB -1.27 %

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented on 42cc3fd Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ecosystem CI detail: Open

suite result
modernjs ❌ failure
rspress ✅ success
rslib ❌ failure
rsbuild ✅ success
rsdoctor ✅ success
examples ✅ success
devserver ✅ success
nuxt ✅ success

Please sign in to comment.