diff --git a/packages/plugin-dva/CHANGELOG.md b/packages/plugin-dva/CHANGELOG.md
index 512e51ca5..a00e5d0ad 100644
--- a/packages/plugin-dva/CHANGELOG.md
+++ b/packages/plugin-dva/CHANGELOG.md
@@ -2,6 +2,18 @@
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [0.11.1](https://github.com/umijs/plugins/compare/@umijs/plugin-dva@0.11.0...@umijs/plugin-dva@0.11.1) (2021-04-09)
+
+### Bug Fixes
+
+- **dva:** dva model import undefined when from umi ([#523](https://github.com/umijs/plugins/issues/523)) ([1d8fb78](https://github.com/umijs/plugins/commit/1d8fb78e6ccda237307867bb0954fb840c95f930))
+
+# [0.11.0](https://github.com/umijs/plugins/compare/@umijs/plugin-dva@0.10.0...@umijs/plugin-dva@0.11.0) (2021-03-26)
+
+### Features
+
+- improve dva log ([#562](https://github.com/umijs/plugins/issues/562)) ([4d84817](https://github.com/umijs/plugins/commit/4d84817a041fd259afb6a8c7f6abfac16e7925e5))
+
# [0.10.0](https://github.com/umijs/plugins/compare/@umijs/plugin-dva@0.9.1...@umijs/plugin-dva@0.10.0) (2021-01-13)
### Features
diff --git a/packages/plugin-dva/package.json b/packages/plugin-dva/package.json
index 23596f42e..1297789e2 100644
--- a/packages/plugin-dva/package.json
+++ b/packages/plugin-dva/package.json
@@ -1,6 +1,6 @@
{
"name": "@umijs/plugin-dva",
- "version": "0.10.0",
+ "version": "0.11.1",
"description": "@umijs/plugin-dva",
"main": "lib/index.js",
"types": "lib/index.d.ts",
diff --git a/packages/plugin-dva/src/dva.tpl b/packages/plugin-dva/src/dva.tpl
index 544faaa32..4be30f721 100644
--- a/packages/plugin-dva/src/dva.tpl
+++ b/packages/plugin-dva/src/dva.tpl
@@ -4,19 +4,24 @@ import dva from 'dva';
// @ts-ignore
import createLoading from '{{{ dvaLoadingPkgPath }}}';
import { plugin, history } from '../core/umiExports';
+{{ ^LazyLoad }}
{{{ RegisterModelImports }}}
+{{ /LazyLoad }}
{{ #dvaImmer }}
import dvaImmer, { enableES5 } from '{{{ dvaImmerPath }}}';
{{ /dvaImmer }}
let app:any = null;
-export function _onCreate(options = {}) {
+export {{ #LazyLoad }}async {{ /LazyLoad }}function _onCreate(options = {}) {
const runtimeDva = plugin.applyPlugins({
key: 'dva',
type: ApplyPluginsType.modify,
initialValue: {},
});
+ {{ #LazyLoad }}
+ {{{ RegisterModelImports }}}
+ {{ /LazyLoad }}
app = dva({
history,
{{{ ExtendDvaConfig }}}
@@ -49,7 +54,13 @@ export class _DvaContainer extends Component {
super(props);
// run only in client, avoid override server _onCreate()
if (typeof window !== 'undefined') {
- _onCreate();
+ _onCreate()
+ {{ #LazyLoad }}
+ .then(() => {
+ // force update
+ this.forceUpdate();
+ });
+ {{ /LazyLoad }}
}
}
@@ -70,6 +81,11 @@ export class _DvaContainer extends Component {
render() {
const app = getApp();
+ {{ #LazyLoad }}
+ if (!app) {
+ return null;
+ }
+ {{ /LazyLoad }}
app.router(() => this.props.children);
return app.start()();
}
diff --git a/packages/plugin-dva/src/fixtures/lazyLoad/.umirc.ts b/packages/plugin-dva/src/fixtures/lazyLoad/.umirc.ts
new file mode 100644
index 000000000..e3e68df1e
--- /dev/null
+++ b/packages/plugin-dva/src/fixtures/lazyLoad/.umirc.ts
@@ -0,0 +1,12 @@
+
+export default {
+ routes: [
+ { path: '/', component: 'index' },
+ ],
+ dva: {
+ lazyLoad: true,
+ },
+ plugins: [
+ require.resolve('../../'),
+ ],
+}
diff --git a/packages/plugin-dva/src/fixtures/lazyLoad/models/foo.ts b/packages/plugin-dva/src/fixtures/lazyLoad/models/foo.ts
new file mode 100644
index 000000000..261afb1ac
--- /dev/null
+++ b/packages/plugin-dva/src/fixtures/lazyLoad/models/foo.ts
@@ -0,0 +1,9 @@
+import { data } from '../utils'
+
+export default {
+ state: {
+ desc: 'foo',
+ count: 0,
+ data,
+ },
+}
diff --git a/packages/plugin-dva/src/fixtures/lazyLoad/pages/index.less b/packages/plugin-dva/src/fixtures/lazyLoad/pages/index.less
new file mode 100644
index 000000000..ea92bb4cf
--- /dev/null
+++ b/packages/plugin-dva/src/fixtures/lazyLoad/pages/index.less
@@ -0,0 +1,7 @@
+
+.normal {
+}
+
+.title {
+ background: rgb(196, 242, 121);
+}
diff --git a/packages/plugin-dva/src/fixtures/lazyLoad/pages/index.tsx b/packages/plugin-dva/src/fixtures/lazyLoad/pages/index.tsx
new file mode 100644
index 000000000..1ab88084d
--- /dev/null
+++ b/packages/plugin-dva/src/fixtures/lazyLoad/pages/index.tsx
@@ -0,0 +1,15 @@
+import React from 'react';
+import styles from './index.less';
+import { connect } from 'dva';
+
+export const data = {};
+
+export default connect(state => ({
+ foo: state.foo,
+}))((props) => {
+ return (
+
+
Page index { props.foo.desc } { props.foo.count }
+
+ );
+})
diff --git a/packages/plugin-dva/src/fixtures/lazyLoad/utils.ts b/packages/plugin-dva/src/fixtures/lazyLoad/utils.ts
new file mode 100644
index 000000000..56955c7d5
--- /dev/null
+++ b/packages/plugin-dva/src/fixtures/lazyLoad/utils.ts
@@ -0,0 +1 @@
+export { data } from './pages/index';
diff --git a/packages/plugin-dva/src/index.test.ts b/packages/plugin-dva/src/index.test.ts
index affd21ea4..c5f3b4c18 100644
--- a/packages/plugin-dva/src/index.test.ts
+++ b/packages/plugin-dva/src/index.test.ts
@@ -38,3 +38,13 @@ test('with-immer', async () => {
'Page index foo 1
',
);
});
+
+test('lazyLoad', async () => {
+ const cwd = join(fixtures, 'lazyLoad');
+ await generateTmp({ cwd });
+ const { container } = render({ cwd });
+ await utils.delay(100);
+ expect(container.innerHTML).toEqual(
+ 'Page index foo 0
',
+ );
+});
diff --git a/packages/plugin-dva/src/index.ts b/packages/plugin-dva/src/index.ts
index 5806b9b71..010fa185f 100644
--- a/packages/plugin-dva/src/index.ts
+++ b/packages/plugin-dva/src/index.ts
@@ -33,6 +33,11 @@ export default (api: IApi) => {
schema(joi) {
return joi.object({
disableModelsReExport: joi.boolean(),
+ lazyLoad: joi
+ .boolean()
+ .description(
+ 'lazy load dva model avoiding the import modules from umi undefined',
+ ),
extraModels: joi.array().items(joi.string()),
hmr: joi.boolean(),
immer: joi.alternatives(joi.boolean(), joi.object()),
@@ -107,11 +112,15 @@ export default (api: IApi) => {
dvaImmerES5:
lodash.isPlainObject(api.config.dva?.immer) &&
api.config.dva?.immer.enableES5,
+ LazyLoad: api.config.dva?.lazyLoad,
RegisterModelImports: models
.map((path, index) => {
- return `import Model${lodash.upperFirst(
+ const modelName = `Model${lodash.upperFirst(
lodash.camelCase(basename(path, extname(path))),
- )}${index} from '${path}';`;
+ )}${index}`;
+ return api.config.dva?.lazyLoad
+ ? `const ${modelName} = (await import('${path}')).default;`
+ : `import ${modelName} from '${path}';`;
})
.join('\r\n'),
RegisterModels: models
diff --git a/packages/plugin-esbuild/CHANGELOG.md b/packages/plugin-esbuild/CHANGELOG.md
index ac03134ff..0cfa02cf1 100644
--- a/packages/plugin-esbuild/CHANGELOG.md
+++ b/packages/plugin-esbuild/CHANGELOG.md
@@ -2,6 +2,18 @@
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+# [1.2.0](https://github.com/umijs/plugins/compare/@umijs/plugin-esbuild@1.1.1...@umijs/plugin-esbuild@1.2.0) (2021-04-09)
+
+### Features
+
+- **esbuild:** exposes minify pure config ([#575](https://github.com/umijs/plugins/issues/575)) ([ed7f688](https://github.com/umijs/plugins/commit/ed7f688da63e343c330211147d74916c510c504a))
+
+## [1.1.1](https://github.com/umijs/plugins/compare/@umijs/plugin-esbuild@1.1.0...@umijs/plugin-esbuild@1.1.1) (2021-03-26)
+
+### Bug Fixes
+
+- **esbuild:** minify exposes target config for es5 projects ([#571](https://github.com/umijs/plugins/issues/571)) ([cb93b3a](https://github.com/umijs/plugins/commit/cb93b3a969d9f94c808eda8e02828f347cc2eca0))
+
## [1.0.3](https://github.com/umijs/plugins/compare/@umijs/plugin-esbuild@1.0.2...@umijs/plugin-esbuild@1.0.3) (2020-12-15)
### Bug Fixes
diff --git a/packages/plugin-esbuild/package.json b/packages/plugin-esbuild/package.json
index ec1c4fb44..f0e1b5eac 100644
--- a/packages/plugin-esbuild/package.json
+++ b/packages/plugin-esbuild/package.json
@@ -1,6 +1,6 @@
{
"name": "@umijs/plugin-esbuild",
- "version": "1.1.0",
+ "version": "1.2.0",
"description": "@umijs/plugin-esbuild",
"main": "lib/index.js",
"types": "lib/index.d.ts",
diff --git a/packages/plugin-esbuild/src/fixtures/es5/.umirc.ts b/packages/plugin-esbuild/src/fixtures/es5/.umirc.ts
new file mode 100644
index 000000000..057c05492
--- /dev/null
+++ b/packages/plugin-esbuild/src/fixtures/es5/.umirc.ts
@@ -0,0 +1,22 @@
+
+export default {
+ nodeModulesTransform: {
+ type: 'none',
+ },
+ targets: {
+ ie: 11,
+ },
+ history: {
+ type: 'memory',
+ options: {
+ initialEntries: ['/'],
+ },
+ },
+ mountElementId: '',
+ routes: [
+ { path: '/', component: 'index' },
+ ],
+ esbuild: {
+ target: 'es5',
+ },
+}
diff --git a/packages/plugin-esbuild/src/fixtures/es5/src/pages/index.js b/packages/plugin-esbuild/src/fixtures/es5/src/pages/index.js
new file mode 100644
index 000000000..4f1f61171
--- /dev/null
+++ b/packages/plugin-esbuild/src/fixtures/es5/src/pages/index.js
@@ -0,0 +1,3 @@
+export default () => {
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
+}
diff --git a/packages/plugin-esbuild/src/fixtures/normal/src/pages/index.js b/packages/plugin-esbuild/src/fixtures/normal/src/pages/index.js
index 59a8984ec..b93650022 100644
--- a/packages/plugin-esbuild/src/fixtures/normal/src/pages/index.js
+++ b/packages/plugin-esbuild/src/fixtures/normal/src/pages/index.js
@@ -1,3 +1,5 @@
import React from 'react';
-export default () => Hello
+export default () => {
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
+}
diff --git a/packages/plugin-esbuild/src/index.test.ts b/packages/plugin-esbuild/src/index.test.ts
index f10bfd13c..a8f14c75c 100644
--- a/packages/plugin-esbuild/src/index.test.ts
+++ b/packages/plugin-esbuild/src/index.test.ts
@@ -1,9 +1,11 @@
import { join } from 'path';
-import { existsSync } from 'fs';
+import { existsSync, readFileSync } from 'fs';
import { Service } from 'umi';
const fixtures = join(__dirname, 'fixtures');
+jest.setTimeout(300000);
+
describe('normal build', () => {
let err: any;
const cwd = join(fixtures, 'normal');
@@ -27,6 +29,38 @@ describe('normal build', () => {
it('normal', () => {
expect(err).toBeFalsy();
expect(existsSync(join(cwd, 'dist', 'umi.js'))).toBeTruthy();
+ expect(readFileSync(join(cwd, 'dist', 'umi.js'), 'utf8')).toContain(
+ 'new TypeError(`Invalid attempt to spread non-iterable',
+ );
+ });
+});
+
+describe('es5 build', () => {
+ let err: any;
+ const cwd = join(fixtures, 'es5');
+ beforeAll(async () => {
+ const service = new Service({
+ cwd,
+ env: 'production',
+ plugins: [require.resolve('./index.ts')],
+ });
+ let err;
+ try {
+ await service.run({
+ name: 'build',
+ });
+ } catch (e) {
+ console.error('es5 build error', e);
+ err = true;
+ }
+ });
+
+ it('es5', () => {
+ expect(err).toBeFalsy();
+ expect(existsSync(join(cwd, 'dist', 'umi.js'))).toBeTruthy();
+ expect(readFileSync(join(cwd, 'dist', 'umi.js'), 'utf8')).toContain(
+ 'new TypeError("Invalid attempt to spread non-iterable',
+ );
});
});
diff --git a/packages/plugin-esbuild/src/index.ts b/packages/plugin-esbuild/src/index.ts
index ed16cd1eb..3362adec5 100644
--- a/packages/plugin-esbuild/src/index.ts
+++ b/packages/plugin-esbuild/src/index.ts
@@ -6,7 +6,12 @@ export default (api: IApi) => {
key: 'esbuild',
config: {
schema(joi) {
- return joi.object();
+ return joi.object({
+ target: joi.alternatives(
+ joi.string(),
+ joi.array().items(joi.string()),
+ ),
+ });
},
},
enableBy: api.EnableBy.config,
@@ -14,14 +19,17 @@ export default (api: IApi) => {
api.modifyBundleConfig((memo, { type }) => {
if (memo.optimization) {
+ const { target = 'es2015', pure } = api.config.esbuild || {};
const optsMap = {
[BundlerConfigType.csr]: {
- target: 'es2015',
minify: true,
+ target,
+ pure,
},
[BundlerConfigType.ssr]: {
target: 'node10',
minify: true,
+ pure,
},
};
const opts = optsMap[type] || optsMap[BundlerConfigType.csr];
diff --git a/packages/plugin-helmet/CHANGELOG.md b/packages/plugin-helmet/CHANGELOG.md
index ba48d9c01..ad6e82213 100644
--- a/packages/plugin-helmet/CHANGELOG.md
+++ b/packages/plugin-helmet/CHANGELOG.md
@@ -2,6 +2,12 @@
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [1.1.2](https://github.com/umijs/plugins/compare/@umijs/plugin-helmet@1.1.1...@umijs/plugin-helmet@1.1.2) (2021-03-26)
+
+### Bug Fixes
+
+- **ssr:** 修复 SSR 下 helmet 无法添加的问题 ([#561](https://github.com/umijs/plugins/issues/561)) ([8072710](https://github.com/umijs/plugins/commit/8072710bb433a109eb01f9d4e56059ff18270592))
+
## [1.1.1](https://github.com/umijs/plugins/compare/@umijs/plugin-helmet@1.1.0...@umijs/plugin-helmet@1.1.1) (2020-08-27)
**Note:** Version bump only for package @umijs/plugin-helmet
diff --git a/packages/plugin-helmet/package.json b/packages/plugin-helmet/package.json
index 296982e7e..1ab98240d 100644
--- a/packages/plugin-helmet/package.json
+++ b/packages/plugin-helmet/package.json
@@ -1,6 +1,6 @@
{
"name": "@umijs/plugin-helmet",
- "version": "1.1.1",
+ "version": "1.1.2",
"description": "@umijs/plugin-helmet",
"main": "lib/index.js",
"types": "lib/index.d.ts",
diff --git a/packages/plugin-helmet/src/templates/runtime.tpl b/packages/plugin-helmet/src/templates/runtime.tpl
index ad677e2a0..f362b34db 100644
--- a/packages/plugin-helmet/src/templates/runtime.tpl
+++ b/packages/plugin-helmet/src/templates/runtime.tpl
@@ -21,7 +21,7 @@ if (process.env.__IS_SERVER) {
$('head').append(meta);
}
if (link) {
- $('link').append(link);
+ $('head').append(link);
}
if (Object.keys(htmlAttributes)) {
Object.keys(htmlAttributes).forEach(attrKey => {
diff --git a/packages/plugin-locale/CHANGELOG.md b/packages/plugin-locale/CHANGELOG.md
index e82356960..54b079c8a 100644
--- a/packages/plugin-locale/CHANGELOG.md
+++ b/packages/plugin-locale/CHANGELOG.md
@@ -1,38 +1,33 @@
# Change Log
-All notable changes to this project will be documented in this file.
-See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
-## [0.10.10](https://github.com/umijs/plugins/compare/@umijs/plugin-locale@0.10.9...@umijs/plugin-locale@0.10.10) (2021-03-19)
+# [0.11.0](https://github.com/umijs/plugins/compare/@umijs/plugin-locale@0.10.10...@umijs/plugin-locale@0.11.0) (2021-04-09)
-**Note:** Version bump only for package @umijs/plugin-locale
+### Bug Fixes
+- to solve the problem that FormattedMessage report [React Intl] Missing message error, it was encountered in the situation when calling addLocale to add/merge translation key-value pairs which were fetched from backend server for current language. ([#573](https://github.com/umijs/plugins/issues/573)) ([e6f5625](https://github.com/umijs/plugins/commit/e6f56255b5df987030dd29468fa67d992036fb78))
+### Features
+- **locale:** add 8px margin between icon and label for SelectLang ([#557](https://github.com/umijs/plugins/issues/557)) ([ff99186](https://github.com/umijs/plugins/commit/ff991860d6ce5308d64eca5129583cceec587ea1))
+## [0.10.10](https://github.com/umijs/plugins/compare/@umijs/plugin-locale@0.10.9...@umijs/plugin-locale@0.10.10) (2021-03-19)
-## [0.10.9](https://github.com/umijs/plugins/compare/@umijs/plugin-locale@0.10.8...@umijs/plugin-locale@0.10.9) (2021-03-04)
+**Note:** Version bump only for package @umijs/plugin-locale
+## [0.10.9](https://github.com/umijs/plugins/compare/@umijs/plugin-locale@0.10.8...@umijs/plugin-locale@0.10.9) (2021-03-04)
### Bug Fixes
-* useLayoutEffect will be warning in ssr mode ([#533](https://github.com/umijs/plugins/issues/533)) ([2b2c169](https://github.com/umijs/plugins/commit/2b2c16996fd228ecab411d916f8ab255d1982416))
-* when has runtimeLocale.setLocale setLocale not work ([#543](https://github.com/umijs/plugins/issues/543)) ([afc144c](https://github.com/umijs/plugins/commit/afc144c282d0156626432ce167dcf9ac3023ca98))
-
-
-
-
+- useLayoutEffect will be warning in ssr mode ([#533](https://github.com/umijs/plugins/issues/533)) ([2b2c169](https://github.com/umijs/plugins/commit/2b2c16996fd228ecab411d916f8ab255d1982416))
+- when has runtimeLocale.setLocale setLocale not work ([#543](https://github.com/umijs/plugins/issues/543)) ([afc144c](https://github.com/umijs/plugins/commit/afc144c282d0156626432ce167dcf9ac3023ca98))
## [0.10.8](https://github.com/umijs/plugins/compare/@umijs/plugin-locale@0.10.7...@umijs/plugin-locale@0.10.8) (2021-01-19)
-
### Bug Fixes
-* **locale:** unused return statement ([#513](https://github.com/umijs/plugins/issues/513)) ([05251df](https://github.com/umijs/plugins/commit/05251df6e33a58084fcd5b7d36d8e0cb60f7f07e))
-
-
-
-
+- **locale:** unused return statement ([#513](https://github.com/umijs/plugins/issues/513)) ([05251df](https://github.com/umijs/plugins/commit/05251df6e33a58084fcd5b7d36d8e0cb60f7f07e))
## [0.10.7](https://github.com/umijs/plugins/compare/@umijs/plugin-locale@0.10.6...@umijs/plugin-locale@0.10.7) (2021-01-13)
diff --git a/packages/plugin-locale/package.json b/packages/plugin-locale/package.json
index 9140220c2..ffa04a8f9 100644
--- a/packages/plugin-locale/package.json
+++ b/packages/plugin-locale/package.json
@@ -1,6 +1,6 @@
{
"name": "@umijs/plugin-locale",
- "version": "0.10.10",
+ "version": "0.11.0",
"description": "@umijs/plugin-locale",
"main": "lib/index.js",
"types": "lib/index.d.ts",
diff --git a/packages/plugin-locale/src/templates/SelectLang.tpl b/packages/plugin-locale/src/templates/SelectLang.tpl
index 9ed9a8dd1..056adc297 100644
--- a/packages/plugin-locale/src/templates/SelectLang.tpl
+++ b/packages/plugin-locale/src/templates/SelectLang.tpl
@@ -403,12 +403,13 @@ export const SelectLang: React.FC = (props) => {
: changeLang;
const menuItemStyle = { minWidth: "160px" };
+ const menuItemIconStyle = { marginRight: "8px" };
const langMenu = (