A module that third party code can modify.
When Webpack loads a module into its bundles, it processes the source code through a set of rules generated by Buildpack. A TargetableModule is a reference to that source file, meant to be passed to interceptors. Inside interceptors, extensions and projects can configure the TargetableModule to transform it in many ways.
-
TargetableModule
- new TargetableModule(file, trackingOwner)
- .addTransform(type, transformModule, options) ⇒
this - .flush() ⇒
Array.<TransformRequest> - .insertAfterSource(after, insert, [options]) ⇒
this - .insertBeforeSource(before, insert, [options]) ⇒
this - .prependSource(insert) ⇒
this - .spliceSource(instruction) ⇒
this
Create a TargetableModule representing a file.
Parameters
stringTrackableAdd a transform request to this module's queue. The fileToTransform of the transform request is automatically set to this module's filename.
Chainable
Returns: Parameters
TransformTypestringsource or a Babel plugin for type babel.ObjectEmpty this module's queue of transforms, returning them as an array.
Returns: Array.<TransformRequest> — An array of Transform requests.
Insert text into the module contents, immediately following the location of the search string if it is found.
Chainable
Returns: Parameters
stringstringObjectnumberInsert text into the module contents, immediately before the location of the search string if it is found.
Chainable
Returns: Parameters
stringstringObjectnumberAdd text to the beginning of a file.
Chainable
Returns: Parameters
stringDo any splice operation supported by splice-source-loader.
Chainable
Returns: Parameters
objectSource Code: pwa-studio/packages/pwa-buildpack/lib/WebpackTools/targetables/TargetableModule.js