developit / greenlet

🦎 Move an async function into its own thread.
https://npm.im/greenlet
4.67k stars 100 forks source link

Cannot use spread operator #55

Closed syu93 closed 3 years ago

syu93 commented 3 years ago

Issue

Hi, I've been following your work on this project since the beginning and now I'm ready to give it a try.

I'm using greenlet inside my Vue 2 application and in one particular case I've the following error :

Uncaught (in promise) ReferenceError: [_PATH_]_node_modules_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_2__ is not defined

It's seems it miss a dependency to transpile the spread operator. I don't know if it is a Vue specific issue or something more global

Sep to reproduce

Inside a vue compoenent :

import greenlet from 'greenlet';

const fnSomeWorkerAction = greenlet((itemsToWorkWith) => {
  return itemsToWorkWith.map((item) => {
    return {
      ...item,
    };
  });
});

export default {
  data() {
    items: Array.from(Array(100)).map((item, idx) => ({ id: idx, name: `Plop ${idx}` }),
    fnSomeWorkerAction
  },
  mounted() {
    this.fnSomeWorkerAction(this.items);
  }
}
developit commented 3 years ago

This is a Vue issue. Don't transpile to helpers when using Greenlet, that isn't supported.