From b9288e3321a21f37e3755ecc80caa2e7eab6cb2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LeoYuan=20=E8=A2=81=E5=8A=9B=E7=9A=93?= Date: Wed, 16 Feb 2022 15:27:50 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BC=98=E5=8C=96=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=BC=95=E6=93=8E=E7=89=88=E6=9C=AC=E5=8F=B7=E7=9A=84=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 15 ++++++++++++--- packages/engine/README.md | 21 ++++++++++++++------- packages/engine/build.plugin.js | 11 ++++++++++- packages/engine/package.json | 4 ++-- packages/engine/src/engine-core.ts | 7 +++---- packages/ignitor/build.plugin.js | 9 +++++++++ packages/ignitor/package.json | 3 ++- 7 files changed, 52 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 9b990cccb..9d54aec0c 100644 --- a/README.md +++ b/README.md @@ -90,14 +90,21 @@ init(document.getElementById('lce')); ``` ### cdn 可选方式: -#### 方式 1:unpkg +#### 方式 1:alifd cdn +```html +https://alifd.alicdn.com/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js + +https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js +``` + +#### 方式 2:unpkg ```html https://unpkg.com/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js https://unpkg.com/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js ``` -#### 方式 2:jsdelivr +#### 方式 3:jsdelivr ```html https://cdn.jsdelivr.net/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js @@ -127,10 +134,12 @@ $ npm run setup $ npm start ``` +> 📢 npm 访问速度较慢,阿里员工可以使用 tnpm,其他同学建议使用 cnpm 或者指定镜像 registry。 + lowcode-engine 启动后,提供了几个 umd 文件,可以结合 [lowcode-demo](https://github.com/alibaba/lowcode-demo) 项目做调试,文件代理规则参考这里。 ## 🤝 参与共建 -请先阅读 [贡献指南 WIP](http://lowcode-engine.cn/docs/react/contributing-cn). +请先阅读 [贡献指南 WIP](http://lowcode-engine.cn/?docs#/doc?url=contributing). > 强烈推荐阅读 [《提问的智慧》](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way)、[《如何向开源社区提问题》](https://github.com/seajs/seajs/issues/545) 和 [《如何有效地报告 Bug》](http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html)、[《如何向开源项目提交无法解答的问题》](https://zhuanlan.zhihu.com/p/25795393),更好的问题更容易获得帮助。 \ No newline at end of file diff --git a/packages/engine/README.md b/packages/engine/README.md index 799193786..9d54aec0c 100644 --- a/packages/engine/README.md +++ b/packages/engine/README.md @@ -16,15 +16,13 @@ [npm-image]: https://img.shields.io/npm/v/@alilc/lowcode-engine.svg?style=flat-square [npm-url]: http://npmjs.org/package/@alilc/lowcode-engine -[github-action-image]: https://github.com/ant-design/ant-design/workflows/%E2%9C%85%20test/badge.svg -[github-action-url]: https://github.com/ant-design/ant-design/actions?query=workflow%3A%22%E2%9C%85+test%22 [download-image]: https://img.shields.io/npm/dm/@alilc/lowcode-engine.svg?style=flat-square [download-url]: https://npmjs.org/package/@alilc/lowcode-engine -[help-wanted-image]: https://flat.badgen.net/github/label-issues/ant-design/ant-design/help%20wanted/open +[help-wanted-image]: https://flat.badgen.net/github/label-issues/alibaba/lowcode-engine/help%20wanted/open [help-wanted-url]: https://github.com/alibaba/lowcode-engine/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22 [discussions-image]: https://img.shields.io/badge/discussions-on%20github-blue?style=flat-square -[discussions-url]: https://github.com/ant-design/ant-design/discussions +[discussions-url]: https://github.com/alibaba/lowcode-engine/discussions [issues-helper-image]: https://img.shields.io/badge/using-issues--helper-orange?style=flat-square [issues-helper-url]: https://github.com/actions-cool/issues-helper @@ -92,14 +90,21 @@ init(document.getElementById('lce')); ``` ### cdn 可选方式: -#### 方式 1:unpkg +#### 方式 1:alifd cdn +```html +https://alifd.alicdn.com/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js + +https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js +``` + +#### 方式 2:unpkg ```html https://unpkg.com/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js https://unpkg.com/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js ``` -#### 方式 2:jsdelivr +#### 方式 3:jsdelivr ```html https://cdn.jsdelivr.net/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js @@ -129,10 +134,12 @@ $ npm run setup $ npm start ``` +> 📢 npm 访问速度较慢,阿里员工可以使用 tnpm,其他同学建议使用 cnpm 或者指定镜像 registry。 + lowcode-engine 启动后,提供了几个 umd 文件,可以结合 [lowcode-demo](https://github.com/alibaba/lowcode-demo) 项目做调试,文件代理规则参考这里。 ## 🤝 参与共建 -请先阅读 [贡献指南 WIP](http://lowcode-engine.cn/docs/react/contributing-cn). +请先阅读 [贡献指南 WIP](http://lowcode-engine.cn/?docs#/doc?url=contributing). > 强烈推荐阅读 [《提问的智慧》](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way)、[《如何向开源社区提问题》](https://github.com/seajs/seajs/issues/545) 和 [《如何有效地报告 Bug》](http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html)、[《如何向开源项目提交无法解答的问题》](https://zhuanlan.zhihu.com/p/25795393),更好的问题更容易获得帮助。 \ No newline at end of file diff --git a/packages/engine/build.plugin.js b/packages/engine/build.plugin.js index 52f363bfb..07b68a383 100644 --- a/packages/engine/build.plugin.js +++ b/packages/engine/build.plugin.js @@ -1,12 +1,21 @@ const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); +const fse = require('fs-extra'); +// read from lerna +const lernaConfig = JSON.parse(fse.readFileSync('../../lerna.json', 'utf8')); +const { version } = lernaConfig; -module.exports = ({ onGetWebpackConfig }) => { +module.exports = ({ context, onGetWebpackConfig }) => { onGetWebpackConfig((config) => { config.resolve .plugin('tsconfigpaths') .use(TsconfigPathsPlugin, [{ configFile: './tsconfig.json', }]); + config + .plugin('define') + .use(context.webpack.DefinePlugin, [{ + VERSION_PLACEHOLDER: JSON.stringify(version), + }]); config.plugins.delete('hot'); config.devServer.hot(false); }); diff --git a/packages/engine/package.json b/packages/engine/package.json index e26897386..473f5fec6 100644 --- a/packages/engine/package.json +++ b/packages/engine/package.json @@ -13,7 +13,7 @@ "start": "build-scripts start", "version:update": "node ./scripts/version.js", "build": "NODE_OPTIONS=--max_old_space_size=8192 build-scripts build --skip-demo", - "build:umd": "NODE_OPTIONS=--max_old_space_size=8192 build-scripts build --config build.umd.json && npm run version:update", + "build:umd": "NODE_OPTIONS=--max_old_space_size=8192 build-scripts build --config build.umd.json", "test": "build-scripts test --config build.test.json --jest-passWithNoTests" }, "license": "MIT", @@ -41,7 +41,7 @@ "build-plugin-fusion": "0.1.17-beta.0", "build-plugin-moment-locales": "^0.1.0", "build-plugin-react-app": "^1.8.0", - "fs-extra": "^9.0.1", + "fs-extra": "^10.0.0", "prop-types": "^15.7.2", "tsconfig-paths-webpack-plugin": "^3.2.0" }, diff --git a/packages/engine/src/engine-core.ts b/packages/engine/src/engine-core.ts index aa0acbf41..d03544e7c 100644 --- a/packages/engine/src/engine-core.ts +++ b/packages/engine/src/engine-core.ts @@ -176,10 +176,9 @@ export { })(); let engineInited = false; -export const version = '{{VERSION_PLACEHOLDER}}'; -const DEFAULT_VERSION = '1.0.0'; -const runtimeVersion = version.indexOf('VERSION_PLACEHOLDER') > -1 ? DEFAULT_VERSION : version; - engineConfig.set('ENGINE_VERSION', runtimeVersion); +// @ts-ignore webpack Define variable +export const version = VERSION_PLACEHOLDER; +engineConfig.set('ENGINE_VERSION', version); export async function init( container?: HTMLElement, options?: EngineOptions, diff --git a/packages/ignitor/build.plugin.js b/packages/ignitor/build.plugin.js index c4255c125..ffa1d4957 100644 --- a/packages/ignitor/build.plugin.js +++ b/packages/ignitor/build.plugin.js @@ -1,4 +1,8 @@ const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); +const fse = require('fs-extra'); +// read from lerna +const lernaConfig = JSON.parse(fse.readFileSync('../../lerna.json', 'utf8')); +const { version } = lernaConfig; module.exports = ({ context, onGetWebpackConfig }) => { onGetWebpackConfig((config) => { @@ -7,6 +11,11 @@ module.exports = ({ context, onGetWebpackConfig }) => { configFile: './tsconfig.json', }, ]); + config + .plugin('define') + .use(context.webpack.DefinePlugin, [{ + VERSION_PLACEHOLDER: JSON.stringify(version), + }]); config.plugins.delete('hot'); config.devServer.hot(false); if (context.command === 'start') { diff --git a/packages/ignitor/package.json b/packages/ignitor/package.json index 0e5edad32..a9d1487a7 100644 --- a/packages/ignitor/package.json +++ b/packages/ignitor/package.json @@ -14,6 +14,7 @@ }, "license": "MIT", "devDependencies": { - "@alib/build-scripts": "^0.1.18" + "@alib/build-scripts": "^0.1.18", + "fs-extra": "^10.0.0" } }