@oazmi/superbuild - v0.3.2
    Preparing search index...

    Class SuperPluginBuild

    this is the extension of esbuild.PluginBuild that introduces additional functionality to esbuild's plugin api.

    Implements

    Index

    Constructors

    Properties

    basePluginBuild: PluginBuild
    pluginName: string
    initialOptions: BuildOptions
    esbuild: SuperBuild
    "[INNER_PLUGIN_BUILD]": PluginBuild

    a reference to the original EsbuildPluginBuild that was used to construct this class.

    Methods

    • receive the internal EsbuildPluginBuild that was used to construct this wrapper class. this is useful when you wish to invoke sub-builds that do not initialize any of super-build's various internal plugins, either because they slow down the sub-build, or cause some kind of weird compatibility issue with your build, or because you may wish to bypass super-build's overloaded hooks in order to write low-level plugins for super-build itself, such as in the case of the nativeReplicaPlugin, and the underlying EsbuildNativeResolver it uses.

      you may also use the presence of this method as a means for checking if your plugin is running on super-build, or pure esbuild.

      Returns PluginBuild

    • Parameters

      • path: string
      • options: ResolveOptions = {}

      Returns Promise<ResolveResult>

    • this method lets you pass arbitrary loaded content through all available onTransform handlers/callbacks, so that you can modularize your plugins further, by making it possible for external plugins to call your plugin's onTransform handlers, or vice-versa.

      the relation between the onTransform hooks and this method is analogous to what the resolve method is to the onResolve hooks.

      keep in mind that when you use this method to transform some loaded content, the plugins' OnTransformCallback functions can tell whether the call request comes from this method, or from an actual/real loaded resource that is now passing through all available onTransform hooks, by simply observing the state of OnTransformArgs.isTransformCall.

      Parameters

      • args: StrictOmit<
            Optional<
                OnTransformArgs,
                "pluginData"
                | "resolveDir"
                | "suffix"
                | "with",
            >,
            "isTransformCall",
        >

      Returns Promise<OnTransformResult | null | undefined>

    • a path resolver function that joins path_segments wherever they're relative, and resolves with respect to the current working directory (cwd) or the esbuild-provided absWorkingDir.

      unlike the resolve method, this method does not involve any onResolve handlers assigned to esbuild, and it only uses basic relative path and absolute path resolution for the computation, and nothing more.

      Parameters

      • ...path_segments: string[]

      Returns string

    • re-route the statically analyzable relative imports of an emitted js or css file's contents. this process is akin to either moving/renaming the base emitted file to a different directory, and/or individually renaming the import paths of a select number of dependency files.

      Parameters

      • on_emit_args: Require<Partial<OnEmitArgs>, "contents" | "outputPath">

        the same OnEmitArgs that you receive in your onEmit hook's callback function. this will describe your emitted output file's contents and its original output path, in addition to all of the imports that it performs (and any imported entities that may need to have their paths updated).

      • loader: any

        specify the kind of content that's in your emitted file. only js and css files are currently supported, as only these two can have their import statements natively parse by esbuild (which is what we use for modifying the relative import paths).

      • Optionalupdated_output_path: string

        the new path where your emitted output file is to be migrated to. you should ideally provide an absolute path here; but if you don't, it will be assumed that the path is relative to on_emit_args.outputPath.

      Returns Promise<
          Pick<OnEmitResult, "path" | "contents" | "warnings" | "errors"> & {
              contents: Uint8Array<ArrayBuffer>;
          },
      >

      the new updated contents of the migrated file, any errors, and the migrated path (which is the same as the input updated_output_path, but resolved to become an absolute path), using the same interface of an onEmit hook's callback function's return value.

      Note

      remember, the returned value is merely the transformed input content. it does not implicitly apply the new contents onto the underlying virtual output file. for that, you will have to use the returned value of this method as the returned value for your resource's onEmit hook's callback function.