@modern-js/module-tools 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/package.json +15 -15
  3. package/src/.eslintrc.json +0 -5
  4. package/src/cli/build.ts +0 -39
  5. package/src/cli/dev.ts +0 -24
  6. package/src/cli/index.ts +0 -3
  7. package/src/cli/new.ts +0 -32
  8. package/src/commands/build.ts +0 -74
  9. package/src/commands/dev.ts +0 -52
  10. package/src/commands/index.ts +0 -2
  11. package/src/features/build/build-platform.ts +0 -83
  12. package/src/features/build/build-watch.ts +0 -99
  13. package/src/features/build/build.ts +0 -111
  14. package/src/features/build/constants.ts +0 -52
  15. package/src/features/build/index.ts +0 -54
  16. package/src/features/build/logger/index.ts +0 -2
  17. package/src/features/build/logger/logText.ts +0 -80
  18. package/src/features/build/logger/loggerManager.ts +0 -132
  19. package/src/features/build/utils.ts +0 -235
  20. package/src/features/dev/index.ts +0 -74
  21. package/src/index.ts +0 -55
  22. package/src/locale/en.ts +0 -21
  23. package/src/locale/index.ts +0 -15
  24. package/src/locale/zh.ts +0 -21
  25. package/src/schema/index.ts +0 -4
  26. package/src/schema/output.ts +0 -41
  27. package/src/schema/schema.d.ts +0 -13
  28. package/src/schema/source.ts +0 -16
  29. package/src/tasks/build-source-code.ts +0 -234
  30. package/src/tasks/build-style.ts +0 -194
  31. package/src/tasks/build-watch-source-code.ts +0 -186
  32. package/src/tasks/build-watch-style.ts +0 -271
  33. package/src/tasks/constants.ts +0 -1
  34. package/src/tasks/copy-assets.ts +0 -123
  35. package/src/tasks/generator-dts.ts +0 -277
  36. package/src/type.d.ts +0 -1
  37. package/src/types.ts +0 -65
  38. package/src/utils/babel.ts +0 -104
  39. package/src/utils/color.ts +0 -3
  40. package/src/utils/copy.ts +0 -71
  41. package/src/utils/init-env.ts +0 -31
  42. package/src/utils/json.ts +0 -13
  43. package/src/utils/language.ts +0 -9
  44. package/src/utils/logger.ts +0 -141
  45. package/src/utils/readline.ts +0 -28
  46. package/src/utils/tsconfig.ts +0 -37
  47. package/src/utils/tspaths-transform/constants.ts +0 -19
  48. package/src/utils/tspaths-transform/index.ts +0 -139
  49. package/src/utils/tspaths-transform/utils.ts +0 -25
  50. package/src/utils/valide.ts +0 -37
@@ -1,54 +0,0 @@
1
- import path from 'path';
2
- import { Import, fs } from '@modern-js/utils';
3
- import type { NormalizedConfig } from '@modern-js/core';
4
- import type { IBuildConfig } from '../../types';
5
-
6
- const buildFeature: typeof import('./build') = Import.lazy('./build', require);
7
- const buildWatchFeature: typeof import('./build-watch') = Import.lazy(
8
- './build-watch',
9
- require,
10
- );
11
- const bp: typeof import('./build-platform') = Import.lazy(
12
- './build-platform',
13
- require,
14
- );
15
-
16
- export const build = async (
17
- config: IBuildConfig,
18
- modernConfig: NormalizedConfig,
19
- ) => {
20
- const {
21
- appDirectory,
22
- enableWatchMode,
23
- platform,
24
- clear = true,
25
- isTsProject,
26
- } = config;
27
- const {
28
- output: { path: outputPath = 'dist' },
29
- } = modernConfig;
30
- // TODO: maybe need watch mode in build platform
31
- if (typeof platform === 'boolean' && platform) {
32
- if (process.env.RUN_PLATFORM) {
33
- await bp.buildPlatform({ platform: 'all', isTsProject });
34
- }
35
- return;
36
- }
37
-
38
- if (typeof platform === 'string') {
39
- if (process.env.RUN_PLATFORM) {
40
- await bp.buildPlatform({ platform, isTsProject });
41
- }
42
- return;
43
- }
44
-
45
- if (clear) {
46
- fs.removeSync(path.join(appDirectory, outputPath));
47
- }
48
-
49
- if (enableWatchMode) {
50
- await buildWatchFeature.buildInWatchMode(config, modernConfig);
51
- } else {
52
- await buildFeature.buildSourceCode(config, modernConfig);
53
- }
54
- };
@@ -1,2 +0,0 @@
1
- export * from './logText';
2
- export * from './loggerManager';
@@ -1,80 +0,0 @@
1
- import { chalk } from '@modern-js/utils';
2
-
3
- export const colors = { title: chalk.rgb(218, 152, 92) };
4
-
5
- export const clearFlag = '\x1Bc';
6
-
7
- export const logTemplate = (
8
- title: string,
9
- messageStack: string[],
10
- {
11
- noBottomBorder = false,
12
- bottomBorderText = '',
13
- noLeftBorder = false,
14
- leftBorder = '',
15
- contentColor = (s: string) => s,
16
- } = {},
17
- ) => {
18
- const maxLength = Infinity; // TODO: 考虑后面是否提供该参数
19
- const leftBorderFlag = noLeftBorder ? '' : leftBorder;
20
- const messageFragments = messageStack
21
- .map(p => {
22
- p.trim();
23
-
24
- return `${leftBorderFlag}${p.replace(clearFlag, '')}`;
25
- }) // 移除 clearFlag
26
- .filter(s => s !== leftBorderFlag) // 过滤空字符串
27
- .slice(0, maxLength); // 控制长度
28
- const template = `${colors.title(title)}:
29
- ${contentColor(messageFragments.join(''))}${
30
- noBottomBorder ? '' : `\n${bottomBorderText}`
31
- }`;
32
- return template;
33
- };
34
-
35
- export interface LoggerTextOption {
36
- title: string;
37
- contentConfig?: {
38
- noBottomBorder?: boolean;
39
- bottomBorderText?: string;
40
- noLeftBorder?: boolean;
41
- leftBorder?: string;
42
- contentColor?: (s: string) => string;
43
- replace?: string[];
44
- };
45
- }
46
- // 处理Log内容如何展示
47
- export class LoggerText {
48
- messages: string[];
49
-
50
- hasErrorMessage: boolean;
51
-
52
- option: LoggerTextOption;
53
-
54
- constructor(option: LoggerTextOption) {
55
- this.messages = [];
56
- this.option = option;
57
- this.hasErrorMessage = false;
58
- }
59
-
60
- append(message: string) {
61
- if (message.includes(clearFlag)) {
62
- this.messages = [];
63
- }
64
- this.messages.push(message);
65
- }
66
-
67
- errorHappen() {
68
- this.hasErrorMessage = true;
69
- }
70
-
71
- hasMessages() {
72
- return this.messages.length > 0;
73
- }
74
-
75
- get value() {
76
- const { title, contentConfig } = this.option;
77
- const messages = [...new Set(this.messages)];
78
- return logTemplate(title, messages, contentConfig);
79
- }
80
- }
@@ -1,132 +0,0 @@
1
- /**
2
- * 1. 注册构建任务
3
- * 2. 监听各个构建任务进程中的信息:process.stdout.on('data' | 'error')
4
- * 3. 分别输出内容
5
- */
6
- import type { ChildProcess } from 'child_process';
7
- import EventEmitter from 'events';
8
- import { chalk, Import } from '@modern-js/utils';
9
- import type { LoggerTextOption, LoggerText } from './logText';
10
-
11
- const logText: typeof import('./logText') = Import.lazy('./logText', require);
12
- const readline: typeof import('../../../utils/readline') = Import.lazy(
13
- '../../../utils/readline',
14
- require,
15
- );
16
-
17
- export type STDOUT =
18
- | ChildProcess['stdout']
19
- | (NodeJS.WriteStream & {
20
- fd: 1;
21
- });
22
- export type STDERR =
23
- | ChildProcess['stderr']
24
- | (NodeJS.WriteStream & {
25
- fd: 2;
26
- });
27
-
28
- interface IAddStdoutConfig {
29
- event?: { data?: boolean; error?: boolean };
30
- colors?: {
31
- data?: (s: string) => string;
32
- error?: (s: string) => string;
33
- warning?: (s: string) => string;
34
- };
35
- }
36
-
37
- export class LoggerManager extends EventEmitter {
38
- private _compilering: boolean;
39
-
40
- private readonly _listeners: STDOUT[];
41
-
42
- constructor() {
43
- super();
44
- this._compilering = false;
45
- this._listeners = [];
46
- }
47
-
48
- createLoggerText(option: LoggerTextOption) {
49
- return new logText.LoggerText(option);
50
- }
51
-
52
- addStdout(
53
- loggerText: LoggerText,
54
- stdout: STDOUT,
55
- config: IAddStdoutConfig = {},
56
- ) {
57
- const {
58
- event = { data: true, error: true },
59
- colors = {
60
- data: chalk.green,
61
- error: chalk.red,
62
- warning: chalk.yellow,
63
- },
64
- } = config;
65
- if (event.data) {
66
- stdout?.on('data', chunk => {
67
- const data = chunk.toString();
68
- const content = colors.data ? colors.data(data) : chalk.green(data);
69
- loggerText.append(content);
70
- this.emit('data');
71
- });
72
- }
73
-
74
- if (event.error) {
75
- stdout?.on('error', error => {
76
- console.info('error');
77
- const data = error.message;
78
- const content = colors.error ? colors.error(data) : chalk.red(data);
79
- loggerText.append(content);
80
- loggerText.errorHappen();
81
- this.emit('data');
82
- });
83
- }
84
-
85
- this._listeners.push(stdout);
86
- }
87
-
88
- addStderr(
89
- loggerText: LoggerText,
90
- stderr: STDERR,
91
- color: (s: string) => string = chalk.red,
92
- ) {
93
- stderr?.on('data', chunk => {
94
- const data = chunk.toString();
95
- loggerText.append(color(data));
96
- loggerText.errorHappen();
97
- this.emit('data');
98
- });
99
- }
100
-
101
- showCompiling() {
102
- if (!this._compilering) {
103
- this._compilering = true;
104
- console.info(chalk.green`Compiling in progress...`);
105
- }
106
- }
107
-
108
- disappearCompiling() {
109
- if (this._compilering) {
110
- readline.ReadlineUtils.clearLine(process.stdout);
111
- this._compilering = false;
112
- }
113
- }
114
-
115
- listenDateAndShow(
116
- logTexts: LoggerText[],
117
- // stdout: NodeJS.WriteStream & {
118
- // fd: 1;
119
- // } = process.stdout,
120
- ) {
121
- this.on('data', () => {
122
- this.disappearCompiling();
123
- const content = logTexts.map(logtext => logtext.value).join('');
124
- // 每次更新,使用新的内容覆盖旧的内容,有几率出现内容错乱问题
125
- console.info(content);
126
- });
127
- return () => {
128
- // eslint-disable-next-line no-process-exit
129
- process.exit(0);
130
- };
131
- }
132
- }
@@ -1,235 +0,0 @@
1
- import * as path from 'path';
2
- import * as os from 'os';
3
- import { Import, chalk } from '@modern-js/utils';
4
- import type {
5
- IBuildConfig,
6
- IPackageModeValue,
7
- JsSyntaxType,
8
- ITaskMapper,
9
- ModuleToolsConfig,
10
- } from '../../types';
11
- import type { LoggerText } from './logger';
12
-
13
- const constants: typeof import('./constants') = Import.lazy(
14
- './constants',
15
- require,
16
- );
17
- const core: typeof import('@modern-js/core') = Import.lazy(
18
- '@modern-js/core',
19
- require,
20
- );
21
-
22
- // 硬解字符串返回相应格式的对象
23
- const updateMapper = (
24
- packageFieldValue: JsSyntaxType,
25
- outDir: IPackageModeValue['outDir'],
26
- mapper: IPackageModeValue[],
27
- ): IPackageModeValue[] => {
28
- if (packageFieldValue === 'CJS+ES6') {
29
- return [...mapper, { type: 'commonjs', syntax: 'es6+', outDir }];
30
- } else if (packageFieldValue === 'ESM+ES5') {
31
- return [...mapper, { type: 'module', syntax: 'es5', outDir }];
32
- } else if (packageFieldValue === 'ESM+ES6') {
33
- return [...mapper, { type: 'module', syntax: 'es6+', outDir }];
34
- } else {
35
- return [...mapper];
36
- }
37
- };
38
-
39
- export const getCodeInitMapper = (_: IBuildConfig) => {
40
- const {
41
- output: { packageFields, packageMode },
42
- } = core.useResolvedConfigContext() as ModuleToolsConfig;
43
- let initMapper: IPackageModeValue[] = [];
44
-
45
- // 如果不存在packageFields配置或者packageFields为空对象,则使用 packageMode
46
- if (
47
- !packageFields ||
48
- (typeof packageFields === 'object' &&
49
- Object.keys(packageFields).length === 0)
50
- ) {
51
- initMapper =
52
- constants.PACKAGE_MODES[packageMode || constants.DEFAULT_PACKAGE_MODE];
53
- } else if (packageFields && Object.keys(packageFields).length > 0) {
54
- if (packageFields.modern) {
55
- initMapper = updateMapper(packageFields.modern, 'modern', initMapper);
56
- }
57
-
58
- if (packageFields.main) {
59
- initMapper = updateMapper(packageFields.main, 'node', initMapper);
60
- }
61
-
62
- if (packageFields.module) {
63
- initMapper = updateMapper(
64
- packageFields.module,
65
- 'treeshaking',
66
- initMapper,
67
- );
68
- }
69
-
70
- // TODO: 如果存在其他配置,需要提示
71
- if (!packageFields.modern && !packageFields.main && !packageFields.module) {
72
- console.error(
73
- chalk.red(
74
- `Unrecognized ${JSON.stringify(
75
- packageFields,
76
- )} configuration, please use keys: 'modern, main, jupiter:modern' and use values: 'CJS+ES6, ESM+ES5, ESM+ES6'`,
77
- ),
78
- );
79
-
80
- // eslint-disable-next-line no-process-exit
81
- process.exit(1);
82
- }
83
- }
84
-
85
- return initMapper;
86
- };
87
-
88
- // 获取执行构建源码的参数
89
- export const getCodeMapper = ({
90
- logger,
91
- taskPath,
92
- config,
93
- initMapper,
94
- srcRootDir,
95
- willCompilerDirOrFile,
96
- }: ITaskMapper & {
97
- config: IBuildConfig;
98
- initMapper: IPackageModeValue[];
99
- srcRootDir: string;
100
- willCompilerDirOrFile: string;
101
- }) => {
102
- const { appDirectory } = core.useAppContext();
103
- const modernConfig = core.useResolvedConfigContext();
104
- const {
105
- output: { enableSourceMap, jsPath = 'js', path: distDir = 'dist' },
106
- } = modernConfig as ModuleToolsConfig;
107
-
108
- const { tsconfigName = 'tsconfig.json' } = config;
109
- const tsconfigPath = path.join(appDirectory, tsconfigName);
110
-
111
- return initMapper.map(option => {
112
- // 不是output.copy配置,而是内部的js copy逻辑
113
- const copyDirs = option.copyDirs?.map(copyDir =>
114
- path.join(appDirectory, `./${distDir}/${jsPath}/${copyDir}`),
115
- );
116
- return {
117
- logger,
118
- taskPath,
119
- params: [
120
- `--syntax=${option.syntax}`,
121
- `--type=${option.type}`,
122
- `--srcRootDir=${srcRootDir}`,
123
- `--willCompilerDirOrFile=${willCompilerDirOrFile}`,
124
- copyDirs ? `--copyDirs=${copyDirs.join(',')}` : '',
125
- `--distDir=${path.join(
126
- appDirectory,
127
- `./${distDir}/${jsPath}/${option.outDir}`,
128
- )}`,
129
- `--appDirectory=${appDirectory}`,
130
- enableSourceMap ? '--sourceMaps' : '',
131
- `--tsconfigPath=${tsconfigPath}`,
132
- ],
133
- };
134
- });
135
- };
136
-
137
- // 获取执行生成 d.ts 的参数
138
- export const getDtsMapper = (config: IBuildConfig, logger: LoggerText) => {
139
- const { appDirectory } = core.useAppContext();
140
- const modernConfig = core.useResolvedConfigContext();
141
- const {
142
- output: { disableTsChecker, path: outputPath = 'dist' },
143
- } = modernConfig as ModuleToolsConfig;
144
- const { tsconfigName = 'tsconfig.json', enableWatchMode, sourceDir } = config;
145
- const srcDir = path.join(appDirectory, './src');
146
- const tsconfigPath = path.join(appDirectory, tsconfigName);
147
- return [
148
- {
149
- logger,
150
- taskPath: require.resolve('../../tasks/generator-dts'),
151
- params: [
152
- `--srcDir=${srcDir}`,
153
- `--distDir=${path.join(appDirectory, `./${outputPath}/types`)}`,
154
- `--appDirectory=${appDirectory}`,
155
- `--tsconfigPath=${tsconfigPath}`,
156
- `--sourceDirName=${sourceDir}`,
157
- enableWatchMode ? `--watch` : '',
158
- disableTsChecker ? '' : `--tsCheck`,
159
- ],
160
- },
161
- ];
162
- };
163
-
164
- /**
165
- * 处理日志信息
166
- */
167
- export class LogStack {
168
- private _codeLogStack: string[];
169
-
170
- constructor() {
171
- this._codeLogStack = [];
172
- }
173
-
174
- update(latestLog: string, { splitEOL = false } = {}) {
175
- if (splitEOL) {
176
- latestLog.split(os.EOL).forEach(log => {
177
- this._codeLogStack.unshift(log.trim());
178
- });
179
- return;
180
- }
181
-
182
- this._codeLogStack.unshift(latestLog.trim());
183
- }
184
-
185
- clear() {
186
- this._codeLogStack = [];
187
- }
188
-
189
- get value() {
190
- return [...new Set(this._codeLogStack)];
191
- }
192
- }
193
-
194
- export const logTemplate = (
195
- title: string,
196
- messageStack: string[],
197
- maxLength: number,
198
- {
199
- noBottomBorder = false,
200
- bottomBorderText = '',
201
- noLeftBorder = false,
202
- leftBorder = '│',
203
- contentColor = (s: string) => s,
204
- } = {},
205
- ) => {
206
- const leftBorderFlag = noLeftBorder ? '' : leftBorder;
207
- const messageFragments = messageStack
208
- .map(p => {
209
- p.trim();
210
-
211
- return `${leftBorderFlag}${p.replace(constants.clearFlag, '')}`;
212
- }) // 移除 clearFlag
213
- .slice(0, maxLength) // 控制长度
214
- .filter(s => s !== leftBorderFlag) // 过滤空字符串
215
- .reverse(); // 调换顺序,最新的消息在最后面
216
- const template = `${title}:
217
- ${contentColor(messageFragments.join(os.EOL))}${
218
- noBottomBorder ? '' : `\n${bottomBorderText}`
219
- }`;
220
- return template;
221
- };
222
-
223
- // eslint-disable-next-line @typescript-eslint/no-extraneous-class
224
- export class TimeCounter {
225
- static _now: number;
226
-
227
- static time() {
228
- this._now = Date.now();
229
- }
230
-
231
- static timeEnd() {
232
- const span = Date.now() - this._now;
233
- return span < 1000 ? `${span}ms` : `${(span / 1000).toFixed(2)}s`;
234
- }
235
- }
@@ -1,74 +0,0 @@
1
- import { Import } from '@modern-js/utils';
2
- import chalk from 'chalk';
3
-
4
- const core: typeof import('@modern-js/core') = Import.lazy(
5
- '@modern-js/core',
6
- require,
7
- );
8
- const inquirer: typeof import('inquirer') = Import.lazy('inquirer', require);
9
- const color: typeof import('../../utils/color') = Import.lazy(
10
- '../../utils/color',
11
- require,
12
- );
13
-
14
- export interface IDevConfig {
15
- appDirectory: string;
16
- isTsProject: boolean;
17
- }
18
-
19
- export type DevTaskType = 'storybook' | 'docsite' | 'unknow';
20
-
21
- export const showMenu = async (config: IDevConfig) => {
22
- const metas = await (core.mountHook() as any).moduleToolsMenu(undefined);
23
- if (metas.length <= 0) {
24
- console.info(
25
- chalk.yellow(
26
- 'No runnable development features found.\nYou can use the `new` command to enable the development features',
27
- ),
28
- );
29
- // eslint-disable-next-line no-process-exit
30
- process.exit(0);
31
- }
32
- const menuMessage = color.devMenuTitle('Select the debug mode:');
33
- const { type } = await inquirer.prompt([
34
- {
35
- name: 'type',
36
- message: menuMessage,
37
- type: 'list',
38
- choices: metas,
39
- },
40
- ]);
41
-
42
- const devMeta = metas.find((meta: any) => meta.value === type);
43
- if (devMeta) {
44
- await devMeta.runTask(config);
45
- }
46
- };
47
-
48
- export const devStorybook = async (config: IDevConfig) => {
49
- const metas = await (core.mountHook() as any).moduleToolsMenu(undefined);
50
- const findStorybook = metas.find((meta: any) => meta.value === 'storybook');
51
- if (findStorybook) {
52
- await findStorybook.runTask(config);
53
- } else {
54
- console.info(
55
- chalk.yellow(
56
- 'No development features found.\nYou can use the `new` command to enable the development features',
57
- ),
58
- );
59
- // eslint-disable-next-line no-process-exit
60
- process.exit(0);
61
- }
62
- };
63
-
64
- export const runSubCmd = async (subCmd: string, config: IDevConfig) => {
65
- const metas = await (core.mountHook() as any).moduleToolsMenu(undefined);
66
-
67
- const devMeta = metas.find((meta: any) => meta.value === subCmd);
68
- if (devMeta) {
69
- await devMeta.runTask(config);
70
- } else {
71
- // eslint-disable-next-line no-process-exit
72
- process.exit(0);
73
- }
74
- };
package/src/index.ts DELETED
@@ -1,55 +0,0 @@
1
- import { Import } from '@modern-js/utils';
2
-
3
- const core: typeof import('@modern-js/core') = Import.lazy(
4
- '@modern-js/core',
5
- require,
6
- );
7
- // const { createPlugin, usePlugins, defineConfig } = core;
8
- const hooks: typeof import('@modern-js/module-tools-hooks') = Import.lazy(
9
- '@modern-js/module-tools-hooks',
10
- require,
11
- );
12
- const cli: typeof import('./cli') = Import.lazy('./cli', require);
13
- const local: typeof import('./locale') = Import.lazy('./locale', require);
14
- const schema: typeof import('./schema') = Import.lazy('./schema', require);
15
- const lang: typeof import('./utils/language') = Import.lazy(
16
- './utils/language',
17
- require,
18
- );
19
-
20
- export const { defineConfig } = core;
21
-
22
- core.usePlugins([
23
- require.resolve('@modern-js/plugin-changeset/cli'),
24
- require.resolve('@modern-js/plugin-analyze/cli'),
25
- ]);
26
-
27
- export default core.createPlugin(
28
- (() => {
29
- const locale = lang.getLocaleLanguage();
30
- local.i18n.changeLanguage({ locale });
31
- hooks.lifecycle();
32
-
33
- return {
34
- validateSchema() {
35
- return schema.addSchema();
36
- },
37
- config() {
38
- return {
39
- output: {
40
- enableSourceMap: false,
41
- jsPath: 'js',
42
- },
43
- };
44
- },
45
- commands({ program }: any) {
46
- cli.devCli(program);
47
- cli.buildCli(program);
48
- cli.newCli(program, locale);
49
- // 便于其他插件辨别
50
- program.$$libraryName = 'module-tools';
51
- },
52
- };
53
- }) as any,
54
- { post: ['@modern-js/plugin-analyze', '@modern-js/plugin-changeset'] },
55
- );
package/src/locale/en.ts DELETED
@@ -1,21 +0,0 @@
1
- export const EN_LOCALE = {
2
- command: {
3
- build: {
4
- describe: 'command for building module',
5
- watch: 'building module in watch mode',
6
- tsconfig: 'Specify a path to the tsconfig.json file',
7
- style_only: 'only build style',
8
- platform: 'building for other platforms',
9
- no_tsc: 'close tsc compiler to emit d.ts',
10
- no_clear: 'disable auto clear dist dir',
11
- },
12
- dev: { describe: 'start dev server' },
13
- new: {
14
- describe: 'generator runner for modern project',
15
- debug: 'using debug mode to log something',
16
- config: 'set default generator config(json string)',
17
- distTag: `use specified tag version for it's generator`,
18
- registry: 'set npm registry url to run npm command',
19
- },
20
- },
21
- };
@@ -1,15 +0,0 @@
1
- import { Import } from '@modern-js/utils';
2
-
3
- import { ZH_LOCALE } from './zh';
4
- import { EN_LOCALE } from './en';
5
-
6
- const i18nPlugin: typeof import('@modern-js/plugin-i18n') = Import.lazy(
7
- '@modern-js/plugin-i18n',
8
- require,
9
- );
10
-
11
- const i18n = new i18nPlugin.I18n();
12
-
13
- const localeKeys = i18n.init('zh', { zh: ZH_LOCALE, en: EN_LOCALE });
14
-
15
- export { i18n, localeKeys };
package/src/locale/zh.ts DELETED
@@ -1,21 +0,0 @@
1
- export const ZH_LOCALE = {
2
- command: {
3
- build: {
4
- describe: '构建模块命令',
5
- watch: '使用 Watch 模式构建模块',
6
- tsconfig: '指定 tsconfig.json 文件的路径',
7
- style_only: '只构建样式文件',
8
- platform: '构建其他平台产物',
9
- no_tsc: '关闭 tsc 编译',
10
- no_clear: '不清理产物目录',
11
- },
12
- dev: { describe: '本地开发命令' },
13
- new: {
14
- describe: '模块化工程方案中执行生成器',
15
- debug: '开启 Debug 模式,打印调试日志信息',
16
- config: '生成器运行默认配置(JSON 字符串)',
17
- distTag: '生成器使用特殊的 npm Tag 版本',
18
- registry: '生成器运行过程中定制 npm Registry',
19
- },
20
- },
21
- };
@@ -1,4 +0,0 @@
1
- import { sourceSchema } from './source';
2
- import { outputSchema } from './output';
3
-
4
- export const addSchema = () => [...sourceSchema, ...outputSchema];