diff --git a/packages/rspack-test-tools/tests/treeShakingCases/issue-7016/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/issue-7016/__snapshots__/treeshaking.snap.txt new file mode 100644 index 000000000000..83f1a216ed0d --- /dev/null +++ b/packages/rspack-test-tools/tests/treeShakingCases/issue-7016/__snapshots__/treeshaking.snap.txt @@ -0,0 +1,23 @@ +```js title=main.js +(self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { +"./index.js": (function () { +if (true) { + const hasConsole = typeof console !== 'undefined'; + const warn = (msg) => { + if (hasConsole) { + console.warn(msg) + } + } + warn() +} + + +}), + +},function(__webpack_require__) { +var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId) } +var __webpack_exports__ = (__webpack_exec__("./index.js")); + +} +]); +``` \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/treeShakingCases/issue-7016/index.js b/packages/rspack-test-tools/tests/treeShakingCases/issue-7016/index.js new file mode 100644 index 000000000000..7c6005efc19b --- /dev/null +++ b/packages/rspack-test-tools/tests/treeShakingCases/issue-7016/index.js @@ -0,0 +1,9 @@ +if (true) { + const hasConsole = typeof console !== 'undefined'; + const warn = (msg) => { + if (hasConsole) { + console.warn(msg) + } + } + warn() +} diff --git a/packages/rspack-test-tools/tests/treeShakingCases/issue-7016/rspack.config.js b/packages/rspack-test-tools/tests/treeShakingCases/issue-7016/rspack.config.js new file mode 100644 index 000000000000..6a9cd7f102d9 --- /dev/null +++ b/packages/rspack-test-tools/tests/treeShakingCases/issue-7016/rspack.config.js @@ -0,0 +1,3 @@ +module.exports = { + +}