Match-id-2f9eb936515eb2fb3b2f7a2061329b3ce03337df

This commit is contained in:
* 2022-03-07 17:22:26 +08:00 committed by *
commit 41f5f7f9bc
15 changed files with 175 additions and 39 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ build/
.idea
.vscode
package-lock.json
libs/**/dist

View File

@ -1,14 +1,52 @@
# horizon
## 工程编译:
1、npm install
2、npm run build
Horizon采用monorepo方式管理项目意思是在版本控制系统的单个代码库里包含了许多项目的代码
全局单元测试 npm run test
monorepo工具采用yarn
### yarn配置
1. yarn1推荐
``` shell
// 先安装yarn
npm i yarn -g
```
`C:\Users\[工号]\.yarnrc`无相应文件需要新建
发布包:
加入yarn配置
```shell
registry "http://szxy1.artifactory.cd-cloud-artifact.tools.huawei.com/artifactory/api/npm/sz-npm-public"
no-proxy .huawei.com
lastUpdateCheck 1646381423295
strict-ssl false
```
2. yarn2
由于yarn2+有不兼容更新安装方式依赖node 16+的corepack功能安装参考 [yarn官网](https://yarnpkg.com/getting-started/install)
`C:\Users\[工号]\.yarnrc.yml`加入yarn配置无相应文件需要新建
加入yarn配置
```shell
npmRegistryServer "http://szxy1.artifactory.cd-cloud-artifact.tools.huawei.com/artifactory/api/npm/sz-npm-public"
```
注意yarn2配置文件和字段都存在大量不兼容参考[详细配置](https://yarnpkg.com/configuration/yarnrc#npmRegistryServer)
### 工程命令
#### 安装
```shell
yarn
```
> 需要使用yarn安装monorepo的依赖才能正确安装到node_modules
#### 打包
```shell
yarn run build
```
#### 全局单元测试
```shell
yarn run test
```
#### 发布包:
```shell
npm publish build/horizon --_auth=XXX
```
XXX是base64编码后的密码值CMO保管。
## 不兼容:

View File

@ -0,0 +1,25 @@
{
"plugins": [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-syntax-import-meta",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-json-strings",
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
],
"@babel/plugin-proposal-function-sent",
"@babel/plugin-proposal-export-namespace-from",
"@babel/plugin-proposal-numeric-separator",
"@babel/plugin-proposal-throw-expressions"
],
"env": {
"test": {
"plugins": [
"@babel/plugin-transform-modules-commonjs"
]
}
}
}

View File

@ -0,0 +1 @@
# horizon jsx babel plugin

View File

@ -0,0 +1,10 @@
/* istanbul ignore next */
module.exports = {
presets: [
'@babel/preset-env',
],
plugins: [
/* eslint-disable-next-line global-require */
[require('./dist/index.js')],
],
};

View File

@ -0,0 +1,10 @@
module.exports = {
transform: {
'\\.(ts|tsx)$': 'ts-jest',
},
globals: {
'ts-jest': {
babelConfig: true,
},
},
};

View File

@ -0,0 +1,37 @@
{
"name": "@cloudsop/horizon-jsx-transform-babel-plugin",
"version": "0.2.0",
"description": "transform jsx for horizon",
"main": "./dist/index.js",
"scripts": {
"build": "rimraf dist && tsc",
"test": "rimraf dist && tsc && jest",
"jest": "jest",
"prepublish": "npm run build"
},
"files": [
"../dist"
],
"dependencies": {
"@babel/generator": "^7.2.2",
"@babel/parser": "^7.2.3"
},
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.2.1",
"@babel/plugin-proposal-decorators": "^7.2.0",
"@babel/plugin-proposal-export-namespace-from": "^7.2.0",
"@babel/plugin-proposal-function-sent": "^7.2.0",
"@babel/plugin-proposal-json-strings": "^7.2.0",
"@babel/plugin-proposal-numeric-separator": "^7.2.0",
"@babel/plugin-proposal-throw-expressions": "^7.2.0",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/plugin-syntax-import-meta": "^7.2.0",
"@babel/plugin-syntax-jsx": "^7.2.0",
"@babel/plugin-transform-modules-commonjs": "^7.2.0",
"@babel/preset-env": "^7.16.11",
"@babel/types": "^7.0.0",
"babel-plugin-tester": "^10.1.0",
"ts-jest": "^26.1.3"
}
}

View File

@ -0,0 +1,25 @@
import SyntaxJSX from '@babel/plugin-syntax-jsx';
import * as BabelCore from '@babel/core';
import * as t from '@babel/types';
import {NodePath} from '@babel/traverse';
export default ({types}: typeof BabelCore) => {
return {
name: 'horizon-jsx-babel-plugin',
inherits: SyntaxJSX,
visitor: {
Program(path: NodePath<t.Program>) {
// program = path
},
JSXElement: {
exit(path) {
},
},
}
};
};

View File

@ -0,0 +1,10 @@
const path = require('path');
const pluginTester = require('babel-plugin-tester').default;
import plugin from '../src';
pluginTester({
plugin,
title: 'horizon jsx plugin',
fixtures: path.join(__dirname, '__fixtures__'),
snapshot: true
});

View File

@ -23,7 +23,7 @@ import {
createElement,
cloneElement,
isValidElement,
} from './horizon/src/external/Horizon';
} from './src/external/Horizon';
import {
render,
@ -31,7 +31,7 @@ import {
unstable_batchedUpdates,
findDOMNode,
unmountComponentAtNode,
} from './horizon/src/dom/DOMExternal';
} from './src/dom/DOMExternal';
const Horizon = {
Children,

View File

@ -3,6 +3,14 @@
"workspaces": [
"libs/*"
],
"scripts": {
"build": " webpack --config ./scripts/webpack/webpack.config.js",
"build-3rdLib": "node ./scripts/gen3rdLib.js",
"build-3rdLib-dev": "node ./scripts/gen3rdLib.js --dev",
"debug-test": "yarn test --debug",
"test": "jest --config=jest.config.js",
"watch-test": "yarn test --watch --dev"
},
"devDependencies": {
"@babel/cli": "^7.10.5",
"@babel/code-frame": "^7.10.4",
@ -40,9 +48,9 @@
"@babel/preset-typescript": "^7.16.7",
"@babel/register": "^7.14.5",
"@babel/traverse": "^7.11.0",
"@cloudsop/eview-ui": "^0.1.65",
"@mattiasbuelens/web-streams-polyfill": "^0.3.2",
"art": "0.10.1",
"@types/jest": "^26.0.24",
"@types/node": "^17.0.18",
"babel-core": "^6.26.3",
"babel-eslint": "^10.0.3",
"babel-jest": "^27.5.1",
@ -52,14 +60,11 @@
"babel-preset-react": "^6.24.1",
"chalk": "^3.0.0",
"clean-webpack-plugin": "^4.0.0-alpha.0",
"cli-table": "^0.3.1",
"coffee-script": "^1.12.7",
"concurrently": "^6.2.0",
"confusing-browser-globals": "^1.0.9",
"copy-webpack-plugin": "5.0.4",
"core-js": "^3.6.4",
"coveralls": "^3.0.9",
"create-react-class": "^15.6.3",
"cross-env": "^7.0.3",
"css-loader": "3.4.2",
"danger": "^9.2.10",
@ -76,15 +81,11 @@
"eslint-plugin-react": "^6.7.1",
"eslint-webpack-plugin": "^3.0.1",
"express": "^4.17.1",
"fbjs-scripts": "1.2.0",
"filesize": "^6.0.1",
"flow-bin": "0.97",
"glob": "^7.1.6",
"glob-stream": "^6.1.0",
"google-closure-compiler": "^20200517.0.0",
"gzip-size": "^5.1.1",
"html-webpack-plugin": "4.4.1",
"jasmine-check": "^1.0.0-rc.0",
"jest": "^25.5.4",
"jest-cli": "^25.2.7",
"jest-diff": "^25.2.6",
@ -94,18 +95,14 @@
"minimatch": "^3.0.4",
"minimist": "^1.2.3",
"mkdirp": "^0.5.1",
"mocha": "^9.0.1",
"ncp": "^2.0.0",
"object-assign": "^4.1.1",
"pacote": "^10.3.0",
"power-assert": "^1.6.1",
"prettier": "1.19.1",
"prop-types": "^15.6.2",
"puppeteer-core": "^10.1.0",
"random-seed": "^0.3.0",
"react-is": "^17.0.2",
"react-lifecycles-compat": "^3.0.4",
"react-router-dom": "^5.2.0",
"regenerator-runtime": "^0.13.9",
"resemblejs": "^4.0.0",
"rimraf": "^3.0.0",
@ -124,23 +121,5 @@
},
"devEngines": {
"node": "8.x || 9.x || 10.x || 11.x || 12.x || 13.x || 14.x"
},
"scripts": {
"build": " webpack --config ./scripts/webpack/webpack.config.js",
"build-3rdLib": "node ./scripts/gen3rdLib.js",
"build-3rdLib-dev": "node ./scripts/gen3rdLib.js --dev",
"debug-test": "yarn test --debug",
"test": "jest --config=jest.config.js",
"watch-test": "yarn test --watch --release-channel=horizon --dev"
},
"dependencies": {
"@elg/speedscope": "^1.9.0-a6f84db",
"@types/node": "^17.0.18",
"babel-code-frame": "^6.26.0",
"grunt-cli": "^1.4.3",
"react-dom": "^17.0.2",
"react-shallow-renderer": "^16.14.1",
"rxjs": "^7.1.0",
"symlink-dir": "^4.2.0"
}
}