import {BuildTranspiler} from 'projext/src/services/building/buildTranspiler.js'
BuildTranspiler
Manages the transpilation of target files using Babel.
Constructor Summary
Public Constructor | ||
public |
constructor(babelConfiguration: BabelConfiguration, appLogger: Logger, targets: Targets, utils: Utils) Class constructor. |
Member Summary
Public Members | ||
public |
A local reference for the |
|
public |
A local reference for the |
|
public |
A local reference for the |
|
public |
A local reference for the |
Method Summary
Public Methods | ||
public |
Find files of a given type on a directory. |
|
public |
getTargetConfigurationForFile(file: string, buildType: string): Object Get a target Babel configuration based on a filepath. |
|
public |
transpileFile(filepath: string | Object, buildType: string, options: Object, writeFile: boolean): Promise<Object|string, Error> Transpile a file. |
|
public |
transpileFileSync(filepath: string | Object, buildType: string, options: Object, writeFile: boolean): Object | string Synchronous version of |
|
public |
transpileTargetFiles(target: Target, buildType: string): Promise<undefined,Error Transpile a target files for a given build type. |
Public Constructors
public constructor(babelConfiguration: BabelConfiguration, appLogger: Logger, targets: Targets, utils: Utils) source
Class constructor.
Params:
Name | Type | Attribute | Description |
babelConfiguration | BabelConfiguration | To get a target Babel configuration. |
|
appLogger | Logger | To print information messages after transpiling files. |
|
targets | Targets | To access targets information. |
|
utils | Utils | To normalize file extensions. |
Public Members
public babelConfiguration: BabelConfiguration source
A local reference for the babelConfiguration
service.
Public Methods
public findFiles(directory: string, pattern: string): Promise<Array, Error> source
Find files of a given type on a directory.
public getTargetConfigurationForFile(file: string, buildType: string): Object source
Get a target Babel configuration based on a filepath.
Params:
Name | Type | Attribute | Description |
file | string | The file that will be used to obtain the target and then the Babel configuration. |
|
buildType | string |
|
The build type for which the configuration is needed for. This allows the method to check if the target has source map enabled for the build type, and if this happens, it will also enable it on the configuration it returns. |
public transpileFile(filepath: string | Object, buildType: string, options: Object, writeFile: boolean): Promise<Object|string, Error> source
Transpile a file.
Params:
Name | Type | Attribute | Description |
filepath | string | Object | If used as a string, it's the path to the
file to transpile; if used as an object, it
should have |
|
buildType | string |
|
The build type for which the file is being
transpiled for. If |
options | Object |
|
The Babel configuration to use. If not defined, the method will try to find a target configuration using the path of the file. |
writeFile | boolean |
|
If |
public transpileFileSync(filepath: string | Object, buildType: string, options: Object, writeFile: boolean): Object | string source
Synchronous version of transpileFile
.
Params:
Name | Type | Attribute | Description |
filepath | string | Object | If used as a string, it's the path to the
file to transpile; if used as an object, it
should have |
|
buildType | string |
|
The build type for which the file is being
transpiled for. If |
options | Object |
|
The Babel configuration to use. If not defined, the method will try to find a target configuration using the path of the file. |
writeFile | boolean |
|
If |