Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
本仓库的 目的 是为 san 提供一个 SSR 代码框架和工具,以及内置了 JavaScript 的代码生成。
npm i san@latest san-ssr@latest
san-ssr 需要 san 提供的模板字符串解析和 TypeScript 类型,因此对 san 的版本有依赖。你需要安装对应版本的 san 和 san-ssr。
san-ssr 支持的 san 版本声明在 peerDependencies
里,因此只要能安装成功就能正确工作。一般的建议如下:
npm i san@latest san-ssr@latest
更多讨论请参考:baidu/san/issues/441
SanProject 类 提供了你会用到的所有接口:
const { SanProject } = require('san-ssr')
const app = require('src/component.js')
const project = new SanProject()
const render = project.compileToRenderer(app)
console.log(render({name: 'harttle'}))
详细请参考 API 文档:SanProject,或 /demo 下的示例项目。
san-ssr 提供了 San 组件的静态分析,提供了项目文件集合和 San 组件树,以及二者的对应关系。 具体的代码生成抽象为 Compiler 接口,目前有 JS 和 PHP 两个实现,其中 san-ssr-target-js 内置在本仓库中:
CLI 参数 --target
参数用来选择目标代码,默认为 js
:
san-ssr --target js ./component.js > ssr.js
编程接口也可以通过 SanProject#compile()
的第二个参数来指定目标,第三个参数来指定传给 Compiler 实现的参数:
import { Target, SanProject } from 'san-ssr'
import { writeFileSync } from 'fs'
const project = new SanProject()
const targetCode = project.compile('src/component.ts', Target.PHP, { emitHeader: true })
writeFileSync('ssr.php', targetCode)
指定非 js
的目标时,san-ssr 会从 CWD 开始寻找 san-ssr-target-${target}
的包,因此需要作为 san-ssr 的 peer 来安装。例如:
npm i san-ssr san-ssr-target-php
欢迎任何类型的 Issue、完整的 Pull Request、或者不完整的 Pull Request。可以按照下面的步骤开始开发:
npm install
./bin/debug array-literal
来查看 SSR 结果。输出包括:
npm run e2e
来查看其它样例是否仍然正常。npm run check
来做最后的编码风格检查,和完整的测试。准备步骤:
export PATH=$PATH:./bin
到你的 Shell 配置里。source ./bin/auto-complete
(如果你想自动补全 case 名字的话)。可以自定义 chpwd() 方法来实现。debug 命令:
debug array-literal
来执行这个 case 的所有编译方式:
render-by-source.js array-literal
来跳过编译,直接执行 ssr.js 并 assert 结果。用于手改 ssr.js 调试。render-onthefly.js array-literal
来把这个 case 编译到 render 函数并 SSR 和 assert 结果。注意:
./bin/debug array-literal
FAQs
San server-side-render framework and utils
The npm package san-ssr receives a total of 1,401 weekly downloads. As such, san-ssr popularity was classified as popular.
We found that san-ssr demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.