@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,179 @@
1
+ export declare const targets: string[];
2
+ export declare const presets: string[];
3
+ export declare const buildSchema: ({
4
+ target: string;
5
+ schema: {
6
+ if: {
7
+ type: string;
8
+ };
9
+ then: {
10
+ items: {
11
+ type: string;
12
+ properties: {
13
+ target: {
14
+ enum: string[];
15
+ };
16
+ format: {
17
+ enum: string[];
18
+ };
19
+ sourceMap: {
20
+ enum: (string | boolean)[];
21
+ };
22
+ buildType: {
23
+ enum: string[];
24
+ };
25
+ bundleOptions: {
26
+ type: string;
27
+ properties: {
28
+ entry: {
29
+ type: string;
30
+ };
31
+ splitting: {
32
+ type: string;
33
+ };
34
+ externals: {
35
+ type: string;
36
+ items: {
37
+ type: string;
38
+ }[];
39
+ };
40
+ platform: {
41
+ enum: string[];
42
+ };
43
+ minify: {
44
+ enum: (string | boolean)[];
45
+ };
46
+ };
47
+ };
48
+ bundlelessOptions: {
49
+ type: string;
50
+ properties: {
51
+ sourceDir: {
52
+ type: string;
53
+ };
54
+ style: {
55
+ type: string;
56
+ properties: {
57
+ compileMode: {
58
+ enum: (string | boolean)[];
59
+ };
60
+ path: {
61
+ type: string;
62
+ };
63
+ };
64
+ };
65
+ static: {
66
+ type: string;
67
+ properties: {
68
+ path: {
69
+ type: string;
70
+ };
71
+ };
72
+ };
73
+ };
74
+ };
75
+ tsconfig: {
76
+ type: string;
77
+ };
78
+ enableDts: {
79
+ type: string;
80
+ };
81
+ dtsOnly: {
82
+ type: string;
83
+ };
84
+ outputPath: {
85
+ type: string;
86
+ };
87
+ };
88
+ }[];
89
+ };
90
+ else: {
91
+ type: string;
92
+ properties: {
93
+ target: {
94
+ enum: string[];
95
+ };
96
+ format: {
97
+ enum: string[];
98
+ };
99
+ sourceMap: {
100
+ enum: (string | boolean)[];
101
+ };
102
+ buildType: {
103
+ enum: string[];
104
+ };
105
+ bundleOptions: {
106
+ type: string;
107
+ properties: {
108
+ entry: {
109
+ type: string;
110
+ };
111
+ splitting: {
112
+ type: string;
113
+ };
114
+ externals: {
115
+ type: string;
116
+ items: {
117
+ type: string;
118
+ }[];
119
+ };
120
+ platform: {
121
+ enum: string[];
122
+ };
123
+ minify: {
124
+ enum: (string | boolean)[];
125
+ };
126
+ };
127
+ };
128
+ bundlelessOptions: {
129
+ type: string;
130
+ properties: {
131
+ sourceDir: {
132
+ type: string;
133
+ };
134
+ style: {
135
+ type: string;
136
+ properties: {
137
+ compileMode: {
138
+ enum: (string | boolean)[];
139
+ };
140
+ path: {
141
+ type: string;
142
+ };
143
+ };
144
+ };
145
+ static: {
146
+ type: string;
147
+ properties: {
148
+ path: {
149
+ type: string;
150
+ };
151
+ };
152
+ };
153
+ };
154
+ };
155
+ tsconfig: {
156
+ type: string;
157
+ };
158
+ enableDts: {
159
+ type: string;
160
+ };
161
+ dtsOnly: {
162
+ type: string;
163
+ };
164
+ outputPath: {
165
+ type: string;
166
+ };
167
+ };
168
+ };
169
+ enum?: undefined;
170
+ };
171
+ } | {
172
+ target: string;
173
+ schema: {
174
+ enum: string[];
175
+ if?: undefined;
176
+ then?: undefined;
177
+ else?: undefined;
178
+ };
179
+ })[];
@@ -1,43 +1,191 @@
1
1
  export declare const addSchema: () => ({
2
- target: string;
3
- schema: {
4
- type: string;
5
- enum?: undefined;
6
- default?: undefined;
7
- };
8
- } | {
9
2
  target: string;
10
3
  schema: {
11
4
  enum: string[];
12
- default: string;
13
- type?: undefined;
14
5
  };
15
6
  } | {
16
7
  target: string;
17
8
  schema: {
18
- enum: string[];
19
- typeof?: undefined;
20
- default?: undefined;
9
+ if: {
10
+ type: string;
11
+ };
12
+ then: {
13
+ items: {
14
+ type: string;
15
+ properties: {
16
+ target: {
17
+ enum: string[];
18
+ };
19
+ format: {
20
+ enum: string[];
21
+ };
22
+ sourceMap: {
23
+ enum: (string | boolean)[];
24
+ };
25
+ buildType: {
26
+ enum: string[];
27
+ };
28
+ bundleOptions: {
29
+ type: string;
30
+ properties: {
31
+ entry: {
32
+ type: string;
33
+ };
34
+ splitting: {
35
+ type: string;
36
+ };
37
+ externals: {
38
+ type: string;
39
+ items: {
40
+ type: string;
41
+ }[];
42
+ };
43
+ platform: {
44
+ enum: string[];
45
+ };
46
+ minify: {
47
+ enum: (string | boolean)[];
48
+ };
49
+ };
50
+ };
51
+ bundlelessOptions: {
52
+ type: string;
53
+ properties: {
54
+ sourceDir: {
55
+ type: string;
56
+ };
57
+ style: {
58
+ type: string;
59
+ properties: {
60
+ compileMode: {
61
+ enum: (string | boolean)[];
62
+ };
63
+ path: {
64
+ type: string;
65
+ };
66
+ };
67
+ };
68
+ static: {
69
+ type: string;
70
+ properties: {
71
+ path: {
72
+ type: string;
73
+ };
74
+ };
75
+ };
76
+ };
77
+ };
78
+ tsconfig: {
79
+ type: string;
80
+ };
81
+ enableDts: {
82
+ type: string;
83
+ };
84
+ dtsOnly: {
85
+ type: string;
86
+ };
87
+ outputPath: {
88
+ type: string;
89
+ };
90
+ };
91
+ }[];
92
+ };
93
+ else: {
94
+ type: string;
95
+ properties: {
96
+ target: {
97
+ enum: string[];
98
+ };
99
+ format: {
100
+ enum: string[];
101
+ };
102
+ sourceMap: {
103
+ enum: (string | boolean)[];
104
+ };
105
+ buildType: {
106
+ enum: string[];
107
+ };
108
+ bundleOptions: {
109
+ type: string;
110
+ properties: {
111
+ entry: {
112
+ type: string;
113
+ };
114
+ splitting: {
115
+ type: string;
116
+ };
117
+ externals: {
118
+ type: string;
119
+ items: {
120
+ type: string;
121
+ }[];
122
+ };
123
+ platform: {
124
+ enum: string[];
125
+ };
126
+ minify: {
127
+ enum: (string | boolean)[];
128
+ };
129
+ };
130
+ };
131
+ bundlelessOptions: {
132
+ type: string;
133
+ properties: {
134
+ sourceDir: {
135
+ type: string;
136
+ };
137
+ style: {
138
+ type: string;
139
+ properties: {
140
+ compileMode: {
141
+ enum: (string | boolean)[];
142
+ };
143
+ path: {
144
+ type: string;
145
+ };
146
+ };
147
+ };
148
+ static: {
149
+ type: string;
150
+ properties: {
151
+ path: {
152
+ type: string;
153
+ };
154
+ };
155
+ };
156
+ };
157
+ };
158
+ tsconfig: {
159
+ type: string;
160
+ };
161
+ enableDts: {
162
+ type: string;
163
+ };
164
+ dtsOnly: {
165
+ type: string;
166
+ };
167
+ outputPath: {
168
+ type: string;
169
+ };
170
+ };
171
+ };
172
+ enum?: undefined;
21
173
  };
22
174
  } | {
23
175
  target: string;
24
176
  schema: {
25
177
  typeof: string;
26
- enum?: undefined;
27
178
  default?: undefined;
28
179
  };
29
180
  } | {
30
181
  target: string;
31
182
  schema: {
32
- enum: string[];
183
+ typeof: string;
33
184
  default: string;
34
- typeof?: undefined;
35
185
  };
36
186
  } | {
37
187
  target: string;
38
188
  schema: {
39
- typeof: string;
40
- default: string;
41
- enum?: undefined;
189
+ typeof: string[];
42
190
  };
43
191
  })[];
@@ -1,29 +1,189 @@
1
1
  export declare const outputSchema: ({
2
2
  target: string;
3
3
  schema: {
4
- enum: string[];
5
- typeof?: undefined;
6
- default?: undefined;
4
+ if: {
5
+ type: string;
6
+ };
7
+ then: {
8
+ items: {
9
+ type: string;
10
+ properties: {
11
+ target: {
12
+ enum: string[];
13
+ };
14
+ format: {
15
+ enum: string[];
16
+ };
17
+ sourceMap: {
18
+ enum: (string | boolean)[];
19
+ };
20
+ buildType: {
21
+ enum: string[];
22
+ };
23
+ bundleOptions: {
24
+ type: string;
25
+ properties: {
26
+ entry: {
27
+ type: string;
28
+ };
29
+ splitting: {
30
+ type: string;
31
+ };
32
+ externals: {
33
+ type: string;
34
+ items: {
35
+ type: string;
36
+ }[];
37
+ };
38
+ platform: {
39
+ enum: string[];
40
+ };
41
+ minify: {
42
+ enum: (string | boolean)[];
43
+ };
44
+ };
45
+ };
46
+ bundlelessOptions: {
47
+ type: string;
48
+ properties: {
49
+ sourceDir: {
50
+ type: string;
51
+ };
52
+ style: {
53
+ type: string;
54
+ properties: {
55
+ compileMode: {
56
+ enum: (string | boolean)[];
57
+ };
58
+ path: {
59
+ type: string;
60
+ };
61
+ };
62
+ };
63
+ static: {
64
+ type: string;
65
+ properties: {
66
+ path: {
67
+ type: string;
68
+ };
69
+ };
70
+ };
71
+ };
72
+ };
73
+ tsconfig: {
74
+ type: string;
75
+ };
76
+ enableDts: {
77
+ type: string;
78
+ };
79
+ dtsOnly: {
80
+ type: string;
81
+ };
82
+ outputPath: {
83
+ type: string;
84
+ };
85
+ };
86
+ }[];
87
+ };
88
+ else: {
89
+ type: string;
90
+ properties: {
91
+ target: {
92
+ enum: string[];
93
+ };
94
+ format: {
95
+ enum: string[];
96
+ };
97
+ sourceMap: {
98
+ enum: (string | boolean)[];
99
+ };
100
+ buildType: {
101
+ enum: string[];
102
+ };
103
+ bundleOptions: {
104
+ type: string;
105
+ properties: {
106
+ entry: {
107
+ type: string;
108
+ };
109
+ splitting: {
110
+ type: string;
111
+ };
112
+ externals: {
113
+ type: string;
114
+ items: {
115
+ type: string;
116
+ }[];
117
+ };
118
+ platform: {
119
+ enum: string[];
120
+ };
121
+ minify: {
122
+ enum: (string | boolean)[];
123
+ };
124
+ };
125
+ };
126
+ bundlelessOptions: {
127
+ type: string;
128
+ properties: {
129
+ sourceDir: {
130
+ type: string;
131
+ };
132
+ style: {
133
+ type: string;
134
+ properties: {
135
+ compileMode: {
136
+ enum: (string | boolean)[];
137
+ };
138
+ path: {
139
+ type: string;
140
+ };
141
+ };
142
+ };
143
+ static: {
144
+ type: string;
145
+ properties: {
146
+ path: {
147
+ type: string;
148
+ };
149
+ };
150
+ };
151
+ };
152
+ };
153
+ tsconfig: {
154
+ type: string;
155
+ };
156
+ enableDts: {
157
+ type: string;
158
+ };
159
+ dtsOnly: {
160
+ type: string;
161
+ };
162
+ outputPath: {
163
+ type: string;
164
+ };
165
+ };
166
+ };
167
+ enum?: undefined;
7
168
  };
8
169
  } | {
9
170
  target: string;
10
171
  schema: {
11
- typeof: string;
12
- enum?: undefined;
13
- default?: undefined;
172
+ enum: string[];
173
+ if?: undefined;
174
+ then?: undefined;
175
+ else?: undefined;
14
176
  };
15
177
  } | {
16
178
  target: string;
17
179
  schema: {
18
- enum: string[];
19
- default: string;
20
- typeof?: undefined;
180
+ typeof: string;
181
+ default?: undefined;
21
182
  };
22
183
  } | {
23
184
  target: string;
24
185
  schema: {
25
186
  typeof: string;
26
187
  default: string;
27
- enum?: undefined;
28
188
  };
29
189
  })[];
@@ -1,15 +1,6 @@
1
- export declare const sourceSchema: ({
2
- target: string;
3
- schema: {
4
- type: string;
5
- enum?: undefined;
6
- default?: undefined;
7
- };
8
- } | {
1
+ export declare const sourceSchema: {
9
2
  target: string;
10
3
  schema: {
11
4
  enum: string[];
12
- default: string;
13
- type?: undefined;
14
5
  };
15
- })[];
6
+ }[];
@@ -0,0 +1,6 @@
1
+ export declare const toolsSchema: {
2
+ target: string;
3
+ schema: {
4
+ typeof: string[];
5
+ };
6
+ }[];
@@ -0,0 +1,45 @@
1
+ import type { UserConfig as SpeedyConfig } from '@speedy-js/speedy-core';
2
+ export declare type Format = 'esm' | 'cjs' | 'umd';
3
+ export declare type Target = 'es5' | 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'esnext';
4
+ export declare type BuildType = 'bundle' | 'bundleless';
5
+ export declare type SourceMap = boolean | 'inline' | 'external';
6
+ export declare type BundleOptions = {
7
+ entry?: Record<string, string>;
8
+ platform?: SpeedyConfig['platform'];
9
+ splitting?: boolean;
10
+ minify?: SpeedyConfig['minify'];
11
+ externals?: SpeedyConfig['external'];
12
+ };
13
+ export declare type BundlelessOptions = {
14
+ sourceDir?: string;
15
+ style?: {
16
+ compileMode?: 'all' | 'only-compiled-code' |
17
+ /* may be will be deprecated */
18
+ 'only-source-code' | false;
19
+ path?: string;
20
+ };
21
+ static?: {
22
+ path?: string;
23
+ };
24
+ };
25
+ export declare type BaseBuildConfig = {
26
+ format?: Format;
27
+ target?: Target;
28
+ sourceMap?: SourceMap;
29
+ buildType?: BuildType;
30
+ bundleOptions?: BundleOptions;
31
+ bundlelessOptions?: BundlelessOptions;
32
+ tsconfig?: string;
33
+ enableDts?: boolean;
34
+ dtsOnly?: boolean;
35
+ outputPath?: string;
36
+ };
37
+ export declare type BuildConfig = BaseBuildConfig | BaseBuildConfig[];
38
+ export declare type BuildPreset = 'npm-library' | 'npm-library-with-umd' | 'npm-component' | 'npm-component-with-umd';
39
+ export declare type JsSyntaxType = 'CJS+ES6' | 'ESM+ES5' | 'ESM+ES6';
40
+ export interface PackageFields {
41
+ main?: JsSyntaxType;
42
+ 'jsnext:modern'?: JsSyntaxType;
43
+ module?: JsSyntaxType;
44
+ }
45
+ export declare type PackageModeType = 'universal-js' | 'universal-js-lite' | 'browser-js' | 'browser-js-lite' | 'node-js';