Code Monkey home page Code Monkey logo

workerize-loader's Introduction

workerize-loader

workerize-loader npm travis

A webpack loader that moves a module and its dependencies into a Web Worker, automatically reflecting exported functions as asynchronous proxies.

  • Bundles a tiny, purpose-built RPC implementation into your app
  • If exported module methods are already async, signature is unchanged
  • Supports synchronous and asynchronous worker functions
  • Works beautifully with async/await
  • Imported value is instantiable, just a decorated Worker

Install

npm install -D workerize-loader

Usage

worker.js:

// block for `time` ms, then return the number of loops we could run in that time:
export function expensive(time) {
    let start = Date.now(),
        count = 0
    while (Date.now() - start < time) count++
    return count
}

index.js: (our demo)

import worker from 'workerize-loader!./worker'

let instance = worker()  // `new` is optional

instance.expensive(1000).then( count => {
    console.log(`Ran ${count} loops`)
})

Options

Workerize options can either be defined in your Webpack configuration, or using Webpack's syntax for inline loader options.

inline

Type: Boolean Default: false

You can also inline the worker as a BLOB with the inline parameter

// webpack.config.js
{
  loader: 'workerize-loader',
  options: { inline: true }
}

or

import worker from 'workerize-loader?inline!./worker'

name

Type: String Default: [hash]

Customize filename generation for worker bundles. Note that a .worker suffix will be injected automatically ({name}.worker.js).

// webpack.config.js
{
  loader: 'workerize-loader',
  options: { name: '[name].[contenthash:8]' }
}

or

import worker from 'workerize-loader?name=[name].[contenthash:8]!./worker'

publicPath

Type: String Default: based on output.publicPath

Workerize uses the configured value of output.publicPath from Webpack unless specified here. The value of publicPath gets prepended to bundle filenames to get their full URL. It can be a path, or a full URL with host.

// webpack.config.js
{
  loader: 'workerize-loader',
  options: { publicPath: '/static/' }
}

ready

Type: Boolean Default: false

If true, the imported "workerized" module will include a ready property, which is a Promise that resolves once the Worker has been loaded. Note: this is unnecessary in most cases, since worker methods can be called prior to the worker being loaded.

// webpack.config.js
{
  loader: 'workerize-loader',
  options: { ready: true }
}

or

import worker from 'workerize-loader?ready!./worker'

let instance = worker()  // `new` is optional
await instance.ready

import

Type: Boolean Default: false

When enabled, generated output will create your Workers using a Data URL that loads your code via importScripts (eg: new Worker('data:,importScripts("url")')). This workaround enables cross-origin script preloading, but Workers are created on an "opaque origin" and cannot access resources on the origin of their host page without CORS enabled. Only enable it if you understand this and specifically need the workaround.

// webpack.config.js
{
  loader: 'workerize-loader',
  options: { import: true }
}

or

import worker from 'workerize-loader?import!./worker'

About Babel

If you're using Babel in your build, make sure you disabled commonJS transform. Otherwize, workerize-loader won't be able to retrieve the list of exported function from your worker script :

{
    test: /\.js$/,
    loader: "babel-loader",
    options: {
        presets: [
            [
                "env",
                {
                    modules: false,
                },
            ],
        ]
    }
}

Polyfill Required for IE11

Workerize-loader supports browsers that support Web Workers - that's IE10+. However, these browsers require a polyfill in order to use Promises, which Workerize-loader relies on. It is recommended that the polyfill be installed globally, since Webpack itself also needs Promises to load bundles.

The smallest implementation is the one we recommend installing:

npm i promise-polyfill

Then, in the module you are "workerizing", just add it as your first import:

import 'promise-polyfill/src/polyfill';

All worker code can now use Promises.

Testing

Without Webpack

To test a module that is normally imported via workerize-loader when not using Webpack, import the module directly in your test:

-const worker = require('workerize-loader!./worker.js');
+const worker = () => require('./worker.js');

const instance = worker();

With Webpack and Jest

In Jest, it's possible to define a custom transform that emulates workerize-loader on the main thread.

First, install babel-jest and identity-object-proxy:

npm i -D babel-jest identity-object-proxy

Then, add these properties to the "transform" and "moduleNameMapper" sections of your Jest config (generally located in your package.json):

{
  "jest": {
    "moduleNameMapper": {
      "workerize-loader(\\?.*)?!(.*)": "identity-obj-proxy"
    },
    "transform": {
      "workerize-loader(\\?.*)?!(.*)": "<rootDir>/workerize-jest.js",
      "^.+\\.[jt]sx?$": "babel-jest",
      "^.+\\.[jt]s?$": "babel-jest"
    }
  }
}

Finally, create the custom Jest transformer referenced above as a file workerize-jest.js in your project's root directory (where the package.json is):

module.exports = {
  process(src, filename) {
    return `
      async function asyncify() { return this.apply(null, arguments); }
      module.exports = function() {
        const w = require(${JSON.stringify(filename.replace(/^.+!/, ''))});
        const m = {};
        for (let i in w) m[i] = asyncify.bind(w[i]);
        return m;
      };
    `;
  }
};

Now your tests and any modules they import can use workerize-loader! prefixes, and the imports will be turned into async functions just like they are in Workerize.

Credit

The inner workings here are heavily inspired by worker-loader. It's worth a read!

License

MIT License © Jason Miller

workerize-loader's People

Contributors

danielbayerlein avatar danieldunderfelt avatar developit avatar dpraimeyuu avatar fnlctrl avatar greenkeeper[bot] avatar jaikme avatar kenrick95 avatar naoak avatar nulladdict avatar princemaple avatar qingwei-li avatar wellcaffeinated avatar yellott avatar

Stargazers

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

Watchers

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

workerize-loader's Issues

[Want to Help] Option to Allow Babel Parsing after `rpc-worker-loader.js`

Basically I want to use babel-loader to polyfill Promise or other ES6+ features via @babel/preset-env.

Looking at this line:

worker.compiler.apply(new SingleEntryPlugin(this.context, `!!${path.resolve(__dirname, 'rpc-worker-loader.js')}!${request}`, 'main'));

const subCache = `subcache ${__dirname} ${request}`;

I'd like to add the ability to pass babel options and plugin. Any idea on the best way to do this? 🙏 🙏 🙏 I'd like to add this functionality.

Trying to load from strange function SyntaxError: Unexpected token <

I'm really struggling with workers in a Create React App.

`import VoiceWorker from 'workerize-loader!./voice.worker.js'// eslint-disable-line import/no-webpack-loader-syntax
...

voiceWorker = VoiceWorker()
voiceWorker.start()

`
It's trying to find the worker here:
https://localhost:3000/course/function()%20%7Bvar%20w%20=%20new%20Worker(__webpack_require__.p%20+%20%22e9945ffae477ccb5331c.worker.js%22,%20%7B%20name:%20%22[hash].worker.js%22%20%7D)addMethods(w,%20methods)return%20w%7D

An in-range update of karmatic is breaking the build 🚨

The devDependency karmatic was updated from 1.2.0 to 1.3.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

karmatic is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for 1.3.0

🦟 Better Debugging

A new karmatic debug command wraps up a few important flags into one easy to remember debug mode. In this mode, coverage is not reported and Chrome is opened in "headful" mode for visual inspection. (#27, thanks @andrewiggins)

🙈 Coverage Reporting

Code coverage reports in HTML and JSON format are now generated by default in a coverage directory. You can also disable these by passing --no-coverage. (#26, thanks @andrewiggins)

🕸 Custom Browsers

karmatic watch --browsers firefox

🧭 Built-in support for SauceLabs

Set the SAUCE_USERNAME and SAUCE_ACCESS_KEY env vars, then pass saucelabs browser/platform combinations to the new --browsers option:

SAUCE_USERNAME=developit SAUCE_ACCESS_KEY=123456 karmatic --browsers sauce-ie-11,sauce-ie-10

🌶 Modern JS

karmatic now transpiles for modern browsers only (last 2 versions of Chrome + Firefox + Safari). Don't worry though - it'll still transpile down to ES5 if --browsers includes "ie" or "internet explorer", or if the --downlevel flag is set.

Commits

The new version differs by 20 commits.

  • 81f8cf3 1.3.0
  • 277f019 Merge pull request #28 from developit/wip
  • c802b6d Add --downlevel option to manually enable IE9+ compat
  • a656ed7 wip
  • a391c9b Merge pull request #27 from andrewiggins/debug-option
  • bf6f0b0 Merge branch 'master' into debug-option
  • 38b3e9e Merge pull request #25 from andrewiggins/update-deps
  • 056363c Merge branch 'master' into update-deps
  • 436182b Merge pull request #24 from ianwalter/master
  • 382cf9d Merge pull request #26 from andrewiggins/coverage
  • 23b8e57 Merge branch 'master' into master
  • 1b8d04f Merge branch 'master' into debug-option
  • fb8b7fb Merge branch 'master' into coverage
  • d2dbeeb Merge branch 'master' into update-deps
  • 4ae5ece add example repo

There are 20 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of serve is breaking the build 🚨

Version 6.4.6 of serve was just published.

Branch Build failing 🚨
Dependency serve
Current Version 6.4.5
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

serve is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes 6.4.6

Patches

Commits

The new version differs by 2 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of css-loader is breaking the build 🚨

Version 0.28.9 of css-loader was just published.

Branch Build failing 🚨
Dependency css-loader
Current Version 0.28.8
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

css-loader is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v0.28.9

2018-01-17

Bug Fixes

Commits

The new version differs by 3 commits.

  • 630579d chore(release): 0.28.9
  • 604bd4b chore(package): update dependencies
  • d1d8221 fix: ignore invalid URLs (url()) (#663)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of karmatic is breaking the build 🚨

Version 1.1.7 of karmatic was just published.

Branch Build failing 🚨
Dependency karmatic
Current Version 1.0.7
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

karmatic is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 2 commits.

  • 56374af 1.1.7
  • eb51eb3 Add support for Webpack 4 (in addition to 3 & prior)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of webpack is breaking the build 🚨

The devDependency webpack was updated from 4.32.2 to 4.33.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

webpack is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v4.33.0

Features

  • add target: "electron-preload" for electron 5
    • renderer should use target: "web" in electron 5

Bugfixes

  • fix HMR rejection of removed and readded self-accepted modules
Commits

The new version differs by 21 commits.

  • d45bec3 4.33.0
  • 96869d9 Merge pull request #9191 from webpack/dependabot/npm_and_yarn/chrome-trace-event-1.0.2
  • e90cf7c Merge pull request #9190 from webpack/dependabot/npm_and_yarn/terser-webpack-plugin-1.3.0
  • 96b97b5 Downstream bug fixed and we can remove workaround
  • 31dae4d update snapshots
  • faba6e4 Merge pull request #9209 from webpack/dependabot/npm_and_yarn/@types/node-10.14.8
  • f571d78 Merge pull request #9205 from webpack/dependabot/npm_and_yarn/typescript-3.5.1
  • f59f31d chore(deps-dev): bump @types/node from 10.14.7 to 10.14.8
  • 289c520 chore(deps-dev): bump typescript from 3.4.5 to 3.5.1
  • c408ff5 Merge pull request #9202 from webpack/bugfix/9198
  • 46b428b fix rejection when removing and readding self-accepted module
  • 671cb18 Merge pull request #9188 from kwonoj/electron-preload-target
  • 4345fc5 chore(deps): bump chrome-trace-event from 1.0.0 to 1.0.2
  • 8712474 chore(deps): bump terser-webpack-plugin from 1.2.4 to 1.3.0
  • 2ec75c1 feat(target): support electron preload async chunk loading

There are 21 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Support for commonjs exports.xxx?

Seems commonjs modules are not supported?

module.exports.xxx = function () {
   return 1
}

or

exports.xxx = () => {
   ...
}

Is there a reason for this?

[Question]: Suggestion on how to handle exception?

With async/await, I tried to return a new Error() but discovered that Workers use the Structured clone algorithm.

Obviously returning a plain object (as below) works with some code to check if the res has a .stack..

// worker.js
export async function expensive(time: number): Promise<number | Error> {
    try {
        const start = Date.now();
        let count: number = 0;
        while (Date.now() - start < time) {
            count++;
            if (count < 8561842) {
                throw new Error('OH NO');
            }
        }
        return count;
    } catch (error) {
        return {
            name: 'Exception in example.worker.ts',
            message: error.message,
            stack: error.stack
        };
    }
}

export default function exampleWorker() {
    return {
        expensive
    };
}
// app.ts
import ExampleWorker from './workers/example.worker';

const instance = ExampleWorker();

instance.expensive(1000)
    .then(res => {
        if (res['stack']) {
            const error: Error = res as Error;
            throw {
                message: error.message,
                stack: error.stack
            };
        }
        return res;
    })
    .then(res => {
        console.log(`Ran ${res} loops`);
    })
    .catch(error => {
        console.log(error);
    });

I was wondering if someone had another idea to pass the exception 🤔

is not a function

I just tried it with webpack-blocks, however I can't get it to run:

// worker.js
export function foo() { return 1; }

// index.js
import worker from 'workerize-loader!./worker'
const inst = worker()
inst.foo()

Uncaught TypeError: inst.foo is not a function

Is there something am I missing?

An in-range update of serve is breaking the build 🚨

Version 6.4.5 of serve was just published.

Branch Build failing 🚨
Dependency serve
Current Version 6.4.4
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

serve is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes 6.4.5

Patches

  • Removed triangle from company name: bccc217
  • Use different package for update notifications: c5444f2
  • Corrected date in license: aa20f77
  • Bumped dependencies to the latest version: 0872fcf
Commits

The new version differs by 5 commits.

  • d9afce3 6.4.5
  • 0872fcf Bumped dependencies to the latest version
  • aa20f77 Corrected date in license
  • c5444f2 Use different package for update notifications
  • bccc217 Removed triangle from company name

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Unit testing functions that use workerize'd imports

Has anyone come up with a way to write unit tests (e.g. jest, mocha) for functions that user workerize-loader imports? It'd be great if there was an easy way to replace the default workerize-loader behavior with a simple promise wrapper when in a testing environment. Any advice would be appreciated.

SharedWorker support

Hi,

Does the shared worker feature is planned ?
I also think that it could be nice for your Stockroom's state management system

enhance README to include ideal use case(s)

I came to workerize-loader for ease-of-use, but now I wonder about about pooling-type issues imposed by my present need for overlapping tasks.

So, I hope this is a helpful suggestion: Clarify use case in README, e.g., greenlet < workerize-loader < workerpool.

For example, does the following feature imply a 'natural' way to limit the number of workers?

     If exported module methods are already async, signature is unchanged

Support for async functions inside workers?

I get the following error

Uncaught (in promise) DOMException: Failed to execute 'postMessage' on 'DedicatedWorkerGlobalScope': Response object could not be cloned.

for

let instance = worker() 
instance.functionReturningAPromise().then(...)

due to the fact that Promises can't be cloned.

Fails when a depedency (module) requires a webpack "external" module

Awesome library! I've just found an edge case when workerizing a module that depends on a webpack external.

In my webpack config i have:

module.exports = {
  // ...
  externals: {
    'config': JSON.stringify(config),
  },
  // ...
}

and in my worker module I have:

import * as config from 'config';

I'm using typescript in case that matters.

Here's the compilation error from webpack:

Module not found: Error: Can't resolve 'config' in '/directory/src'
 @ ./src/MyWorker.ts 1:0-33

An in-range update of microbundle is breaking the build 🚨

Version 0.4.2 of microbundle was just published.

Branch Build failing 🚨
Dependency microbundle
Current Version 0.4.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

microbundle is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 7 commits.

  • 096b8ba 0.4.2
  • fa91a22 Add JSX test
  • b38b860 Fix Nodent usage of acorn-jsx. (thanks @songawee - see developit/karmatic#8)
  • a133de8 Show error stack traces
  • 004adc6 Merge pull request #59 from Andarist/snapshots
  • e8cb46f Merge branch 'master' into snapshots
  • c2627c7 Auto generate tests with snapshots

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint is breaking the build 🚨

The devDependency eslint was updated from 5.13.0 to 5.14.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v5.14.0
  • 85a04b3 Fix: adds conditional for separateRequires in one-var (fixes #10179) (#10980) (Scott Stern)
  • 0c02932 Upgrade: [email protected] (#11401) (Ilya Volodin)
  • 104ae88 Docs: Update governance doc with reviewers status (#11399) (Nicholas C. Zakas)
  • ab8ac6a Fix: Support boundary spread elements in sort-keys (#11158) (Jakub Rożek)
  • a23d197 New: add allowSingleLineBlocks opt. to padded-blocks rule (fixes #7145) (#11243) (richie3366)
  • e25e7aa Fix: comma-spacing ignore comma before closing paren (fixes #11295) (#11374) (Pig Fang)
  • a1f7c44 Docs: fix space-before-blocks correct code for "classes": "never" (#11391) (PoziWorld)
  • 14f58a2 Docs: fix grammar in object-curly-spacing docs (#11389) (PoziWorld)
  • d3e9a27 Docs: fix grammar in “those who says” (#11390) (PoziWorld)
  • ea8e804 Docs: Add note about support for object spread (fixes #11136) (#11395) (Steven Thomas)
  • 95aa3fd Docs: Update README team and sponsors (ESLint Jenkins)
  • 51c4972 Update: Behavior of --init (fixes #11105) (#11332) (Nicholas C. Zakas)
  • ad7a380 Docs: Update README team and sponsors (ESLint Jenkins)
  • 550de1e Update: use default keyword in JSON schema (fixes #9929) (#11288) (Pig Fang)
  • 983c520 Update: Use 'readonly' and 'writable' for globals (fixes #11359) (#11384) (Nicholas C. Zakas)
  • f1d3a7e Upgrade: some deps (fixes #11372) (#11373) (薛定谔的猫)
  • 3e0c417 Docs: Fix grammar in “there’s nothing prevent you” (#11385) (PoziWorld)
  • de988bc Docs: Fix grammar: Spacing improve -> Spacing improves (#11386) (PoziWorld)
  • 1309dfd Revert "Build: fix test failure on Node 11 (#11100)" (#11375) (薛定谔的猫)
  • 1e56897 Docs: “the function actually use”: use -> uses (#11380) (PoziWorld)
  • 5a71bc9 Docs: Update README team and sponsors (ESLint Jenkins)
  • 82a58ce Docs: Update README team and sponsors (ESLint Jenkins)
  • 546d355 Docs: Update README with latest sponsors/team data (#11378) (Nicholas C. Zakas)
  • c0df9fe Docs: ... is not an operator (#11232) (Felix Kling)
  • 7ecfdef Docs: update typescript parser (refs #11368) (#11369) (薛定谔的猫)
  • 3c90dd7 Update: remove prefer-spread autofix (fixes #11330) (#11365) (薛定谔的猫)
  • 5eb3121 Update: add fixer for prefer-destructuring (fixes #11151) (#11301) (golopot)
  • 173eb38 Docs: Clarify ecmaVersion doesn't imply globals (refs #9812) (#11364) (Keith Maxwell)
  • 84ce72f Fix: Remove extraneous linefeeds in one-var fixer (fixes #10741) (#10955) (st-sloth)
  • 389362a Docs: clarify motivation for no-prototype-builtins (#11356) (Teddy Katz)
  • 533d240 Update: no-shadow-restricted-names lets unassigned vars shadow undefined (#11341) (Teddy Katz)
  • d0e823a Update: Make --init run js config files through linter (fixes #9947) (#11337) (Brian Kurek)
  • 92fc2f4 Fix: CircularJSON dependency warning (fixes #11052) (#11314) (Terry)
  • 4dd19a3 Docs: mention 'prefer-spread' in docs of 'no-useless-call' (#11348) (Klaus Meinhardt)
  • 4fd83d5 Docs: fix a misleading example in one-var (#11350) (薛定谔的猫)
  • 9441ce7 Chore: update incorrect tests to fix build failing (#11354) (薛定谔的猫)
Commits

The new version differs by 38 commits.

  • af9688b 5.14.0
  • 0ce3ac7 Build: changelog update for 5.14.0
  • 85a04b3 Fix: adds conditional for separateRequires in one-var (fixes #10179) (#10980)
  • 0c02932 Upgrade: [email protected] (#11401)
  • 104ae88 Docs: Update governance doc with reviewers status (#11399)
  • ab8ac6a Fix: Support boundary spread elements in sort-keys (#11158)
  • a23d197 New: add allowSingleLineBlocks opt. to padded-blocks rule (fixes #7145) (#11243)
  • e25e7aa Fix: comma-spacing ignore comma before closing paren (fixes #11295) (#11374)
  • a1f7c44 Docs: fix space-before-blocks correct code for "classes": "never" (#11391)
  • 14f58a2 Docs: fix grammar in object-curly-spacing docs (#11389)
  • d3e9a27 Docs: fix grammar in “those who says” (#11390)
  • ea8e804 Docs: Add note about support for object spread (fixes #11136) (#11395)
  • 95aa3fd Docs: Update README team and sponsors
  • 51c4972 Update: Behavior of --init (fixes #11105) (#11332)
  • ad7a380 Docs: Update README team and sponsors

There are 38 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Integration with Create React App

I need to setup a worker in CRA. I have ejected CRA, so I can add the loader via Webpack configs.

However, I am not sure I am doing this correctly. I have been using the test/webpack.config.js as a helper. The only thing I noticed that was different, was the resolveLoader section in the webpack config. Have I missed something else?

Current config:

module.exports = {
  ...
  resolveLoader: {
    alias: {
      'workerize-loader': path.resolve(__dirname, 'workerize-loader')
    }
  },
  ...
};

Typescript Cannot find name '__webpack_public_path__'

component.tsx

import * as DiffWorker from "../../workers/Diff.worker";

Diff.worker.ts

import * as DiffMatchPatch from "diff-match-patch";
const Changeset = require("changesets").Changeset;

const dmp = new DiffMatchPatch();

export function diffCalc(a, b) {
  console.log("a", typeof a, "b", typeof b);
  const diff = dmp.diff_main(a, b);
  // @ts-ignore
  const changeSetPack = Changeset.fromDiff(diff).pack();
  return changeSetPack;
}

tsconfig.json

  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "allowJs": true,
    "forceConsistentCasingInFileNames": true,
    "lib": [
      "esnext",
      "webworker",
      "dom"
    ],
    "module": "commonjs",
    "target": "es5",
    "moduleResolution": "node",
    "outDir": "build",
    "rootDir": "/",
    "sourceMap": true,
    "strictNullChecks": false,
    "noImplicitReturns": false,
    "noImplicitThis": false,
    "noImplicitAny": false,
    "jsx": "react",
    "suppressImplicitAnyIndexErrors": false
  },
  "exclude": [
    "node_modules",
    "build"
  ],
}

webpack.config

      {
        test: /\.(ts|tsx)$/,
        use: ['awesome-typescript-loader'],
        exclude: path.resolve(__dirname, 'node_modules'),
      },
      {
        test: /\.worker\.ts$/,
        use: ['workerize-loader'],
        exclude: path.resolve(__dirname, 'node_modules'),
      }

output error

 「atl」: Checking finished with 1 errors
[at-loader] ./src/client/workers/Diff.worker.ts:5:25
    TS2304: Cannot find name '__webpack_public_path__'.

SOLUTIONS
this help me

How to handle blob data?

I don't cant find solution to handle blob file data sended to worker. Its possible?

My object sended to worker:

{
id: 'jnakjnkjnkdjnkd',
item: {},
blob: Blob
}

Blob have no file content in worker, just type and size.
Thanks! :)

ReferenceError: regeneratorRuntime is not defined

I'm trying to use this library with Babel and TypeScript, but I'm getting a weird error.

// queue.worker.ts

import { TrackData } from "modules/track/types"
import { shuffleArray } from "common/lang/array/helpers/shuffleArray"

export async function getShuffledTracks(tracks: TrackData[], active: number) {
  return shuffleArray(tracks).sort((track) => (track.id === active ? -1 : 0))
}
// somewhere.ts

import * as QueueWorker from "../queue.worker"
const worker = (QueueWorker as any)() as typeof QueueWorker

//  somewhere in the file
await worker.getShuffledTracks(...)

Then, when the function is called, I get this error:
image

This is what the config for the loader looks like:

const workerRule = {
  test: /\.worker\.ts$/,
  use: [
    "workerize-loader",
    {
      loader: "babel-loader",
      options: {
        presets: [
          [
            "@babel/env",
            {
              modules: false,
            },
          ],
        ],
      },
    },
  ],
}

Can't use arrow function

When I use

export const func=()=>{}

in worker.js,workerlize-loader won't add it to worker instance
but

export function func(){}

is ok

Support for export specifiers?

It appears like workerize-loader only supports moving export declarations in the target module into a worker. I'm attempting to use it with Bucklescript, which compiles modules down to an export specifier list, i.e. export { foo, bar, } instead of export declarations.

I took a pass at implementing this and couldn't get around Webpack declaring its own parser plugin and bailing on export specifier, I think for tree-shaking purposes. I don't have much experience with Webpack plugins though and it seems like there should be a way to get this to work. Are there any alternate approaches you can suggest, or maybe workarounds?

One other thought I had for my purposes would be to instead compile to commonjs and tweak workerize so that it would accept the pre-compiled source instead of doing the current find-and-replace compilation step.

Enable tree-shaking

I have used workerize-loader for a small web worker implementation and it worked great! I ran into trouble once i started importing helper utility functions which ended up bundling almost the entire project.

I want to add tree shaking ability in order to:
1- Reduce bundle size
2- Prevent importing unused code which may contain code window.location.. etc.

Can you point me towards a direction so i can make a PR?

Thanks

An in-range update of serve is breaking the build 🚨

Version 6.4.9 of serve was just published.

Branch Build failing 🚨
Dependency serve
Current Version 6.4.8
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

serve is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes 6.4.9

Patches

  • Scope to working directory correctly: #316
Commits

The new version differs by 2 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Typescript types?

Its a bit difficult to write a definition file... any ideas how to handle that?

Would be easier if the export was the factory function that returns the exported functions:

export default function worker() {
    function expensive(time) {
        let start = Date.now(), count = 0
        while (Date.now() - start < time) count++
        return count
    }
    return {expensive}
}

then the types would be identical if the functions return promises.

An in-range update of webpack-dev-server is breaking the build 🚨

Version 2.11.0 of webpack-dev-server was just published.

Branch Build failing 🚨
Dependency webpack-dev-server
Current Version 2.10.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

webpack-dev-server is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v2.11.0

Version 2.11.0 adds the transpilation of the client scripts via babel to ES5 which restores backwards compatibility (that was removed in 2.8.0) to very old or out of date browsers.

Commits

The new version differs by 5 commits.

  • 8c1ed7a 2.11.0
  • b0fa5f6 Merge pull request #1270 from yyx990803/client-refactor
  • 676d590 revert to prepublish (fix ci)
  • 449494f cleanup client build setup
  • 6689cb8 adding test for dependency lock-down

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of webpack is breaking the build 🚨

The devDependency webpack was updated from 4.23.0 to 4.23.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

webpack is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v4.23.1

Bugfixes

  • add space when replacing expression with constant
    • i. e. for code like return'development'===process.env.NODE_ENV&&'foo'
Commits

The new version differs by 3 commits.

  • 607cf70 4.23.1
  • 5e5e7b7 Merge pull request #8270 from ljqx/logical-expression-fix
  • 13d1dab [ConstPlugin] fix bug introduced by evaluation of && and ||

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of microbundle is breaking the build 🚨

Version 0.4.5 of microbundle was just published.

Branch Build failing 🚨
Dependency microbundle
Current Version 0.4.4
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

microbundle is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 63 commits.

  • 6a95870 0.4.5
  • 41e0dc3 Fix mangle.json name caching (seemed to break in a recent rollup update)
  • 42050bb Fix Rollup upgrade adding __esModule properties to exports.
  • 0a6a791 Merge pull request #161 from philipp-spiess/patch-1
  • 1ffccee Add react-recomponent to "Built with Microbundle"
  • bf2d068 Updated rollup to 0.60.1, made code changes to support it (#151)
  • 8286def Merge pull request #153 from mattdesl/fix/111
  • fcbfa8f Merge pull request #149 from developit/greenkeeper/pretty-bytes-5.1.0
  • d786f03 fix #111 and log errors during watch
  • 8393af2 fix(package): update pretty-bytes to version 5.1.0
  • 818a7d5 Revert "Update rollup to the latest version 🚀" (#148)
  • c7fbe3e Merge pull request #145 from developit/greenkeeper/rollup-0.60.0
  • 9d77676 fix(package): update rollup to version 0.60.0
  • 4d5ff56 Turn off eslint rules inconsistent with prettier settings and run prettier through eslint (#136)
  • 3afc4f4 Merge pull request #140 from developit/greenkeeper/rollup-0.59.3

There are 63 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint is breaking the build 🚨

Version 4.16.0 of eslint was just published.

Branch Build failing 🚨
Dependency eslint
Current Version 4.15.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v4.16.0
  • e26a25f Update: allow continue instead of if wrap in guard-for-in (fixes #7567) (#9796) (Michael Ficarra)
  • af043eb Update: Add NewExpression support to comma-style (#9591) (Frazer McLean)
  • 4f898c7 Build: Fix JSDoc syntax errors (#9813) (Matija Marohnić)
  • 13bcf3c Fix: Removing curly quotes in no-eq-null report message (#9852) (Kevin Partington)
  • b96fb31 Docs: configuration hierarchy for CLIEngine options (fixes #9526) (#9855) (PiIsFour)
  • 8ccbdda Docs: Clarify that -c configs merge with .eslintrc.* (fixes #9535) (#9847) (Kevin Partington)
  • 978574f Docs: Fix examples for no-useless-escape (#9853) (Toru Kobayashi)
  • cd5681d Chore: Deactivate consistent-docs-url in internal rules folder (#9815) (Kevin Partington)
  • 2e87ddd Docs: Sync messageId examples' style with other examples (#9816) (Kevin Partington)
  • 1d61930 Update: use doctrine range information in valid-jsdoc (#9831) (Teddy Katz)
  • 133336e Update: fix indent behavior on template literal arguments (fixes #9061) (#9820) (Teddy Katz)
  • ea1b15d Fix: avoid crashing on malformed configuration comments (fixes #9373) (#9819) (Teddy Katz)
  • add1e70 Update: fix indent bug on comments in ternary expressions (fixes #9729) (#9818) (Teddy Katz)
  • 6a5cd32 Fix: prefer-destructuring error with computed properties (fixes #9784) (#9817) (Teddy Katz)
  • 601f851 Docs: Minor modification to code comments for clarity (#9821) (rgovind92)
  • b9da067 Docs: fix misleading info about RuleTester column numbers (#9830) (Teddy Katz)
  • 2cf4522 Update: Rename and deprecate object-property-newline option (#9570) (Jonathan Pool)
  • acde640 Docs: Add ES 2018 to Configuring ESLint (#9829) (Kai Cataldo)
  • ccfce15 Docs: Minor tweaks to working with rules page (#9824) (Kevin Partington)
  • 54b329a Docs: fix substitution of {{ name }} (#9822) (Andres Kalle)
Commits

The new version differs by 22 commits.

  • 33ca1ea 4.16.0
  • 1a9ddee Build: changelog update for 4.16.0
  • e26a25f Update: allow continue instead of if wrap in guard-for-in (fixes #7567) (#9796)
  • af043eb Update: Add NewExpression support to comma-style (#9591)
  • 4f898c7 Build: Fix JSDoc syntax errors (#9813)
  • 13bcf3c Fix: Removing curly quotes in no-eq-null report message (#9852)
  • b96fb31 Docs: configuration hierarchy for CLIEngine options (fixes #9526) (#9855)
  • 8ccbdda Docs: Clarify that -c configs merge with .eslintrc.* (fixes #9535) (#9847)
  • 978574f Docs: Fix examples for no-useless-escape (#9853)
  • cd5681d Chore: Deactivate consistent-docs-url in internal rules folder (#9815)
  • 2e87ddd Docs: Sync messageId examples' style with other examples (#9816)
  • 1d61930 Update: use doctrine range information in valid-jsdoc (#9831)
  • 133336e Update: fix indent behavior on template literal arguments (fixes #9061) (#9820)
  • ea1b15d Fix: avoid crashing on malformed configuration comments (fixes #9373) (#9819)
  • add1e70 Update: fix indent bug on comments in ternary expressions (fixes #9729) (#9818)

There are 22 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Getting workerize-loader to work with nuxt

I'm at the end of a nuxt project and want to move some code into a web worker. I've tried to use worker-loader, but failed and was suggested (by @pi0) to give workerize-loader a shot.

Unfortunately, I'm blocked on an nuxt error. Below is the stack trace and after that, the code snippets from the stack trace I've dug up. code in the toCjs function appears to be undefined.

Nuxt error

  TypeError: e.replace is not a function

  - workerize.js:39
    [webviewer4]/[workerize]/dist/workerize.js:39:23

  - workerize.js:44 ModuleContainer.module.exports
    [webviewer4]/[workerize]/dist/workerize.js:44:4

  - module.js:162 Promise
    [webviewer4]/[nuxt]/lib/core/module.js:162:30

  - new Promise

  - module.js:146 ModuleContainer.addModule
    [webviewer4]/[nuxt]/lib/core/module.js:146:12

  - utils.js:96 promise.then
    [webviewer4]/[nuxt]/lib/common/utils.js:96:43


  - next_tick.js:188 process._tickCallback
    internal/process/next_tick.js:188:7

  - module.js:686 Function.Module.runMain
    module.js:686:11

  - bootstrap_node.js:187 startup
    bootstrap_node.js:187:16

  - bootstrap_node.js:608
    bootstrap_node.js:608:3

I've tracked e.replace to ([workerize]/dist/workerize.js:39:23):

function toCjs(code, exportsObjName, exports) {
	code = code.replace(/^(\s*)export\s+default\s+/m, (s, before) => {
		exports.default = true;
		return `${before}${exportsObjName}.default=`;
	});
	code = code.replace(/^(\s*)export\s+((?:async\s*)?function(?:\s*\*)?|const|let|var)(\s+)([a-zA-Z$_][a-zA-Z0-9$_]*)/mg, (s, before, type, ws, name) => {
		exports[name] = true;
		return `${before}${exportsObjName}.${name}=${type}${ws}${name}`;
	});
	return `var ${exportsObjName}={};\n${code}\n${exportsObjName};`;
}

Which is called by ([nuxt]/lib/core/module.js:162:30):

// Call module with `this` context and pass options
const result = handler.call(this, options, cb)

What is in options, you ask? - an empty object. Do I need to setup something in my webpack configuration?

I've copied the example from this README

assets/js/shared/Loader.worker.js

export function expensive(time) {
  let start = Date.now(),
  ...
}

store/pages.js

import Worker from 'workerize-loader!~/assets/js/shared/Loader.worker.js'

const worker = new Worker
worker.expensive(1000).then(count => {
  console.log(`Ran ${count} loops`)
})

my nuxt.config.js, which setup webpack

module.exports = {
  modules: [
    '@nuxtjs/dotenv',
    '@nuxtjs/font-awesome',
    'traits.js',
    'workerize'
  ],
  build: {
    /*
    ** Run ESLint on save
    */
    extend (config, { isDev, isClient }) {
      if (isDev && isClient) {
        config.module.rules.push({
          enforce: 'pre',
          test: /\.(js|vue)$/,
          loader: 'eslint-loader',
          exclude: /(node_modules)/
        })
      }
      // NOT WORKING! Web Worker support
      config.module.rules.push({
        test: /\.worker\.js$/,
        use: { loader: 'workerize-loader' },
        exclude: /(node_modules)/
      })
    }
  }
}

Trouble loading WASM modules in worker (with possible solution)

I believe this loader suffers from the same issue as worker-loader
webpack/webpack#7647

When using a wasm-pack compiled module i get the error message:

TypeError: Cannot read property '.wasm' of undefined

referring to __webpack_require__.w

That worker-loader issue also has a pull request referencing it which does fix my problem... but I'd love to use workerize if possible.

Any chance of getting this fix into workerize-loader pretty please? :)

_compilation property deprecated and undefined in latest webpack ?

Hi,
with [email protected], I'm unable to get this loader working. It throws an error at build time!
I can see _compilation in the deprecated properties in the loader API https://webpack.js.org/api/loaders/#deprecated-context-properties
Maybe it has been removed completely in the latest webpack versions ??

Cannot read property 'createChildCompiler' of undefined
    at Object.loader.pitch (/node_modules/workerize-loader/dist/index.js:28:41)

Here's what gives when I console.log(this._compilation)

{ version: 2,
  resolve: [Function: resolve],
  emitWarning: [Function: emitWarning],
  emitError: [Function: emitError],
  exec: [Function: exec],
  options:
   { context: '' },
  webpack: true,
  'thread-loader': true,
  sourceMap: true,
  context: '/src/core/shared/timer',
  loaderIndex: 1,
  loaders:
   [ { path: '/node_modules/babel-loader/lib/index.js',
       query: '',
       options: undefined,
       ident: undefined,
       normal: [Function],
       pitch: undefined,
       raw: undefined,
       data: null,
       pitchExecuted: true,
       normalExecuted: false,
       request: [Getter/Setter] },
     { path: '/node_modules/worker-loader/dist/cjs.js',
       query: '',
       options: undefined,
       ident: undefined,
       normal: [Function],
       pitch: [Function: pitch],
       raw: undefined,
       data: {},
       pitchExecuted: true,
       normalExecuted: false,
       request: [Getter/Setter] },
     { path: '/node_modules/eslint-loader/index.js',
       query: '??ref--13-0',
       options: [Object],
       ident: 'ref--13-0',
       normal: null,
       pitch: null,
       raw: null,
       data: null,
       pitchExecuted: false,
       normalExecuted: false,
       request: [Getter/Setter] } ],
  resourcePath: '/src/core/shared/timer/refresh.worker.js',
  resourceQuery: '',
  async: [Function: async],
  callback: [Function],
  cacheable: [Function: cacheable],
  addDependency: [Function: addDependency],
  dependency: [Function: addDependency],
  addContextDependency: [Function: addContextDependency],
  getDependencies: [Function: getDependencies],
  getContextDependencies: [Function: getContextDependencies],
  clearDependencies: [Function: clearDependencies],
  resource: [Getter/Setter],
  request: [Getter],
  remainingRequest: [Getter],
  currentRequest: [Getter],
  previousRequest: [Getter],
  query: [Getter],
  data: [Getter] }
{ version: 2,
  resolve: [Function: resolve],
  emitWarning: [Function: emitWarning],
  emitError: [Function: emitError],
  exec: [Function: exec],
  options:
   { context: '' },
  webpack: true,
  'thread-loader': true,
  sourceMap: true,
  context: '/src/location',
  loaderIndex: 1,
  loaders:
   [ { path: '/node_modules/babel-loader/lib/index.js',
       query: '',
       options: undefined,
       ident: undefined,
       normal: [Function],
       pitch: undefined,
       raw: undefined,
       data: null,
       pitchExecuted: true,
       normalExecuted: false,
       request: [Getter/Setter] },
     { path: '/node_modules/worker-loader/dist/cjs.js',
       query: '',
       options: undefined,
       ident: undefined,
       normal: [Function],
       pitch: [Function: pitch],
       raw: undefined,
       data: {},
       pitchExecuted: true,
       normalExecuted: false,
       request: [Getter/Setter] },
     { path: '/node_modules/eslint-loader/index.js',
       query: '??ref--13-0',
       options: [Object],
       ident: 'ref--13-0',
       normal: null,
       pitch: null,
       raw: null,
       data: null,
       pitchExecuted: false,
       normalExecuted: false,
       request: [Getter/Setter] } ],
  resourcePath: '/src/location/conflict-detector.worker.js',
  resourceQuery: '',
  async: [Function: async],
  callback: [Function],
  cacheable: [Function: cacheable],
  addDependency: [Function: addDependency],
  dependency: [Function: addDependency],
  addContextDependency: [Function: addContextDependency],
  getDependencies: [Function: getDependencies],
  getContextDependencies: [Function: getContextDependencies],
  clearDependencies: [Function: clearDependencies],
  resource: [Getter/Setter],
  request: [Getter],
  remainingRequest: [Getter],
  currentRequest: [Getter],
  previousRequest: [Getter],
  query: [Getter],
  data: [Getter] }

Hope to hear from you guys!
Thanks for this awesome package!

An in-range update of microbundle is breaking the build 🚨

Version 0.3.1 of microbundle was just published.

Branch Build failing 🚨
Dependency microbundle
Current Version 0.3.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

microbundle is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes 0.3.1
  • Detect when default & named exports are used in duplicate (eg: preact) and only export a single object.
Commits

The new version differs by 3 commits.

  • 932acd6 0.3.1
  • d10fb70 second demo
  • 8960114 If defaults + named exports are detected, only export default and prune named. Enable pure properties for tree-shaking (since they're already enabled for uglify)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Empty Worker returned after hot-reloading

For some reason, no methods are being exposed.

After I run webpack, and then make changes to a file imported into Worker.js, the Worker file returns an empty Worker with no methods. I think hot-reloading chunks doesn't play well with this loader. Restarting Yarn and refreshing the browser seems to fix the issue.

Worker.js
import someCostlyFunction from './here'

export function labelGeofences (data) {
    return someCostlyFunction(data)
}
App.js
import Worker from 'workerize-loader?inline=true!./worker'
const worker = new Worker()
console.log(worker)
// => Worker {onmessage: null, onerror: null}
worker.labelGeofences(...)
// => Error, no such property

Handling callbacks from worker to main thread

I like this approach, it makes handling tasks for webworkers really easy! However I'm missing one thing - How can I handle callbacks from the worker thread back to the main thread? This is necessary for example when the worker wants to provide some progress info to the main thread.

Any opinions on this? I could imagine a somehow "reverse" setup, where the webworker can access functions of the main thread in a similar way like the main thread calls functions of the webworker.

An in-range update of webpack-dev-server is breaking the build 🚨

Version 2.11.1 of webpack-dev-server was just published.

Branch Build failing 🚨
Dependency webpack-dev-server
Current Version 2.11.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

webpack-dev-server is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v2.11.1

Our third attempt to fix compatibility with old browsers (#1273), this time we'll get it right.

Commits

The new version differs by 3 commits.

  • 83c1625 2.11.1
  • 3aa15aa Merge pull request #1273 from yyx990803/master
  • b78e249 fix: pin strip-ansi to 3.x for ES5 compat

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Transferable support

Hi!
Do you think you could include a way to pass Transferable objects correctly?
It would be great to be able to return a MessagePort so that the function can return a stream instead of a single value.

DeprecationWarning: Tapable.apply is deprecated.

On my Webpack 4 build, I'm getting this warning:

DeprecationWarning: Tapable.apply is deprecated. Call apply on the plugin directly instead

If I run my Webpack build like:

node --trace-deprecation ./node_modules/.bin/webpack-dev-server

I can see that this warning is coming from workerize-loader:

(node:31068) DeprecationWarning: Tapable.apply is deprecated. Call apply on the plugin directly instead
    at Object.loader.pitch (/Users/me/my-app/node_modules/workerize-loader/dist/index.js:29:21)
    at LOADER_EXECUTION (/Users/me/my-app/node_modules/loader-runner/lib/LoaderRunner.js:119:14)
    at runSyncOrAsync (/Users/me/my-app/node_modules/loader-runner/lib/LoaderRunner.js:120:4)
    at /Users/me/my-app/node_modules/loader-runner/lib/LoaderRunner.js:175:3
    at loadLoader (/Users/me/my-app/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/Users/me/my-app/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at runLoaders (/Users/me/my-app/node_modules/loader-runner/lib/LoaderRunner.js:362:2)
    at NormalModule.doBuild (/Users/me/my-app/node_modules/webpack/lib/NormalModule.js:219:3)
    at NormalModule.build (/Users/me/my-app/node_modules/webpack/lib/NormalModule.js:337:15)
    at Compilation.buildModule (/Users/me/my-app/node_modules/webpack/lib/Compilation.js:346:10)
(node:31068) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
    at Object.loader.pitch (/Users/me/my-app/node_modules/workerize-loader/dist/index.js:35:21)
    at LOADER_EXECUTION (/Users/me/my-app/node_modules/loader-runner/lib/LoaderRunner.js:119:14)
    at runSyncOrAsync (/Users/me/my-app/node_modules/loader-runner/lib/LoaderRunner.js:120:4)
    at /Users/me/my-app/node_modules/loader-runner/lib/LoaderRunner.js:175:3
    at loadLoader (/Users/me/my-app/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/Users/me/my-app/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at runLoaders (/Users/me/my-app/node_modules/loader-runner/lib/LoaderRunner.js:362:2)
    at NormalModule.doBuild (/Users/me/my-app/node_modules/webpack/lib/NormalModule.js:219:3)
    at NormalModule.build (/Users/me/my-app/node_modules/webpack/lib/NormalModule.js:337:15)
    at Compilation.buildModule (/Users/me/my-app/node_modules/webpack/lib/Compilation.js:346:10)

An in-range update of loader-utils is breaking the build 🚨

The dependency loader-utils was updated from 1.1.0 to 1.2.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

loader-utils is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v1.2.0

1.2.0 (2018-12-24)

Features

  • interpolateName: support [contenthash]

Fixes

  • urlToRequest: empty urls are not rewritten to relative requests
  • urlToRequest: don't rewrite absolute urls
  • isUrlRequest: ignore all url with extension (like moz-extension:, ms-browser-extension: and etc)
  • isUrlRequest: ignore about:blank
  • interpolateName: failing explicitly when ran out of emoji
  • interpolateName: [hash] token regex in interpolate string to capture any hash algorithm name
  • interpolateName: parse string for emoji count before use
Commits

The new version differs by 36 commits.

  • ba4f0d0 chore(release): 1.2.0 (#131)
  • c5c7322 test: more (#132)
  • c17d9cd refactor: migrate on jest (#130)
  • 3a854ba style: integrate prettier
  • 0f2b227 chore(deps): update
  • 914c09f chore(deps): update
  • db92b11 chore(deps): update dev dependencies
  • ad3a6b2 chore(deps): update dev dependencies
  • 3b6b8ff feat: support [contenthash]
  • 6982934 feat: support [contenthash]
  • 6fb379f ci: test on windows
  • 7485ded ci: test on windows
  • ad3c359 fix(isUrlRequest): ignore about:blank
  • ac05880 fix(isUrlRequest): ignore about:blank
  • 47e2e02 fix: ignore all nonstandard extension protocols

There are 36 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Error: Failed to execute 'postMessage' on 'DedicatedWorkerGlobalScope': #<Promise> could not be cloned

I query a large Firebase collection in my app.
I'd like to offload data traversing to a Web Worker. The .map callback in the code below is the function that blocks the main thread, so I moved it to a Web Worker.

// worker.js
import { db } from '../client';

// eslint-disable-next-line
export const getCollection = async (collection) => {
  const ref = await db.collection(collection).get();

  return ref.docs.map((doc) => {
    const data = doc.data(); // When I remove this line the error is gone

    return Object.defineProperty(data, 'id', {
      value: doc.id,
      enumerable: false,
      writable: false,
    });
  });
};

When I run the worker as follows:

// app.js
import Worker from 'workerize-loader!./worker';

const worker = new Worker();
worker.getCollection('collection'); // Causes an error

The worker.getCollection('collection') call causes:

Error: Failed to execute 'postMessage' on 'DedicatedWorkerGlobalScope': #<Promise> could not be cloned

I found that the problem is somehow related to the doc.data() call. If I comment out that line, the error is gone. The same code, when it's not ran as a WebWorker thread, works fine.

Is it a bug in workerize or is it me doing something wrong?

Webpack runs out of heap memory, only when using workerize-loader

Hi,

Wonder if you might know what might be causing this this error.
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

When I take away workerize-loader, the bundle compiles and Node/Webpack does not run out of memory.

Using Workerize-Loader 2.0.0
and Webpack 4.27.1 (via Webpacker Rails)

My worker is pretty simple..

import parseLine from './parse_line';


export function runParseLine(linesStr, varTable) {

  const lines = linesStr.split(/\n/);

  const value = lines.map((lineText, lineNum) => {
    return {
      lineNum,
      lineText: parseLine(lineText, varTable),
    };
  });

  return value;
}

and I'm importing it like this:

import ParseLineWorker from 'workerize-loader!../utils/parser/parse_line_worker';
const parseLineWorker = new ParseLineWorker();

If I comment out workerize-loader! in the import and change the worker to export default, it compiles ok.

When running ./bin/webpack --progress, it get stuck on the parse_line_worker.js file...

69% building 1702/1704 modules 2 active ...d/lib/utils/parser/parse_line_worker.js

until it eventually runs out of memory and fails.

Been Googling this to death for the last three days. Would appreciate any suggestions...

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.