JuniorTour / vue-template-babel-compiler

Enable Optional Chaining(?.), Nullish Coalescing(??) and many new ES syntax for Vue.js SFC based on Babel
https://www.npmjs.com/package/vue-template-babel-compiler
118 stars 9 forks source link

[Bug] Get "ReferenceError: _toConsumableArray is not defined" when use ... #25

Closed xachary closed 2 years ago

xachary commented 2 years ago

Current behavior

ReferenceError: _toConsumableArray is not defined.

Expected behavior

No ReferenceError.

Usage

{{ [...document.querySelectorAll('div')] }}
JuniorTour commented 2 years ago

It is a bug.

Currently Babel will transform [...document.querySelectorAll('div')] into:

function _toConsumableArray(arr) {
  // ...
}

_toConsumableArray(document.querySelectorAll("div"));

But this compiler will drop _toConsumableArray directly, So your error occured.

Babel Playground DEMO Link


May be we can fix it by add "arrayLikeIsIterable": true to assumptions, according to babel-plugin-transform-spread Doc.

Do you have interest to fix this issue and become our Contributor?

You can:

  1. Try to reproduce this error. Setup DEMO Project can help.

  2. Follow CONTRIBUTING.md to make a Pull Request.

JuniorTour commented 2 years ago

We just publish a beta version 1.0.7-beta.0 which will fix the error _toConsumableArray is not defined.

You can try it by yarn add vue-template-babel-compiler@beta.

Thanks for your feedback again!

JuniorTour commented 2 years ago

We just publish a beta version 1.0.7-beta.0 which will fix the error _toConsumableArray is not defined.

You can try it by yarn add vue-template-babel-compiler@beta.

1.0.7-beta.0 did't fix this error, I will look into this deeply.

JuniorTour commented 2 years ago

We just publish v1.1.2, it will fix this issue,

Try it by:

npm install vue-template-babel-compiler@latest
// or 
yarn add vue-template-babel-compiler@latest

Thanks for your feedback again!