Giter Club home page Giter Club logo

rollup-typescript-webworkers's People

Contributors

ashubham avatar darionco avatar dependabot[bot] avatar thivi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rollup-typescript-webworkers's Issues

What about a SharedWorker version?

Hi
I tried converting your web-worker type to a shared-worker type but the 'yarn start' run output says reports =>

(!) Missing global variable name
Use output.globals to specify browser global variable names corresponding to external modules

These are the changes I tried =>
workers.d.ts

declare module 'shared-worker:*' {
    const WorkerFactory: new () => SharedWorker;
    export default WorkerFactory;
}

line 9 of Worker.ts

const ctx: SharedWorker = self as any;
ctx.addEventListener('message', (e: any) => {
    const message = e.data || e;

index.ts

import SharedWorker from 'shared-worker:./Worker.ts';

function main(): void {
    const messageManager = new MessageManager('This instance was created on the main thread');

    const worker = new SharedWorker();
    console.log('worker : ', worker)
    if (!worker.port) {
      console.log("!! worker is not a SharedWorker !!")
      return
    }
    worker.port.postMessage({type: 'init', args: 'This instance was created in a worker'});

    messageManager.sayHello('main thread');
    worker.port.postMessage({type: 'exec', func:'sayHello', args: 'web worker'});

    messageManager.printMessage();
    worker.port.postMessage({type: 'exec', func:'printMessage', args: null});
}

SharedWorker wasn't generated by the WorkerFactory.
So I didn't bother trying to add code to Worker.ts for replying back to the main caller which requires getting the port from event.ports[0]
Thank for any help

Adding preserveModules: true within rollup config Outputs _virual/index.ts

Hey again ๐Ÿ‘‹

I have been working to optimize my rollup config on a large project and I have added preserveModules: true to my rollup config - when this is the case, it seems the worker plugin creates a _virtual folder with an index.ts file. Furthermore, it ends up replacing the import of the worker with something like ../_virtual/index.ts

Any thoughts on this?

Cheers,
-Tsavo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.