@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @modern-js/module-tools
2
2
 
3
+ ## 1.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 83166714: change .npmignore
8
+ - Updated dependencies [83166714]
9
+ - Updated dependencies [c3de9882]
10
+ - Updated dependencies [33ff48af]
11
+ - Updated dependencies [b7c48198]
12
+ - @modern-js/babel-preset-module@1.3.1
13
+ - @modern-js/core@1.3.2
14
+ - @modern-js/css-config@1.2.1
15
+ - @modern-js/i18n-cli-language-detector@1.2.1
16
+ - @modern-js/plugin-analyze@1.2.1
17
+ - @modern-js/plugin-changeset@1.2.1
18
+ - @modern-js/plugin-fast-refresh@1.2.1
19
+ - @modern-js/plugin-i18n@1.2.1
20
+ - @modern-js/new-action@1.3.1
21
+ - @modern-js/babel-compiler@1.2.1
22
+ - @modern-js/style-compiler@1.2.1
23
+ - @modern-js/module-tools-hooks@1.2.1
24
+ - @modern-js/utils@1.2.2
25
+
3
26
  ## 1.3.0
4
27
 
5
28
  ### Minor Changes
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.3.0",
14
+ "version": "1.3.1",
15
15
  "bin": {
16
16
  "modern": "./bin/modern.js"
17
17
  },
@@ -51,19 +51,19 @@
51
51
  "@babel/runtime": "^7",
52
52
  "@babel/traverse": "^7.15.0",
53
53
  "@babel/types": "^7.15.0",
54
- "@modern-js/babel-compiler": "^1.2.0",
55
- "@modern-js/babel-preset-module": "^1.3.0",
56
- "@modern-js/core": "^1.3.1",
57
- "@modern-js/css-config": "^1.2.0",
58
- "@modern-js/i18n-cli-language-detector": "^1.2.0",
59
- "@modern-js/module-tools-hooks": "^1.2.0",
60
- "@modern-js/new-action": "^1.3.0",
61
- "@modern-js/plugin-analyze": "^1.2.0",
62
- "@modern-js/plugin-changeset": "^1.2.0",
63
- "@modern-js/plugin-fast-refresh": "^1.2.0",
64
- "@modern-js/plugin-i18n": "^1.2.0",
65
- "@modern-js/style-compiler": "^1.2.0",
66
- "@modern-js/utils": "^1.2.1",
54
+ "@modern-js/babel-compiler": "^1.2.1",
55
+ "@modern-js/babel-preset-module": "^1.3.1",
56
+ "@modern-js/core": "^1.3.2",
57
+ "@modern-js/css-config": "^1.2.1",
58
+ "@modern-js/i18n-cli-language-detector": "^1.2.1",
59
+ "@modern-js/module-tools-hooks": "^1.2.1",
60
+ "@modern-js/new-action": "^1.3.1",
61
+ "@modern-js/plugin-analyze": "^1.2.1",
62
+ "@modern-js/plugin-changeset": "^1.2.1",
63
+ "@modern-js/plugin-fast-refresh": "^1.2.1",
64
+ "@modern-js/plugin-i18n": "^1.2.1",
65
+ "@modern-js/style-compiler": "^1.2.1",
66
+ "@modern-js/utils": "^1.2.2",
67
67
  "chalk": "^4.1.2",
68
68
  "chokidar": "^3.5.2",
69
69
  "dotenv": "^10.0.0",
@@ -82,7 +82,7 @@
82
82
  },
83
83
  "devDependencies": {
84
84
  "@babel/preset-typescript": "^7.15.0",
85
- "@modern-js/babel-chain": "^1.2.0",
85
+ "@modern-js/babel-chain": "^1.2.1",
86
86
  "@types/babel__core": "^7.1.15",
87
87
  "@types/babel__generator": "^7.6.3",
88
88
  "@types/babel__traverse": "^7.14.2",
@@ -1,5 +0,0 @@
1
- {
2
- "rules": {
3
- "react-hooks/rules-of-hooks": "off"
4
- }
5
- }
package/src/cli/build.ts DELETED
@@ -1,39 +0,0 @@
1
- import { Import } from '@modern-js/utils';
2
- import type { Command } from 'commander';
3
- import type { IBuildOption } from '../commands/build';
4
-
5
- const local: typeof import('../locale') = Import.lazy(
6
- '../locale/index',
7
- require,
8
- );
9
- const commands: typeof import('../commands') = Import.lazy(
10
- '../commands',
11
- require,
12
- );
13
-
14
- export const buildCli = (program: Command) => {
15
- // TODO: 初始化环境变量
16
- program
17
- .command('build')
18
- .usage('[options]')
19
- .description(local.i18n.t(local.localeKeys.command.build.describe))
20
- .option('-w, --watch', local.i18n.t(local.localeKeys.command.build.watch))
21
- .option(
22
- '--tsconfig [tsconfig]',
23
- local.i18n.t(local.localeKeys.command.build.tsconfig),
24
- './tsconfig.json',
25
- )
26
- .option(
27
- '--style-only',
28
- local.i18n.t(local.localeKeys.command.build.style_only),
29
- )
30
- .option(
31
- '-p, --platform [platform]',
32
- local.i18n.t(local.localeKeys.command.build.platform),
33
- )
34
- .option('--no-tsc', local.i18n.t(local.localeKeys.command.build.no_tsc))
35
- .option('--no-clear', local.i18n.t(local.localeKeys.command.build.no_clear))
36
- .action(async (subCommand: IBuildOption) => {
37
- await commands.build(subCommand);
38
- });
39
- };
package/src/cli/dev.ts DELETED
@@ -1,24 +0,0 @@
1
- import { Import } from '@modern-js/utils';
2
- import type { Command } from 'commander';
3
- import type { IDevOption } from '../commands/dev';
4
-
5
- const local: typeof import('../locale') = Import.lazy('../locale', require);
6
- const commands: typeof import('../commands') = Import.lazy(
7
- '../commands',
8
- require,
9
- );
10
-
11
- export const devCli = (program: Command) => {
12
- program
13
- .command('dev [subCmd]')
14
- .usage('[options]')
15
- .description(local.i18n.t(local.localeKeys.command.dev.describe))
16
- .option(
17
- '--tsconfig [tsconfig]',
18
- local.i18n.t(local.localeKeys.command.build.tsconfig),
19
- './tsconfig.json',
20
- )
21
- .action(async (subCmd: string, params: IDevOption) => {
22
- await commands.dev(params, subCmd);
23
- });
24
- };
package/src/cli/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './build';
2
- export * from './dev';
3
- export * from './new';
package/src/cli/new.ts DELETED
@@ -1,32 +0,0 @@
1
- import type { Command } from 'commander';
2
- import { Import } from '@modern-js/utils';
3
-
4
- const newAction: typeof import('@modern-js/new-action') = Import.lazy(
5
- '@modern-js/new-action',
6
- require,
7
- );
8
- const local: typeof import('../locale') = Import.lazy('../locale', require);
9
-
10
- export const newCli = (program: Command, locale?: string) => {
11
- program
12
- .command('new')
13
- .usage('[options]')
14
- .description(local.i18n.t(local.localeKeys.command.new.describe))
15
- .option(
16
- '-d, --debug',
17
- local.i18n.t(local.localeKeys.command.new.debug),
18
- false,
19
- )
20
- .option(
21
- '-c, --config <config>',
22
- local.i18n.t(local.localeKeys.command.new.config),
23
- )
24
- .option(
25
- '--dist-tag <tag>',
26
- local.i18n.t(local.localeKeys.command.new.distTag),
27
- )
28
- .option('--registry', local.i18n.t(local.localeKeys.command.new.registry))
29
- .action(async options => {
30
- await newAction.ModuleNewAction({ ...options, locale });
31
- });
32
- };
@@ -1,74 +0,0 @@
1
- import * as path from 'path';
2
- import { fs, Import } from '@modern-js/utils';
3
- import type { Platform } from '../types';
4
-
5
- const tsConfigutils: typeof import('../utils/tsconfig') = Import.lazy(
6
- '../utils/tsconfig',
7
- require,
8
- );
9
-
10
- const valid: typeof import('../utils/valide') = Import.lazy(
11
- '../utils/valide',
12
- require,
13
- );
14
- const buildFeature: typeof import('../features/build') = Import.lazy(
15
- '../features/build',
16
- require,
17
- );
18
- const core: typeof import('@modern-js/core') = Import.lazy(
19
- '@modern-js/core',
20
- require,
21
- );
22
- const dotenv: typeof import('dotenv') = Import.lazy('dotenv', require);
23
-
24
- export interface IBuildOption {
25
- watch: boolean;
26
- tsconfig: string;
27
- platform: boolean | Exclude<Platform, 'all'>;
28
- styleOnly: boolean;
29
- tsc: boolean;
30
- clear: boolean;
31
- }
32
-
33
- export const build = async ({
34
- watch = false,
35
- tsconfig: tsconfigName,
36
- tsc,
37
- clear = true,
38
- platform,
39
- }: IBuildOption) => {
40
- const { appDirectory } = core.useAppContext();
41
- const modernConfig = core.useResolvedConfigContext();
42
- const tsconfigPath = path.join(appDirectory, tsconfigName);
43
- dotenv.config();
44
- const isTsProject = tsConfigutils.existTsConfigFile(tsconfigPath);
45
- const enableTscCompiler = isTsProject && tsc;
46
-
47
- valid.valideBeforeTask({ modernConfig, tsconfigPath });
48
-
49
- // TODO: 一些配置只需要从modernConfig中获取
50
- await buildFeature.build(
51
- {
52
- appDirectory,
53
- enableWatchMode: watch,
54
- isTsProject,
55
- platform,
56
- sourceDir: 'src',
57
- tsconfigName,
58
- enableTscCompiler,
59
- clear,
60
- },
61
- modernConfig,
62
- );
63
-
64
- process.on('SIGBREAK', () => {
65
- console.info('exit');
66
- const tempTsconfigFilePath = path.join(
67
- appDirectory,
68
- './tsconfig.temp.json',
69
- );
70
- if (fs.existsSync(tempTsconfigFilePath)) {
71
- fs.removeSync(tempTsconfigFilePath);
72
- }
73
- });
74
- };
@@ -1,52 +0,0 @@
1
- import * as path from 'path';
2
- import { Import } from '@modern-js/utils';
3
-
4
- const devFeature: typeof import('../features/dev') = Import.lazy(
5
- '../features/dev',
6
- require,
7
- );
8
- const core: typeof import('@modern-js/core') = Import.lazy(
9
- '@modern-js/core',
10
- require,
11
- );
12
- const dotenv: typeof import('dotenv') = Import.lazy('dotenv', require);
13
- const tsConfigutils: typeof import('../utils/tsconfig') = Import.lazy(
14
- '../utils/tsconfig',
15
- require,
16
- );
17
- const valid: typeof import('../utils/valide') = Import.lazy(
18
- '../utils/valide',
19
- require,
20
- );
21
-
22
- export interface IDevOption {
23
- tsconfig: string;
24
- }
25
-
26
- const existSubCmd = (subCmd: string) => subCmd.length > 0;
27
-
28
- export const dev = async (option: IDevOption, subCmd = '') => {
29
- const { tsconfig: tsconfigName } = option;
30
- const appContext = core.useAppContext();
31
- const modernConfig = core.useResolvedConfigContext();
32
- const { appDirectory } = appContext;
33
- const tsconfigPath = path.join(appDirectory, tsconfigName);
34
-
35
- dotenv.config();
36
-
37
- valid.valideBeforeTask({ modernConfig, tsconfigPath });
38
-
39
- const isTsProject = tsConfigutils.existTsConfigFile(tsconfigPath);
40
-
41
- if (existSubCmd(subCmd)) {
42
- await devFeature.runSubCmd(subCmd, { isTsProject, appDirectory });
43
- return;
44
- }
45
-
46
- // Compatible with the use of jupiter, RUN_PLATFORM is used in jupiter
47
- if (process.env.RUN_PLATFORM) {
48
- await devFeature.showMenu({ isTsProject, appDirectory });
49
- } else {
50
- await devFeature.devStorybook({ isTsProject, appDirectory });
51
- }
52
- };
@@ -1,2 +0,0 @@
1
- export { dev } from './dev';
2
- export { build } from './build';
@@ -1,83 +0,0 @@
1
- import { Import, chalk } from '@modern-js/utils';
2
- import type { LoggerText } from './logger';
3
-
4
- const core: typeof import('@modern-js/core') = Import.lazy(
5
- '@modern-js/core',
6
- require,
7
- );
8
- const execa: typeof import('execa') = Import.lazy('execa', require);
9
- const lg: typeof import('./logger') = Import.lazy('./logger', require);
10
- const pMap: typeof import('p-map') = Import.lazy('p-map', require);
11
-
12
- export type Platform = 'all' | 'docs' | 'storybook';
13
-
14
- export interface IBuildPlatformOption {
15
- platform: Platform;
16
- isTsProject?: boolean;
17
- }
18
-
19
- export const buildPlatform = async (option: IBuildPlatformOption) => {
20
- const { isTsProject = false, platform } = option;
21
- const lm = new lg.LoggerManager();
22
- // 获取platforms的参数
23
- const buildTasks = await (core.mountHook() as any).platformBuild({
24
- isTsProject,
25
- });
26
-
27
- if (buildTasks.length <= 0) {
28
- console.info(
29
- chalk.yellow(
30
- 'No build tasks detected.\nYou can use the `new` command to enable the more features',
31
- ),
32
- );
33
- return;
34
- }
35
-
36
- const loggerMap: Record<string, LoggerText> = {};
37
- const taskMapper = buildTasks
38
- .filter((task: any) => platform === 'all' || task.name === platform)
39
- .map((params: any) => {
40
- const logger = lm.createLoggerText({ title: params.title });
41
- loggerMap[params.name] = logger;
42
- return {
43
- logger,
44
- ...params,
45
- };
46
- });
47
- if (taskMapper.length <= 0) {
48
- console.info(chalk.yellow(`'${platform}' is undefined task`));
49
- return;
50
- }
51
-
52
- lm.showCompiling();
53
- await pMap(
54
- taskMapper,
55
- async ({ taskPath, params, logger: _ }: any) => {
56
- const childProcess = execa.node(taskPath, params, {
57
- stdio: 'inherit',
58
- all: true,
59
- });
60
-
61
- // lm.addStdout(logger, childProcess.stdout, {
62
- // event: { data: true, error: true },
63
- // });
64
-
65
- // lm.addStderr(logger, childProcess.stderr);
66
- try {
67
- await childProcess;
68
- } catch {
69
- // eslint-disable-next-line no-process-exit
70
- process.exit(1);
71
- }
72
- // lm.disappearCompiling();
73
- // console.info(lg.colors.title(title));
74
- // console.info(a.all);
75
- },
76
- { concurrency: 1 },
77
- );
78
-
79
- // lm.disappearCompiling();
80
- // for (const key of Object.keys(loggerMap)) {
81
- // console.info(loggerMap[key].value);
82
- // }
83
- };
@@ -1,99 +0,0 @@
1
- import * as path from 'path';
2
- import * as os from 'os';
3
- import { Import } from '@modern-js/utils';
4
-
5
- import type { NormalizedConfig } from '@modern-js/core';
6
- import type { IBuildConfig, ITaskMapper } from '../../types';
7
-
8
- const core: typeof import('@modern-js/core') = Import.lazy(
9
- '@modern-js/core',
10
- require,
11
- );
12
- const execa: typeof import('execa') = Import.lazy('execa', require);
13
- const lg: typeof import('./logger') = Import.lazy('./logger', require);
14
- const pMap: typeof import('p-map') = Import.lazy('p-map', require);
15
- const utils: typeof import('./utils') = Import.lazy('./utils', require);
16
- const constants: typeof import('./constants') = Import.lazy(
17
- './constants',
18
- require,
19
- );
20
-
21
- export const buildInWatchMode = async (
22
- config: IBuildConfig,
23
- _: NormalizedConfig,
24
- ) => {
25
- const { appDirectory } = core.useAppContext();
26
- const { sourceDir, enableTscCompiler } = config;
27
- const srcRootDir = path.join(appDirectory, sourceDir);
28
- const concurrency = os.cpus().length;
29
- const lm = new lg.LoggerManager();
30
- const codeLog = lm.createLoggerText({
31
- title: constants.runBabelCompilerTitle,
32
- });
33
- const dtsLog = lm.createLoggerText({ title: constants.runTscWatchTitle });
34
- const styleLog = lm.createLoggerText({
35
- title: constants.runStyleCompilerTitle,
36
- });
37
- const copyLog = lm.createLoggerText({ title: 'Copy Log:' });
38
- const initCodeMapper = utils.getCodeInitMapper(config);
39
- const taskMapper: ITaskMapper[] = [
40
- ...utils.getCodeMapper({
41
- logger: codeLog,
42
- taskPath: require.resolve('../../tasks/build-watch-source-code'),
43
- config,
44
- willCompilerDirOrFile: sourceDir,
45
- initMapper: initCodeMapper,
46
- srcRootDir,
47
- }),
48
- ...(enableTscCompiler ? utils.getDtsMapper(config, dtsLog) : []),
49
- {
50
- logger: styleLog,
51
- taskPath: require.resolve('../../tasks/build-watch-style'),
52
- },
53
- {
54
- logger: copyLog,
55
- taskPath: require.resolve('../../tasks/copy-assets'),
56
- params: ['--watch'],
57
- },
58
- ];
59
- lm.on('data', () => {
60
- console.info(constants.clearFlag);
61
- enableTscCompiler && console.info(dtsLog.value);
62
- console.info(codeLog.value);
63
- console.info(styleLog.value);
64
- });
65
- await pMap(
66
- taskMapper,
67
- async ({ logger, taskPath, params }) => {
68
- const childProcess = execa.node(taskPath, params, { stdio: 'pipe' });
69
- if (logger === codeLog) {
70
- lm.addStdout(logger, childProcess.stdout, {
71
- event: { error: true, data: true },
72
- // colors: { data: s => s },
73
- });
74
- lm.addStderr(logger, childProcess.stderr);
75
- }
76
-
77
- if (logger === dtsLog) {
78
- lm.addStdout(logger, childProcess.stdout, {
79
- event: { data: true, error: true },
80
- colors: {
81
- // tsc 的log信息无论是错误还是正确都是从 data event 中获取到的
82
- data: s => s,
83
- },
84
- });
85
- }
86
-
87
- if (logger === styleLog || logger === copyLog) {
88
- lm.addStdout(logger, childProcess.stdout, {
89
- event: { error: true, data: true },
90
- // colors: { data: s => s },
91
- });
92
- lm.addStderr(logger, childProcess.stderr);
93
- }
94
-
95
- await childProcess;
96
- },
97
- { concurrency },
98
- );
99
- };
@@ -1,111 +0,0 @@
1
- /* eslint-disable max-statements */
2
- import * as path from 'path';
3
- import * as os from 'os';
4
- import { Import } from '@modern-js/utils';
5
- import type { NormalizedConfig } from '@modern-js/core';
6
- import type { IBuildConfig, ITaskMapper } from '../../types';
7
-
8
- const pMap: typeof import('p-map') = Import.lazy('p-map', require);
9
- const utils: typeof import('./utils') = Import.lazy('./utils', require);
10
- const execa: typeof import('execa') = Import.lazy('execa', require);
11
- const lg: typeof import('./logger') = Import.lazy('./logger', require);
12
- const constants: typeof import('./constants') = Import.lazy(
13
- './constants',
14
- require,
15
- );
16
- const core: typeof import('@modern-js/core') = Import.lazy(
17
- '@modern-js/core',
18
- require,
19
- );
20
-
21
- export const buildSourceCode = async (
22
- config: IBuildConfig,
23
- _: NormalizedConfig,
24
- ) => {
25
- const { sourceDir, enableTscCompiler } = config;
26
- const { appDirectory } = core.useAppContext();
27
- const concurrency = os.cpus().length;
28
- const srcRootDir = path.join(appDirectory, sourceDir);
29
- const lm = new lg.LoggerManager();
30
- const codeLog = lm.createLoggerText({
31
- title: constants.runBabelCompilerTitle,
32
- });
33
- const dtsLog = lm.createLoggerText({ title: constants.runTscTitle });
34
- const styleLog = lm.createLoggerText({
35
- title: constants.runStyleCompilerTitle,
36
- });
37
- const copyLog = lm.createLoggerText({ title: 'Copy Log:' });
38
- const initCodeMapper = utils.getCodeInitMapper(config);
39
- const taskMapper: ITaskMapper[] = [
40
- ...utils.getCodeMapper({
41
- logger: codeLog,
42
- taskPath: require.resolve('../../tasks/build-source-code'),
43
- config,
44
- willCompilerDirOrFile: sourceDir,
45
- initMapper: initCodeMapper,
46
- srcRootDir,
47
- }),
48
- ...(enableTscCompiler ? utils.getDtsMapper(config, dtsLog) : []),
49
- {
50
- logger: styleLog,
51
- taskPath: require.resolve('../../tasks/build-style'),
52
- },
53
- {
54
- logger: copyLog,
55
- taskPath: require.resolve('../../tasks/copy-assets'),
56
- },
57
- ];
58
-
59
- lm.showCompiling();
60
- await pMap(
61
- taskMapper,
62
- async ({ logger, taskPath, params }) => {
63
- const childProcess = execa.node(taskPath, params, { stdio: 'pipe' });
64
-
65
- if (logger === codeLog || logger === copyLog) {
66
- lm.addStdout(logger, childProcess.stdout, {
67
- event: { data: true, error: true },
68
- });
69
- lm.addStderr(logger, childProcess.stderr);
70
- }
71
-
72
- if (logger === dtsLog) {
73
- lm.addStdout(dtsLog, childProcess.stdout, {
74
- event: { data: true, error: true },
75
- });
76
- lm.addStderr(dtsLog, childProcess.stderr);
77
- }
78
- if (logger === styleLog) {
79
- lm.addStdout(logger, childProcess.stdout, {
80
- event: { data: true, error: true },
81
- });
82
- lm.addStderr(logger, childProcess.stderr);
83
- }
84
- await childProcess;
85
- },
86
- { concurrency },
87
- );
88
-
89
- lm.disappearCompiling();
90
- enableTscCompiler && console.info(dtsLog.value);
91
- console.info(codeLog.value);
92
- if (styleLog.hasMessages()) {
93
- console.info(styleLog.value);
94
- }
95
-
96
- if (copyLog.hasMessages()) {
97
- console.info(copyLog.value);
98
- }
99
-
100
- if (
101
- dtsLog.hasErrorMessage ||
102
- codeLog.hasErrorMessage ||
103
- styleLog.hasErrorMessage ||
104
- copyLog.hasErrorMessage
105
- ) {
106
- // eslint-disable-next-line no-process-exit
107
- process.exit(1);
108
- }
109
- };
110
-
111
- /* eslint-enable max-statements */
@@ -1,52 +0,0 @@
1
- import type { IPackageModeValue } from '../../types';
2
-
3
- // Universal JS 的默认选择,三份构建产物,支持 Node.js,对现代浏览器有优化
4
- const universalJs: IPackageModeValue[] = [
5
- { type: 'module', syntax: 'es5', outDir: 'treeshaking' },
6
- { type: 'commonjs', syntax: 'es6+', outDir: 'node' },
7
- { type: 'module', syntax: 'es6+', outDir: 'modern' },
8
- ];
9
-
10
- // Universal JS 的优化选择,两份构建产物,对现代浏览器无优化
11
- const universalJsLite: IPackageModeValue[] = [
12
- { type: 'module', syntax: 'es5', outDir: 'treeshaking' },
13
- { type: 'commonjs', syntax: 'es6+', outDir: 'node', copyDirs: ['modern'] },
14
- ];
15
-
16
- // 纯前端代码的默认选择,两份构建产物
17
- const browserJs: IPackageModeValue[] = [
18
- { type: 'module', syntax: 'es5', outDir: 'treeshaking', copyDirs: ['node'] },
19
- { type: 'module', syntax: 'es6+', outDir: 'modern' },
20
- ];
21
-
22
- // 纯前端代码的优化选择,单份构建产物,对现代浏览器无优化
23
- const browserJsLite: IPackageModeValue[] = [
24
- {
25
- type: 'module',
26
- syntax: 'es5',
27
- outDir: 'treeshaking',
28
- copyDirs: ['modern', 'node'],
29
- },
30
- ];
31
-
32
- // 纯 Node.js 代码的默认选择,两份构建产物
33
- const nodeJs: IPackageModeValue[] = [
34
- { type: 'commonjs', syntax: 'es6+', outDir: 'node' },
35
- { type: 'module', syntax: 'es6+', outDir: 'modern' },
36
- ];
37
-
38
- export const DEFAULT_PACKAGE_MODE = 'universal-js';
39
-
40
- export const PACKAGE_MODES = {
41
- 'universal-js': universalJs,
42
- 'universal-js-lite': universalJsLite,
43
- 'browser-js': browserJs,
44
- 'browser-js-lite': browserJsLite,
45
- 'node-js': nodeJs,
46
- };
47
-
48
- export const runBabelCompilerTitle = 'Run babel compiler code log';
49
- export const runTscWatchTitle = 'Run `tsc -w` log';
50
- export const runTscTitle = 'Run `tsc` log';
51
- export const runStyleCompilerTitle = 'Run style compiler code log';
52
- export const clearFlag = '\x1Bc';