Classes
ModuleTransformConfig
Configuration builder for module transforms. Accepts TransformRequests and emits loader config objects for Buildpack's custom transform loaders.
Understands all transform types and normalizes them correctly. Mostly this involves resolving the file paths using Webpack or Node resolution rules.
For some special types of transform, ModuleTransformConfig has helpers to apply the requested transforms itself. But configureWebpack consumes most of the transforms by calling transformConfig.collect() on this object, which yields a structured object that configureWebpack can use to set up loader and plugin configuration.
Typedefs
addTransform ⇒
Add a request to transform a file in the build. This function is passed as the first argument to an interceptor of the transformModules target.
TransformRequest : Object
Instruction for configuring Webpack to apply custom transformations to one particular file. The configureWebpack() function gathers TransformRequests from all interceptors of the transformModules target and turns them into a configuration of Webpack module rules.
Configuration builder for module transforms. Accepts TransformRequests and emits loader config objects for Buildpack's custom transform loaders.
Understands all transform types and normalizes them correctly. Mostly this involves resolving the file paths using Webpack or Node resolution rules.
For some special types of transform, ModuleTransformConfig has helpers to apply the requested transforms itself. But configureWebpack consumes most of the transforms by calling transformConfig.collect() on this object, which yields a structured object that configureWebpack can use to set up loader and plugin configuration.
-
ModuleTransformConfig
- new ModuleTransformConfig(resolver, localProjectName)
- .add()
- .add ⇒
- .toLoaderOptions() ⇒
object
Parameters
MagentoResolverstringname field.Add a request to transform a file in the build. This function is passed as the first argument to an interceptor of the transformModules target.
Returns: null
Parameters
TransformRequestResolve paths and emit as JSON.
Returns: object — Configuration object
Properties
stringsourcefileToTransform through the transformModule as text. When applying a source TransformRequest, Buildpack will use the transformModule as a Webpack loader, so it must implement that interface. Any Webpack loader can be used as a transformModule for source TransformRequests. source transforms are fast and can run on source code of any language, but they aren't as precise and safe as AST-type transforms when modifying code.stringbabelfileToTransform through the transformModule as a Babel AST. When applying a babel TransformRequest, Buildpack will use the transformModule as a Babel plugin, so it must implement that interface. Any Babel plugin can be used as a transformModule for babel TransformRequests. babel transforms are powerful and versatile, giving the transformer much more insight into the structure of the source code to modify. However, they are slower than source transforms, and they can only work on ES Modules.Add a request to transform a file in the build. This function is passed as the first argument to an interceptor of the transformModules target.
Returns: null
Parameters
TransformRequestInstruction for configuring Webpack to apply custom transformations to one particular file. The configureWebpack() function gathers TransformRequests from all interceptors of the transformModules target and turns them into a configuration of Webpack module rules.
Properties
TransformTypestringimport or require().stringobjectSource Code: pwa-studio/packages/pwa-buildpack/lib/WebpackTools/ModuleTransformConfig.js