1.0.61 • Published 1 year ago

@hyext/compile v1.0.61

Weekly downloads
52
License
ISC
Repository
-
Last release
1 year ago

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 code
    • transformStylesheet(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 compiler
      • compileStrategy object, the compilestrategy
    • instance
      • compiler.assets(from, to) the files be processed from raw place to other place
        • from 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
    interface ProcessFile = {
      contents: Buffer,
    }
    
    compiler.compile(file: ProcessFile, filePath: String): ProcessFile
1.0.61

1 year ago

1.0.60

2 years ago

1.0.60-alpha.0

2 years ago

1.0.59

2 years ago

1.0.58

2 years ago

1.0.57

2 years ago

1.0.56

2 years ago

1.0.55

2 years ago

1.0.54

2 years ago

1.0.53

2 years ago

1.0.52

3 years ago

1.0.50

3 years ago

1.0.49

3 years ago

1.0.48

3 years ago

1.0.47

4 years ago

1.0.46

4 years ago

1.0.45

4 years ago

1.0.44

4 years ago

1.0.43

4 years ago

1.0.42

4 years ago

1.0.41

4 years ago

1.0.40

4 years ago

1.0.39

4 years ago

1.0.38

4 years ago

1.0.37

4 years ago

1.0.36

4 years ago

1.0.35

4 years ago

1.0.34

4 years ago

1.0.33

4 years ago

1.0.32

4 years ago

1.0.31

4 years ago

1.0.30

4 years ago

1.0.29

4 years ago

1.0.28

4 years ago

1.0.27

4 years ago

1.0.24

4 years ago

1.0.22

4 years ago

1.0.23

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.10

4 years ago