C# Класс React.Babel

Handles compiling JavaScript files via Babel (http://babeljs.io/).
Наследование: IBabel
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
_babelConfig string
_cache ICache
_config IReactSiteConfiguration
_environment IReactEnvironment
_fileCacheHash IFileCacheHash
_fileSystem IFileSystem

Открытые методы

Метод Описание
Babel ( IReactEnvironment environment, ICache cache, IFileSystem fileSystem, IFileCacheHash fileCacheHash, IReactSiteConfiguration siteConfig ) : System

Initializes a new instance of the Babel class.

CacheIsValid ( string inputFileContents, string outputPath ) : bool

Checks whether an input file (given as inputFileContents) should be transpiled by calculating the hash and comparing it to the hash value stored in the file given by outputPath. If the outputPath file does not exist the input file should always be transpiled.

GetOutputPath ( string path ) : string

Returns the path the specified file's compilation will be cached to

GetSourceMapOutputPath ( string path ) : string

Returns the path the specified file's source map will be cached to if TransformAndSaveFile is called.

Transform ( string input, string filename = "unknown" ) : string

Transforms JavaScript via Babel. The result is not cached. Use TransformFile if loading from a file since this will cache the result.

TransformAndSaveFile ( string filename ) : string

Transforms JavaScript via Babel and saves the result into a ".generated.js" file alongside the original file.

TransformFile ( string filename ) : string

Transforms a JavaScript file. Results of the transformation are cached.

TransformFileWithSourceMap ( string filename, bool forceGenerateSourceMap = false ) : JavaScriptWithSourceMap

Transforms a JavaScript file via Babel and also returns a source map to map the compiled source to the original version. Results of the transformation are cached.

TransformWithSourceMap ( string input, string filename = "unknown" ) : JavaScriptWithSourceMap

Transforms JavaScript via Babel and also returns a source map to map the compiled source to the original version. The result is not cached.

Защищенные методы

Метод Описание
GetFileHeader ( string hash, string babelVersion ) : string

Gets the header prepended to transformed files. Contains a hash that is used to validate the cache.

LoadFromFileCache ( string filename, string hash, bool forceGenerateSourceMap ) : JavaScriptWithSourceMap

Loads a transformed JavaScript file from the disk cache. If the cache is invalid or there is no cached version, returns null.

TransformWithHeader ( string filename, string contents, string hash = null ) : JavaScriptWithSourceMap

Transforms JavaScript via Babel, and prepends a header used for caching purposes.

Описание методов

Babel() публичный Метод

Initializes a new instance of the Babel class.
public Babel ( IReactEnvironment environment, ICache cache, IFileSystem fileSystem, IFileCacheHash fileCacheHash, IReactSiteConfiguration siteConfig ) : System
environment IReactEnvironment The ReactJS.NET environment
cache ICache The cache to use for compilation
fileSystem IFileSystem File system wrapper
fileCacheHash IFileCacheHash Hash algorithm for file-based cache
siteConfig IReactSiteConfiguration Site-wide configuration
Результат System

CacheIsValid() публичный Метод

Checks whether an input file (given as inputFileContents) should be transpiled by calculating the hash and comparing it to the hash value stored in the file given by outputPath. If the outputPath file does not exist the input file should always be transpiled.
public CacheIsValid ( string inputFileContents, string outputPath ) : bool
inputFileContents string The contents of the input file.
outputPath string The output path of the (possibly previously) generated file.
Результат bool

GetFileHeader() защищенный Метод

Gets the header prepended to transformed files. Contains a hash that is used to validate the cache.
protected GetFileHeader ( string hash, string babelVersion ) : string
hash string Hash of the input
babelVersion string Version of Babel used to perform this transformation
Результат string

GetOutputPath() публичный Метод

Returns the path the specified file's compilation will be cached to
public GetOutputPath ( string path ) : string
path string Path of the input file
Результат string

GetSourceMapOutputPath() публичный Метод

Returns the path the specified file's source map will be cached to if TransformAndSaveFile is called.
public GetSourceMapOutputPath ( string path ) : string
path string Path of the input file
Результат string

LoadFromFileCache() защищенный Метод

Loads a transformed JavaScript file from the disk cache. If the cache is invalid or there is no cached version, returns null.
protected LoadFromFileCache ( string filename, string hash, bool forceGenerateSourceMap ) : JavaScriptWithSourceMap
filename string Name of the file to load
hash string Hash of the input file, to validate the cache
forceGenerateSourceMap bool /// true to re-transform the file if a cached version with no source map is available ///
Результат JavaScriptWithSourceMap

Transform() публичный Метод

Transforms JavaScript via Babel. The result is not cached. Use TransformFile if loading from a file since this will cache the result.
public Transform ( string input, string filename = "unknown" ) : string
input string JavaScript
filename string Name of the file being transformed
Результат string

TransformAndSaveFile() публичный Метод

Transforms JavaScript via Babel and saves the result into a ".generated.js" file alongside the original file.
public TransformAndSaveFile ( string filename ) : string
filename string Name of the file to load
Результат string

TransformFile() публичный Метод

Transforms a JavaScript file. Results of the transformation are cached.
public TransformFile ( string filename ) : string
filename string Name of the file to load
Результат string

TransformFileWithSourceMap() публичный Метод

Transforms a JavaScript file via Babel and also returns a source map to map the compiled source to the original version. Results of the transformation are cached.
public TransformFileWithSourceMap ( string filename, bool forceGenerateSourceMap = false ) : JavaScriptWithSourceMap
filename string Name of the file to load
forceGenerateSourceMap bool /// true to re-transform the file if a cached version with no source map is available ///
Результат JavaScriptWithSourceMap

TransformWithHeader() защищенный Метод

Transforms JavaScript via Babel, and prepends a header used for caching purposes.
protected TransformWithHeader ( string filename, string contents, string hash = null ) : JavaScriptWithSourceMap
filename string Name of the file being transformed
contents string Contents of the input file
hash string Hash of the input. If null, it will be calculated
Результат JavaScriptWithSourceMap

TransformWithSourceMap() публичный Метод

Transforms JavaScript via Babel and also returns a source map to map the compiled source to the original version. The result is not cached.
public TransformWithSourceMap ( string input, string filename = "unknown" ) : JavaScriptWithSourceMap
input string JavaScript
filename string Name of the file being transformed
Результат JavaScriptWithSourceMap

Описание свойств

_babelConfig защищенное свойство

The serialized Babel configuration
protected string _babelConfig
Результат string

_cache защищенное свойство

Cache used for storing compiled JavaScript
protected ICache _cache
Результат ICache

_config защищенное свойство

Site-wide configuration
protected IReactSiteConfiguration _config
Результат IReactSiteConfiguration

_environment защищенное свойство

Environment this transformer has been created in
protected IReactEnvironment _environment
Результат IReactEnvironment

_fileCacheHash защищенное свойство

Hash algorithm for file-based cache
protected IFileCacheHash _fileCacheHash
Результат IFileCacheHash

_fileSystem защищенное свойство

File system wrapper
protected IFileSystem _fileSystem
Результат IFileSystem