We're trying to move our webpack compilation off terser and on to swc, but we are noticing a few scenarios where our bundles are significantly larger than our current terser generated bundle.
Expected output should be small, like what terser outputs. Namely, it should not include the large FluentV9ColorTokens object and just inline the used property value.
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Describe the bug
We're trying to move our webpack compilation off terser and on to swc, but we are noticing a few scenarios where our bundles are significantly larger than our current terser generated bundle.
Input code
Config
Playground link
https://play.swc.rs/?version=1.3.60&code=H4sIAAAAAAAAA5WaW2vjSBCF3wP%2BD3oYSAIzhkj2wG7IhiRD2LDDZMBhn0eRexNhWTJtOUMI%2Fu8r6xL1rU5V8mRUXx11n251dymaHGVVua2j22KnyvrfP26qotIP1UqV2%2BgiepscRc1fdrj4Q%2B1qnRa3lVZPutqVy7M%2Fo%2BMvX4jY8WeY%2Bnf1ojTKbwFG5KdW261aIpkeYYQWqlBZjZUGBkvFQCJmUjlPYoEnMe9JLPIkFngSCz251mm5ZHs3UhI5QT9NTiIp6bEFYtEE6CRMKmdWIvAp4S1KRO4kAmMSoSeiqZBIp0IinAqJfCok0qmQfGAqzIDODKd%2By7fpYwFbMiCWUNu6kfmel6tRIhDkkp0xowhOxhsrmuGk%2FDECEPP82%2FaE4wIJdo0L%2BxTmBCsc5VaYlKxvpGc31XpzIByPjTMARYhkHOcgJhL03GNA7N992aYB53oCy9yVTfPxCAyITIibcBYnk%2BSnnUPKZAWTz0VlwujE9c5gqUWd1nkmGBwblLWPWVpMTC4oHXfhemPi8vEXrz5mwgfmgXz9HjIEm6WLol3mjNxazlBaTKYx8%2FCsm1%2BwCmkJdHd%2FGhOARATv%2BvTqQoDc7o9WFge9L7%2FnT881KdXHBRK4jyYkEON6aGMCQfaU43ChGXadZiuqZDdiTGp4zXEBRoRaXXyEESLXkQCDpfwNxIgxqZwndMluMLwnqGQ3KIEnsGQfMb92NWJMKucJXbsaDO8Jql0NSuAJrF1HzC%2FijBiTynkyE3gy4z2ZiTyZCTyZy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AAAA41VwZLaMAy98xVMzj1QTp1%2BwN76DR4Ty8HUsTKWzMLs8O9VTMKyi5LphSF6fpIlPckfm%2B22OVHb%2FN5%2ByF%2F5GGwmyI9vsdA1sb2IpYG2t9TmMHDzY0ZPNELeRoJqut2Rhm3ugCuL9rv9bmI0EZFgZky2PqTgr88xW%2ByHDERPNrGKy9JDYvrKn7CM7yPAuTzbD4gRbFpBjCUTEkMHWXPcYox2IDBnmxUv401tDoRaiBEsDM4MGQcVTy5wwCQxX1EH1pkWHShQyNByOINGk1hCSyTpKflU2MGhdF3t8zc2nG0slpWYcKktkdsqXo8YiI0vSSvhHVyowR2civudGbzJwCWnV94JQ1royV8AqUC0RMn2oPmtJ7zoaYntV5kheZEsXxVc9K1lmaCTopoQvFLZsTKQOWjdzOBKC2NlW%2B06E7xQPgoODHgvWlFc03vg9qgF5esA6BVA%2Bmu9pqo7YB5TuICPA7ECv0mWrAtsOtFbPi6jdO0PGFcC9MBHdCsHpBWMy3CWLXEZlvGSHIg0wKlHClXgdQnIADCaWPflizZkPMSj6SIe1DUxiM5rE%2FeT7fZYzr1NXV0CT0uUcYhwhrik7f%2BYm1VULnwepT6P%2B8tIwy9NqVamMfzcfXlLJJXN%2FFuTanp05SmhKtTxjRFd9ZhO1HyenN%2BUuVpNoD8ze7Rtbv8AccrBqP0GAAA%3D
Expected behavior
Expected output should be small, like what terser outputs. Namely, it should not include the large FluentV9ColorTokens object and just inline the used property value.
The output from terser is something like this:
Actual behavior
The entire FluentV9ColorTokens object appears in the output
Version
1.3.60
Additional context
One interesting thing to note is that the if statement below is critical to repro this behavior:
If I removed the if statement, the output is similar to terser