-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### What? Patch cjs finder to detect `exports.foo` (instead of module.exports) ### Why? This causes an issue for `react.production.min.js`. x-ref: https://vercel.slack.com/archives/C02HY34AKME/p1707343215879979 ### How? Closes PACK-2443
- Loading branch information
Showing
9 changed files
with
86 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 5 additions & 36 deletions
41
packages/next-swc/crates/next-custom-transforms/tests/full/example/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,8 @@ | ||
function r(r, t) { | ||
(null == t || t > r.length) && (t = r.length); | ||
for(var e = 0, n = Array(t); e < t; e++)n[e] = r[e]; | ||
return n; | ||
} | ||
import t from "other"; | ||
((function(r) { | ||
if (Array.isArray(r)) return r; | ||
})(t) || function(r, t) { | ||
var e, n, o = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; | ||
if (null != o) { | ||
var a = [], l = !0, u = !1; | ||
try { | ||
for(o = o.call(r); !(l = (e = o.next()).done) && (a.push(e.value), !t || a.length !== t); l = !0); | ||
} catch (r) { | ||
u = !0, n = r; | ||
} finally{ | ||
try { | ||
l || null == o.return || o.return(); | ||
} finally{ | ||
if (u) throw n; | ||
} | ||
} | ||
return a; | ||
} | ||
}(t, 1) || function(t, e) { | ||
if (t) { | ||
if ("string" == typeof t) return r(t, e); | ||
var n = Object.prototype.toString.call(t).slice(8, -1); | ||
if ("Object" === n && t.constructor && (n = t.constructor.name), "Map" === n || "Set" === n) return Array.from(n); | ||
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return r(t, e); | ||
} | ||
}(t, 1) || function() { | ||
throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
}())[0]; | ||
import "@swc/helpers/_/_class_call_check"; | ||
import { _ as e } from "@swc/helpers/_/_sliced_to_array"; | ||
import r from "other"; | ||
e(r, 1)[0]; | ||
export var __N_SSG = !0; | ||
export default function e() { | ||
export default function t() { | ||
return React.createElement("div", null); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/next-swc/crates/next-custom-transforms/tests/loader/auto-cjs/react-prod/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// This file should not import helpers using ESM syntax | ||
const E = class Foo {} | ||
exports.Component = E |
11 changes: 11 additions & 0 deletions
11
packages/next-swc/crates/next-custom-transforms/tests/loader/auto-cjs/react-prod/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// This file should not import helpers using ESM syntax | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _class_call_check = require("@swc/helpers/_/_class_call_check"); | ||
var E = function Foo() { | ||
"use strict"; | ||
_class_call_check._(this, Foo); | ||
}; | ||
exports.Component = E; |
53 changes: 2 additions & 51 deletions
53
packages/next-swc/crates/next-custom-transforms/tests/loader/example/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 1 addition & 5 deletions
6
packages/next-swc/crates/next-custom-transforms/tests/loader/issue-31627/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters