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

Follow up to #5090 #5092

Closed
Timer opened this issue Sep 25, 2018 · 0 comments
Closed

Follow up to #5090 #5092

Timer opened this issue Sep 25, 2018 · 0 comments

Comments

@Timer
Copy link
Contributor

Timer commented Sep 25, 2018

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 };
@Timer Timer added this to the 2.0.0 milestone Sep 25, 2018
@lock lock bot locked and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant