Skip to content

[Bug]: LoaderContext's emitError and emitWarning aren't backwards compatible #9271

@dinofx

Description

@dinofx

System Info

mac

Details

emitError andemitWarning are methods in Rspack, which means they can only be called via the loader context instance, e.g.:

loaderContext.emitError(err)

in webpack, the following works:

const {emitError} = loaderContext;
emitError(err);

the workaround is:

const emitError = loaderContext.emitError.bind(loaderContext);
emitError(err);

For backwards compatibility, would it make sense for these to be "function properties", meaning functions implicitly bound to the correct context?

Reproduce link

No response

Reproduce Steps

see details above

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions