pshihn / workly

A really simple way to move a function or class to a web worker. 🏋️‍♀️→ 😄
MIT License
1.88k stars 51 forks source link

Get an empty object when using ES6 import #15

Open ndabAP opened 5 years ago

ndabAP commented 5 years ago

Maybe I miss something but when I do:

import workly from 'workly'

the workly object is empty.

pshihn commented 5 years ago

workly is essentially two functions expose and proxy, so depending on which ones you want to use you import those.

import {proxy, expose} from 'workly'

I should update the docs with this

ndabAP commented 5 years ago

Thanks for your feedback. Also tried that and it gave me undefined.

pshihn commented 5 years ago

Ok i'll take a look later today. Probably something I overlooked.

ndabAP commented 5 years ago

Thanks :) Using Webpack (actually Vue.js but it uses Webpack).

pshihn commented 5 years ago

I'm so sorry. I never got back to you on this. Please let me know if you're still using workly

ndabAP commented 5 years ago

Actually no, but the problem is likely not gone ;)

pshihn commented 5 years ago

Thanks. It has something to do with es6 modules in a Webpack that is not configured for that. I have not used web pack much but will try setting up a Vue project with it

colshacol commented 5 years ago

I am experiencing this, currently.

I created a CodeSandbox to demonstrate the issue. :)

https://codesandbox.io/s/awesome-stonebraker-19e9w

AnonymousArthur commented 5 years ago

Same issue here, getting empty object when doing import * as workly from "workly". Also tried

import { proxy, expose } from 'workly';
[ERROR] Cannot find name 'proxy'. Did you mean 'Proxy'?
Cannot find name 'expose'.

Checked source code and generated d.ts file, both proxy and expose are exported. Any idea why this is happening?

AnonymousArthur commented 5 years ago

UPDATE: fixed by import * as workly from 'workly/dist/workly.m.js'; Which isn't that intuitive.

ndabAP commented 5 years ago

fixed by import * as workly from 'workly/dist/workly.m.js';

That's a work around.

kairos666 commented 4 years ago

I was using workerize but came to workly because of the clean and simple interface. Unfortunately ES6 import unreliable support was a deal breaker for my use case.

Will check again though