ProtectedctxProtectedbaseProtected ReadonlypluginReadonlyesbuildProtected Readonly[a reference to the original EsbuildPluginBuild that was used to construct this class.
type cast this SuperPluginBuild as an esbuild-compatible EsbuildPluginBuild. there's no logic that gets executed. this function merely performs a type casting for the sake of esbuild-compatibility.
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.
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.
Protectedperformpasses the provided OnTransformArgs to all onTransformHandlers | onTransform handlers,
and returns the result of the very first handler callback function that produces a non-nullable result.
TODO: add documentation and usage examples.
TODO: add documentation and usage examples.
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.
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.
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).
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: stringthe 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.
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.
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.
this is the extension of
esbuild.PluginBuildthat introduces additional functionality to esbuild's plugin api.