Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #5092
Closed
Open
Issue created Sep 25, 2018 by Administrator@rootContributor

Follow up to #5090

Created by: 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 };
Assignee
Assign to
Time tracking