0.18.1 • Published 1 year ago

@chialab/esbuild-plugin-worker v0.18.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

How it works

Esbuild Plugin Worker looks for new Worker('./path/to/worker.js') statements in JavaScript and TypeScript files and instructs esbuild to treat that references as entrypoints. Final output will be used to correctly update the statement.

For example, the following script:

const worker = new Worker('./path/to/worker.js');

will be transformed to:

const worker = new Worker(new URL('./path/to/worker.js', import.meta.url));

and then resolved by the @chialab/esbuild-plugin-meta-url plugin.

Please note that RNA does not generate a Worker class to instantiate like webpack does, but it will just correctly update the import reference. If you need a Worker class, you have to wrap it yourself:

const workerClass = function() {
    return new Worker('./path/to/worker.js');
};

⚠️ At the moment this plugin does not collect importScript() statements and does treat workers as modules, but we have plan to support the { type: "module" } option in the near future.


Install

$ npm i @chialab/esbuild-plugin-worker -D
$ yarn add @chialab/esbuild-plugin-worker -D

Usage

import esbuild from 'esbuild';
import transfrom from '@chialab/esbuild-plugin-transform';
import workerPlugin from '@chialab/esbuild-plugin-worker';
import metaUrlPlugin from '@chialab/esbuild-plugin-meta-url';

await esbuild.build({
    plugins: [
        transfrom([
            workerPlugin(),
            metaUrlPlugin(),
        ]),
    ],
});

You can also define a list of Worker constructors to use (default it will look for Worker and SharedWorker):

workerPlugin({ constructors: ['Worker', 'MyWorker'] });

License

Esbuild Plugin Worker is released under the MIT license.

0.19.0-beta.0

1 year ago

0.18.1

1 year ago

0.18.0

1 year ago

0.18.0-alpha.1

2 years ago

0.17.5

2 years ago

0.18.0-alpha.0

2 years ago

0.17.4

2 years ago

0.17.3

3 years ago

0.17.2

3 years ago

0.17.0

3 years ago

0.17.1

3 years ago

0.15.39

3 years ago

0.15.37

3 years ago

0.15.38

3 years ago

0.16.0

3 years ago

0.16.1

3 years ago

0.16.2

3 years ago

0.15.20

3 years ago

0.15.23

3 years ago

0.15.28

3 years ago

0.15.17

3 years ago

0.15.6

3 years ago

0.15.9

3 years ago

0.15.14

3 years ago

0.15.15

3 years ago

0.15.16

3 years ago

0.15.4

3 years ago

0.15.0

3 years ago

0.15.2

3 years ago

0.15.3

3 years ago

0.14.11

3 years ago

0.14.10

3 years ago

0.14.17

3 years ago

0.14.15

3 years ago

0.14.19

3 years ago

0.13.13

4 years ago

0.15.0-alpha.1

3 years ago

0.14.0

4 years ago

0.14.1

4 years ago

0.14.2

4 years ago

0.14.3

4 years ago

0.14.4

4 years ago

0.13.8

4 years ago

0.12.39

4 years ago

0.13.0

4 years ago

0.13.2

4 years ago

0.13.11

4 years ago

0.12.34

4 years ago

0.12.31

4 years ago

0.12.11

4 years ago

0.12.19

4 years ago

0.12.12

4 years ago

0.12.15

4 years ago

0.12.22

4 years ago

0.12.24

4 years ago

0.12.26

4 years ago

0.12.7

4 years ago

0.12.9

4 years ago

0.12.2

4 years ago

0.12.3

4 years ago

0.12.0

4 years ago

0.11.39

4 years ago

0.11.38

4 years ago

0.11.37

4 years ago

0.11.35

4 years ago

0.11.36

4 years ago

0.11.34

4 years ago

0.11.32

4 years ago

0.11.26

4 years ago

0.11.28

4 years ago

0.11.29

4 years ago

0.11.25

4 years ago

0.11.19

4 years ago

0.11.8

4 years ago

0.11.9

4 years ago

0.11.10

4 years ago

0.11.11

4 years ago

0.11.13

4 years ago

0.11.5

4 years ago

0.11.4

4 years ago

0.11.2

4 years ago

0.11.0

4 years ago