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

Transpiled spread in array becomes incorrectly minified. #589

Closed
frzi opened this issue Jun 19, 2017 · 2 comments
Closed

Transpiled spread in array becomes incorrectly minified. #589

frzi opened this issue Jun 19, 2017 · 2 comments

Comments

@frzi
Copy link

frzi commented Jun 19, 2017

Hello,

Recently I've been having troubles minifying spreads in arrays, after being transpiled using Babel (using babel-preset-env).

The following code

let a = [...document.body.children]
console.log(a)

becomes, after transpiling and minifying, the following:

var a=[babelHelpers.toConsumableArray(document.body.children)];console.log(a);

Notice how the babelHelpers.toConsumableArray is called inside another array. The result is an array within an array.

To reproduce, the package.json:

{
  "name": "babili-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "build": "babel index.js -o index.min.js"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-cli": "^6.24.1",
    "babel-core": "^6.25.0",
    "babel-plugin-external-helpers": "^6.22.0",
    "babel-polyfill": "^6.23.0",
    "babel-preset-babili": "^0.1.3",
    "babel-preset-env": "^1.5.2"
  }
}

And the .babelrc:

{
	"presets": [
		["env", {
			"targets": {
				"ie": "11",
				"ios": "7",
				"android": "4.4"
			},
			"modules": false,
			"useBuiltIns": true
		}],
		"babili"
	],
	"plugins": [
		"external-helpers"
	]
}

I'd like to point out that, when you remove "babili" from the .babelrc, the code is transpiled correctly.

If I'm overlooking something incredibly obvious, please let me know. 😄

@j-f1
Copy link
Contributor

j-f1 commented Jun 19, 2017

You’ve got the same issue as #580. The issue has been fixed on master, and the maintainers said they’d do a release today.

@frzi
Copy link
Author

frzi commented Jun 19, 2017

Well, there you go. Thanks for the heads up! Sorry for the 'duplicate' issue.

@frzi frzi closed this as completed Jun 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants