C# 클래스 React.Babel

Handles compiling JavaScript files via Babel (http://babeljs.io/).
상속: IBabel
파일 보기 프로젝트 열기: reactjs/React.NET 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
_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