From f65215fab0d3af366f81a2bd81659d4aac8f2bdd Mon Sep 17 00:00:00 2001 From: Qingyu Wang Date: Fri, 3 Jan 2025 10:18:21 +0800 Subject: [PATCH] feat: add `optimization.avoidEntryIife` (#33) --- package.json | 2 +- pnpm-lock.yaml | 144 +++++++++++++++++-------------- src/Optimization.js | 1 + types/index.d.ts | 1 + types/test/rspack-chain-tests.ts | 1 + 5 files changed, 83 insertions(+), 66 deletions(-) diff --git a/package.json b/package.json index e73e9a0..c8cd226 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "javascript-stringify": "^2.0.1" }, "devDependencies": { - "@rspack/core": "^1.1.8", + "@rspack/core": "^1.2.0-alpha.0", "jest": "^27.0.0", "prettier": "^2.0.5", "typescript": "^5.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7104397..2b8ca32 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -16,8 +16,8 @@ importers: version: 2.1.0 devDependencies: '@rspack/core': - specifier: ^1.1.8 - version: 1.1.8 + specifier: ^1.2.0-alpha.0 + version: 1.2.0-alpha.0 jest: specifier: ^27.0.0 version: 27.5.1 @@ -275,68 +275,71 @@ packages: '@jridgewell/trace-mapping@0.3.25': resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} - '@module-federation/runtime-tools@0.5.1': - resolution: {integrity: sha512-nfBedkoZ3/SWyO0hnmaxuz0R0iGPSikHZOAZ0N/dVSQaIzlffUo35B5nlC2wgWIc0JdMZfkwkjZRrnuuDIJbzg==} + '@module-federation/error-codes@0.8.4': + resolution: {integrity: sha512-55LYmrDdKb4jt+qr8qE8U3al62ZANp3FhfVaNPOaAmdTh0jHdD8M3yf5HKFlr5xVkVO4eV/F/J2NCfpbh+pEXQ==} - '@module-federation/runtime@0.5.1': - resolution: {integrity: sha512-xgiMUWwGLWDrvZc9JibuEbXIbhXg6z2oUkemogSvQ4LKvrl/n0kbqP1Blk669mXzyWbqtSp6PpvNdwaE1aN5xQ==} + '@module-federation/runtime-tools@0.8.4': + resolution: {integrity: sha512-fjVOsItJ1u5YY6E9FnS56UDwZgqEQUrWFnouRiPtK123LUuqUI9FH4redZoKWlE1PB0ir1Z3tnqy8eFYzPO38Q==} - '@module-federation/sdk@0.5.1': - resolution: {integrity: sha512-exvchtjNURJJkpqjQ3/opdbfeT2wPKvrbnGnyRkrwW5o3FH1LaST1tkiNviT6OXTexGaVc2DahbdniQHVtQ7pA==} + '@module-federation/runtime@0.8.4': + resolution: {integrity: sha512-yZeZ7z2Rx4gv/0E97oLTF3V6N25vglmwXGgoeju/W2YjsFvWzVtCDI7zRRb0mJhU6+jmSM8jP1DeQGbea/AiZQ==} - '@module-federation/webpack-bundler-runtime@0.5.1': - resolution: {integrity: sha512-mMhRFH0k2VjwHt3Jol9JkUsmI/4XlrAoBG3E0o7HoyoPYv1UFOWyqAflfANcUPgbYpvqmyLzDcO+3IT36LXnrA==} + '@module-federation/sdk@0.8.4': + resolution: {integrity: sha512-waABomIjg/5m1rPDBWYG4KUhS5r7OUUY7S+avpaVIY/tkPWB3ibRDKy2dNLLAMaLKq0u+B1qIdEp4NIWkqhqpg==} - '@rspack/binding-darwin-arm64@1.1.8': - resolution: {integrity: sha512-I7avr471ghQ3LAqKm2fuXuJPLgQ9gffn5Q4nHi8rsukuZUtiLDPfYzK1QuupEp2JXRWM1gG5lIbSUOht3cD6Ug==} + '@module-federation/webpack-bundler-runtime@0.8.4': + resolution: {integrity: sha512-HggROJhvHPUX7uqBD/XlajGygMNM1DG0+4OAkk8MBQe4a18QzrRNzZt6XQbRTSG4OaEoyRWhQHvYD3Yps405tQ==} + + '@rspack/binding-darwin-arm64@1.2.0-alpha.0': + resolution: {integrity: sha512-EPprIe6BrkJ9XuWL5HBXJFaH4vvt5C2kBTvyu+t5E3wacyH9A0gIDaMOEmH30Kt3zl4B07OCBC1nCiJ1sTtimw==} cpu: [arm64] os: [darwin] - '@rspack/binding-darwin-x64@1.1.8': - resolution: {integrity: sha512-vfqf/c+mcx8rr1M8LnqKmzDdnrgguflZnjGerBLjNerAc+dcUp3lCvNxRIvZ2TkSZZBW8BpCMgjj3n70CZ4VLQ==} + '@rspack/binding-darwin-x64@1.2.0-alpha.0': + resolution: {integrity: sha512-ACwdgWg0V9j0o3gs1wvhqRJ4xui82L+Fii9Fa74az7P974iWO0ZHw4QIUaO5r434+v9OWMqpyBRN1M7cBrx3GA==} cpu: [x64] os: [darwin] - '@rspack/binding-linux-arm64-gnu@1.1.8': - resolution: {integrity: sha512-lZlO/rAJSeozi+qtVLkGSXfe+riPawCwM4FsrflELfNlvvEXpANwtrdJ+LsaNVXcgvhh50ZX2KicTdmx9G2b6Q==} + '@rspack/binding-linux-arm64-gnu@1.2.0-alpha.0': + resolution: {integrity: sha512-Ex9SviDikz9E36R4I5si/626FsYOJ35l1Lb+DCRUijjjsvoq4k8Shi8csyBfubR+JZ1M0uOXjJftu1Gm5z8Q0Q==} cpu: [arm64] os: [linux] - '@rspack/binding-linux-arm64-musl@1.1.8': - resolution: {integrity: sha512-bX7exULSZwy8xtDh6Z65b6sRC4uSxGuyvSLCEKyhmG6AnJkg0gQMxk3hoO0hWnyGEZgdJEn+jEhk0fjl+6ZRAQ==} + '@rspack/binding-linux-arm64-musl@1.2.0-alpha.0': + resolution: {integrity: sha512-U320xZmTcTwQ0BR8yIzE1L4olMCqzYkT3VFjXPR6iok/Mj0xjfk/SiKhLoZml473qQrHSGaFJ321cp02zgTFJg==} cpu: [arm64] os: [linux] - '@rspack/binding-linux-x64-gnu@1.1.8': - resolution: {integrity: sha512-2Prw2USgTJ3aLdLExfik8pAwAHbX4MZrACBGEmR7Vbb56kLjC+++fXkciRc50pUDK4JFr1VQ7eNZrJuDR6GG6Q==} + '@rspack/binding-linux-x64-gnu@1.2.0-alpha.0': + resolution: {integrity: sha512-GNur7VXJ29NtJhY8PYgv3Fv1Zxbx0XZhDUj/+7Wp40CAXRFsLgXScZIRh2U30TECYaihboZ7BD+xugv8MQPDoA==} cpu: [x64] os: [linux] - '@rspack/binding-linux-x64-musl@1.1.8': - resolution: {integrity: sha512-bnVGB/mQBKEdzOU/CPmcOE3qEXxGOGGW7/i6iLl2MamVOykJq8fYjL9j86yi6L0r009ja16OgWckykQGc4UqGw==} + '@rspack/binding-linux-x64-musl@1.2.0-alpha.0': + resolution: {integrity: sha512-0IdswzpG9+sgxvGu7KTwSeqfV0hvciaHMoZvGklfZa2txpcUqAg4ASp7uxrNaUo+G2a1fTUMOtP9351Cnl8DBg==} cpu: [x64] os: [linux] - '@rspack/binding-win32-arm64-msvc@1.1.8': - resolution: {integrity: sha512-u+na3gxhzeksm4xZyAzn1+XWo5a5j7hgWA/KcFPDQ8qQNkRknx4jnQMxVtcZ9pLskAYV4AcOV/AIximx7zvv8A==} + '@rspack/binding-win32-arm64-msvc@1.2.0-alpha.0': + resolution: {integrity: sha512-FcFgoWGjSrCfJwDZY5bDA2aO02l5BP7qdyW6ehjwBiMxNZyeSbGvKz3jXl5TtTHR1IgdLzi9kEJkTPYLLMiE1A==} cpu: [arm64] os: [win32] - '@rspack/binding-win32-ia32-msvc@1.1.8': - resolution: {integrity: sha512-FijUxym1INd5fFHwVCLuVP8XEAb4Sk1sMwEEQUlugiDra9ZsLaPw4OgPGxbxkD6SB0DeUz9Zq46Xbcf6d3OgfA==} + '@rspack/binding-win32-ia32-msvc@1.2.0-alpha.0': + resolution: {integrity: sha512-cZYFJw6DKCaPPz9VDJPndZ9KSp+/eedgt11Mv8OTpq+MJTUjB2HjtcjqJh8xxVcp3IuwvSMndTkC69WWt/4feA==} cpu: [ia32] os: [win32] - '@rspack/binding-win32-x64-msvc@1.1.8': - resolution: {integrity: sha512-SBzIcND4qpDt71jlu1MCDxt335tqInT3YID9V4DoQ4t8wgM/uad7EgKOWKTK6vc2RRaOIShfS2XzqjNUxPXh4w==} + '@rspack/binding-win32-x64-msvc@1.2.0-alpha.0': + resolution: {integrity: sha512-gfOqb/rq5716NV+Vbk5MteBhV4VhJeSoh2+dRQjdy4EN1wPZ+Uebs9ORVrT9uRjY3JrPn/5PkAHJXtgaOA9Uyg==} cpu: [x64] os: [win32] - '@rspack/binding@1.1.8': - resolution: {integrity: sha512-+/JzXx1HctfgPj+XtsCTbRkxiaOfAXGZZLEvs7jgp04WgWRSZ5u97WRCePNPvy+sCfOEH/2zw2ZK36Z7oQRGhQ==} + '@rspack/binding@1.2.0-alpha.0': + resolution: {integrity: sha512-rtmDScjtGUxv1zA1m3jXecuX2LsgNp4aWaAjOowHasoO1YqfHK0fMyprCiPowTjoHtpZ7Xt/tnMhii0GlGIITQ==} - '@rspack/core@1.1.8': - resolution: {integrity: sha512-pcZtcj5iXLCuw9oElTYC47bp/RQADm/MMEb3djHdwJuSlFWfWPQi5QFgJ/lJAxIW9UNHnTFrYtytycfjpuoEcA==} + '@rspack/core@1.2.0-alpha.0': + resolution: {integrity: sha512-YiD0vFDj+PfHs3ZqJwPNhTYyVTb4xR6FpOI5WJ4jJHV4lgdErS+RChTCPhf1xeqxfuTSSnFA7UeqosLhBuNSqQ==} engines: {node: '>=16.0.0'} peerDependencies: '@swc/helpers': '>=0.5.1' @@ -903,6 +906,10 @@ packages: isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} + isomorphic-rslog@0.0.6: + resolution: {integrity: sha512-HM0q6XqQ93psDlqvuViNs/Ea3hAyGDkIdVAHlrEocjjAwGrs1fZ+EdQjS9eUPacnYB7Y8SoDdSY3H8p3ce205A==} + engines: {node: '>=14.17.6'} + istanbul-lib-coverage@3.2.2: resolution: {integrity: sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==} engines: {node: '>=8'} @@ -1948,65 +1955,70 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.0 - '@module-federation/runtime-tools@0.5.1': + '@module-federation/error-codes@0.8.4': {} + + '@module-federation/runtime-tools@0.8.4': dependencies: - '@module-federation/runtime': 0.5.1 - '@module-federation/webpack-bundler-runtime': 0.5.1 + '@module-federation/runtime': 0.8.4 + '@module-federation/webpack-bundler-runtime': 0.8.4 - '@module-federation/runtime@0.5.1': + '@module-federation/runtime@0.8.4': dependencies: - '@module-federation/sdk': 0.5.1 + '@module-federation/error-codes': 0.8.4 + '@module-federation/sdk': 0.8.4 - '@module-federation/sdk@0.5.1': {} + '@module-federation/sdk@0.8.4': + dependencies: + isomorphic-rslog: 0.0.6 - '@module-federation/webpack-bundler-runtime@0.5.1': + '@module-federation/webpack-bundler-runtime@0.8.4': dependencies: - '@module-federation/runtime': 0.5.1 - '@module-federation/sdk': 0.5.1 + '@module-federation/runtime': 0.8.4 + '@module-federation/sdk': 0.8.4 - '@rspack/binding-darwin-arm64@1.1.8': + '@rspack/binding-darwin-arm64@1.2.0-alpha.0': optional: true - '@rspack/binding-darwin-x64@1.1.8': + '@rspack/binding-darwin-x64@1.2.0-alpha.0': optional: true - '@rspack/binding-linux-arm64-gnu@1.1.8': + '@rspack/binding-linux-arm64-gnu@1.2.0-alpha.0': optional: true - '@rspack/binding-linux-arm64-musl@1.1.8': + '@rspack/binding-linux-arm64-musl@1.2.0-alpha.0': optional: true - '@rspack/binding-linux-x64-gnu@1.1.8': + '@rspack/binding-linux-x64-gnu@1.2.0-alpha.0': optional: true - '@rspack/binding-linux-x64-musl@1.1.8': + '@rspack/binding-linux-x64-musl@1.2.0-alpha.0': optional: true - '@rspack/binding-win32-arm64-msvc@1.1.8': + '@rspack/binding-win32-arm64-msvc@1.2.0-alpha.0': optional: true - '@rspack/binding-win32-ia32-msvc@1.1.8': + '@rspack/binding-win32-ia32-msvc@1.2.0-alpha.0': optional: true - '@rspack/binding-win32-x64-msvc@1.1.8': + '@rspack/binding-win32-x64-msvc@1.2.0-alpha.0': optional: true - '@rspack/binding@1.1.8': + '@rspack/binding@1.2.0-alpha.0': optionalDependencies: - '@rspack/binding-darwin-arm64': 1.1.8 - '@rspack/binding-darwin-x64': 1.1.8 - '@rspack/binding-linux-arm64-gnu': 1.1.8 - '@rspack/binding-linux-arm64-musl': 1.1.8 - '@rspack/binding-linux-x64-gnu': 1.1.8 - '@rspack/binding-linux-x64-musl': 1.1.8 - '@rspack/binding-win32-arm64-msvc': 1.1.8 - '@rspack/binding-win32-ia32-msvc': 1.1.8 - '@rspack/binding-win32-x64-msvc': 1.1.8 - - '@rspack/core@1.1.8': - dependencies: - '@module-federation/runtime-tools': 0.5.1 - '@rspack/binding': 1.1.8 + '@rspack/binding-darwin-arm64': 1.2.0-alpha.0 + '@rspack/binding-darwin-x64': 1.2.0-alpha.0 + '@rspack/binding-linux-arm64-gnu': 1.2.0-alpha.0 + '@rspack/binding-linux-arm64-musl': 1.2.0-alpha.0 + '@rspack/binding-linux-x64-gnu': 1.2.0-alpha.0 + '@rspack/binding-linux-x64-musl': 1.2.0-alpha.0 + '@rspack/binding-win32-arm64-msvc': 1.2.0-alpha.0 + '@rspack/binding-win32-ia32-msvc': 1.2.0-alpha.0 + '@rspack/binding-win32-x64-msvc': 1.2.0-alpha.0 + + '@rspack/core@1.2.0-alpha.0': + dependencies: + '@module-federation/runtime-tools': 0.8.4 + '@rspack/binding': 1.2.0-alpha.0 '@rspack/lite-tapable': 1.0.1 caniuse-lite: 1.0.30001673 @@ -2572,6 +2584,8 @@ snapshots: isexe@2.0.0: {} + isomorphic-rslog@0.0.6: {} + istanbul-lib-coverage@3.2.2: {} istanbul-lib-instrument@5.2.1: diff --git a/src/Optimization.js b/src/Optimization.js index fcb0f41..2ea692a 100644 --- a/src/Optimization.js +++ b/src/Optimization.js @@ -27,6 +27,7 @@ module.exports = class extends ChainedMap { 'mangleExports', 'innerGraph', 'realContentHash', + 'avoidEntryIife', ]); } diff --git a/types/index.d.ts b/types/index.d.ts index 837805d..5ad5b5e 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -470,6 +470,7 @@ declare namespace Config { mangleExports(value: RspackOptimization['mangleExports']): this; innerGraph(value: RspackOptimization['innerGraph']): this; realContentHash(value: RspackOptimization['realContentHash']): this; + avoidEntryIife(value: RspackOptimization['avoidEntryIife']): this; } interface RuntimeChunk { diff --git a/types/test/rspack-chain-tests.ts b/types/test/rspack-chain-tests.ts index 95f49d3..2a6c39a 100644 --- a/types/test/rspack-chain-tests.ts +++ b/types/test/rspack-chain-tests.ts @@ -245,6 +245,7 @@ config .runtimeChunk({ name: ({}) => 'hello' }) .sideEffects(true) .usedExports(true) + .avoidEntryIife(true) .splitChunks(false) .splitChunks.set('chunks', 'all') .set('chunks', 'all')