Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(next-swc): Detect exports.foo from cjs_finder #61795

Merged
merged 9 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ fn test(input: &Path, minify: bool) {
tsx: true,
..Default::default()
})),
external_helpers: true.into(),
..Default::default()
},
..Default::default()
Expand Down
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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
var _esm = /*#__PURE__*/ _interop_require_default(require("esm"));
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
var _interop_require_default = require("@swc/helpers/_/_interop_require_default");
var _esm = /*#__PURE__*/ _interop_require_default._(require("esm"));
console.log(_esm.default.foo);
module.exports = _esm.default;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This file should not import helpers using ESM syntax
const E = class Foo {
kdy1 marked this conversation as resolved.
Show resolved Hide resolved

};
exports.Component=E
Original file line number Diff line number Diff line change
@@ -1,54 +1,5 @@
function _array_like_to_array(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
return arr2;
}
function _array_with_holes(arr) {
if (Array.isArray(arr)) return arr;
}
function _class_call_check(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _iterable_to_array_limit(arr, i) {
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
if (_i == null) return;
var _arr = [];
var _n = true;
var _d = false;
var _s, _e;
try {
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally{
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally{
if (_d) throw _e;
}
}
return _arr;
}
function _non_iterable_rest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _sliced_to_array(arr, i) {
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _unsupported_iterable_to_array(o, minLen) {
if (!o) return;
if (typeof o === "string") return _array_like_to_array(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(n);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
import other from "other";
var _other = _sliced_to_array(other, 1), foo = _other[0];
var Foo = function Foo() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
function _class_call_check(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { useEffect } from "react";
import { select, selectAll } from "d3-selection";
export default function Home() {
Expand Down
Loading