Files
node/lib
Izaak Schroeder 6ad8318373 esm: add initialize hook, integrate with register
Follows @giltayar's proposed API:

> `register` can pass any data it wants to the loader, which will be
passed to the exported `initialize` function of the loader.
Additionally, if the user of `register` wants to communicate with the
loader, it can just create a `MessageChannel` and pass the port to the
loader as data.

The `register` API is now:

```ts
interface Options {
  parentUrl?: string;
  data?: any;
  transferList?: any[];
}

function register(loader: string, parentUrl?: string): any;
function register(loader: string, options?: Options): any;
```

This API is backwards compatible with the old one (new arguments are
optional and at the end) and allows for passing data into the new
`initialize` hook. If this hook returns data it is passed back to
`register`:

```ts
function initialize(data: any): Promise<any>;
```

**NOTE**: Currently there is no mechanism for a loader to exchange
ownership of something back to the caller.

Refs: https://github.com/nodejs/loaders/issues/147
PR-URL: https://github.com/nodejs/node/pull/48842
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
2023-08-03 05:10:59 +00:00
..
2023-07-11 19:50:13 +03:00
2023-06-24 15:52:38 +00:00
2023-01-10 05:38:36 +00:00
2023-04-29 06:57:08 +00:00
2023-03-26 18:03:58 +00:00
2023-07-11 21:10:27 +00:00
2023-07-26 19:32:31 +08:00
2023-07-16 09:46:27 +00:00
2023-06-12 00:00:46 +00:00
2023-07-11 21:10:28 +00:00
2023-05-02 00:48:20 +00:00
2023-04-03 17:47:28 +00:00
2023-07-11 19:50:13 +03:00
2023-05-02 00:48:20 +00:00
2023-07-05 13:39:38 +00:00
2023-05-02 00:48:20 +00:00