@modern-js/builder 2.46.0 → 3.0.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 (121) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +14 -16
  3. package/compiled/postcss-load-config/index.d.ts +1 -0
  4. package/compiled/postcss-load-config/index.js +14 -0
  5. package/compiled/postcss-load-config/license +20 -0
  6. package/compiled/postcss-load-config/package.json +1 -0
  7. package/dist/createBuilder.d.ts +8 -2
  8. package/dist/createBuilder.js +124 -39
  9. package/dist/index.d.ts +8 -4
  10. package/dist/index.js +18 -7
  11. package/dist/plugins/babel-post.d.ts +5 -0
  12. package/dist/plugins/{asset.js → babel-post.js} +21 -22
  13. package/dist/plugins/devtools.d.ts +4 -0
  14. package/dist/plugins/{devtool.js → devtools.js} +15 -16
  15. package/dist/plugins/emitRouteFile.d.ts +6 -0
  16. package/dist/plugins/{cleanOutput.js → emitRouteFile.js} +34 -16
  17. package/dist/plugins/environmentDefaults.d.ts +3 -0
  18. package/dist/plugins/environmentDefaults.js +99 -0
  19. package/dist/plugins/globalVars.d.ts +3 -0
  20. package/dist/plugins/{moment.js → globalVars.js} +23 -16
  21. package/dist/plugins/htmlMinify.d.ts +2 -0
  22. package/dist/plugins/htmlMinify.js +126 -0
  23. package/dist/plugins/manifest.d.ts +2 -0
  24. package/dist/plugins/{entry.js → manifest.js} +18 -16
  25. package/dist/plugins/postcss.d.ts +6 -0
  26. package/dist/plugins/postcss.js +133 -0
  27. package/dist/plugins/runtimeChunk.d.ts +2 -0
  28. package/dist/plugins/runtimeChunk.js +55 -0
  29. package/dist/rsc/common.d.ts +22 -0
  30. package/dist/rsc/common.js +174 -0
  31. package/dist/rsc/plugins/rsbuild-rsc-plugin.d.ts +7 -0
  32. package/dist/rsc/plugins/rsbuild-rsc-plugin.js +166 -0
  33. package/dist/rsc/plugins/rspack-rsc-client-plugin.d.ts +14 -0
  34. package/dist/rsc/plugins/rspack-rsc-client-plugin.js +233 -0
  35. package/dist/rsc/plugins/rspack-rsc-server-plugin.d.ts +32 -0
  36. package/dist/rsc/plugins/rspack-rsc-server-plugin.js +290 -0
  37. package/dist/rsc/rsc-client-loader.d.ts +7 -0
  38. package/dist/rsc/rsc-client-loader.js +70 -0
  39. package/dist/rsc/rsc-css-loader.d.ts +2 -0
  40. package/dist/{plugins/yaml.js → rsc/rsc-css-loader.js} +11 -17
  41. package/dist/rsc/rsc-server-loader.d.ts +6 -0
  42. package/dist/rsc/rsc-server-loader.js +95 -0
  43. package/dist/rsc/rsc-ssr-loader.d.ts +6 -0
  44. package/dist/rsc/rsc-ssr-loader.js +58 -0
  45. package/dist/shared/devServer.d.ts +6 -0
  46. package/dist/shared/devServer.js +83 -0
  47. package/dist/shared/getCssSupport.d.ts +1 -0
  48. package/dist/shared/getCssSupport.js +113 -0
  49. package/dist/shared/manifest.d.ts +2 -0
  50. package/dist/{plugins/toml.js → shared/manifest.js} +16 -14
  51. package/dist/shared/parseCommonConfig.d.ts +8 -0
  52. package/dist/shared/parseCommonConfig.js +232 -0
  53. package/dist/shared/utils.d.ts +12 -0
  54. package/dist/shared/utils.js +109 -0
  55. package/dist/types.d.ts +283 -0
  56. package/dist/types.js +16 -0
  57. package/package.json +54 -59
  58. package/dist/cli/commands.d.ts +0 -2
  59. package/dist/cli/commands.js +0 -45
  60. package/dist/cli/config.d.ts +0 -14
  61. package/dist/cli/config.js +0 -72
  62. package/dist/cli/index.d.ts +0 -6
  63. package/dist/cli/index.js +0 -51
  64. package/dist/cli/provider.d.ts +0 -2
  65. package/dist/cli/provider.js +0 -73
  66. package/dist/plugins/antd.d.ts +0 -3
  67. package/dist/plugins/antd.js +0 -63
  68. package/dist/plugins/arco.d.ts +0 -2
  69. package/dist/plugins/arco.js +0 -61
  70. package/dist/plugins/asset.d.ts +0 -2
  71. package/dist/plugins/assetsRetry.d.ts +0 -2
  72. package/dist/plugins/assetsRetry.js +0 -64
  73. package/dist/plugins/bundleAnalyzer.d.ts +0 -2
  74. package/dist/plugins/bundleAnalyzer.js +0 -59
  75. package/dist/plugins/cache.d.ts +0 -2
  76. package/dist/plugins/cache.js +0 -129
  77. package/dist/plugins/checkSyntax.d.ts +0 -2
  78. package/dist/plugins/checkSyntax.js +0 -73
  79. package/dist/plugins/cleanOutput.d.ts +0 -2
  80. package/dist/plugins/define.d.ts +0 -2
  81. package/dist/plugins/define.js +0 -68
  82. package/dist/plugins/devtool.d.ts +0 -2
  83. package/dist/plugins/entry.d.ts +0 -2
  84. package/dist/plugins/externals.d.ts +0 -2
  85. package/dist/plugins/externals.js +0 -48
  86. package/dist/plugins/fileSize.d.ts +0 -4
  87. package/dist/plugins/fileSize.js +0 -164
  88. package/dist/plugins/html.d.ts +0 -3
  89. package/dist/plugins/html.js +0 -236
  90. package/dist/plugins/index.d.ts +0 -2
  91. package/dist/plugins/index.js +0 -74
  92. package/dist/plugins/inlineChunk.d.ts +0 -2
  93. package/dist/plugins/inlineChunk.js +0 -82
  94. package/dist/plugins/moment.d.ts +0 -2
  95. package/dist/plugins/networkPerformance.d.ts +0 -2
  96. package/dist/plugins/networkPerformance.js +0 -54
  97. package/dist/plugins/nodeAddons.d.ts +0 -2
  98. package/dist/plugins/nodeAddons.js +0 -73
  99. package/dist/plugins/performance.d.ts +0 -5
  100. package/dist/plugins/performance.js +0 -66
  101. package/dist/plugins/preloadOrPrefetch.d.ts +0 -2
  102. package/dist/plugins/preloadOrPrefetch.js +0 -57
  103. package/dist/plugins/rem.d.ts +0 -2
  104. package/dist/plugins/rem.js +0 -106
  105. package/dist/plugins/sourceBuild.d.ts +0 -15
  106. package/dist/plugins/sourceBuild.js +0 -121
  107. package/dist/plugins/splitChunks.d.ts +0 -4
  108. package/dist/plugins/splitChunks.js +0 -249
  109. package/dist/plugins/startUrl.d.ts +0 -3
  110. package/dist/plugins/startUrl.js +0 -86
  111. package/dist/plugins/svg.d.ts +0 -2
  112. package/dist/plugins/svg.js +0 -89
  113. package/dist/plugins/target.d.ts +0 -2
  114. package/dist/plugins/target.js +0 -73
  115. package/dist/plugins/toml.d.ts +0 -2
  116. package/dist/plugins/tsChecker.d.ts +0 -2
  117. package/dist/plugins/tsChecker.js +0 -109
  118. package/dist/plugins/wasm.d.ts +0 -2
  119. package/dist/plugins/wasm.js +0 -51
  120. package/dist/plugins/yaml.d.ts +0 -2
  121. package/vitest.config.ts +0 -19
@@ -0,0 +1,283 @@
1
+ import type { AliasOption } from '@modern-js/utils';
2
+ import type { ConfigChain, ConfigChainWithContext, DevConfig, DistPathConfig, EnvironmentConfig, HtmlConfig, OutputConfig, Polyfill, RsbuildConfig, RsbuildPluginAPI, RsbuildPlugins, RsbuildTarget, Rspack, SecurityConfig, ServerConfig, SourceConfig, ToolsConfig } from '@rsbuild/core';
3
+ import type { PluginAssetsRetryOptions } from '@rsbuild/plugin-assets-retry';
4
+ import type { PluginBabelOptions } from '@rsbuild/plugin-babel';
5
+ import type { PluginCheckSyntaxOptions } from '@rsbuild/plugin-check-syntax';
6
+ import type { PluginCssMinimizerOptions } from '@rsbuild/plugin-css-minimizer';
7
+ import type { PluginLessOptions } from '@rsbuild/plugin-less';
8
+ import type { PluginRemOptions } from '@rsbuild/plugin-rem';
9
+ import type { PluginSassOptions } from '@rsbuild/plugin-sass';
10
+ import type { PluginSourceBuildOptions } from '@rsbuild/plugin-source-build';
11
+ import type { SvgDefaultExport } from '@rsbuild/plugin-svgr';
12
+ import type { PluginTypeCheckerOptions } from '@rsbuild/plugin-type-check';
13
+ import type { Options as AutoprefixerOptions } from 'autoprefixer';
14
+ export type CacheGroup = Rspack.OptimizationSplitChunksCacheGroup;
15
+ export type Stats = Omit<Rspack.Stats, '#private' | 'hash' | 'startTime' | 'endTime'>;
16
+ export type RspackConfig = Rspack.Configuration;
17
+ export type MultiStats = Rspack.MultiStats;
18
+ /**
19
+ * custom properties
20
+ * e.g. { name: 'viewport' content: 'width=500, initial-scale=1' }
21
+ * */
22
+ type MetaAttrs = {
23
+ [attrName: string]: string | boolean;
24
+ };
25
+ export type MetaOptions = {
26
+ /**
27
+ * name content pair
28
+ * e.g. { viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no' }`
29
+ * */
30
+ [name: string]: string | false | MetaAttrs;
31
+ };
32
+ export type CreateBuilderCommonOptions = {
33
+ frameworkConfigPath?: string;
34
+ /** The root path of current project. */
35
+ cwd: string;
36
+ rscClientRuntimePath?: string;
37
+ rscServerRuntimePath?: string;
38
+ internalDirectory?: string;
39
+ };
40
+ export type BundlerType = 'rspack';
41
+ export type CreateBuilderOptions = {
42
+ rscClientRuntimePath?: string;
43
+ rscServerRuntimePath?: string;
44
+ bundlerType: BundlerType;
45
+ config: BuilderConfig;
46
+ } & Partial<CreateBuilderCommonOptions>;
47
+ export type GlobalVars = Record<string, any>;
48
+ export type ChainedGlobalVars = ConfigChainWithContext<GlobalVars, {
49
+ env: string;
50
+ target: RsbuildTarget;
51
+ }>;
52
+ export type MainFields = (string | string[])[];
53
+ export type DevServerHttpsOptions = boolean | {
54
+ key: string;
55
+ cert: string;
56
+ };
57
+ /**
58
+ * @deprecated This configuration is deprecated, please use `dev.server` instead.
59
+ */
60
+ export type ToolsDevServerConfig = ConfigChain<{
61
+ /**
62
+ * @deprecated Use `dev.server.compress` instead.
63
+ */
64
+ compress?: ServerConfig['compress'];
65
+ /**
66
+ * @deprecated Use `dev.server.headers` instead.
67
+ */
68
+ headers?: ServerConfig['headers'];
69
+ /**
70
+ * @deprecated Use `dev.server.historyApiFallback` instead.
71
+ */
72
+ historyApiFallback?: ServerConfig['historyApiFallback'];
73
+ /**
74
+ * @deprecated Use `dev.server.proxy` instead.
75
+ */
76
+ proxy?: ServerConfig['proxy'];
77
+ /**
78
+ * @deprecated Use `dev.server.watch` instead.
79
+ */
80
+ watch?: boolean;
81
+ }>;
82
+ export type ToolsAutoprefixerConfig = ConfigChain<AutoprefixerOptions>;
83
+ export type BuilderExtraConfig = {
84
+ tools?: {
85
+ /**
86
+ * Modify the config of [autoprefixer](https://github.com/postcss/autoprefixer)
87
+ */
88
+ autoprefixer?: ToolsAutoprefixerConfig;
89
+ htmlPlugin?: ToolsConfig['htmlPlugin'];
90
+ /**
91
+ * @deprecated Use `dev.server` instead.
92
+ */
93
+ devServer?: ToolsDevServerConfig;
94
+ /**
95
+ * Modify the options of [fork-ts-checker-webpack-plugin](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin).
96
+ */
97
+ tsChecker?: PluginTypeCheckerOptions['tsCheckerOptions'];
98
+ /**
99
+ * Modify the options of [css-minimizer-webpack-plugin](https://github.com/webpack-contrib/css-minimizer-webpack-plugin).
100
+ */
101
+ minifyCss?: PluginCssMinimizerOptions['pluginOptions'];
102
+ /**
103
+ * Modify the options of [babel-loader](https://github.com/babel/babel-loader)
104
+ * When `tools.babel`'s type is Function,the default babel config will be passed in as the first parameter, the config object can be modified directly, or a value can be returned as the final result.
105
+ * When `tools.babel`'s type is `Object`, the config will be shallow merged with default config by `Object.assign`.
106
+ * Note that `Object.assign` is a shallow copy and will completely overwrite the built-in `presets` or `plugins` array, please use it with caution.
107
+ */
108
+ babel?: PluginBabelOptions['babelLoaderOptions'];
109
+ /**
110
+ * Modify the config of [less-loader](https://github.com/webpack-contrib/less-loader).
111
+ */
112
+ less?: PluginLessOptions['lessLoaderOptions'];
113
+ /**
114
+ * Modify the config of [sass-loader](https://github.com/webpack-contrib/sass-loader).
115
+ */
116
+ sass?: PluginSassOptions['sassLoaderOptions'];
117
+ };
118
+ dev?: {
119
+ /** Set the page URL to open when the server starts. */
120
+ startUrl?: boolean | string | string[];
121
+ /** Execute a callback function before opening the `startUrl`. */
122
+ beforeStartUrl?: () => Promise<void> | void;
123
+ /**
124
+ * Used to set the host of Dev Server.
125
+ */
126
+ host?: string;
127
+ /**
128
+ * After configuring this option, you can enable HTTPS Dev Server, and disabling the HTTP Dev Server.
129
+ */
130
+ https?: DevServerHttpsOptions;
131
+ /**
132
+ * Server configuration for Dev Server.
133
+ */
134
+ server?: {
135
+ compress?: ServerConfig['compress'];
136
+ headers?: ServerConfig['headers'];
137
+ historyApiFallback?: ServerConfig['historyApiFallback'];
138
+ proxy?: ServerConfig['proxy'];
139
+ watch?: boolean;
140
+ };
141
+ };
142
+ source?: {
143
+ transformImport?: SourceConfig['transformImport'] | false;
144
+ alias?: AliasOption;
145
+ /**
146
+ * Define global variables. It can replace expressions like `process.env.FOO` in your code after compile.
147
+ */
148
+ globalVars?: ChainedGlobalVars;
149
+ };
150
+ output?: {
151
+ /**
152
+ * Whether to generate a TypeScript declaration file for CSS Modules.
153
+ */
154
+ enableCssModuleTSDeclaration?: boolean;
155
+ /**
156
+ * Whether to generate a manifest file that contains information of all assets.
157
+ */
158
+ enableAssetManifest?: boolean;
159
+ /**
160
+ * Configure the retry of assets.
161
+ */
162
+ assetsRetry?: PluginAssetsRetryOptions;
163
+ /**
164
+ * Controls whether to the inline the runtime chunk to HTML.
165
+ */
166
+ disableInlineRuntimeChunk?: boolean;
167
+ /**
168
+ * Convert px to rem in CSS.
169
+ */
170
+ convertToRem?: boolean | PluginRemOptions;
171
+ /**
172
+ * Whether to treat all .css files in the source directory as CSS Modules.
173
+ */
174
+ disableCssModuleExtension?: boolean;
175
+ /**
176
+ * Whether to disable TypeScript Type Checker.
177
+ */
178
+ disableTsChecker?: boolean;
179
+ /**
180
+ * Configure the default export type of SVG files.
181
+ */
182
+ svgDefaultExport?: SvgDefaultExport;
183
+ /**
184
+ * Whether to transform SVGs into React components. If true, will treat all .svg files as assets.
185
+ */
186
+ disableSvgr?: boolean;
187
+ };
188
+ html?: {
189
+ appIcon?: HtmlConfig['appIcon'];
190
+ favicon?: string;
191
+ };
192
+ security?: {
193
+ /**
194
+ * Adding an integrity attribute (`integrity`) to sub-resources introduced by HTML allows the browser to
195
+ * verify the integrity of the introduced resource, thus preventing tampering with the downloaded resource.
196
+ *
197
+ * Tips: this configuration is not yet supported in rspack
198
+ */
199
+ sri?: SriOptions | boolean;
200
+ /**
201
+ * Analyze the build artifacts to identify advanced syntax that is incompatible with the current browser scope.
202
+ */
203
+ checkSyntax?: boolean | PluginCheckSyntaxOptions;
204
+ };
205
+ experiments?: {
206
+ /**
207
+ * Enable the ability for source code building
208
+ */
209
+ sourceBuild?: boolean | Pick<PluginSourceBuildOptions, 'sourceField' | 'resolvePriority'>;
210
+ };
211
+ };
212
+ export type SriOptions = {
213
+ hashFuncNames?: [string, ...string[]];
214
+ enabled?: 'auto' | true | false;
215
+ hashLoading?: 'eager' | 'lazy';
216
+ };
217
+ export type BuilderContext = RsbuildPluginAPI['context'] & {
218
+ target: RsbuildTarget[];
219
+ framework: string;
220
+ srcPath: string;
221
+ entry: Record<string, string | string[]>;
222
+ };
223
+ /**
224
+ * make the plugins type looser to avoid type mismatch
225
+ */
226
+ export type BuilderPluginAPI = {
227
+ [key in keyof RsbuildPluginAPI]: any;
228
+ } & {
229
+ /** The following APIs only type incompatibility */
230
+ onBeforeCreateCompiler: (fn: any) => void;
231
+ onAfterCreateCompiler: (fn: any) => void;
232
+ onBeforeBuild: (fn: any) => void;
233
+ modifyBundlerChain: (fn: any) => void;
234
+ getNormalizedConfig: () => any;
235
+ /** The following APIs need to be compatible */
236
+ context: BuilderContext;
237
+ getBuilderConfig: () => Readonly<any>;
238
+ modifyBuilderConfig: (fn: (config: any, utils: {
239
+ mergeBuilderConfig: <T>(...configs: T[]) => T;
240
+ }) => any | Promise<any>) => void;
241
+ };
242
+ export type DistPath = DistPathConfig & {
243
+ server?: string;
244
+ worker?: string;
245
+ };
246
+ export type BuilderConfig = {
247
+ dev?: Omit<DevConfig, 'setupMiddlewares'> & {
248
+ server?: {
249
+ compress?: ServerConfig['compress'];
250
+ headers?: ServerConfig['headers'];
251
+ historyApiFallback?: ServerConfig['historyApiFallback'];
252
+ proxy?: ServerConfig['proxy'];
253
+ watch?: boolean;
254
+ };
255
+ };
256
+ html?: Omit<HtmlConfig, 'appIcon'>;
257
+ output?: Omit<OutputConfig, 'polyfill' | 'distPath'> & {
258
+ polyfill?: Polyfill | 'ua';
259
+ distPath?: DistPath;
260
+ };
261
+ server?: {
262
+ rsc?: boolean;
263
+ port?: number;
264
+ cors?: ServerConfig['cors'];
265
+ };
266
+ performance?: RsbuildConfig['performance'];
267
+ security?: Omit<SecurityConfig, 'sri'>;
268
+ tools?: Omit<ToolsConfig, 'htmlPlugin'>;
269
+ resolve?: RsbuildConfig['resolve'];
270
+ source?: Omit<SourceConfig, 'alias' | 'transformImport'>;
271
+ plugins?: RsbuildPlugins;
272
+ environments?: {
273
+ [key: string]: EnvironmentConfig & {
274
+ tools?: {
275
+ /**
276
+ * Modify the options of [babel-loader](https://github.com/babel/babel-loader)
277
+ */
278
+ babel?: PluginBabelOptions['babelLoaderOptions'];
279
+ };
280
+ };
281
+ };
282
+ } & BuilderExtraConfig;
283
+ export {};
package/dist/types.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
package/package.json CHANGED
@@ -1,84 +1,79 @@
1
1
  {
2
2
  "name": "@modern-js/builder",
3
- "description": "Builder of modern.js.",
4
- "homepage": "https://modernjs.dev",
5
- "bugs": "https://github.com/web-infra-dev/modern.js/issues",
3
+ "version": "3.0.0-alpha.0",
4
+ "description": "A builder for Modern.js",
6
5
  "repository": {
7
6
  "type": "git",
8
7
  "url": "https://github.com/web-infra-dev/modern.js",
9
- "directory": "packages/builder/builder"
8
+ "directory": "packages/cli/builder"
10
9
  },
11
10
  "license": "MIT",
12
- "keywords": [
13
- "react",
14
- "framework",
15
- "modern",
16
- "modern.js"
17
- ],
18
- "engines": {
19
- "node": ">=14.0.0"
20
- },
21
- "version": "2.46.0",
22
- "jsnext:source": "./src/index.ts",
23
- "types": "./dist/index.d.ts",
24
- "main": "./dist/index.js",
25
- "module": "./dist/index.js",
11
+ "type": "commonjs",
26
12
  "exports": {
27
13
  ".": {
28
14
  "types": "./dist/index.d.ts",
29
- "jsnext:source": "./src/index.ts",
30
15
  "default": "./dist/index.js"
31
- },
32
- "./cli": {
33
- "types": "./dist/cli/index.d.ts",
34
- "jsnext:source": "./src/cli/index.ts",
35
- "default": "./dist/cli/index.js"
36
- },
37
- "./plugins/*": {
38
- "types": "./dist/plugins/*.d.ts",
39
- "jsnext:source": "./src/plugins/*.ts",
40
- "default": "./dist/plugins/*.js"
41
- }
42
- },
43
- "typesVersions": {
44
- "*": {
45
- "cli": [
46
- "./dist/cli/index.d.ts"
47
- ],
48
- "plugins/*": [
49
- "./dist/plugins/*.d.ts"
50
- ]
51
16
  }
52
17
  },
18
+ "main": "./dist/index.js",
19
+ "types": "./dist/index.d.ts",
20
+ "files": [
21
+ "compiled",
22
+ "dist"
23
+ ],
53
24
  "dependencies": {
54
- "@rsbuild/monorepo-utils": "0.3.3",
55
- "@svgr/webpack": "8.1.0",
56
- "@swc/helpers": "0.5.3",
57
- "deepmerge": "^4.3.1",
58
- "jiti": "^1.20.0",
59
- "@modern-js/builder-shared": "2.46.0",
60
- "@modern-js/utils": "2.46.0"
25
+ "@rsbuild/core": "1.6.15",
26
+ "@rsbuild/plugin-assets-retry": "1.5.0",
27
+ "@rsbuild/plugin-babel": "1.0.6",
28
+ "@rsbuild/plugin-check-syntax": "1.6.0",
29
+ "@rsbuild/plugin-css-minimizer": "1.1.0",
30
+ "@rsbuild/plugin-less": "1.5.0",
31
+ "@rsbuild/plugin-react": "1.4.2",
32
+ "@rsbuild/plugin-rem": "1.0.4",
33
+ "@rsbuild/plugin-sass": "1.4.0",
34
+ "@rsbuild/plugin-source-build": "1.0.3",
35
+ "@rsbuild/plugin-svgr": "1.2.3",
36
+ "@rsbuild/plugin-type-check": "1.3.2",
37
+ "@rsbuild/plugin-typed-css-modules": "1.2.0",
38
+ "@swc/core": "1.14.0",
39
+ "@swc/helpers": "^0.5.17",
40
+ "autoprefixer": "10.4.23",
41
+ "browserslist": "4.28.1",
42
+ "cssnano": "6.1.2",
43
+ "html-minifier-terser": "^7.2.0",
44
+ "jiti": "1.21.7",
45
+ "lodash": "^4.17.21",
46
+ "postcss": "^8.5.6",
47
+ "postcss-custom-properties": "13.3.12",
48
+ "postcss-flexbugs-fixes": "5.0.2",
49
+ "postcss-font-variant": "5.0.0",
50
+ "postcss-initial": "4.0.1",
51
+ "postcss-media-minmax": "5.0.0",
52
+ "postcss-nesting": "12.1.5",
53
+ "postcss-page-break": "3.0.4",
54
+ "rspack-manifest-plugin": "5.1.0",
55
+ "ts-deepmerge": "7.0.3",
56
+ "@modern-js/flight-server-transform-plugin": "3.0.0-alpha.0",
57
+ "@modern-js/utils": "3.0.0-alpha.0"
61
58
  },
62
59
  "devDependencies": {
63
- "@types/babel__core": "^7.20.1",
64
- "@types/node": "^14",
65
- "typescript": "^5",
66
- "@modern-js/builder-rspack-provider": "2.46.0",
67
- "@modern-js/builder-webpack-provider": "2.46.0",
68
- "@scripts/build": "2.46.0",
69
- "@scripts/vitest-config": "2.46.0"
60
+ "@types/html-minifier-terser": "^7.0.2",
61
+ "@types/lodash": "^4.17.21",
62
+ "react": "^19.2.3",
63
+ "terser": "^5.44.1",
64
+ "typescript": "^5.3.0",
65
+ "@modern-js/types": "3.0.0-alpha.0",
66
+ "@scripts/rstest-config": "2.66.0",
67
+ "@scripts/build": "2.66.0"
70
68
  },
71
69
  "publishConfig": {
72
- "registry": "https://registry.npmjs.org/",
73
70
  "access": "public",
74
- "provenance": true
71
+ "registry": "https://registry.npmjs.org/"
75
72
  },
76
73
  "scripts": {
77
- "new": "modern new",
78
74
  "build": "modern-lib build",
79
75
  "dev": "modern-lib build --watch",
80
- "test": "vitest run",
81
- "test:watch": "vitest dev",
82
- "test:ui": "vitest --ui"
76
+ "test": "rstest run",
77
+ "test:watch": "rstest watch"
83
78
  }
84
79
  }
@@ -1,2 +0,0 @@
1
- import type { BuilderInstance } from '..';
2
- export declare function setupProgram(builder: BuilderInstance): void;
@@ -1,45 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var commands_exports = {};
20
- __export(commands_exports, {
21
- setupProgram: () => setupProgram
22
- });
23
- module.exports = __toCommonJS(commands_exports);
24
- var import_path = require("path");
25
- var import_utils = require("@modern-js/utils");
26
- var import_commander = require("@modern-js/utils/commander");
27
- function setupProgram(builder) {
28
- const pkgJson = (0, import_path.join)(__dirname, "../../package.json");
29
- const { version } = import_utils.fs.readJSONSync(pkgJson);
30
- import_commander.program.name("builder").usage("<command> [options]").version(version);
31
- import_commander.program.command("dev").description("starting the dev server").action(async () => {
32
- await builder.startDevServer();
33
- });
34
- import_commander.program.command("build").description("build the app for production").action(async () => {
35
- await builder.build();
36
- });
37
- import_commander.program.command("serve").description("preview the production build locally").action(async () => {
38
- await builder.serve();
39
- });
40
- import_commander.program.parse();
41
- }
42
- // Annotate the CommonJS export names for ESM import in node:
43
- 0 && (module.exports = {
44
- setupProgram
45
- });
@@ -1,14 +0,0 @@
1
- import type { BuilderEntry, BuilderPlugin } from '@modern-js/builder-shared';
2
- import type { BuilderConfig as WebpackBuilderConfig } from '@modern-js/builder-webpack-provider';
3
- import type { BuilderConfig as RspackBuilderConfig } from '@modern-js/builder-rspack-provider';
4
- export type BuilderConfig<Bundler extends 'rspack' | 'webpack' = 'webpack'> = (Bundler extends 'webpack' ? WebpackBuilderConfig : RspackBuilderConfig) & {
5
- source?: {
6
- entries?: BuilderEntry;
7
- };
8
- builderPlugins?: BuilderPlugin[];
9
- };
10
- export declare const defineConfig: <Bundler extends "webpack" | "rspack" = "webpack">(config: BuilderConfig<Bundler>) => BuilderConfig<Bundler>;
11
- export declare function loadConfig(): Promise<BuilderConfig>;
12
- export declare function getDefaultEntries(): {
13
- index: string;
14
- };
@@ -1,72 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var config_exports = {};
30
- __export(config_exports, {
31
- defineConfig: () => defineConfig,
32
- getDefaultEntries: () => getDefaultEntries,
33
- loadConfig: () => loadConfig
34
- });
35
- module.exports = __toCommonJS(config_exports);
36
- var import_jiti = __toESM(require("jiti"));
37
- var import_path = require("path");
38
- var import_utils = require("@modern-js/utils");
39
- var import_fs_extra = require("@modern-js/utils/fs-extra");
40
- const defineConfig = (config) => config;
41
- async function loadConfig() {
42
- const configFile = (0, import_path.join)(process.cwd(), "builder.config.ts");
43
- if ((0, import_fs_extra.existsSync)(configFile)) {
44
- const loadConfig2 = (0, import_jiti.default)(__filename, {
45
- interopDefault: true
46
- });
47
- return loadConfig2(configFile);
48
- }
49
- return {};
50
- }
51
- function getDefaultEntries() {
52
- const cwd = process.cwd();
53
- const files = [
54
- "ts",
55
- "tsx",
56
- "js",
57
- "jsx"
58
- ].map((ext) => (0, import_path.join)(cwd, `src/index.${ext}`));
59
- const entryFile = (0, import_utils.findExists)(files);
60
- if (entryFile) {
61
- return {
62
- index: entryFile
63
- };
64
- }
65
- throw new Error("Could not find the entry file, please make sure that `src/index.(js|ts|tsx|jsx)` exists, or customize entry through the `source.entries` configuration.");
66
- }
67
- // Annotate the CommonJS export names for ESM import in node:
68
- 0 && (module.exports = {
69
- defineConfig,
70
- getDefaultEntries,
71
- loadConfig
72
- });
@@ -1,6 +0,0 @@
1
- import { BuilderPlugin } from '..';
2
- export { defineConfig } from './config';
3
- type RunCliOptions = {
4
- defaultPlugins?: BuilderPlugin[];
5
- };
6
- export declare function runCli(options?: RunCliOptions): Promise<void>;
package/dist/cli/index.js DELETED
@@ -1,51 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var cli_exports = {};
20
- __export(cli_exports, {
21
- defineConfig: () => import_config2.defineConfig,
22
- runCli: () => runCli
23
- });
24
- module.exports = __toCommonJS(cli_exports);
25
- var import__ = require("..");
26
- var import_commands = require("./commands");
27
- var import_provider = require("./provider");
28
- var import_config = require("./config");
29
- var import_config2 = require("./config");
30
- async function runCli(options = {}) {
31
- var _config_source;
32
- const provider = await (0, import_provider.loadProvider)();
33
- const config = await (0, import_config.loadConfig)();
34
- const builder = await (0, import__.createBuilder)(provider({
35
- builderConfig: config
36
- }), {
37
- entry: ((_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.entries) || (0, import_config.getDefaultEntries)()
38
- });
39
- if (options.defaultPlugins) {
40
- builder.addPlugins(options.defaultPlugins);
41
- }
42
- if (config.builderPlugins) {
43
- builder.addPlugins(config.builderPlugins);
44
- }
45
- (0, import_commands.setupProgram)(builder);
46
- }
47
- // Annotate the CommonJS export names for ESM import in node:
48
- 0 && (module.exports = {
49
- defineConfig,
50
- runCli
51
- });
@@ -1,2 +0,0 @@
1
- export declare function getProviderType(): "webpack" | "rspack";
2
- export declare function loadProvider(): Promise<typeof import("@modern-js/builder-rspack-provider").builderRspackProvider | typeof import("@modern-js/builder-webpack-provider").builderWebpackProvider>;