1.0.1 • Published 6 years ago

spaceworker-loader v1.0.1

Weekly downloads
6
License
MIT
Repository
github
Last release
6 years ago

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

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

worker.run("sayHelloWorld", "hello", "world")
    .then(res => {
        console.log(res)
    })
// 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
1.0.1

6 years ago

1.0.0

6 years ago