@modern-js/module-tools 1.5.5 → 1.6.0-alpha.0

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 (116) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/dist/js/modern/cli/build.js +5 -4
  3. package/dist/js/modern/commands/build.js +40 -27
  4. package/dist/js/modern/features/build/bundle/index.js +6 -0
  5. package/dist/js/modern/features/build/bundle/runRollup.js +149 -0
  6. package/dist/js/modern/features/build/bundle/runSpeedy.js +185 -0
  7. package/dist/js/modern/{tasks → features/build/bundleless}/copy-assets.js +31 -55
  8. package/dist/js/modern/{tasks → features/build/bundleless}/generator-dts/index.js +46 -70
  9. package/dist/js/modern/{tasks → features/build/bundleless}/generator-dts/utils.js +6 -6
  10. package/dist/js/modern/features/build/bundleless/index.js +13 -0
  11. package/dist/js/modern/features/build/bundleless/runBabel.js +269 -0
  12. package/dist/js/modern/features/build/bundleless/style.js +266 -0
  13. package/dist/js/modern/features/build/constants.js +94 -59
  14. package/dist/js/modern/features/build/error.js +150 -0
  15. package/dist/js/modern/features/build/index.js +84 -19
  16. package/dist/js/modern/features/build/legacy-constants.js +99 -0
  17. package/dist/js/modern/features/build/normalize.js +293 -0
  18. package/dist/js/modern/features/build/types.js +0 -0
  19. package/dist/js/modern/features/build/utils.js +29 -137
  20. package/dist/js/modern/index.js +3 -1
  21. package/dist/js/modern/locale/en.js +5 -3
  22. package/dist/js/modern/locale/zh.js +5 -3
  23. package/dist/js/modern/schema/build-config.js +104 -0
  24. package/dist/js/modern/schema/index.js +2 -1
  25. package/dist/js/modern/schema/output.js +18 -9
  26. package/dist/js/modern/schema/source.js +2 -10
  27. package/dist/js/modern/schema/tools.js +6 -0
  28. package/dist/js/modern/schema/types.js +0 -0
  29. package/dist/js/modern/utils/babel.js +6 -3
  30. package/dist/js/modern/utils/constants.js +3 -0
  31. package/dist/js/node/cli/build.js +5 -4
  32. package/dist/js/node/commands/build.js +50 -29
  33. package/dist/js/node/features/build/bundle/index.js +17 -0
  34. package/dist/js/node/features/build/bundle/runRollup.js +174 -0
  35. package/dist/js/node/features/build/bundle/runSpeedy.js +209 -0
  36. package/dist/js/node/{tasks → features/build/bundleless}/copy-assets.js +37 -55
  37. package/dist/js/node/{tasks → features/build/bundleless}/generator-dts/index.js +59 -73
  38. package/dist/js/node/{tasks → features/build/bundleless}/generator-dts/utils.js +6 -6
  39. package/dist/js/node/features/build/bundleless/index.js +26 -0
  40. package/dist/js/node/features/build/bundleless/runBabel.js +309 -0
  41. package/dist/js/node/features/build/bundleless/style.js +299 -0
  42. package/dist/js/node/features/build/constants.js +115 -67
  43. package/dist/js/node/features/build/error.js +175 -0
  44. package/dist/js/node/features/build/index.js +92 -19
  45. package/dist/js/node/features/build/legacy-constants.js +107 -0
  46. package/dist/js/node/features/build/normalize.js +322 -0
  47. package/dist/js/node/features/build/types.js +0 -0
  48. package/dist/js/node/features/build/utils.js +31 -145
  49. package/dist/js/node/index.js +5 -1
  50. package/dist/js/node/locale/en.js +5 -3
  51. package/dist/js/node/locale/zh.js +5 -3
  52. package/dist/js/node/schema/build-config.js +113 -0
  53. package/dist/js/node/schema/index.js +3 -1
  54. package/dist/js/node/schema/output.js +20 -9
  55. package/dist/js/node/schema/source.js +2 -10
  56. package/dist/js/node/schema/tools.js +13 -0
  57. package/dist/js/node/schema/types.js +0 -0
  58. package/dist/js/node/utils/babel.js +5 -2
  59. package/dist/js/node/utils/constants.js +11 -0
  60. package/dist/types/cli/build.d.ts +1 -1
  61. package/dist/types/cli/new.d.ts +1 -1
  62. package/dist/types/commands/build.d.ts +12 -12
  63. package/dist/types/features/build/bundle/index.d.ts +3 -0
  64. package/dist/types/features/build/bundle/runRollup.d.ts +3 -0
  65. package/dist/types/features/build/bundle/runSpeedy.d.ts +10 -0
  66. package/dist/types/features/build/bundleless/copy-assets.d.ts +3 -0
  67. package/dist/types/features/build/bundleless/generator-dts/index.d.ts +3 -0
  68. package/dist/types/{tasks → features/build/bundleless}/generator-dts/utils.d.ts +3 -6
  69. package/dist/types/features/build/bundleless/index.d.ts +4 -0
  70. package/dist/types/features/build/bundleless/runBabel.d.ts +32 -0
  71. package/dist/types/features/build/bundleless/style.d.ts +25 -0
  72. package/dist/types/features/build/constants.d.ts +17 -13
  73. package/dist/types/features/build/error.d.ts +33 -0
  74. package/dist/types/features/build/index.d.ts +4 -3
  75. package/dist/types/features/build/legacy-constants.d.ts +8 -0
  76. package/dist/types/features/build/logger/loggerManager.d.ts +2 -0
  77. package/dist/types/features/build/normalize.d.ts +18 -0
  78. package/dist/types/features/build/types.d.ts +15 -0
  79. package/dist/types/features/build/utils.d.ts +9 -31
  80. package/dist/types/locale/en.d.ts +2 -0
  81. package/dist/types/locale/index.d.ts +4 -0
  82. package/dist/types/locale/zh.d.ts +2 -0
  83. package/dist/types/schema/build-config.d.ts +179 -0
  84. package/dist/types/schema/index.d.ts +166 -18
  85. package/dist/types/schema/output.d.ts +170 -10
  86. package/dist/types/schema/source.d.ts +2 -11
  87. package/dist/types/schema/tools.d.ts +6 -0
  88. package/dist/types/schema/types.d.ts +45 -0
  89. package/dist/types/types.d.ts +29 -28
  90. package/dist/types/utils/babel.d.ts +3 -2
  91. package/dist/types/utils/constants.d.ts +2 -0
  92. package/dist/types/utils/logger.d.ts +2 -0
  93. package/package.json +29 -16
  94. package/dist/js/modern/features/build/build-watch.js +0 -101
  95. package/dist/js/modern/features/build/build.js +0 -123
  96. package/dist/js/modern/tasks/build-source-code.js +0 -207
  97. package/dist/js/modern/tasks/build-style.js +0 -168
  98. package/dist/js/modern/tasks/build-watch-source-code.js +0 -161
  99. package/dist/js/modern/tasks/build-watch-style.js +0 -215
  100. package/dist/js/modern/tasks/constants.js +0 -1
  101. package/dist/js/node/features/build/build-watch.js +0 -121
  102. package/dist/js/node/features/build/build.js +0 -143
  103. package/dist/js/node/tasks/build-source-code.js +0 -233
  104. package/dist/js/node/tasks/build-style.js +0 -183
  105. package/dist/js/node/tasks/build-watch-source-code.js +0 -173
  106. package/dist/js/node/tasks/build-watch-style.js +0 -232
  107. package/dist/js/node/tasks/constants.js +0 -8
  108. package/dist/types/features/build/build-watch.d.ts +0 -3
  109. package/dist/types/features/build/build.d.ts +0 -3
  110. package/dist/types/tasks/build-source-code.d.ts +0 -25
  111. package/dist/types/tasks/build-style.d.ts +0 -1
  112. package/dist/types/tasks/build-watch-source-code.d.ts +0 -1
  113. package/dist/types/tasks/build-watch-style.d.ts +0 -1
  114. package/dist/types/tasks/constants.d.ts +0 -1
  115. package/dist/types/tasks/copy-assets.d.ts +0 -1
  116. package/dist/types/tasks/generator-dts/index.d.ts +0 -1
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.targets = exports.presets = exports.buildSchema = void 0;
7
+ const targets = ['es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', // The default target is esnext which means that by default, assume all of the latest JavaScript and CSS features are supported.
8
+ 'esnext'];
9
+ exports.targets = targets;
10
+ const presets = ['npm-library', 'npm-library-with-umd', 'npm-component', 'npm-component-with-umd', ...['npm-library', 'npm-library-with-umd', 'npm-component', 'npm-component-with-umd'].reduce((ret, crt) => {
11
+ return [...ret, ...targets.map(t => `${crt}-${t}`)];
12
+ }, [])];
13
+ exports.presets = presets;
14
+ const properties = {
15
+ target: {
16
+ enum: targets
17
+ },
18
+ format: {
19
+ enum: ['cjs', 'esm', 'umd']
20
+ },
21
+ sourceMap: {
22
+ enum: [true, false, 'inline', 'external']
23
+ },
24
+ buildType: {
25
+ enum: ['bundle', 'bundleless']
26
+ },
27
+ bundleOptions: {
28
+ type: 'object',
29
+ properties: {
30
+ entry: {
31
+ type: 'object'
32
+ },
33
+ splitting: {
34
+ type: 'boolean'
35
+ },
36
+ externals: {
37
+ type: 'array',
38
+ items: [{
39
+ type: 'string'
40
+ }]
41
+ },
42
+ platform: {
43
+ enum: ['node', 'browser']
44
+ },
45
+ minify: {
46
+ enum: ['esbuild', 'terser', false]
47
+ }
48
+ }
49
+ },
50
+ bundlelessOptions: {
51
+ type: 'object',
52
+ properties: {
53
+ sourceDir: {
54
+ type: 'string'
55
+ },
56
+ style: {
57
+ type: 'object',
58
+ properties: {
59
+ compileMode: {
60
+ enum: ['all', 'only-compiled-code', 'only-source-code', false]
61
+ },
62
+ path: {
63
+ type: 'string'
64
+ }
65
+ }
66
+ },
67
+ static: {
68
+ type: 'object',
69
+ properties: {
70
+ path: {
71
+ type: 'string'
72
+ }
73
+ }
74
+ }
75
+ }
76
+ },
77
+ tsconfig: {
78
+ type: 'string'
79
+ },
80
+ enableDts: {
81
+ type: 'boolean'
82
+ },
83
+ dtsOnly: {
84
+ type: 'boolean'
85
+ },
86
+ outputPath: {
87
+ type: 'string'
88
+ }
89
+ };
90
+ const buildSchema = [{
91
+ target: 'output.buildConfig',
92
+ schema: {
93
+ if: {
94
+ type: 'array'
95
+ },
96
+ then: {
97
+ items: [{
98
+ type: 'object',
99
+ properties
100
+ }]
101
+ },
102
+ else: {
103
+ type: 'object',
104
+ properties
105
+ }
106
+ }
107
+ }, {
108
+ target: 'output.buildPreset',
109
+ schema: {
110
+ enum: presets
111
+ }
112
+ }];
113
+ exports.buildSchema = buildSchema;
@@ -9,6 +9,8 @@ var _source = require("./source");
9
9
 
10
10
  var _output = require("./output");
11
11
 
12
- const addSchema = () => [..._source.sourceSchema, ..._output.outputSchema];
12
+ var _tools = require("./tools");
13
+
14
+ const addSchema = () => [..._source.sourceSchema, ..._output.outputSchema, ..._tools.toolsSchema];
13
15
 
14
16
  exports.addSchema = addSchema;
@@ -4,34 +4,45 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.outputSchema = void 0;
7
+
8
+ var _buildConfig = require("./build-config");
9
+
7
10
  const PACKAGE_MODE_LIST = ['universal-js', 'universal-js-lite', 'browser-js', 'browser-js-lite', 'node-js'];
8
- const outputSchema = [{
11
+ const outputSchema = [
12
+ /** packageMode will deprecated */
13
+ {
9
14
  target: 'output.packageMode',
10
15
  schema: {
11
16
  enum: PACKAGE_MODE_LIST
12
17
  }
13
- }, {
18
+ },
19
+ /** packageFields will deprecated */
20
+ {
14
21
  target: 'output.packageFields',
15
22
  schema: {
16
23
  typeof: 'object'
17
24
  }
18
- }, {
25
+ },
26
+ /** enableSourceMap will deprecated */
27
+ {
19
28
  target: 'output.enableSourceMap',
20
29
  schema: {
21
30
  typeof: 'boolean'
22
31
  }
23
- }, {
32
+ },
33
+ /** importStyle will deprecated */
34
+ {
24
35
  target: 'output.importStyle',
25
36
  schema: {
26
- enum: ['compiled-code', 'source-code'],
27
- // TODO: 目前default是无效的
28
- default: 'source-code'
37
+ enum: ['compiled-code', 'source-code']
29
38
  }
30
- }, {
39
+ },
40
+ /** assetsPath will deprecated */
41
+ {
31
42
  target: 'output.assetsPath',
32
43
  schema: {
33
44
  typeof: 'string',
34
45
  default: 'styles'
35
46
  }
36
- }];
47
+ }, ..._buildConfig.buildSchema];
37
48
  exports.outputSchema = outputSchema;
@@ -4,19 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.sourceSchema = void 0;
7
- const sourceSchema = [// 启动区块运行时
8
- {
9
- target: 'source.enableBlockRuntime',
10
- schema: {
11
- type: 'boolean'
12
- }
13
- }, {
7
+ const sourceSchema = [{
14
8
  target: 'source.jsxTransformRuntime',
15
9
  schema: {
16
10
  // https://babeljs.io/docs/en/babel-preset-react#runtime
17
- enum: ['classic', 'automatic'],
18
- // TODO: 目前default是无效的
19
- default: 'automatic'
11
+ enum: ['classic', 'automatic']
20
12
  }
21
13
  }];
22
14
  exports.sourceSchema = sourceSchema;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.toolsSchema = void 0;
7
+ const toolsSchema = [{
8
+ target: 'tools.speedy',
9
+ schema: {
10
+ typeof: ['object', 'function']
11
+ }
12
+ }];
13
+ exports.toolsSchema = toolsSchema;
File without changes
@@ -37,7 +37,7 @@ const getFinalAlias = (modernConfig, option) => {
37
37
 
38
38
  exports.getFinalAlias = getFinalAlias;
39
39
 
40
- const resolveBabelConfig = (appDirectory, modernConfig, option) => {
40
+ const resolveBabelConfig = (appDirectory, modernConfig, sourceMap, bundlelessOptions, option) => {
41
41
  const {
42
42
  source: {
43
43
  envVars,
@@ -72,6 +72,8 @@ const resolveBabelConfig = (appDirectory, modernConfig, option) => {
72
72
  lodashOptions,
73
73
  jsxTransformRuntime,
74
74
  importStyle,
75
+ styleDir: bundlelessOptions.style.path,
76
+ staticDir: bundlelessOptions.static.path,
75
77
  styledComponentsOptions: (0, _utils.applyOptionsChain)({
76
78
  pure: true,
77
79
  displayName: true,
@@ -84,8 +86,9 @@ const resolveBabelConfig = (appDirectory, modernConfig, option) => {
84
86
  }); // Preventing warning when files are too large
85
87
 
86
88
  internalBabelConfig.compact = false;
89
+ internalBabelConfig.sourceMaps = sourceMap === 'external' ? true : sourceMap;
87
90
  const userBabelConfig = modernConfig.tools.babel;
88
- return (0, _utils.applyOptionsChain)(internalBabelConfig, userBabelConfig);
91
+ return (0, _babelPresetModule.applyUserBabelConfig)(internalBabelConfig, userBabelConfig);
89
92
  };
90
93
 
91
94
  exports.resolveBabelConfig = resolveBabelConfig;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.tempTsconfigName = exports.cliTsConfigDefaultValue = void 0;
7
+ // generator tsconfig file
8
+ const tempTsconfigName = 'tsconfig.temp.json';
9
+ exports.tempTsconfigName = tempTsconfigName;
10
+ const cliTsConfigDefaultValue = './tsconfig.json';
11
+ exports.cliTsConfigDefaultValue = cliTsConfigDefaultValue;
@@ -1,3 +1,3 @@
1
1
  import { Command } from '@modern-js/utils';
2
2
  import type { PluginAPI } from '@modern-js/core';
3
- export declare const buildCli: (program: Command, api: PluginAPI) => void;
3
+ export declare const buildCli: (program: Command, api: PluginAPI) => Command;
@@ -1,2 +1,2 @@
1
1
  import { Command } from '@modern-js/utils';
2
- export declare const newCli: (program: Command, locale?: string | undefined) => void;
2
+ export declare const newCli: (program: Command, locale?: string) => void;
@@ -1,18 +1,18 @@
1
1
  import type { PluginAPI } from '@modern-js/core';
2
2
  import type { Platform } from '../types';
3
- export interface IBuildOption {
4
- watch: boolean;
3
+ /**
4
+ * init work before build task.
5
+ * @param api
6
+ */
7
+
8
+ export declare const init: (api: PluginAPI) => void;
9
+ export interface IBuildCommandOption {
10
+ watch?: boolean;
5
11
  tsconfig: string;
6
- platform: boolean | Exclude<Platform, 'all'>;
7
- styleOnly: boolean;
12
+ platform?: boolean | Exclude<Platform, 'all'>;
13
+ styleOnly?: boolean;
8
14
  tsc: boolean;
15
+ dts?: boolean;
9
16
  clear: boolean;
10
17
  }
11
- export declare const build: (api: PluginAPI, {
12
- watch,
13
- tsconfig: tsconfigName,
14
- tsc,
15
- clear,
16
- platform,
17
- styleOnly
18
- }: IBuildOption) => Promise<void>;
18
+ export declare const build: (api: PluginAPI, buildCommandOption: IBuildCommandOption) => Promise<void>;
@@ -0,0 +1,3 @@
1
+ import type { PluginAPI } from '@modern-js/core';
2
+ import type { NormalizedBundleBuildConfig } from '../types';
3
+ export declare const build: (api: PluginAPI, config: NormalizedBundleBuildConfig) => Promise<void>;
@@ -0,0 +1,3 @@
1
+ import type { PluginAPI } from '@modern-js/core';
2
+ import type { NormalizedBundleBuildConfig } from '../types';
3
+ export declare const startRollup: (api: PluginAPI, options: NormalizedBundleBuildConfig) => Promise<void>;
@@ -0,0 +1,10 @@
1
+ import type { PluginAPI } from '@modern-js/core';
2
+ import { NormalizedBundleBuildConfig } from '../types';
3
+ export declare type ResolveAlias = {
4
+ [index: string]: string;
5
+ };
6
+ export declare const getAlias: (api: PluginAPI) => {};
7
+ export declare const getDefine: (api: PluginAPI) => {
8
+ [x: string]: string;
9
+ };
10
+ export declare const runSpeedy: (api: PluginAPI, config: NormalizedBundleBuildConfig) => Promise<void>;
@@ -0,0 +1,3 @@
1
+ import type { PluginAPI } from '@modern-js/core';
2
+ import { NormalizedBundlelessBuildConfig } from '../types';
3
+ export declare const copyStaticAssets: (api: PluginAPI, config: NormalizedBundlelessBuildConfig) => Promise<void>;
@@ -0,0 +1,3 @@
1
+ import type { PluginAPI } from '@modern-js/core';
2
+ import type { NormalizedBundlelessBuildConfig } from '../../types';
3
+ export declare const genDts: (api: PluginAPI, config: NormalizedBundlelessBuildConfig) => Promise<void>;
@@ -1,12 +1,9 @@
1
1
  import type { NormalizedConfig } from '@modern-js/core';
2
- import type { ITsconfig } from '../../types';
2
+ import type { ITsconfig } from '../../../../types';
3
3
  export interface IGeneratorConfig {
4
- sourceDirName?: string;
5
- srcDir: string;
4
+ appDirectory: string;
5
+ sourceDir?: string;
6
6
  distDir: string;
7
- projectData: {
8
- appDirectory: string;
9
- };
10
7
  tsconfigPath?: string;
11
8
  tsCheck?: boolean;
12
9
  watch?: boolean;
@@ -0,0 +1,4 @@
1
+ import type { PluginAPI } from '@modern-js/core';
2
+ import type { NormalizedBundlelessBuildConfig } from '../types';
3
+ import type { IBuildFeatOption } from '../../../types';
4
+ export declare const build: (api: PluginAPI, config: NormalizedBundlelessBuildConfig, legacyOptions?: IBuildFeatOption) => Promise<void>;
@@ -0,0 +1,32 @@
1
+ import type { PluginAPI } from '@modern-js/core';
2
+ import type { BabelOptions, ICompilerResult, BuildWatchEmitter, ICompilerMessageDetail } from '@modern-js/babel-compiler';
3
+ import type { NormalizedBundlelessBuildConfig } from '../types';
4
+ import type { ITsconfig } from '../../../types';
5
+ export declare class BabelBuildError extends Error {
6
+ readonly summary?: string;
7
+ readonly details?: ICompilerMessageDetail[];
8
+ constructor(message: string, opts?: {
9
+ summary?: string;
10
+ details?: ICompilerMessageDetail[];
11
+ });
12
+ toString(): string;
13
+ formatError(): string[];
14
+ }
15
+ interface IBuildSourceCodeConfig {
16
+ appDirectory: string;
17
+ watch?: boolean;
18
+ babelConfig: BabelOptions;
19
+ srcRootDir: string;
20
+ willCompilerDirOrFile: string;
21
+ distDir: string;
22
+ tsconfigPath: string;
23
+ }
24
+ export declare const getWillCompilerCode: (srcDirOrFile: string, option: {
25
+ tsconfig: ITsconfig | null;
26
+ isTsProject: boolean;
27
+ }) => string[];
28
+ export declare const buildSourceCode: (config: IBuildSourceCodeConfig) => Promise<ICompilerResult | BuildWatchEmitter>;
29
+ export declare const jsFileSuffix: string[];
30
+ export declare const haveNotAnyJsFile: (sourceDir: string) => Promise<boolean>;
31
+ export declare const runBabelBuild: (api: PluginAPI, config: NormalizedBundlelessBuildConfig) => Promise<void>;
32
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { PluginAPI } from '@modern-js/core';
2
+ import type { BuildWatchEmitter, ICompilerResult, SingleFileCompilerResult, LessOption, PostcssOption, SassOptions } from '@modern-js/style-compiler';
3
+ import type { NormalizedBundlelessBuildConfig } from '../types';
4
+ export declare class StyleBuildError extends Error {
5
+ readonly summary?: string;
6
+ readonly details?: SingleFileCompilerResult[];
7
+ constructor(message: string, opts?: {
8
+ summary?: string;
9
+ details?: SingleFileCompilerResult[];
10
+ });
11
+ toString(): string;
12
+ formatError(): string[];
13
+ }
14
+ export declare const runBuild: (option: {
15
+ appDirectory: string;
16
+ srcDir: string;
17
+ outDir: string;
18
+ watch: boolean;
19
+ lessOption: LessOption | undefined;
20
+ sassOption: SassOptions<'sync'> | undefined;
21
+ postcssOption: PostcssOption;
22
+ }) => Promise<BuildWatchEmitter | ICompilerResult | undefined>;
23
+ export declare const styleFileSuffix: string[];
24
+ export declare const haveNotAnyStyles: (sourceDir: string) => Promise<boolean>;
25
+ export declare const buildStyle: (api: PluginAPI, config: NormalizedBundlelessBuildConfig) => Promise<void>;
@@ -1,14 +1,18 @@
1
- import type { IPackageModeValue } from '../../types';
2
- export declare const DEFAULT_PACKAGE_MODE = "universal-js";
3
- export declare const PACKAGE_MODES: {
4
- 'universal-js': IPackageModeValue[];
5
- 'universal-js-lite': IPackageModeValue[];
6
- 'browser-js': IPackageModeValue[];
7
- 'browser-js-lite': IPackageModeValue[];
8
- 'node-js': IPackageModeValue[];
1
+ import type { BaseBuildConfig, Target } from '../../schema/types';
2
+ export declare const clearFlag = "\u001Bc";
3
+ export declare const buildingText: string;
4
+ export declare const buildSuccessText: string;
5
+ export declare const buildFailText: string;
6
+ export declare const targets: Target[];
7
+ export declare const npmLibraryPresetConfig: BaseBuildConfig[];
8
+ export declare const npmLibraryWithUmdPresetConfig: BaseBuildConfig[];
9
+ export declare const npmComponentPresetConfig: BaseBuildConfig[];
10
+ export declare const npmComponentWithUmdPresetConfig: BaseBuildConfig[];
11
+ export declare const unPresetConfigs: {
12
+ 'npm-library': BaseBuildConfig[];
13
+ 'npm-library-with-umd': BaseBuildConfig[];
14
+ 'npm-component': BaseBuildConfig[];
15
+ 'npm-component-with-umd': BaseBuildConfig[];
9
16
  };
10
- export declare const runBabelCompilerTitle = "Run babel compiler code log";
11
- export declare const runTscWatchTitle = "Run `tsc -w` log";
12
- export declare const runTscTitle = "Run `tsc` log";
13
- export declare const runStyleCompilerTitle = "Run style compiler code log";
14
- export declare const clearFlag = "\u001Bc";
17
+ export declare const unPresets: ("npm-library" | "npm-library-with-umd" | "npm-component" | "npm-component-with-umd")[];
18
+ export declare const unPresetWithTargetConfigs: Record<string, BaseBuildConfig[]>;
@@ -0,0 +1,33 @@
1
+ import type { ExecaError } from '@modern-js/utils';
2
+ import type { BuildType, Format, Target } from '../../schema/types';
3
+ export declare const padSpaceWith: (str: string, targetL: number, opts?: {
4
+ endStr?: string | undefined;
5
+ style?: ((s: string) => string) | undefined;
6
+ }) => string;
7
+ export declare class InternalBuildError extends Error {
8
+ buildType: BuildType;
9
+ target: Target;
10
+ format: Format;
11
+ private e;
12
+ constructor(e: Error, opts: {
13
+ buildType: BuildType;
14
+ format: Format;
15
+ target: Target;
16
+ });
17
+ toString(): string;
18
+ formatError(): string[];
19
+ }
20
+ export declare class InternalDTSError extends Error {
21
+ buildType: BuildType;
22
+ private e;
23
+ constructor(e: Error | ExecaError, opts: {
24
+ buildType: BuildType;
25
+ });
26
+ toString(): string;
27
+ formatError(): string[];
28
+ }
29
+ export declare class ModuleBuildError extends Error {
30
+ constructor(e: InternalBuildError | InternalDTSError);
31
+ }
32
+ export declare const isInternalError: (e: unknown) => e is InternalBuildError | InternalDTSError;
33
+ export declare const isExecaError: (e: any) => e is ExecaError<string>;
@@ -1,3 +1,4 @@
1
- import type { NormalizedConfig, PluginAPI } from '@modern-js/core';
2
- import type { IBuildConfig } from '../../types';
3
- export declare const build: (api: PluginAPI, config: IBuildConfig, modernConfig: NormalizedConfig) => Promise<void>;
1
+ import type { PluginAPI } from '@modern-js/core';
2
+ import type { IBuildFeatOption } from '../../types';
3
+ export declare const buildInNormalMode: (buildTasks: Promise<void>[]) => Promise<void>;
4
+ export declare const build: (api: PluginAPI, config: IBuildFeatOption) => Promise<void>;
@@ -0,0 +1,8 @@
1
+ export declare const DEFAULT_PACKAGE_MODE = "universal-js";
2
+ export declare const PACKAGE_MODES: {
3
+ 'universal-js': import("../../schema/types").BaseBuildConfig[];
4
+ 'universal-js-lite': import("../../schema/types").BaseBuildConfig[];
5
+ 'browser-js': import("../../schema/types").BaseBuildConfig[];
6
+ 'browser-js-lite': import("../../schema/types").BaseBuildConfig[];
7
+ 'node-js': import("../../schema/types").BaseBuildConfig[];
8
+ };
@@ -1,4 +1,6 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
2
4
 
3
5
  /**
4
6
  * 1. 注册构建任务
@@ -0,0 +1,18 @@
1
+ import type { PluginAPI } from '@modern-js/core';
2
+ import type { BuildConfig, BaseBuildConfig, SourceMap } from '../../schema/types';
3
+ import type { IBuildFeatOption } from '../../types';
4
+ import type { NormalizedBuildConfig } from './types';
5
+ export declare const getNormalizeModuleConfigByPackageModeAndFileds: (api: PluginAPI, buildFeatOption: IBuildFeatOption) => BuildConfig;
6
+ export declare const getFinalTsconfig: (config: {
7
+ tsconfig?: string;
8
+ }, buildFeatOption: IBuildFeatOption) => string;
9
+ export declare const getFinalDts: (config: Pick<BaseBuildConfig, 'enableDts'>, buildFeatOption: IBuildFeatOption) => boolean;
10
+ export declare const getSourceMap: (config: Pick<BaseBuildConfig, 'sourceMap'>, buildType: BaseBuildConfig['buildType'], api: PluginAPI) => SourceMap;
11
+ export declare const normalizeBuildConfig: (context: {
12
+ buildFeatOption: IBuildFeatOption;
13
+ api: PluginAPI;
14
+ }, buildConfig: BuildConfig) => NormalizedBuildConfig[];
15
+ export declare const normalizeModuleConfig: (context: {
16
+ buildFeatOption: IBuildFeatOption;
17
+ api: PluginAPI;
18
+ }) => NormalizedBuildConfig[];
@@ -0,0 +1,15 @@
1
+ import type { BaseBuildConfig, BundlelessOptions, BundleOptions } from '../../schema/types';
2
+ export declare type NormalizedBuildConfig = NormalizedBundleBuildConfig | NormalizedBundlelessBuildConfig;
3
+ export declare type CommonNormalizedBuildConfig = Required<Omit<BaseBuildConfig, 'bundleOptions' | 'bundlelessOptions'>> & {
4
+ watch?: boolean;
5
+ };
6
+ export declare type NormalizedBundleBuildConfig = {
7
+ buildType: 'bundle';
8
+ } & CommonNormalizedBuildConfig & {
9
+ bundleOptions: BundleOptions;
10
+ };
11
+ export declare type NormalizedBundlelessBuildConfig = {
12
+ buildType: 'bundleless';
13
+ } & CommonNormalizedBuildConfig & {
14
+ bundlelessOptions: Required<BundlelessOptions>;
15
+ };
@@ -1,29 +1,5 @@
1
- import type { PluginAPI } from '@modern-js/core';
2
- import type { IBuildConfig, IPackageModeValue, ITaskMapper } from '../../types';
3
- import type { LoggerText } from './logger';
4
- export declare const getCodeInitMapper: (api: PluginAPI, _: IBuildConfig) => IPackageModeValue[];
5
- export declare const getCodeMapper: (api: PluginAPI, {
6
- logger,
7
- taskPath,
8
- config,
9
- initMapper,
10
- srcRootDir,
11
- willCompilerDirOrFile
12
- }: ITaskMapper & {
13
- config: IBuildConfig;
14
- initMapper: IPackageModeValue[];
15
- srcRootDir: string;
16
- willCompilerDirOrFile: string;
17
- }) => {
18
- logger: LoggerText | null;
19
- taskPath: string;
20
- params: string[];
21
- }[];
22
- export declare const getDtsMapper: (api: PluginAPI, config: IBuildConfig, logger: LoggerText) => {
23
- logger: LoggerText;
24
- taskPath: string;
25
- params: string[];
26
- }[];
1
+ import type { NormalizedConfig } from '@modern-js/core';
2
+ import type { PostcssOption } from '@modern-js/style-compiler';
27
3
  /**
28
4
  * 处理日志信息
29
5
  */
@@ -52,8 +28,10 @@ export declare const logTemplate: (title: string, messageStack: string[], maxLen
52
28
  leftBorder?: string | undefined;
53
29
  contentColor?: ((s: string) => string) | undefined;
54
30
  }) => string;
55
- export declare class TimeCounter {
56
- static _now: number;
57
- static time(): void;
58
- static timeEnd(): string;
59
- }
31
+ export declare enum SectionTitleStatus {
32
+ Success = 0,
33
+ Fail = 1,
34
+ Log = 2,
35
+ }
36
+ export declare const watchSectionTitle: (str: string, status: SectionTitleStatus) => string;
37
+ export declare const getPostcssOption: (appDirectory: string, modernConfig: NormalizedConfig) => PostcssOption;
@@ -7,7 +7,9 @@ export declare const EN_LOCALE: {
7
7
  style_only: string;
8
8
  platform: string;
9
9
  no_tsc: string;
10
+ dts: string;
10
11
  no_clear: string;
12
+ config: string;
11
13
  };
12
14
  dev: {
13
15
  describe: string;
@@ -8,7 +8,9 @@ declare const localeKeys: {
8
8
  style_only: string;
9
9
  platform: string;
10
10
  no_tsc: string;
11
+ dts: string;
11
12
  no_clear: string;
13
+ config: string;
12
14
  };
13
15
  dev: {
14
16
  describe: string;
@@ -30,7 +32,9 @@ declare const localeKeys: {
30
32
  style_only: string;
31
33
  platform: string;
32
34
  no_tsc: string;
35
+ dts: string;
33
36
  no_clear: string;
37
+ config: string;
34
38
  };
35
39
  dev: {
36
40
  describe: string;
@@ -7,7 +7,9 @@ export declare const ZH_LOCALE: {
7
7
  style_only: string;
8
8
  platform: string;
9
9
  no_tsc: string;
10
+ dts: string;
10
11
  no_clear: string;
12
+ config: string;
11
13
  };
12
14
  dev: {
13
15
  describe: string;