@hyext/compile
v1.0.61
Published
A compiler for hyminapp, it can compile any files to any where by strategy you use.
Downloads
299
Keywords
Readme
hyext-compile
A compiler for hyminapp, it can compile any files to any where by strategy you use.
Installation
npm install --save-dev @hyext/compile
Modules
compile.feature
transformCss2Js(code)
, transform the css code to js code, return transformed codetransformStylesheet(code)
, replace jsx className to Styleheet, return transformed code
compile.strategy it is internal strategy used by Compiler
transformStyle
a strategy for miniapp code to rn code, if you want design own strategy, you should follow as appoint
interface BeProcessFile = {
contents: Buffer,
}
// process file of special ext
function compileProcessFn(file: BeProcessFile, filePath:String) {
return new Promise((resolve) => {
let code = file.contents.toString()
let processedCode = transform(code) // the transform fn of you design
file.contents = Buffer.from(processedCode)
resolve(file)
})
}
interface ProcssStrategy = {
fileExtName:(js|jsx|css|...): fn
}
const strategy:ProcssStrategy = { js: compileProcessFn }
- compile.Compiler The constructor of compiler, it can compile file from local to other place, and offer hot replace.
- constructor(type, compileStrategy)
type
string, the type of compilercompileStrategy
object, the compilestrategy
- instance
compiler.assets(from, to)
the files be processed from raw place to other placefrom
file path (absolute)to
file path (absolute or relative)
compiler.watch()
watch raw files change, and imediately compile to distination, you should call it after call compiler.assets.compiler.compile(file, filePath)
compile single file, and return modified file obj
- constructor(type, compileStrategy)
interface ProcessFile = {
contents: Buffer,
}
compiler.compile(file: ProcessFile, filePath: String): ProcessFile