Repository: next.js
Issue: bug: swc external helper breaking webpack's dependency resolution in next 15
Labels: bug,SWC,Webpack

### Link to the code that reproduces this issue

https://github.com/rishabh3112/next-15-swc-external-helpers-bug

### To Reproduce

1. Clone reproduction repo
2. `npm install`
3. `npm run dev`

### Current vs. Expected behavior

It should work as it was working in next 14.

#### Current: After webpack parsing with external helper (Next 15):

```
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _swc_helpers_type_of__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @swc/helpers/_/_type_of */ "./node_modules/@swc/helpers/esm/_type_of.js");

(function(root, factory) {
    if (typeof define === "function" && __webpack_require__.amdO) {
        define([
            "exports"
        ], function(exports1) {
            root.Backbone = factory(root, exports1);
        });
    } else if (typeof exports !== "undefined") {
        factory(root, exports);
    } else {
        root.Backbone = factory(root, {});
    }
})(window, function(root, Backbone) {
    // Removed actual backbone code for minimal reproduction
    Backbone.Modal = function() {
        var something = root.something;
        // So that _type_of swc helper import gets added to the code
        if ((typeof something === "undefined" ? "undefined" : (0,_swc_helpers_type_of__WEBPACK_IMPORTED_MODULE_0__._)(something)) === "object") {
            return "object";
        }
        return "don't know";
    };
    return Backbone;
});
```
SWC playground link: [link](https://play.swc.rs/?version=1.9.2&code=H4sIAAAAAAAAA31RMW7DMBDb8wrWQ%2BoARfKAwEv3LulYFIEjnRM1ts6Q5bpB4L9XsqRAS7vYwJFH8qiyGbWwijVKw2xf0NTCsrltcF8BqkFpbz1xA0mN0oSqqlCknQLrdQS2dSfDDuKk%2FCjop2djh%2BLTyT5s4jCRAe%2B7fa3F9cTeICWIeRJ9v7Dn5T%2BD2oHydJGFJx9v1CGBLJLJ35JRKtD%2BT3KP5qt5U05KS57yswInLQfj3Q4H6vibJJzSWLc4JXHBktCwQae06hxiqDcsx0XNrSah7RtLh1aZUzpKsB4sBu7IXpQ%2BO86S%2FzEIjbkM7wx7qS2Ovqyja2uYBC7U9mSgOt8FzuTKq6V0Sa1nh4CLQNZy5uV75tMXCVtkL0l2NPoBxCdb5ZBk%2FWxx1Twt8Ow%2FEUsn713B%2B1%2BA%2B%2BJUmAIAAA%3D%3D&config=H4sIAAAAAAAAA22PSw7CMAxE95wi8potLDgBGw4RBbcKyk%2B2K7WqeneSNCkgsYtn3mTs9aQUvNjATa35mYekiZGOOSu8BNFzVkCWhGzIJoFzd4WLNWjHWKVtd0A0jSglhXxpOLgYGTveNG%2BDHZbvQhN9ImT%2BBQuqw%2Bjwbx3OghS0u6NLSCUqNBWkAuDjc6rJdmW5ZN%2FtCh%2Bob3K0guVHT9b%2FtjeNDDPTMQEAAA%3D%3D)

#### Expected: After webpack parsing without external helper (Next 14):
```
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function(root, factory) {
    if (true) {
        !(__WEBPACK_AMD_DEFINE_ARRAY__ = [
            exports
        ], __WEBPACK_AMD_DEFINE_RESULT__ = (function(exports1) {
            root.Backbone = factory(root, exports1);
        }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
		__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
    } else {}
})(window, function(root, Backbone) {
    // Removed actual backbone code for minimal reproduction
    Backbone.Modal = function() {
        var something = root.something;
        // So that _type_of swc helper import gets added to the code
        if (typeof something === "object") {
            return "object";
        }
        return "don't know";
    };
    return Backbone;
});
```

SWC playground link: [link](https://play.swc.rs/?version=1.5.7&code=H4sIAAAAAAAAA31RMW7DMBDb8wrWQ%2BoARfKAwEv3LulYFIEjnRM1ts6Q5bpB4L9XsqRAS7vYwJFH8qiyGbWwijVKw2xf0NTCsrltcF8BqkFpbz1xA0mN0oSqqlCknQLrdQS2dSfDDuKk%2FCjop2djh%2BLTyT5s4jCRAe%2B7fa3F9cTeICWIeRJ9v7Dn5T%2BD2oHydJGFJx9v1CGBLJLJ35JRKtD%2BT3KP5qt5U05KS57yswInLQfj3Q4H6vibJJzSWLc4JXHBktCwQae06hxiqDcsx0XNrSah7RtLh1aZUzpKsB4sBu7IXpQ%2BO86S%2FzEIjbkM7wx7qS2Ovqyja2uYBC7U9mSgOt8FzuTKq6V0Sa1nh4CLQNZy5uV75tMXCVtkL0l2NPoBxCdb5ZBk%2FWxx1Twt8Ow%2FEUsn713B%2B1%2BA%2B%2BJUmAIAAA%3D%3D&config=H4sIAAAAAAAAA22PSw7CMAxE95yi8potLDgBGw5hBRelyk%2B2K7WqeneStCkgsYtn3mTs5dR1MIiBW7fkZx4SshAfc1ZkDopTVoCMRzFsk8K5uYMUq0cnVKV1c0CRX6Q1JZcdBxejUMN3zdtg%2B%2Fm70ESfmER%2BwYJieDn6W0eTEgd0d3KJuESVx4JUAHx8jjW5X6lzom23K3ygtsnRClYeLVn%2FW98mTB8tMQEAAA%3D%3D)


### Provide environment information

```bash
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 21.6.0: Wed Apr 24 06:05:14 PDT 2024; root:xnu-8020.240.18.708.4~1/RELEASE_ARM64_T6000
  Available memory (MB): 65536
  Available CPU cores: 10
Binaries:
  Node: 18.18.2
  npm: 9.8.1
  Yarn: 1.22.22
  pnpm: 9.12.2
Relevant Packages:
  next: 15.0.3 // Latest available version is detected (15.0.3).
  eslint-config-next: N/A
  react: 18.3.1
  react-dom: 18.3.1
  typescript: N/A
Next.js Config:
  output: N/A
```


### Which area(s) are affected? (Select all that apply)

SWC, Webpack

### Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local), Other (Deployed)

### Additional context

It should work like it was working in next 14.
Willing to contribute.