This package has been deprecated

Author message:

This plugin is deprecated because it doesn't solve the problem it was intended for. There should be no reason to use.

rollup-plugin-replace-worker-import-meta-url
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

rollup-plugin-replace-worker-import-meta-url [deprecated]

npm version

⚠️ This package is deprecated as it didn't actually solve the problem it was trying to solve. There should be no reason to use this plugin.

Rollup plugin to update Worker constructors using new URL('file.js', import.meta.url) to solve a Vite build issue.

For example, this plugin will transform the following code:

const worker = new Worker(new URL("./my-worker.js", import.meta.url));
worker.postMessage({ foo: "bar" });

Into:

const worker = new Worker(import.meta.resolve("./my-worker.js"));
worker.postMessage({ foo: "bar" });

Why?

This plugin was trying to solve a niche problem with Vite. Vite seems to have some issues with using a worker inside a worker. Unfortunately the plugin didn't actually solve the problem. I'm leaving this here for posterity but I don't recommend using it.

Installation

npm install --save-dev rollup-plugin-replace-worker-import-meta-url

Usage

// rollup.config.js
import replaceWorkerImportMetaUrl from "rollup-plugin-replace-worker-import-meta-url";

export default {
  input: "src/index.js",
  output: {
    file: "dist/index.js",
    format: "esm",
  },
  plugins: [replaceWorkerImportMetaUrl()],
};

Options

include (optional)

Type: Array[RegExp | String]

When include is configured only matching files will be transformed by the plugin.

exclude (optional)

Type: Array[RegExp | String]

When exclude is configured any matching files will not be transformed by the plugin.

Package Sidebar

Install

npm i rollup-plugin-replace-worker-import-meta-url

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

5.57 kB

Total Files

5

Last publish

Collaborators

  • jamsinclair