Skip to content

Follow up to #5090 #5092

Closed
Closed
@Timer

Description

@Timer

Following up on #5090, it looks like Array.from is required.

Unfortunately, it looks like babel wastes a lot of bytes by duplicating helpers:

(window.webpackJsonp = window.webpackJsonp || []).push([
  [0],
  [
    function(r, t, n) {
      r.exports = n(1);
    },
    function(r, t, n) {
      'use strict';
      n.r(t);
      var e,
        o = new Set([9, 8, 7]),
        a = [1, 2, 3].concat(
          (function(r) {
            if (Array.isArray(r)) {
              for (var t = 0, n = new Array(r.length); t < r.length; t++)
                n[t] = r[t];
              return n;
            }
          })((e = o)) ||
            (function(r) {
              if (
                Symbol.iterator in Object(r) ||
                '[object Arguments]' === Object.prototype.toString.call(r)
              )
                return Array.from(r);
            })(e) ||
            (function() {
              throw new TypeError(
                'Invalid attempt to spread non-iterable instance'
              );
            })()
        );
      function i(r) {
        return (
          (function(r) {
            if (Array.isArray(r)) {
              for (var t = 0, n = new Array(r.length); t < r.length; t++)
                n[t] = r[t];
              return n;
            }
          })(r) ||
          (function(r) {
            if (
              Symbol.iterator in Object(r) ||
              '[object Arguments]' === Object.prototype.toString.call(r)
            )
              return Array.from(r);
          })(r) ||
          (function() {
            throw new TypeError(
              'Invalid attempt to spread non-iterable instance'
            );
          })()
        );
      }
      var c = new Set([4, 5, 6]);
      console.log([1, 2, 3].concat(i(c), i(a)));
    },
  ],
  [[0, 1]],
]);
//# sourceMappingURL=main.91f74b1f.chunk.js.map

from:

// src/index.js
import { c } from './boo';
const a = [1, 2, 3];
const b = new Set([4, 5, 6]);

console.log([...a, ...b, ...c]);

// src/boo.js
const d = [1, 2, 3];
const e = new Set([9, 8, 7]);
const c = [...d, ...e];
export { c };

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions