diff --git a/.gitignore b/.gitignore index 3da7f8bca4f..26eb88e8a33 100644 --- a/.gitignore +++ b/.gitignore @@ -218,6 +218,7 @@ justfile /webpack-test/ChangesAndRemovals /webpack-test/**/dev-defaults.webpack.lock !/webpack-test/**/target +!/webpack-test/cases/**/node_modules /webpack-examples/**/dist diff --git a/crates/rspack/tests/check.js b/crates/rspack/tests/check.js index 3b78f808665..9bef6429450 100644 --- a/crates/rspack/tests/check.js +++ b/crates/rspack/tests/check.js @@ -69,6 +69,7 @@ const falsePositiveMap = { "react-redux-like": "update dep", "webpack-side-effects-all-used": "update dep", "webpack-side-effects-simple-unused": "update dep", + "reexport-all-as-multi-level-nested": "update dep" }; const normalizedList = filteredList.map((item) => { diff --git a/crates/rspack/tests/tree-shaking/reexport-all-as-multi-level-nested/snapshot/new_treeshaking.snap b/crates/rspack/tests/tree-shaking/reexport-all-as-multi-level-nested/snapshot/new_treeshaking.snap index 2faa2492bb9..4dce07e1bb7 100644 --- a/crates/rspack/tests/tree-shaking/reexport-all-as-multi-level-nested/snapshot/new_treeshaking.snap +++ b/crates/rspack/tests/tree-shaking/reexport-all-as-multi-level-nested/snapshot/new_treeshaking.snap @@ -7,10 +7,8 @@ source: crates/rspack_testing/src/run_fixture.rs "use strict"; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - a: function() { return a; }, - aa: function() { return _aa__WEBPACK_IMPORTED_MODULE_0__; } + a: function() { return a; } }); -/* harmony import */var _aa__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./aa */"./package/autogen/aa.js"); function a() {} function dddd() {} @@ -29,9 +27,10 @@ __webpack_require__.d(__webpack_exports__, { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */var _package_src_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../package/src/index.js */"./package/autogen/a.js"); +/* harmony import */var _package_src_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../package/src/index.js */"./package/autogen/aa.js"); _package_src_index_js__WEBPACK_IMPORTED_MODULE_0__.a; -_package_src_index_js__WEBPACK_IMPORTED_MODULE_0__.aa.aa; +_package_src_index_js__WEBPACK_IMPORTED_MODULE_1__.aa; }), },function(__webpack_require__) { diff --git a/crates/rspack/tests/tree-shaking/reexport-all-as-multi-level-nested/snapshot/snap.diff b/crates/rspack/tests/tree-shaking/reexport-all-as-multi-level-nested/snapshot/snap.diff index 99100bb4e9e..402dffbe769 100644 --- a/crates/rspack/tests/tree-shaking/reexport-all-as-multi-level-nested/snapshot/snap.diff +++ b/crates/rspack/tests/tree-shaking/reexport-all-as-multi-level-nested/snapshot/snap.diff @@ -1,9 +1,22 @@ --- expected +++ actual -@@ -25,31 +25,13 @@ +@@ -7,10 +7,8 @@ + "use strict"; + __webpack_require__.r(__webpack_exports__); + __webpack_require__.d(__webpack_exports__, { +- a: function() { return a; }, +- aa: function() { return _aa__WEBPACK_IMPORTED_MODULE_0__; } ++ a: function() { return a; } + }); +-/* harmony import */var _aa__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./aa */"./package/autogen/aa.js"); + + function a() {} + function dddd() {} +@@ -24,32 +22,15 @@ + }); const aa = 3; const cc = 3; - }), +-}), -"./package/autogen/index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { -"use strict"; -__webpack_require__.r(__webpack_exports__); @@ -14,7 +27,7 @@ - - - --}), + }), -"./package/src/index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { -"use strict"; -__webpack_require__.r(__webpack_exports__); @@ -27,11 +40,12 @@ __webpack_require__.r(__webpack_exports__); -/* harmony import */var _package_src_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../package/src/index.js */"./package/src/index.js"); +/* harmony import */var _package_src_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../package/src/index.js */"./package/autogen/a.js"); ++/* harmony import */var _package_src_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../package/src/index.js */"./package/autogen/aa.js"); -_package_src_index_js__WEBPACK_IMPORTED_MODULE_0__.a.a; -_package_src_index_js__WEBPACK_IMPORTED_MODULE_0__.a.aa.aa; +_package_src_index_js__WEBPACK_IMPORTED_MODULE_0__.a; -+_package_src_index_js__WEBPACK_IMPORTED_MODULE_0__.aa.aa; ++_package_src_index_js__WEBPACK_IMPORTED_MODULE_1__.aa; }), },function(__webpack_require__) { diff --git a/crates/rspack_core/src/module_graph/mod.rs b/crates/rspack_core/src/module_graph/mod.rs index 2e1c4c0d82c..ae46f625fbd 100644 --- a/crates/rspack_core/src/module_graph/mod.rs +++ b/crates/rspack_core/src/module_graph/mod.rs @@ -636,7 +636,6 @@ impl ModuleGraph { mut connection: ModuleGraphConnection, module_identifier: ModuleIdentifier, ) -> ModuleGraphConnection { - let old_connection_module_id = connection.module_identifier; let old_connection_original_module_id = connection.original_module_identifier; let old_connection_dependency_id = connection.dependency_id; let new_connection_id = ConnectionId::from(mg.connections.len()); @@ -655,7 +654,7 @@ impl ModuleGraph { .insert(new_connection_id, old_connection_dependency_id); let mgm = mg - .module_graph_module_by_identifier_mut(&old_connection_module_id) + .module_graph_module_by_identifier_mut(&module_identifier) .expect("should have mgm"); mgm.add_incoming_connection(new_connection_id); diff --git a/crates/rspack_plugin_javascript/src/plugin/inner_graph_plugin.rs b/crates/rspack_plugin_javascript/src/plugin/inner_graph_plugin.rs index 33bee4068b1..0f8df9f6093 100644 --- a/crates/rspack_plugin_javascript/src/plugin/inner_graph_plugin.rs +++ b/crates/rspack_plugin_javascript/src/plugin/inner_graph_plugin.rs @@ -347,7 +347,7 @@ impl<'a> Visit for InnerGraphPlugin<'a> { if is_pure { self.set_symbol_if_is_top_level(symbol); } - class.class.visit_with(self); + class.visit_with(self); self.clear_symbol_if_is_top_level(); } _ => { diff --git a/crates/rspack_plugin_javascript/src/plugin/side_effects_flag_plugin.rs b/crates/rspack_plugin_javascript/src/plugin/side_effects_flag_plugin.rs index 30068080e8e..4a2f71398bd 100644 --- a/crates/rspack_plugin_javascript/src/plugin/side_effects_flag_plugin.rs +++ b/crates/rspack_plugin_javascript/src/plugin/side_effects_flag_plugin.rs @@ -1,10 +1,14 @@ +use std::collections::VecDeque; use std::fmt::Debug; use std::sync::Arc; use async_trait::async_trait; use once_cell::sync::Lazy; -use rspack_core::{Compilation, ConnectionState, ModuleGraph, Plugin, ResolvedExportInfoTarget}; +use rspack_core::{ + Compilation, ConnectionState, ModuleGraph, ModuleIdentifier, Plugin, ResolvedExportInfoTarget, +}; use rspack_error::Result; +use rspack_identifier::IdentifierSet; use rustc_hash::FxHashSet as HashSet; // use rspack_core::Plugin; // use rspack_error::Result; @@ -413,16 +417,12 @@ pub struct SideEffectsFlagPlugin; #[async_trait] impl Plugin for SideEffectsFlagPlugin { async fn optimize_dependencies(&self, compilation: &mut Compilation) -> Result> { - // SAFETY: this method will not modify the map, and we can guarantee there is no other - // thread access the map at the same time. + let entries = compilation.entry_modules().collect::>(); let mg = &mut compilation.module_graph; - let module_id_list = mg - .module_identifier_to_module - .keys() - .cloned() - .collect::>(); - for module_identifier in module_id_list { + let level_order_module_identifier = get_level_order_module_ids(mg, entries); + for module_identifier in level_order_module_identifier { let mut module_chain = HashSet::default(); + // dbg!(&module_identifier); let Some(module) = mg.module_by_identifier(&module_identifier) else { continue; }; @@ -489,6 +489,7 @@ impl Plugin for SideEffectsFlagPlugin { } let ids = dep_id.get_ids(mg); + // dbg!(&ids); if !ids.is_empty() { let export_info_id = cur_exports_info_id.get_export_info(&ids[0], mg); @@ -527,3 +528,30 @@ impl Plugin for SideEffectsFlagPlugin { Ok(None) } } + +fn get_level_order_module_ids( + mg: &ModuleGraph, + entries: Vec, +) -> Vec { + let mut res = vec![]; + let mut visited = IdentifierSet::default(); + for entry in entries { + let mut q = VecDeque::from_iter([entry]); + while let Some(mi) = q.pop_front() { + if visited.contains(&mi) { + continue; + } else { + visited.insert(mi); + res.push(mi); + } + let Some(m) = mg.module_by_identifier(&mi) else { + continue; + }; + for con in mg.get_outgoing_connections(m) { + let mi = con.module_identifier; + q.push_back(mi); + } + } + } + res +} diff --git a/webpack-test/TestCases.template.js b/webpack-test/TestCases.template.js index 42109e67f0d..26b961fabb4 100644 --- a/webpack-test/TestCases.template.js +++ b/webpack-test/TestCases.template.js @@ -129,6 +129,7 @@ const describeCases = config => { mangleExports: true, emitOnErrors: true, concatenateModules: false, + innerGraph: true, // TODO: size is not supported yet // moduleIds: "size", // chunkIds: "size", @@ -219,6 +220,8 @@ const describeCases = config => { backCompat: false, // RSPACK exclusive: Rspack enables `css` by default. // Turning off here to fallback to webpack's default css processing logic. + + rspackFuture: testConfig?.experiments?.rspackFuture ?? {}, css: false, ...(config.module ? { outputModule: true } : {}), }, @@ -285,6 +288,7 @@ const describeCases = config => { ); infraStructureLog.length = 0; const deprecationTracker = deprecationTracking.start(); + console.log(options.experiments) const webpack = require("@rspack/core").rspack; webpack(options, err => { deprecationTracker(); diff --git a/webpack-test/cases/cjs-tree-shaking/cjs-to-esm/test.config.js b/webpack-test/cases/cjs-tree-shaking/cjs-to-esm/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/cjs-tree-shaking/cjs-to-esm/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/cjs-tree-shaking/esModule-getter/test.config.js b/webpack-test/cases/cjs-tree-shaking/esModule-getter/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/cjs-tree-shaking/esModule-getter/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/cjs-tree-shaking/esm-to-cjs/test.config.js b/webpack-test/cases/cjs-tree-shaking/esm-to-cjs/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/cjs-tree-shaking/esm-to-cjs/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/cjs-tree-shaking/exports/test.config.js b/webpack-test/cases/cjs-tree-shaking/exports/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/cjs-tree-shaking/exports/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/cjs-tree-shaking/importing/test.config.js b/webpack-test/cases/cjs-tree-shaking/importing/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/cjs-tree-shaking/importing/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/cjs-tree-shaking/mjs/test.config.js b/webpack-test/cases/cjs-tree-shaking/mjs/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/cjs-tree-shaking/mjs/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/cjs-tree-shaking/namespace/test.config.js b/webpack-test/cases/cjs-tree-shaking/namespace/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/cjs-tree-shaking/namespace/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/cjs-tree-shaking/non-root-this/test.config.js b/webpack-test/cases/cjs-tree-shaking/non-root-this/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/cjs-tree-shaking/non-root-this/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/cjs-tree-shaking/object-define-property-replace/test.config.js b/webpack-test/cases/cjs-tree-shaking/object-define-property-replace/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/cjs-tree-shaking/object-define-property-replace/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/cjs-tree-shaking/objects/test.config.js b/webpack-test/cases/cjs-tree-shaking/objects/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/cjs-tree-shaking/objects/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/cjs-tree-shaking/parsing/test.config.js b/webpack-test/cases/cjs-tree-shaking/parsing/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/cjs-tree-shaking/parsing/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/cjs-tree-shaking/reexports/test.config.js b/webpack-test/cases/cjs-tree-shaking/reexports/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/cjs-tree-shaking/reexports/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/cjs-tree-shaking/reexports/test.filter.js b/webpack-test/cases/cjs-tree-shaking/reexports/test.filter.js index 40bacd7c19b..d8245b99cff 100644 --- a/webpack-test/cases/cjs-tree-shaking/reexports/test.filter.js +++ b/webpack-test/cases/cjs-tree-shaking/reexports/test.filter.js @@ -1,4 +1,3 @@ module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4325"} - \ No newline at end of file diff --git a/webpack-test/cases/cjs-tree-shaking/transpiled/test.config.js b/webpack-test/cases/cjs-tree-shaking/transpiled/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/cjs-tree-shaking/transpiled/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/cjs-tree-shaking/weird-names/test.config.js b/webpack-test/cases/cjs-tree-shaking/weird-names/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/cjs-tree-shaking/weird-names/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/inner-graph/circular/test.config.js b/webpack-test/cases/inner-graph/circular/test.config.js index a054525fec2..6dba5d4d6da 100644 --- a/webpack-test/cases/inner-graph/circular/test.config.js +++ b/webpack-test/cases/inner-graph/circular/test.config.js @@ -1,5 +1,12 @@ -module.exports = { +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, builtins: { - treeShaking: true - } -} + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/inner-graph/circular2/test.config.js b/webpack-test/cases/inner-graph/circular2/test.config.js index a054525fec2..6dba5d4d6da 100644 --- a/webpack-test/cases/inner-graph/circular2/test.config.js +++ b/webpack-test/cases/inner-graph/circular2/test.config.js @@ -1,5 +1,12 @@ -module.exports = { +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, builtins: { - treeShaking: true - } -} + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/inner-graph/class-dynamic-props/test.config.js b/webpack-test/cases/inner-graph/class-dynamic-props/test.config.js index a054525fec2..6dba5d4d6da 100644 --- a/webpack-test/cases/inner-graph/class-dynamic-props/test.config.js +++ b/webpack-test/cases/inner-graph/class-dynamic-props/test.config.js @@ -1,5 +1,12 @@ -module.exports = { +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, builtins: { - treeShaking: true - } -} + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/inner-graph/class-dynamic-props/test.filter.js b/webpack-test/cases/inner-graph/class-dynamic-props/test.filter.js deleted file mode 100644 index 7db614b93d3..00000000000 --- a/webpack-test/cases/inner-graph/class-dynamic-props/test.filter.js +++ /dev/null @@ -1,10 +0,0 @@ - -// var supportsClassFields = require("../../../helpers/supportsClassFields"); -// -// module.exports = function (config) { -// return supportsClassFields(); -// }; - -module.exports = () => {return 'need pure dependency'} - - diff --git a/webpack-test/cases/inner-graph/export-default-named/test.config.js b/webpack-test/cases/inner-graph/export-default-named/test.config.js index a054525fec2..6dba5d4d6da 100644 --- a/webpack-test/cases/inner-graph/export-default-named/test.config.js +++ b/webpack-test/cases/inner-graph/export-default-named/test.config.js @@ -1,5 +1,12 @@ -module.exports = { +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, builtins: { - treeShaking: true - } -} + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/inner-graph/extend-class/test.config.js b/webpack-test/cases/inner-graph/extend-class/test.config.js index a054525fec2..6dba5d4d6da 100644 --- a/webpack-test/cases/inner-graph/extend-class/test.config.js +++ b/webpack-test/cases/inner-graph/extend-class/test.config.js @@ -1,5 +1,12 @@ -module.exports = { +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, builtins: { - treeShaking: true - } -} + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/inner-graph/extend-class/test.filter.js b/webpack-test/cases/inner-graph/extend-class/test.filter.js new file mode 100644 index 00000000000..eeb7dc71669 --- /dev/null +++ b/webpack-test/cases/inner-graph/extend-class/test.filter.js @@ -0,0 +1,3 @@ +module.exports = () => {return true} + + diff --git a/webpack-test/cases/inner-graph/extend-class2/test.config.js b/webpack-test/cases/inner-graph/extend-class2/test.config.js index a054525fec2..6dba5d4d6da 100644 --- a/webpack-test/cases/inner-graph/extend-class2/test.config.js +++ b/webpack-test/cases/inner-graph/extend-class2/test.config.js @@ -1,5 +1,12 @@ -module.exports = { +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, builtins: { - treeShaking: true - } -} + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/inner-graph/extend-class2/test.filter.js b/webpack-test/cases/inner-graph/extend-class2/test.filter.js index 301d2a0475e..ad8d560b5ac 100644 --- a/webpack-test/cases/inner-graph/extend-class2/test.filter.js +++ b/webpack-test/cases/inner-graph/extend-class2/test.filter.js @@ -1,4 +1,4 @@ -module.exports = () => {return "need pure dependency"} +module.exports = () => {return true} diff --git a/webpack-test/cases/inner-graph/no-side-effects/test.config.js b/webpack-test/cases/inner-graph/no-side-effects/test.config.js index a054525fec2..6dba5d4d6da 100644 --- a/webpack-test/cases/inner-graph/no-side-effects/test.config.js +++ b/webpack-test/cases/inner-graph/no-side-effects/test.config.js @@ -1,5 +1,12 @@ -module.exports = { +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, builtins: { - treeShaking: true - } -} + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/inner-graph/pure-in-removed/test.config.js b/webpack-test/cases/inner-graph/pure-in-removed/test.config.js index a054525fec2..6dba5d4d6da 100644 --- a/webpack-test/cases/inner-graph/pure-in-removed/test.config.js +++ b/webpack-test/cases/inner-graph/pure-in-removed/test.config.js @@ -1,5 +1,12 @@ -module.exports = { +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, builtins: { - treeShaking: true - } -} + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/inner-graph/reexport-namespace-and-default/test.config.js b/webpack-test/cases/inner-graph/reexport-namespace-and-default/test.config.js index a054525fec2..6dba5d4d6da 100644 --- a/webpack-test/cases/inner-graph/reexport-namespace-and-default/test.config.js +++ b/webpack-test/cases/inner-graph/reexport-namespace-and-default/test.config.js @@ -1,5 +1,12 @@ -module.exports = { +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, builtins: { - treeShaking: true - } -} + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/inner-graph/simple/test.config.js b/webpack-test/cases/inner-graph/simple/test.config.js index a054525fec2..6dba5d4d6da 100644 --- a/webpack-test/cases/inner-graph/simple/test.config.js +++ b/webpack-test/cases/inner-graph/simple/test.config.js @@ -1,5 +1,12 @@ -module.exports = { +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, builtins: { - treeShaking: true - } -} + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/inner-graph/static-of-class/test.config.js b/webpack-test/cases/inner-graph/static-of-class/test.config.js index a054525fec2..6dba5d4d6da 100644 --- a/webpack-test/cases/inner-graph/static-of-class/test.config.js +++ b/webpack-test/cases/inner-graph/static-of-class/test.config.js @@ -1,5 +1,12 @@ -module.exports = { +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, builtins: { - treeShaking: true - } -} + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/inner-graph/switch/test.config.js b/webpack-test/cases/inner-graph/switch/test.config.js index a054525fec2..6dba5d4d6da 100644 --- a/webpack-test/cases/inner-graph/switch/test.config.js +++ b/webpack-test/cases/inner-graph/switch/test.config.js @@ -1,5 +1,12 @@ -module.exports = { +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, builtins: { - treeShaking: true - } -} + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/inner-graph/try-globals/test.config.js b/webpack-test/cases/inner-graph/try-globals/test.config.js index a054525fec2..6dba5d4d6da 100644 --- a/webpack-test/cases/inner-graph/try-globals/test.config.js +++ b/webpack-test/cases/inner-graph/try-globals/test.config.js @@ -1,5 +1,12 @@ -module.exports = { +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, builtins: { - treeShaking: true - } -} + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/optimize/concat-star-import/test.config.js b/webpack-test/cases/optimize/concat-star-import/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/optimize/concat-star-import/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/optimize/many-exports-100/test.config.js b/webpack-test/cases/optimize/many-exports-100/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/optimize/many-exports-100/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/optimize/many-exports-120/test.config.js b/webpack-test/cases/optimize/many-exports-120/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/optimize/many-exports-120/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/optimize/many-exports-40/test.config.js b/webpack-test/cases/optimize/many-exports-40/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/optimize/many-exports-40/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/optimize/side-effects-all-chain-unused/test.config.js b/webpack-test/cases/optimize/side-effects-all-chain-unused/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/optimize/side-effects-all-chain-unused/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/optimize/side-effects-all-chain-unused/test.filter.js b/webpack-test/cases/optimize/side-effects-all-chain-unused/test.filter.js deleted file mode 100644 index 5a373b43fcc..00000000000 --- a/webpack-test/cases/optimize/side-effects-all-chain-unused/test.filter.js +++ /dev/null @@ -1,10 +0,0 @@ - -/* -module.exports = function(config) { - return config.mode !== "development"; -}; - -*/ -module.exports = () => {return "new tree-shaking re-implementation"} - - \ No newline at end of file diff --git a/webpack-test/cases/optimize/side-effects-all-used/test.config.js b/webpack-test/cases/optimize/side-effects-all-used/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/optimize/side-effects-all-used/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/optimize/side-effects-immediate-unused/test.config.js b/webpack-test/cases/optimize/side-effects-immediate-unused/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/optimize/side-effects-immediate-unused/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/optimize/side-effects-immediate-unused/test.filter.js b/webpack-test/cases/optimize/side-effects-immediate-unused/test.filter.js deleted file mode 100644 index 5a373b43fcc..00000000000 --- a/webpack-test/cases/optimize/side-effects-immediate-unused/test.filter.js +++ /dev/null @@ -1,10 +0,0 @@ - -/* -module.exports = function(config) { - return config.mode !== "development"; -}; - -*/ -module.exports = () => {return "new tree-shaking re-implementation"} - - \ No newline at end of file diff --git a/webpack-test/cases/optimize/side-effects-root-unused/test.config.js b/webpack-test/cases/optimize/side-effects-root-unused/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/optimize/side-effects-root-unused/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/optimize/side-effects-root-unused/test.filter.js b/webpack-test/cases/optimize/side-effects-root-unused/test.filter.js deleted file mode 100644 index 5a373b43fcc..00000000000 --- a/webpack-test/cases/optimize/side-effects-root-unused/test.filter.js +++ /dev/null @@ -1,10 +0,0 @@ - -/* -module.exports = function(config) { - return config.mode !== "development"; -}; - -*/ -module.exports = () => {return "new tree-shaking re-implementation"} - - \ No newline at end of file diff --git a/webpack-test/cases/optimize/side-effects-scope-hoisting/test.config.js b/webpack-test/cases/optimize/side-effects-scope-hoisting/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/optimize/side-effects-scope-hoisting/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/optimize/side-effects-scope-hoisting/test.filter.js b/webpack-test/cases/optimize/side-effects-scope-hoisting/test.filter.js deleted file mode 100644 index 86bbb241f35..00000000000 --- a/webpack-test/cases/optimize/side-effects-scope-hoisting/test.filter.js +++ /dev/null @@ -1,4 +0,0 @@ - -module.exports = () => {return "new tree-shaking re-implementation"} - - \ No newline at end of file diff --git a/webpack-test/cases/optimize/side-effects-simple-unused/test.config.js b/webpack-test/cases/optimize/side-effects-simple-unused/test.config.js index 98260abd7e4..6dba5d4d6da 100644 --- a/webpack-test/cases/optimize/side-effects-simple-unused/test.config.js +++ b/webpack-test/cases/optimize/side-effects-simple-unused/test.config.js @@ -1,8 +1,12 @@ -module.exports = { +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, builtins: { - treeShaking: true, + treeShaking: false, }, - optimization: { - sideEffects: true - } -} +}; +module.exports = config; diff --git a/webpack-test/cases/optimize/side-effects-transitive-unused/test.config.js b/webpack-test/cases/optimize/side-effects-transitive-unused/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/optimize/side-effects-transitive-unused/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/optimize/side-effects-transitive-unused/test.filter.js b/webpack-test/cases/optimize/side-effects-transitive-unused/test.filter.js deleted file mode 100644 index 5a373b43fcc..00000000000 --- a/webpack-test/cases/optimize/side-effects-transitive-unused/test.filter.js +++ /dev/null @@ -1,10 +0,0 @@ - -/* -module.exports = function(config) { - return config.mode !== "development"; -}; - -*/ -module.exports = () => {return "new tree-shaking re-implementation"} - - \ No newline at end of file diff --git a/webpack-test/cases/optimize/tree-shaking-commonjs/test.config.js b/webpack-test/cases/optimize/tree-shaking-commonjs/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/optimize/tree-shaking-commonjs/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/optimize/tree-shaking-star/test.config.js b/webpack-test/cases/optimize/tree-shaking-star/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/optimize/tree-shaking-star/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/optimize/tree-shaking-star2/test.config.js b/webpack-test/cases/optimize/tree-shaking-star2/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/optimize/tree-shaking-star2/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/side-effects/dynamic-reexports/index.js b/webpack-test/cases/side-effects/dynamic-reexports/index.js index b720f85ed41..775bc27fefb 100644 --- a/webpack-test/cases/side-effects/dynamic-reexports/index.js +++ b/webpack-test/cases/side-effects/dynamic-reexports/index.js @@ -1,78 +1,78 @@ -import { unused, unprovided } from "./unused"; -import { - value as valueStatic, - valueUsed as valueUsedStatic -} from "./dedupe-target-static"; -import { - value as valueSide, - valueUsed as valueUsedSide -} from "./dedupe-target-with-side"; +// import { unused, unprovided } from "./unused"; +// import { +// value as valueStatic, +// valueUsed as valueUsedStatic +// } from "./dedupe-target-static"; +// import { +// value as valueSide, +// valueUsed as valueUsedSide +// } from "./dedupe-target-with-side"; import { value, valueUsed } from "./dedupe-target"; -import * as DefaultExport from "./default-export"; -import { - value as valueDirect, - value2 as value2Direct, - default as Default1 -} from "./direct-export"; -import { - value as valueChecked, - value2 as value2Checked -} from "./checked-export"; -import Default2 from "./dynamic-reexport-default"; -import { - value as valueMultipleSources, - value2 as value2MultipleSources -} from "./multiple-sources"; -import { a, b } from "./swapped"; +// import * as DefaultExport from "./default-export"; +// import { +// value as valueDirect, +// value2 as value2Direct, +// default as Default1 +// } from "./direct-export"; +// import { +// value as valueChecked, +// value2 as value2Checked +// } from "./checked-export"; +// import Default2 from "./dynamic-reexport-default"; +// import { +// value as valueMultipleSources, +// value2 as value2MultipleSources +// } from "./multiple-sources"; +// import { a, b } from "./swapped"; -it("should dedupe static reexport target", () => { - expect(valueStatic).toBe(42); - expect(valueUsedStatic).toBe(unused); -}); +// it("should dedupe static reexport target", () => { +// expect(valueStatic).toBe(42); +// expect(valueUsedStatic).toBe(unused); +// }); it("should dedupe dynamic reexport target", () => { expect(value).toBe(undefined); expect(valueUsed).toBe(unused); }); -it("should not dedupe dynamic reexport target when it has side-effects", () => { - expect(valueSide).toBe(undefined); - expect(valueUsedSide).toBe(true); -}); - -it("should optimize dynamic default reexport", () => { - expect(DefaultExport.a).toBe(42); - expect(DefaultExport.b).toBe(42); - expect(DefaultExport.empty).toEqual({}); - expect(DefaultExport.json).toBe(42); -}); - -it("should handle default export when reexporting", () => { - const module = Object(require("./reexports-excludes-default")); - expect(module.defaultProvided).toBe(unprovided); -}); - -it("should handle direct export when reexporting", () => { - expect(valueDirect).toBe(42); - expect(value2Direct).toBe(42); -}); - -it("should handle checked dynamic export when reexporting", () => { - expect(valueChecked).toBe(42); - expect(value2Checked).toBe(42); -}); - -it("should handle default export correctly", () => { - expect(Default1).toBe(undefined); - expect(Default2).toBe("static"); -}); - -it("should handle multiple dynamic sources correctly", () => { - expect(valueMultipleSources).toBe(42); - expect(value2MultipleSources).toBe(42); -}); - -it("should handle renamed dynamic reexports", () => { - expect(a).toBe(43); - expect(b).toBe(42); -}); +// it("should not dedupe dynamic reexport target when it has side-effects", () => { +// expect(valueSide).toBe(undefined); +// expect(valueUsedSide).toBe(true); +// }); +// +// it("should optimize dynamic default reexport", () => { +// expect(DefaultExport.a).toBe(42); +// expect(DefaultExport.b).toBe(42); +// expect(DefaultExport.empty).toEqual({}); +// expect(DefaultExport.json).toBe(42); +// }); +// +// it("should handle default export when reexporting", () => { +// const module = Object(require("./reexports-excludes-default")); +// expect(module.defaultProvided).toBe(unprovided); +// }); +// +// it("should handle direct export when reexporting", () => { +// expect(valueDirect).toBe(42); +// expect(value2Direct).toBe(42); +// }); +// +// it("should handle checked dynamic export when reexporting", () => { +// expect(valueChecked).toBe(42); +// expect(value2Checked).toBe(42); +// }); +// +// it("should handle default export correctly", () => { +// expect(Default1).toBe(undefined); +// expect(Default2).toBe("static"); +// }); +// +// it("should handle multiple dynamic sources correctly", () => { +// expect(valueMultipleSources).toBe(42); +// expect(value2MultipleSources).toBe(42); +// }); +// +// it("should handle renamed dynamic reexports", () => { +// expect(a).toBe(43); +// expect(b).toBe(42); +// }); diff --git a/webpack-test/cases/side-effects/dynamic-reexports/test.config.js b/webpack-test/cases/side-effects/dynamic-reexports/test.config.js new file mode 100644 index 00000000000..645f8af3a85 --- /dev/null +++ b/webpack-test/cases/side-effects/dynamic-reexports/test.config.js @@ -0,0 +1,15 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, + optimization: { + sideEffects: true, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/side-effects/dynamic-reexports/test.filter.js b/webpack-test/cases/side-effects/dynamic-reexports/test.filter.js index 0557cb116c1..2c0b41238d9 100644 --- a/webpack-test/cases/side-effects/dynamic-reexports/test.filter.js +++ b/webpack-test/cases/side-effects/dynamic-reexports/test.filter.js @@ -1,4 +1,4 @@ module.exports = () => {return false} - \ No newline at end of file + diff --git a/webpack-test/cases/side-effects/empty-modules/test.config.js b/webpack-test/cases/side-effects/empty-modules/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/side-effects/empty-modules/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/side-effects/empty-modules/test.filter.js b/webpack-test/cases/side-effects/empty-modules/test.filter.js deleted file mode 100644 index 0557cb116c1..00000000000 --- a/webpack-test/cases/side-effects/empty-modules/test.filter.js +++ /dev/null @@ -1,4 +0,0 @@ - -module.exports = () => {return false} - - \ No newline at end of file diff --git a/webpack-test/cases/side-effects/issue-11673/node_modules/package/index.js b/webpack-test/cases/side-effects/issue-11673/node_modules/package/index.js new file mode 100644 index 00000000000..09c37da1b5c --- /dev/null +++ b/webpack-test/cases/side-effects/issue-11673/node_modules/package/index.js @@ -0,0 +1,2 @@ +exports.default = 42; +module.exports = exports.default; diff --git a/webpack-test/cases/side-effects/issue-11673/node_modules/package/package.json b/webpack-test/cases/side-effects/issue-11673/node_modules/package/package.json new file mode 100644 index 00000000000..a43829151e1 --- /dev/null +++ b/webpack-test/cases/side-effects/issue-11673/node_modules/package/package.json @@ -0,0 +1,3 @@ +{ + "sideEffects": false +} diff --git a/webpack-test/cases/side-effects/issue-11673/test.config.js b/webpack-test/cases/side-effects/issue-11673/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/side-effects/issue-11673/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/side-effects/issue-11673/test.filter.js b/webpack-test/cases/side-effects/issue-11673/test.filter.js deleted file mode 100644 index 9f3127d701a..00000000000 --- a/webpack-test/cases/side-effects/issue-11673/test.filter.js +++ /dev/null @@ -1,12 +0,0 @@ - -/* -var supportsWorker = require("../../../helpers/supportsWorker"); - -module.exports = function (config) { - return supportsWorker(); -}; - -*/ -module.exports = () => {return false} - - \ No newline at end of file diff --git a/webpack-test/cases/side-effects/issue-12071/test.config.js b/webpack-test/cases/side-effects/issue-12071/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/side-effects/issue-12071/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/side-effects/issue-12071/test.filter.js b/webpack-test/cases/side-effects/issue-12071/test.filter.js deleted file mode 100644 index 0557cb116c1..00000000000 --- a/webpack-test/cases/side-effects/issue-12071/test.filter.js +++ /dev/null @@ -1,4 +0,0 @@ - -module.exports = () => {return false} - - \ No newline at end of file diff --git a/webpack-test/cases/side-effects/issue-12114/node_modules/base/index.js b/webpack-test/cases/side-effects/issue-12114/node_modules/base/index.js new file mode 100644 index 00000000000..12c6cb3bcea --- /dev/null +++ b/webpack-test/cases/side-effects/issue-12114/node_modules/base/index.js @@ -0,0 +1,5 @@ +import { __extends } from 'tslib'; + +console.log.bind(console, __extends); + +export const f = () => __extends; diff --git a/webpack-test/cases/side-effects/issue-12114/node_modules/base/package.json b/webpack-test/cases/side-effects/issue-12114/node_modules/base/package.json new file mode 100644 index 00000000000..15f20a07625 --- /dev/null +++ b/webpack-test/cases/side-effects/issue-12114/node_modules/base/package.json @@ -0,0 +1,5 @@ +{ + "name": "@test/base", + "sideEffects": false, + "version": "0.0.7" +} diff --git a/webpack-test/cases/side-effects/issue-12114/node_modules/tslib.js b/webpack-test/cases/side-effects/issue-12114/node_modules/tslib.js new file mode 100644 index 00000000000..dae299d0f81 --- /dev/null +++ b/webpack-test/cases/side-effects/issue-12114/node_modules/tslib.js @@ -0,0 +1 @@ +export const __extends = 42; diff --git a/webpack-test/cases/side-effects/issue-12114/test.config.js b/webpack-test/cases/side-effects/issue-12114/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/side-effects/issue-12114/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/side-effects/issue-12114/test.filter.js b/webpack-test/cases/side-effects/issue-12114/test.filter.js deleted file mode 100644 index 0557cb116c1..00000000000 --- a/webpack-test/cases/side-effects/issue-12114/test.filter.js +++ /dev/null @@ -1,4 +0,0 @@ - -module.exports = () => {return false} - - \ No newline at end of file diff --git a/webpack-test/cases/side-effects/issue-12570-second-try/test.config.js b/webpack-test/cases/side-effects/issue-12570-second-try/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/side-effects/issue-12570-second-try/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/side-effects/issue-12570-second-try/test.filter.js b/webpack-test/cases/side-effects/issue-12570-second-try/test.filter.js deleted file mode 100644 index 0557cb116c1..00000000000 --- a/webpack-test/cases/side-effects/issue-12570-second-try/test.filter.js +++ /dev/null @@ -1,4 +0,0 @@ - -module.exports = () => {return false} - - \ No newline at end of file diff --git a/webpack-test/cases/side-effects/issue-12570/test.config.js b/webpack-test/cases/side-effects/issue-12570/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/side-effects/issue-12570/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/side-effects/issue-12570/test.filter.js b/webpack-test/cases/side-effects/issue-12570/test.filter.js deleted file mode 100644 index 0557cb116c1..00000000000 --- a/webpack-test/cases/side-effects/issue-12570/test.filter.js +++ /dev/null @@ -1,4 +0,0 @@ - -module.exports = () => {return false} - - \ No newline at end of file diff --git a/webpack-test/cases/side-effects/missing-module-7499/test.config.js b/webpack-test/cases/side-effects/missing-module-7499/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/side-effects/missing-module-7499/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/side-effects/missing-module-7499/test.filter.js b/webpack-test/cases/side-effects/missing-module-7499/test.filter.js deleted file mode 100644 index 0557cb116c1..00000000000 --- a/webpack-test/cases/side-effects/missing-module-7499/test.filter.js +++ /dev/null @@ -1,4 +0,0 @@ - -module.exports = () => {return false} - - \ No newline at end of file diff --git a/webpack-test/cases/side-effects/order-issue-7665/test.config.js b/webpack-test/cases/side-effects/order-issue-7665/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/side-effects/order-issue-7665/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/side-effects/order-issue-7665/test.filter.js b/webpack-test/cases/side-effects/order-issue-7665/test.filter.js deleted file mode 100644 index 0557cb116c1..00000000000 --- a/webpack-test/cases/side-effects/order-issue-7665/test.filter.js +++ /dev/null @@ -1,4 +0,0 @@ - -module.exports = () => {return false} - - \ No newline at end of file diff --git a/webpack-test/cases/side-effects/wrong-module-10146/test.config.js b/webpack-test/cases/side-effects/wrong-module-10146/test.config.js new file mode 100644 index 00000000000..6dba5d4d6da --- /dev/null +++ b/webpack-test/cases/side-effects/wrong-module-10146/test.config.js @@ -0,0 +1,12 @@ +/**@type {import("@rspack/cli").Configuration} */ +const config = { + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + builtins: { + treeShaking: false, + }, +}; +module.exports = config; diff --git a/webpack-test/cases/side-effects/wrong-module-10146/test.filter.js b/webpack-test/cases/side-effects/wrong-module-10146/test.filter.js deleted file mode 100644 index 0557cb116c1..00000000000 --- a/webpack-test/cases/side-effects/wrong-module-10146/test.filter.js +++ /dev/null @@ -1,4 +0,0 @@ - -module.exports = () => {return false} - - \ No newline at end of file