Skip to content
This repository has been archived by the owner on May 2, 2020. It is now read-only.

datsteves/spaceworker-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spaceworker.js Webpack-loader

This is the Webpack loader for my simple libary to make it easier to use WebWorker called Spaceworker.js

Install

npm install --save-dev spaceworker-loader
OR
yarn add --dev spaceworker-loader

Usage

import '/spaceworker.js' into your html file :)

// app.js
const worker = require("./iss.worker.js")

worker.run("sayHelloWorld", "hello", "world")
    .then(res => {
        console.log(res) // hello world :)
    })
// iss.worker.js
class ISS {
    sayHelloWorld(hello, world) {
        return hello + " " + world + " :)"
    }
}

SpaceWorker.provide(ISS, self)
// webpack.config.js
const path = require('path')
const config = {
    entry: "./app.js",
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: "bundle.js"
    },
    module: {
        rules: [
            { test: /\.worker\.js$/, use: { loader: 'spaceworker-loader' } }
        ]
    }
}

module.exports = config

About

An easy way to use Webworker with promises in webpack

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published