diff --git a/packages/icejs/package.json b/packages/icejs/package.json index f25fd40a75..cc6282191e 100644 --- a/packages/icejs/package.json +++ b/packages/icejs/package.json @@ -1,6 +1,6 @@ { "name": "ice.js", - "version": "1.17.5", + "version": "1.17.6", "description": "command line interface and builtin plugin for icejs", "author": "ice-admin@alibaba-inc.com", "homepage": "", diff --git a/packages/icejs/src/getBuiltInPlugins.ts b/packages/icejs/src/getBuiltInPlugins.ts index 4c1567c640..cee9a72967 100644 --- a/packages/icejs/src/getBuiltInPlugins.ts +++ b/packages/icejs/src/getBuiltInPlugins.ts @@ -10,6 +10,9 @@ const getBuiltInPlugins: IGetBuiltInPlugins = (userConfig) => { 'build-plugin-ice-mpa' ]; } + // eslint-disable-next-line + const pkg = require('../package.json'); + process.env.__FRAMEWORK_VERSION__ = pkg.version; const coreOptions = { 'framework': 'react', 'alias': process.env.__FRAMEWORK_NAME__ || 'ice' diff --git a/packages/plugin-icestark/CHANGELOG.md b/packages/plugin-icestark/CHANGELOG.md index 55eabb2f5d..65476d01e0 100644 --- a/packages/plugin-icestark/CHANGELOG.md +++ b/packages/plugin-icestark/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +# 2.0.9 + +- [fix] compatible with the case which icejs version is locked + # 2.0.8 - [fix] make `router.basename` work in a non-icestark context. ([#4234](https://github.com/alibaba/ice/issues/4234)) diff --git a/packages/plugin-icestark/src/index.ts b/packages/plugin-icestark/src/index.ts index fa1cf87257..e98197e5d1 100644 --- a/packages/plugin-icestark/src/index.ts +++ b/packages/plugin-icestark/src/index.ts @@ -12,6 +12,9 @@ const plugin: IPlugin = async ({ onGetWebpackConfig, getValue, applyMethod, cont const hasDefaultLayout = glob.sync(`${path.join(rootDir, 'src/layouts/index')}.@(ts?(x)|js?(x))`).length; onGetWebpackConfig((config) => { + config + .plugin('DefinePlugin') + .tap(([args]) => [{ ...args, 'process.env.__FRAMEWORK_VERSION__': JSON.stringify(process.env.__FRAMEWORK_VERSION__) }]); // set alias for default layout config.resolve.alias.set('$ice/Layout', hasDefaultLayout ? path.join(rootDir, 'src/layouts') : path.join(__dirname, 'runtime/Layout')); // set alias for icestark diff --git a/packages/plugin-icestark/src/runtime.tsx b/packages/plugin-icestark/src/runtime.tsx index 532efe689a..8a26733999 100644 --- a/packages/plugin-icestark/src/runtime.tsx +++ b/packages/plugin-icestark/src/runtime.tsx @@ -68,7 +68,8 @@ const module = ({ appConfig, addDOMRender, buildConfig, setRenderRouter, wrapper fallback }; - if (wrapperRouterRender) { + // compatible with the case which lock icejs version + if (wrapperRouterRender && !!process.env.__FRAMEWORK_VERSION__) { wrapperRouterRender((originRender) => (routes, RoutesComponent) => { return originRender(routes, RoutesComponent, routerProps); });