Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ npm i @eggjs/utils
- {String} baseDir - the current directory of application
- {String} framework - the directory of framework

### `setBundleModuleLoader(loader)`

Register a bundle module loader for `importModule()`. The loader is shared globally via `globalThis` across all instances of `@eggjs/utils` in the same process.

- {Function|undefined} loader - a synchronous hook called with a POSIX-normalized filepath or virtual specifier before normal module resolution.

Return `undefined` from the loader to fall back to standard module resolution. Otherwise, return the module exports synchronously; any non-`undefined` return value is treated as a bundle hit and uses the same default export handling as `importModule()`, including `importDefaultOnly` and double-default `__esModule` compatibility.

The loader must not be an `async` function or return a `Promise`, because `importModule()` does not `await` the hook.

Pass `undefined` to clear the registered loader.

## License

[MIT](LICENSE)
Expand Down
Loading