type

OnLoadResult

type OnLoadResult =
| undefined
| null
| void

Return undefined or null to skip the module. The next matching onLoad callback runs instead. If every callback skips it, the module is loaded as if no plugin had matched it.

Referenced types

interface OnLoadResultSourceCode

interface OnLoadResultObject

  • exports: Record<string, unknown>

    The object to use as the module

    // In your loader
    builder.onLoad({ filter: /^hello:world$/ }, (args) => {
       return { exports: { foo: "bar" }, loader: "object" };
    });
    
    // In your script
    import {foo} from "hello:world";
    console.log(foo); // "bar"
  • loader: 'object'

    The loader to use for this file