1.0.0 • Published 4 years ago
san-ssr-target-js v1.0.0
san-ssr-target-js
Supported Environment
- Node.js >= 6.4.0
CLI Usage
Command line interface:
san-ssr ./component.ts > ssr.php
Programmatic Interface
Pass 'php'
as the second parameter of SanProject
SanProject#compile(filepath, target, options) method.
TypeScript:
import { Target, SanProject } from 'san-project'
import { writeFileSync } from 'fs'
const project = new SanProject()
const targetCode = project.compile('src/component.ts')
writeFileSync('ssr.js', targetCode)
Or in JavaScript:
const { SanProject } = require('san-project')
import { writeFileSync } from 'fs'
const project = new SanProject()
const targetCode = project.compile('src/component.ts')
writeFileSync('ssr.js', targetCode)
Known Issues
THIS SECTION IS FOR MAINTAINERS ONLY
- san runtime 要求 filters/computed 是 static,而 static 属性无法用接口来描述
- ssr 通过 toString 来编译 function,以下情况编译不了:
- ES6 method。toString 后形如: foo: foo() {}
- 值为 funciton 的表达式。例如:_.curry(sum, 2)
- 成员通过 Object.keys 遍历,以下情况遍历不到:
- ES6 Method,需要通过 getOwnPropertyNames/Symbols 来取。
- ES6 Property 必须中 constructor 中赋值,也会找不到。
- 只能编译 Component 文件,不支持引用纯工具文件。例如:
const someFilter = require('./somfilter'); export default class Component { static filters = { someFilter }}
Contribution Guide
Development Prerequisites:
- Node.js>=8
Install dependencies and run tests:
npm install
npm test
Debug a single case (e.g. test/cases/array-literal
):
./bin/debug array-literal
source ./bin/auto-complete
to make zsh to auto complete test case names.
1.0.0
4 years ago