Skip to content

Commit 3c4e0a5

Browse files
authored
chore(utils): move generateMetaTags method to builder-shared (#3678)
* chore(utils): move generateMetaTags method to builder-shared * chore: update type * chore: fix typing
1 parent 975e815 commit 3c4e0a5

File tree

12 files changed

+20
-14
lines changed

12 files changed

+20
-14
lines changed

.changeset/beige-pandas-switch.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@modern-js/builder-shared': patch
3+
'@modern-js/main-doc': patch
4+
'@modern-js/utils': patch
5+
---
6+
7+
chore(utils): move generateMetaTags method to builder-shared
8+
9+
chore(utils): 移动 generateMetaTags 方法到 builder-shared

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,10 @@ Some implementations of Modern.js are modified from existing projects, such as [
6464

6565
- `@modern-js/bundle-require`: is modified from [bundle-require](https://github.com/egoist/bundle-require).
6666
- `@modern-js/plugin`: the hooks API is referenced from [farrow-pipeline](https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline).
67-
- `@modern-js/builder`: the moduleScope and fileSize plugins are referenced from [create-react-app](https://github.com/facebook/create-react-app), the TsConfigPathsPlugin is referenced from [tsconfig-paths-webpack-plugin](https://github.com/dividab/tsconfig-paths-webpack-plugin)
67+
- `@modern-js/builder`: the moduleScope and fileSize plugins are referenced from [create-react-app](https://github.com/facebook/create-react-app), the TsConfigPathsPlugin is referenced from [tsconfig-paths-webpack-plugin](https://github.com/dividab/tsconfig-paths-webpack-plugin), the generateMetaTags function is referenced from [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin).
6868
- `@modern-js/plugin-testing`: the jest runner is referenced from [jest-cli](https://github.com/facebook/jest/blob/fdc74af37235354e077edeeee8aa2d1a4a863032/packages/jest-cli/src/cli/index.ts#L21).
6969
- `@modern-js/plugin-data-loader`: some code is referenced from [remix](https://github.com/remix-run/remix)
7070
- `@modern-js/doc-tools`: some styles are referenced from [vitepress](https://github.com/vuejs/vitepress).
71-
- `@modern-js/utils`: the generateMetaTags function is referenced from [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin).
7271

7372
## License
7473

README.zh-CN.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,10 @@ Modern.js 中的部分代码是参考社区中的其他项目实现的,比如
6464

6565
- `@modern-js/bundle-require`: 修改自 [bundle-require](https://github.com/egoist/bundle-require)
6666
- `@modern-js/plugin`: hook API 的实现参考了 [farrow-pipeline](https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline)
67-
- `@modern-js/builder`: moduleScope 和 fileSize 插件参考了 [create-react-app](https://github.com/facebook/create-react-app),TsConfigPathsPlugin 参考了 [tsconfig-paths-webpack-plugin](https://github.com/dividab/tsconfig-paths-webpack-plugin)
67+
- `@modern-js/builder`: moduleScope 和 fileSize 插件参考了 [create-react-app](https://github.com/facebook/create-react-app),TsConfigPathsPlugin 参考了 [tsconfig-paths-webpack-plugin](https://github.com/dividab/tsconfig-paths-webpack-plugin),generateMetaTags 函数参考了 [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin)
6868
- `@modern-js/plugin-testing`: jest runner 参考了 [jest-cli](https://github.com/facebook/jest/blob/fdc74af37235354e077edeeee8aa2d1a4a863032/packages/jest-cli/src/cli/index.ts#L21)
6969
- `@modern-js/doc-tools`: 部分样式参考了 [vitepress](https://github.com/vuejs/vitepress)
7070
- `@modern-js/plugin-data-loader`: 部分实现参考了 [remix](https://github.com/remix-run/remix)
71-
- `@modern-js/utils`: generateMetaTags 函数参考了 [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin)
7271

7372
## License
7473

packages/builder/builder-shared/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
DEFAULT_MOUNT_ID,
1515
DEFAULT_DATA_URL_SIZE,
1616
} from './constants';
17+
import { generateMetaTags } from './generateMetaTags';
1718
import type {
1819
BuilderTarget,
1920
SharedHtmlConfig,
@@ -270,7 +271,6 @@ export async function getMetaTags(
270271
entryName: string,
271272
config: { html: SharedHtmlConfig; output: NormalizedSharedOutputConfig },
272273
) {
273-
const { generateMetaTags } = await import('@modern-js/utils');
274274
const { meta, metaByEntries } = config.html;
275275

276276
const metaOptions = {

packages/toolkit/utils/src/cli/generateMetaTags.ts renamed to packages/builder/builder-shared/src/generateMetaTags.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Todo: only @modern-js/builder-shared used
21
/**
32
* Copyright JS Foundation and other contributors.
43
*

packages/builder/builder-shared/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export * from './createPluginStore';
55
export * from './createContext';
66
export * from './utils';
77
export * from './fs';
8+
export * from './generateMetaTags';
89
export * from './getBrowserslist';
910
export * from './getCssSupport';
1011
export * from './logger';

packages/builder/builder-shared/src/schema/html.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MetaAttributes, MetaOptions } from '@modern-js/utils';
1+
import { MetaAttributes, MetaOptions } from '../generateMetaTags';
22
import {
33
CrossOrigin,
44
HtmlInjectTag,

packages/builder/builder-shared/src/types/config/html.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { MetaOptions } from '@modern-js/utils';
1+
import type { MetaOptions } from '../../generateMetaTags';
22
import type { ArrayOrNot, ChainedConfig } from '../utils';
33

44
export type CrossOrigin = 'anonymous' | 'use-credentials';

packages/toolkit/utils/tests/generateMetaTags.test.ts renamed to packages/builder/builder-shared/tests/generateMetaTags.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { generateMetaTags } from '../src';
1+
import { expect, describe, it } from 'vitest';
2+
import { generateMetaTags } from '../src/generateMetaTags';
23

34
describe('generateMetaTags', () => {
45
it('should return empty string when params is empty', () => {

packages/document/main-doc/docs/zh/community/blog/v2-release-note.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,10 @@ Modern.js 中的部分代码实现参考了社区中的开源项目,我们对
234234

235235
- `@modern-js/bundle-require`: 修改自 [bundle-require](https://github.com/egoist/bundle-require)
236236
- `@modern-js/plugin`: hook API 的实现参考了 [farrow-pipeline](https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline)
237-
- `@modern-js/builder`: moduleScope 和 fileSize 插件参考了 [create-react-app](https://github.com/facebook/create-react-app),TsConfigPathsPlugin 参考了 [tsconfig-paths-webpack-plugin](https://github.com/dividab/tsconfig-paths-webpack-plugin)
237+
- `@modern-js/builder`: moduleScope 和 fileSize 插件参考了 [create-react-app](https://github.com/facebook/create-react-app),TsConfigPathsPlugin 参考了 [tsconfig-paths-webpack-plugin](https://github.com/dividab/tsconfig-paths-webpack-plugin),generateMetaTags 函数参考了 [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin)
238238
- `@modern-js/plugin-testing`: jest runner 参考了 [jest-cli](https://github.com/facebook/jest/blob/fdc74af37235354e077edeeee8aa2d1a4a863032/packages/jest-cli/src/cli/index.ts#L21)
239239
- `@modern-js/doc-tools`: 部分样式参考了 [vitepress](https://github.com/vuejs/vitepress)
240240
- `@modern-js/plugin-data-loader`: 部分实现参考了 [remix](https://github.com/remix-run/remix)
241-
- `@modern-js/utils`: generateMetaTags 函数参考了 [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin)
242241

243242
## 最后
244243

0 commit comments

Comments
 (0)