diff --git a/libs/horizon/index.d.ts b/libs/horizon/global.d.ts similarity index 65% rename from libs/horizon/index.d.ts rename to libs/horizon/global.d.ts index bab6684d..0ebd7135 100644 --- a/libs/horizon/index.d.ts +++ b/libs/horizon/global.d.ts @@ -2,3 +2,4 @@ 区分是否开发者模式 */ declare var isDev: boolean; +declare const __VERSION__: string; diff --git a/libs/horizon/index.ts b/libs/horizon/index.ts index 7004f914..71d104a9 100644 --- a/libs/horizon/index.ts +++ b/libs/horizon/index.ts @@ -83,6 +83,7 @@ const Horizon = { _getProcessingVNode, }; +export const version = __VERSION__; export { Children, createRef, @@ -115,7 +116,6 @@ export { findDOMNode, unmountComponentAtNode, act, - // 暂时给HorizonX使用 _launchUpdateFromVNode, _getProcessingVNode, diff --git a/libs/horizon/package.json b/libs/horizon/package.json index f3ffb19d..dedb9445 100644 --- a/libs/horizon/package.json +++ b/libs/horizon/package.json @@ -4,7 +4,7 @@ "keywords": [ "horizon" ], - "version": "0.0.6", + "version": "0.0.7", "homepage": "", "bugs": "", "main": "index.js", diff --git a/scripts/__tests__/jest/jestEnvironment.js b/scripts/__tests__/jest/jestEnvironment.js index d19a3b87..824f8a9d 100644 --- a/scripts/__tests__/jest/jestEnvironment.js +++ b/scripts/__tests__/jest/jestEnvironment.js @@ -5,3 +5,4 @@ global.MessageChannel = function MessageChannel() { postMessage() { } }; }; +global.__VERSION__ = require('../../../libs/horizon/package.json').version; diff --git a/scripts/webpack/webpack.dev.js b/scripts/webpack/webpack.dev.js index 5490fb66..7a537a9c 100644 --- a/scripts/webpack/webpack.dev.js +++ b/scripts/webpack/webpack.dev.js @@ -2,6 +2,7 @@ const webpack = require('webpack'); const ESLintPlugin = require('eslint-webpack-plugin'); const baseConfig = require('./webpack.base'); const path = require('path'); +const horizonVersion = require('../../libs/horizon/package.json').version; const mode = 'development'; const devtool = 'inline-source-map'; @@ -12,6 +13,7 @@ const plugins = [ new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"development"', isDev: 'true', + __VERSION__: `"${horizonVersion}"`, }), ]; diff --git a/scripts/webpack/webpack.pro.js b/scripts/webpack/webpack.pro.js index 3494e99e..64bb472b 100644 --- a/scripts/webpack/webpack.pro.js +++ b/scripts/webpack/webpack.pro.js @@ -2,6 +2,7 @@ const webpack = require('webpack'); const CopyWebpackPlugin = require('copy-webpack-plugin'); const baseConfig = require('./webpack.base'); const path = require('path'); +const horizonVersion = require('../../libs/horizon/package.json').version; const mode = 'production'; const devtool = 'none'; @@ -11,6 +12,7 @@ const plugins = [ new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"production"', isDev: 'false', + __VERSION__: `"${horizonVersion}"`, }) ]; diff --git a/tsconfig.json b/tsconfig.json index e85c8cac..dbd77f67 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -34,7 +34,8 @@ }, "include": [ "./libs/**/src/**/*.ts", - "libs/horizon/index.d.ts" + "./libs/**/*.ts", + "./libs/horizon/global.d.ts" ], "exclude": ["node_modules", "**/*.spec.ts", "dev"], "types": ["node"]