env-runner 0.2.3 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +370 -20
  2. package/dist/_chunks/common-base-runner.d.mts +486 -15
  3. package/dist/_chunks/common-base-runner.mjs +712 -32
  4. package/dist/_chunks/common-process-data.mjs +13 -0
  5. package/dist/_chunks/common-worker-utils.mjs +47 -114
  6. package/dist/_chunks/deno-process-runner.d.mts +4 -1
  7. package/dist/_chunks/deno-process-runner.mjs +9 -6
  8. package/dist/_chunks/lexer.mjs +2 -0
  9. package/dist/_chunks/libs/cjs-module-lexer.mjs +6 -1
  10. package/dist/_chunks/miniflare-runner.d.mts +26 -14
  11. package/dist/_chunks/miniflare-runner.mjs +430 -134
  12. package/dist/_chunks/netlify-runner.d.mts +3 -1
  13. package/dist/_chunks/node-worker-runner.d.mts +3 -1
  14. package/dist/_chunks/node-worker-runner.mjs +8 -4
  15. package/dist/_chunks/plugin-hooks.mjs +1656 -0
  16. package/dist/_chunks/server.mjs +21 -5
  17. package/dist/_chunks/types.d.mts +37 -1
  18. package/dist/_chunks/vercel-runner.d.mts +3 -1
  19. package/dist/cli.mjs +0 -0
  20. package/dist/index.d.mts +21 -4
  21. package/dist/runners/bun-process/runner.d.mts +4 -1
  22. package/dist/runners/bun-process/runner.mjs +12 -9
  23. package/dist/runners/bun-process/worker.mjs +12 -11
  24. package/dist/runners/deno-process/worker.mjs +12 -11
  25. package/dist/runners/node-process/runner.d.mts +3 -1
  26. package/dist/runners/node-process/runner.mjs +2 -6
  27. package/dist/runners/node-process/worker.mjs +12 -11
  28. package/dist/runners/node-worker/worker.mjs +10 -10
  29. package/dist/runners/self/runner.d.mts +5 -2
  30. package/dist/runners/self/runner.mjs +12 -0
  31. package/package.json +26 -26
  32. package/dist/_chunks/common-host-env.mjs +0 -11
  33. package/dist/_chunks/virtual-loader.mjs +0 -71
@@ -1,11 +1,13 @@
1
1
  import { WorkerHooks } from "./types.mjs";
2
- import { EnvRunnerData } from "./common-base-runner.mjs";
2
+ import { EnvRunnerData, EnvRunnerPluginOption } from "./common-base-runner.mjs";
3
3
  import { NodeWorkerEnvRunner } from "./node-worker-runner.mjs";
4
4
  export interface NetlifyEnvRunnerOptions {
5
5
  name: string;
6
6
  workerEntry?: string;
7
7
  hooks?: WorkerHooks;
8
8
  data?: EnvRunnerData;
9
+ /** Host-side transform plugins (see `EnvRunnerPluginOption`). */
10
+ plugins?: EnvRunnerPluginOption[];
9
11
  /**
10
12
  * `@netlify/runtime` specifier (resolved from cwd), imported inside the worker
11
13
  * since a module instance can't cross into it. Omitted: imported optionally,
@@ -1,5 +1,5 @@
1
1
  import { WorkerHooks } from "./types.mjs";
2
- import { BaseEnvRunner, EnvRunnerData } from "./common-base-runner.mjs";
2
+ import { BaseEnvRunner, EnvRunnerData, EnvRunnerPluginOption } from "./common-base-runner.mjs";
3
3
  export declare class NodeWorkerEnvRunner extends BaseEnvRunner {
4
4
  #private;
5
5
  constructor(opts: {
@@ -7,6 +7,8 @@ export declare class NodeWorkerEnvRunner extends BaseEnvRunner {
7
7
  workerEntry?: string;
8
8
  hooks?: WorkerHooks;
9
9
  data?: EnvRunnerData;
10
+ /** Host-side transform plugins (see `EnvRunnerPluginOption`). */
11
+ plugins?: EnvRunnerPluginOption[];
10
12
  });
11
13
  sendMessage(message: unknown): void;
12
14
  protected _hasRuntime(): boolean;
@@ -1,5 +1,5 @@
1
- import { BaseEnvRunner } from "./common-base-runner.mjs";
2
- import { hostEnv } from "./common-host-env.mjs";
1
+ import { PLUGINS_DATA_KEY } from "./plugin-hooks.mjs";
2
+ import { BaseEnvRunner, hostEnv } from "./common-base-runner.mjs";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { existsSync } from "node:fs";
5
5
  import { Worker } from "node:worker_threads";
@@ -37,12 +37,16 @@ var NodeWorkerEnvRunner = class extends BaseEnvRunner {
37
37
  this.close(`worker entry not found in "${this._workerEntry}".`);
38
38
  return;
39
39
  }
40
+ const plugins = this._pluginWorkerData("port");
41
+ const port = plugins[PLUGINS_DATA_KEY]?.port;
40
42
  const worker = new Worker(this._workerEntry, {
41
43
  env: hostEnv(),
42
44
  workerData: {
43
45
  name: this._name,
44
- ...this._data
45
- }
46
+ ...this._data,
47
+ ...plugins
48
+ },
49
+ transferList: port ? [port] : void 0
46
50
  });
47
51
  worker.once("exit", (code) => {
48
52
  worker._exitCode = code;