@modern-js/app-tools 2.45.0 → 2.45.1-alpha.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 (91) hide show
  1. package/dist/cjs/analyze/generateCode.js +1 -0
  2. package/dist/cjs/analyze/index.js +5 -1
  3. package/dist/cjs/analyze/nestedRoutes.js +1 -1
  4. package/dist/cjs/analyze/templates.js +0 -2
  5. package/dist/cjs/analyze/utils.js +1 -0
  6. package/dist/cjs/builder/builder-rspack/index.js +1 -2
  7. package/dist/cjs/builder/builder-webpack/createCopyPattern.js +2 -0
  8. package/dist/cjs/builder/builder-webpack/index.js +3 -4
  9. package/dist/cjs/builder/generator/createBuilderOptions.js +2 -3
  10. package/dist/cjs/builder/generator/createBuilderProviderConfig.js +1 -0
  11. package/dist/cjs/builder/generator/index.js +9 -8
  12. package/dist/cjs/builder/index.js +2 -10
  13. package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +1 -3
  14. package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +3 -3
  15. package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +4 -4
  16. package/dist/cjs/commands/dev.js +0 -1
  17. package/dist/cjs/config/default.js +12 -12
  18. package/dist/cjs/initialize/index.js +1 -1
  19. package/dist/esm/analyze/generateCode.js +1 -0
  20. package/dist/esm/analyze/index.js +5 -1
  21. package/dist/esm/analyze/nestedRoutes.js +1 -1
  22. package/dist/esm/analyze/templates.js +1 -1
  23. package/dist/esm/analyze/utils.js +1 -0
  24. package/dist/esm/builder/builder-rspack/index.js +1 -2
  25. package/dist/esm/builder/builder-webpack/createCopyPattern.js +2 -0
  26. package/dist/esm/builder/builder-webpack/index.js +5 -6
  27. package/dist/esm/builder/generator/createBuilderOptions.js +2 -3
  28. package/dist/esm/builder/generator/createBuilderProviderConfig.js +1 -0
  29. package/dist/esm/builder/generator/index.js +14 -12
  30. package/dist/esm/builder/index.js +5 -30
  31. package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +1 -3
  32. package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +1 -1
  33. package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +3 -3
  34. package/dist/esm/commands/dev.js +0 -1
  35. package/dist/esm/config/default.js +20 -15
  36. package/dist/esm/initialize/index.js +1 -1
  37. package/dist/esm-node/analyze/generateCode.js +1 -0
  38. package/dist/esm-node/analyze/index.js +5 -1
  39. package/dist/esm-node/analyze/nestedRoutes.js +1 -1
  40. package/dist/esm-node/analyze/templates.js +0 -2
  41. package/dist/esm-node/analyze/utils.js +1 -0
  42. package/dist/esm-node/builder/builder-rspack/index.js +1 -2
  43. package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +2 -0
  44. package/dist/esm-node/builder/builder-webpack/index.js +3 -4
  45. package/dist/esm-node/builder/generator/createBuilderOptions.js +2 -3
  46. package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +1 -0
  47. package/dist/esm-node/builder/generator/index.js +9 -8
  48. package/dist/esm-node/builder/index.js +2 -10
  49. package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +1 -3
  50. package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +1 -1
  51. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +3 -3
  52. package/dist/esm-node/commands/dev.js +0 -1
  53. package/dist/esm-node/config/default.js +12 -12
  54. package/dist/esm-node/initialize/index.js +1 -1
  55. package/dist/types/analyze/generateCode.d.ts +2 -2
  56. package/dist/types/builder/builder-rspack/adapterCopy.d.ts +2 -3
  57. package/dist/types/builder/builder-rspack/index.d.ts +1 -1
  58. package/dist/types/builder/builder-webpack/adapterModern.d.ts +2 -3
  59. package/dist/types/builder/builder-webpack/createCopyPattern.d.ts +2 -12
  60. package/dist/types/builder/builder-webpack/index.d.ts +1 -3
  61. package/dist/types/builder/generator/createBuilderOptions.d.ts +3 -2
  62. package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +1 -1
  63. package/dist/types/builder/generator/getBuilderTargets.d.ts +2 -2
  64. package/dist/types/builder/generator/index.d.ts +4 -6
  65. package/dist/types/builder/index.d.ts +1 -1
  66. package/dist/types/builder/shared/builderPlugins/adapterBasic.d.ts +2 -3
  67. package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +3 -3
  68. package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +3 -3
  69. package/dist/types/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.d.ts +1 -3
  70. package/dist/types/builder/shared/bundlerPlugins/HtmlBottomTemplate.d.ts +1 -3
  71. package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +3 -5
  72. package/dist/types/builder/shared/loaders/serverModuleLoader.d.ts +1 -2
  73. package/dist/types/builder/shared/types.d.ts +0 -7
  74. package/dist/types/commands/inspect.d.ts +1 -8
  75. package/dist/types/config/default.d.ts +1 -1
  76. package/dist/types/config/initialize/inits.d.ts +1 -1
  77. package/dist/types/defineConfig.d.ts +1 -1
  78. package/dist/types/types/config/dev.d.ts +2 -2
  79. package/dist/types/types/config/experiments.d.ts +2 -2
  80. package/dist/types/types/config/html.d.ts +3 -5
  81. package/dist/types/types/config/index.d.ts +15 -31
  82. package/dist/types/types/config/output.d.ts +3 -10
  83. package/dist/types/types/config/performance.d.ts +3 -6
  84. package/dist/types/types/config/security.d.ts +2 -7
  85. package/dist/types/types/config/source.d.ts +2 -7
  86. package/dist/types/types/config/tools.d.ts +11 -13
  87. package/dist/types/types/hooks.d.ts +2 -3
  88. package/dist/types/types/index.d.ts +5 -14
  89. package/dist/types/types/legacyConfig/output.d.ts +1 -1
  90. package/dist/types/types/legacyConfig/tools.d.ts +2 -2
  91. package/package.json +11 -21
@@ -2,7 +2,7 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
3
  import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
4
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
5
- import { isHtmlDisabled, createVirtualModule } from "@modern-js/builder-shared";
5
+ import { isHtmlDisabled, createVirtualModule } from "@rsbuild/shared";
6
6
  import { MAIN_ENTRY_NAME, getEntryOptions, removeTailSlash } from "@modern-js/utils";
7
7
  import { template as lodashTemplate } from "@modern-js/utils/lodash";
8
8
  import { BottomTemplatePlugin } from "../bundlerPlugins";
@@ -1,7 +1,7 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import * as path from "path";
4
- import { isHtmlDisabled, mergeBuilderConfig } from "@modern-js/builder-shared";
4
+ import { isHtmlDisabled, mergeRsbuildConfig } from "@rsbuild/shared";
5
5
  import { isSSR, fs } from "@modern-js/utils";
6
6
  import { HtmlAsyncChunkPlugin, RouterPlugin } from "../bundlerPlugins";
7
7
  import { getServerCombinedModueFile } from "../../../analyze/utils";
@@ -10,9 +10,9 @@ var builderPluginAdapterSSR = function(options) {
10
10
  name: "builder-plugin-adapter-modern-ssr",
11
11
  setup: function setup(api) {
12
12
  var normalizedConfig = options.normalizedConfig;
13
- api.modifyBuilderConfig(function(config) {
13
+ api.modifyRsbuildConfig(function(config) {
14
14
  if (isStreamingSSR(normalizedConfig)) {
15
- return mergeBuilderConfig(config, {
15
+ return mergeRsbuildConfig(config, {
16
16
  html: {
17
17
  inject: "body"
18
18
  }
@@ -119,7 +119,6 @@ var dev = function() {
119
119
  return [
120
120
  4,
121
121
  appContext.builder.startDevServer({
122
- printURLs: false,
123
122
  serverOptions
124
123
  })
125
124
  ];
@@ -1,23 +1,28 @@
1
1
  import { _ as _define_property } from "@swc/helpers/_/_define_property";
2
- import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
- import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
- import { createDefaultConfig as createDefaultBuilderConfig } from "@modern-js/builder-webpack-provider";
5
2
  import { MAIN_ENTRY_NAME } from "@modern-js/utils";
6
3
  import { getAutoInjectEnv } from "../utils/env";
7
- function createDefaultConfig(appContext, bundler) {
8
- var defaultBuilderConfig = createDefaultBuilderConfig();
9
- var dev = _object_spread_props(_object_spread({}, defaultBuilderConfig.dev), {
4
+ function createDefaultConfig(appContext) {
5
+ var dev = {
10
6
  // `dev.port` should not have a default value
11
7
  // because we will use `server.port` by default
12
8
  port: void 0
13
- });
14
- var output = _object_spread_props(_object_spread({}, defaultBuilderConfig.output), {
9
+ };
10
+ var output = {
11
+ distPath: {
12
+ root: "dist",
13
+ html: "html",
14
+ js: "static/js",
15
+ css: "static/css",
16
+ server: "bundles",
17
+ worker: "worker"
18
+ },
19
+ cleanDistPath: true,
15
20
  disableNodePolyfill: true,
16
21
  enableInlineRouteManifests: true,
17
22
  disableInlineRouteManifests: false
18
- });
23
+ };
19
24
  var _obj;
20
- var source = _object_spread_props(_object_spread({}, defaultBuilderConfig.source), {
25
+ var source = {
21
26
  entries: void 0,
22
27
  mainEntryName: MAIN_ENTRY_NAME,
23
28
  enableAsyncEntry: false,
@@ -26,9 +31,10 @@ function createDefaultConfig(appContext, bundler) {
26
31
  configDir: "./config",
27
32
  globalVars: getAutoInjectEnv(appContext),
28
33
  alias: (_obj = {}, _define_property(_obj, appContext.internalDirAlias, appContext.internalDirectory), _define_property(_obj, appContext.internalSrcAlias, appContext.srcDirectory), _define_property(_obj, "@", appContext.srcDirectory), _define_property(_obj, "@shared", appContext.sharedDirectory), _obj)
29
- });
30
- var html = _object_spread_props(_object_spread({}, defaultBuilderConfig.html), {
34
+ };
35
+ var html = {
31
36
  title: "",
37
+ mountId: "root",
32
38
  meta: {
33
39
  charset: {
34
40
  charset: "utf-8"
@@ -44,7 +50,7 @@ function createDefaultConfig(appContext, bundler) {
44
50
  "wap-font-scale": "no",
45
51
  "format-detection": "telephone=no"
46
52
  }
47
- });
53
+ };
48
54
  var server = {
49
55
  routes: void 0,
50
56
  publicRoutes: void 0,
@@ -53,7 +59,7 @@ function createDefaultConfig(appContext, bundler) {
53
59
  baseUrl: "/",
54
60
  port: 8080
55
61
  };
56
- var defaultTsCheckerConfig = {
62
+ var tools = {
57
63
  tsChecker: {
58
64
  issue: {
59
65
  include: [
@@ -64,7 +70,6 @@ function createDefaultConfig(appContext, bundler) {
64
70
  }
65
71
  }
66
72
  };
67
- var tools = bundler === "webpack" ? _object_spread({}, defaultBuilderConfig.tools, defaultTsCheckerConfig) : defaultTsCheckerConfig;
68
73
  return {
69
74
  source,
70
75
  output,
@@ -23,7 +23,7 @@ function initialize_default(param) {
23
23
  api.setAppContext(_object_spread_props(_object_spread({}, appContext), {
24
24
  bundlerType: bundler
25
25
  }));
26
- return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext, bundler);
26
+ return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext);
27
27
  };
28
28
  return {
29
29
  config,
@@ -146,6 +146,7 @@ const generateCode = async (appContext, config, entrypoints, api) => {
146
146
  internalDirAlias
147
147
  })
148
148
  });
149
+ console.log("222222222", imports);
149
150
  importsStatemets.set(entryName, imports);
150
151
  const entryFile = path.resolve(internalDirectory, `./${entryName}/${ENTRY_POINT_FILE_NAME}`);
151
152
  entrypoint.internalEntry = entryFile;
@@ -11,6 +11,10 @@ import { checkIsBuildCommands, isPageComponentFile, parseModule, replaceWithAlia
11
11
  import { APP_CONFIG_NAME, APP_INIT_EXPORTED, APP_INIT_IMPORTED } from "./constants";
12
12
  import { generateIndexCode } from "./generateCode";
13
13
  const debug = createDebugger("plugin-analyze");
14
+ const getPathWithoutExt = (filename) => {
15
+ const extname = path.extname(filename);
16
+ return filename.slice(0, -extname.length);
17
+ };
14
18
  var analyze_default = ({ bundler }) => ({
15
19
  name: "@modern-js/plugin-analyze",
16
20
  setup: (api) => {
@@ -183,7 +187,7 @@ var analyze_default = ({ bundler }) => ({
183
187
  filename: rootLayoutFile
184
188
  });
185
189
  const hasAppConfig = moduleExports.some((e) => e.n === APP_CONFIG_NAME);
186
- const generateLayoutPath = replaceWithAlias(srcDirectory, rootLayoutFile, internalSrcAlias);
190
+ const generateLayoutPath = getPathWithoutExt(replaceWithAlias(srcDirectory, rootLayoutFile, internalSrcAlias));
187
191
  if (hasAppConfig) {
188
192
  imports.push({
189
193
  value: generateLayoutPath,
@@ -108,7 +108,7 @@ const walk = async (dirname, rootDir, alias, entryName, isMainEntry, oldVersion)
108
108
  const items = await fs.readdir(dirname);
109
109
  for (const item of items) {
110
110
  const itemPath = path.join(dirname, item);
111
- const itemPathWithAlias = replaceWithAlias(alias.basename, itemPath, alias.name);
111
+ const itemPathWithAlias = getPathWithoutExt(replaceWithAlias(alias.basename, itemPath, alias.name));
112
112
  const extname = path.extname(item);
113
113
  const itemWithoutExt = item.slice(0, -extname.length);
114
114
  const isDirectory2 = (await fs.stat(itemPath)).isDirectory();
@@ -53,8 +53,6 @@ const html = (partials) => `
53
53
  <!DOCTYPE html>
54
54
  <html>
55
55
  <head>
56
- <%= meta %>
57
- <title><%= title %></title>
58
56
 
59
57
  ${partials.top.join("\n")}
60
58
 
@@ -89,6 +89,7 @@ const getDefaultImports = ({ entrypoint, srcDirectory, appDirectory, internalSrc
89
89
  value: normalizeToPosixPath(entry.replace(srcDirectory, internalSrcAlias))
90
90
  });
91
91
  }
92
+ console.log("iiiiiiiiiii", imports);
92
93
  return imports;
93
94
  };
94
95
  const isPageComponentFile = (filePath) => {
@@ -1,8 +1,7 @@
1
- import { builderRspackProvider } from "@modern-js/builder-rspack-provider";
2
1
  import { generateBuilder } from "../generator";
3
2
  import { builderPluginAdpaterCopy } from "./adapterCopy";
4
3
  async function createRspackBuilderForModern(options) {
5
- const builder = await generateBuilder(options, builderRspackProvider);
4
+ const builder = await generateBuilder(options, "rspack");
6
5
  builder.addPlugins([
7
6
  builderPluginAdpaterCopy(options)
8
7
  ]);
@@ -27,6 +27,8 @@ function createPublicPattern(appContext, config, chain) {
27
27
  function createUploadPattern(appContext, config) {
28
28
  const { uploadDir } = createCopyInfo(appContext, config);
29
29
  return {
30
+ // rspack copy info structure is inconsistent with webpack, it only used in webpack mode
31
+ // @ts-expect-error
30
32
  info,
31
33
  from: "**/*",
32
34
  to: "upload",
@@ -1,14 +1,13 @@
1
- import { builderWebpackProvider } from "@modern-js/builder-webpack-provider";
2
1
  import { generateBuilder } from "../generator";
3
2
  import { builderPluginAdapterModern } from "./adapterModern";
4
3
  async function createWebpackBuilderForModern(options) {
5
- const builder = await generateBuilder(options, builderWebpackProvider);
4
+ const builder = await generateBuilder(options, "webpack");
6
5
  const { normalizedConfig } = options;
7
6
  if (normalizedConfig.tools.esbuild) {
8
7
  const { esbuild: esbuildOptions } = normalizedConfig.tools;
9
- const { builderPluginEsbuild } = await import("@modern-js/builder-plugin-esbuild");
8
+ const { pluginEsbuild } = await import("@rsbuild/plugin-esbuild");
10
9
  builder.addPlugins([
11
- builderPluginEsbuild(esbuildOptions)
10
+ pluginEsbuild(esbuildOptions)
12
11
  ]);
13
12
  }
14
13
  builder.addPlugins([
@@ -17,9 +17,8 @@ function createBuilderOptions(target, appContext) {
17
17
  return {
18
18
  cwd: appContext.appDirectory,
19
19
  target,
20
- configPath: appContext.configFile || void 0,
21
- entry: entries,
22
- framework: appContext.metaName
20
+ frameworkConfigPath: appContext.configFile || void 0,
21
+ entry: entries
23
22
  };
24
23
  }
25
24
  export {
@@ -24,6 +24,7 @@ function createBuilderProviderConfig(resolveConfig, appContext) {
24
24
  }
25
25
  const config = {
26
26
  ...resolveConfig,
27
+ plugins: [],
27
28
  dev: {
28
29
  ...resolveConfig.dev,
29
30
  port: appContext.port
@@ -1,16 +1,17 @@
1
- import { createBuilder } from "@modern-js/builder";
1
+ import { createUniBuilder } from "@modern-js/uni-builder";
2
2
  import { createBuilderProviderConfig } from "./createBuilderProviderConfig";
3
3
  import { getBuilderTargets } from "./getBuilderTargets";
4
4
  import { createBuilderOptions } from "./createBuilderOptions";
5
- async function generateBuilder(options, generateProvider) {
5
+ async function generateBuilder(options, bundlerType) {
6
6
  const { normalizedConfig, appContext } = options;
7
7
  const builderConfig = createBuilderProviderConfig(normalizedConfig, appContext);
8
- const provider = generateProvider({
9
- builderConfig
10
- });
11
8
  const target = getBuilderTargets(normalizedConfig);
12
9
  const builderOptions = createBuilderOptions(target, appContext);
13
- const builder = await createBuilder(provider, builderOptions);
10
+ const builder = await createUniBuilder({
11
+ ...builderOptions,
12
+ bundlerType,
13
+ config: builderConfig
14
+ });
14
15
  await applyBuilderPlugins(builder, options);
15
16
  return builder;
16
17
  }
@@ -23,9 +24,9 @@ async function applyBuilderPlugins(builder, options) {
23
24
  ]);
24
25
  const { normalizedConfig } = options;
25
26
  if (!normalizedConfig.output.disableNodePolyfill) {
26
- const { builderPluginNodePolyfill } = await import("@modern-js/builder-plugin-node-polyfill");
27
+ const { pluginNodePolyfill } = await import("@rsbuild/plugin-node-polyfill");
27
28
  builder.addPlugins([
28
- builderPluginNodePolyfill()
29
+ pluginNodePolyfill()
29
30
  ]);
30
31
  }
31
32
  }
@@ -1,15 +1,7 @@
1
- import { logger } from "@modern-js/utils";
2
1
  async function createBuilderGenerator(bundler) {
3
2
  if (bundler === "rspack") {
4
- try {
5
- const { createRspackBuilderForModern } = await import("./builder-rspack");
6
- const { getRspackVersion } = await import("@modern-js/builder-rspack-provider");
7
- const version = await getRspackVersion();
8
- logger.info(`Using Rspack v${version}`);
9
- return createRspackBuilderForModern;
10
- } catch (_) {
11
- throw new Error("Failed to use Rspack, please check if you have `@modern-js/builder-rspack-provider` installed");
12
- }
3
+ const { createRspackBuilderForModern } = await import("./builder-rspack");
4
+ return createRspackBuilderForModern;
13
5
  }
14
6
  const { createWebpackBuilderForModern } = await import("./builder-webpack");
15
7
  return createWebpackBuilderForModern;
@@ -9,15 +9,13 @@ const builderPluginAdapterBasic = () => ({
9
9
  chain.name("service-worker");
10
10
  } else if (target === "web-worker") {
11
11
  chain.name("worker");
12
- } else if (target === "modern-web") {
13
- chain.name("modern");
14
12
  } else {
15
13
  chain.name("client");
16
14
  }
17
15
  if (target === "node" || target === "service-worker") {
18
16
  applyNodeCompat(target, chain);
19
17
  }
20
- if (target === "web" || target === "modern-web") {
18
+ if (target === "web") {
21
19
  const bareServerModuleReg = /\.(server|node)\.[tj]sx?$/;
22
20
  chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(bareServerModuleReg);
23
21
  chain.module.rule("bare-server-module").test(bareServerModuleReg).use("server-module-loader").loader(require.resolve("../loaders/serverModuleLoader"));
@@ -1,4 +1,4 @@
1
- import { isHtmlDisabled, createVirtualModule } from "@modern-js/builder-shared";
1
+ import { isHtmlDisabled, createVirtualModule } from "@rsbuild/shared";
2
2
  import { MAIN_ENTRY_NAME, getEntryOptions, removeTailSlash } from "@modern-js/utils";
3
3
  import { template as lodashTemplate } from "@modern-js/utils/lodash";
4
4
  import { BottomTemplatePlugin } from "../bundlerPlugins";
@@ -1,5 +1,5 @@
1
1
  import * as path from "path";
2
- import { isHtmlDisabled, mergeBuilderConfig } from "@modern-js/builder-shared";
2
+ import { isHtmlDisabled, mergeRsbuildConfig } from "@rsbuild/shared";
3
3
  import { isSSR, fs } from "@modern-js/utils";
4
4
  import { HtmlAsyncChunkPlugin, RouterPlugin } from "../bundlerPlugins";
5
5
  import { getServerCombinedModueFile } from "../../../analyze/utils";
@@ -7,9 +7,9 @@ const builderPluginAdapterSSR = (options) => ({
7
7
  name: "builder-plugin-adapter-modern-ssr",
8
8
  setup(api) {
9
9
  const { normalizedConfig } = options;
10
- api.modifyBuilderConfig((config) => {
10
+ api.modifyRsbuildConfig((config) => {
11
11
  if (isStreamingSSR(normalizedConfig)) {
12
- return mergeBuilderConfig(config, {
12
+ return mergeRsbuildConfig(config, {
13
13
  html: {
14
14
  inject: "body"
15
15
  }
@@ -69,7 +69,6 @@ const dev = async (api, options, devServerOptions = {}) => {
69
69
  });
70
70
  } else {
71
71
  const { server } = await appContext.builder.startDevServer({
72
- printURLs: false,
73
72
  serverOptions
74
73
  });
75
74
  setServer(server);
@@ -1,22 +1,26 @@
1
- import { createDefaultConfig as createDefaultBuilderConfig } from "@modern-js/builder-webpack-provider";
2
1
  import { MAIN_ENTRY_NAME } from "@modern-js/utils";
3
2
  import { getAutoInjectEnv } from "../utils/env";
4
- function createDefaultConfig(appContext, bundler) {
5
- const defaultBuilderConfig = createDefaultBuilderConfig();
3
+ function createDefaultConfig(appContext) {
6
4
  const dev = {
7
- ...defaultBuilderConfig.dev,
8
5
  // `dev.port` should not have a default value
9
6
  // because we will use `server.port` by default
10
7
  port: void 0
11
8
  };
12
9
  const output = {
13
- ...defaultBuilderConfig.output,
10
+ distPath: {
11
+ root: "dist",
12
+ html: "html",
13
+ js: "static/js",
14
+ css: "static/css",
15
+ server: "bundles",
16
+ worker: "worker"
17
+ },
18
+ cleanDistPath: true,
14
19
  disableNodePolyfill: true,
15
20
  enableInlineRouteManifests: true,
16
21
  disableInlineRouteManifests: false
17
22
  };
18
23
  const source = {
19
- ...defaultBuilderConfig.source,
20
24
  entries: void 0,
21
25
  mainEntryName: MAIN_ENTRY_NAME,
22
26
  enableAsyncEntry: false,
@@ -32,8 +36,8 @@ function createDefaultConfig(appContext, bundler) {
32
36
  }
33
37
  };
34
38
  const html = {
35
- ...defaultBuilderConfig.html,
36
39
  title: "",
40
+ mountId: "root",
37
41
  meta: {
38
42
  charset: {
39
43
  charset: "utf-8"
@@ -58,7 +62,7 @@ function createDefaultConfig(appContext, bundler) {
58
62
  baseUrl: "/",
59
63
  port: 8080
60
64
  };
61
- const defaultTsCheckerConfig = {
65
+ const tools = {
62
66
  tsChecker: {
63
67
  issue: {
64
68
  include: [
@@ -69,10 +73,6 @@ function createDefaultConfig(appContext, bundler) {
69
73
  }
70
74
  }
71
75
  };
72
- const tools = bundler === "webpack" ? {
73
- ...defaultBuilderConfig.tools,
74
- ...defaultTsCheckerConfig
75
- } : defaultTsCheckerConfig;
76
76
  return {
77
77
  source,
78
78
  output,
@@ -18,7 +18,7 @@ var initialize_default = ({ bundler }) => ({
18
18
  ...appContext,
19
19
  bundlerType: bundler
20
20
  });
21
- return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext, bundler);
21
+ return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext);
22
22
  };
23
23
  return {
24
24
  config,
@@ -1,6 +1,6 @@
1
1
  import { IAppContext, PluginAPI } from '@modern-js/core';
2
2
  import type { Entrypoint } from '@modern-js/types';
3
- import { BundlerConfig } from '@modern-js/builder-shared';
3
+ import { RspackConfig, WebpackConfig } from '@rsbuild/shared';
4
4
  import { AppNormalizedConfig, AppTools, ImportStatement } from '../types';
5
5
  export declare const createImportStatements: (statements: ImportStatement[]) => string;
6
6
  export declare const generateCode: (appContext: IAppContext, config: AppNormalizedConfig<'shared'>, entrypoints: Entrypoint[], api: PluginAPI<AppTools<'shared'>>) => Promise<{
@@ -12,5 +12,5 @@ export declare const generateIndexCode: ({ appContext, api, entrypoints, config,
12
12
  entrypoints: Entrypoint[];
13
13
  config: AppNormalizedConfig<'shared'>;
14
14
  importsStatemets: Map<string, ImportStatement[]>;
15
- bundlerConfigs?: BundlerConfig[] | undefined;
15
+ bundlerConfigs?: RspackConfig[] | WebpackConfig[] | undefined;
16
16
  }) => Promise<void>;
@@ -1,4 +1,3 @@
1
- import { BuilderPlugin } from '@modern-js/builder-shared';
2
- import { BuilderPluginAPI } from '@modern-js/builder-rspack-provider';
1
+ import { RsbuildPlugin } from '@modern-js/uni-builder';
3
2
  import { BuilderOptions } from '../shared';
4
- export declare const builderPluginAdpaterCopy: (options: BuilderOptions<'rspack'>) => BuilderPlugin<BuilderPluginAPI>;
3
+ export declare const builderPluginAdpaterCopy: (options: BuilderOptions<'rspack'>) => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import { BuilderOptions } from '../shared';
2
- export declare function createRspackBuilderForModern(options: BuilderOptions<'rspack'>): Promise<import("@modern-js/builder-shared").BuilderInstance<import("@modern-js/builder-shared").BuilderProvider>>;
2
+ export declare function createRspackBuilderForModern(options: BuilderOptions<'rspack'>): Promise<import("@modern-js/uni-builder").UniBuilderInstance>;
@@ -1,7 +1,6 @@
1
- import { BuilderPlugin } from '@modern-js/builder-shared';
2
- import type { BuilderPluginAPI } from '@modern-js/builder-webpack-provider';
1
+ import { RsbuildPlugin } from '@modern-js/uni-builder';
3
2
  import { BuilderOptions } from '../shared';
4
3
  /**
5
4
  * Provides default configuration consistent with modern.js v1
6
5
  */
7
- export declare const builderPluginAdapterModern: (options: BuilderOptions<'webpack'>) => BuilderPlugin<BuilderPluginAPI>;
6
+ export declare const builderPluginAdapterModern: (options: BuilderOptions<'webpack'>) => RsbuildPlugin;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { WebpackChain } from '@modern-js/builder-webpack-provider';
2
+ import { CopyPluginOptions, WebpackChain } from '@modern-js/uni-builder';
3
3
  import type { AppNormalizedConfig, Bundler, IAppContext } from '../../types';
4
4
  export declare function createPublicPattern(appContext: IAppContext, config: AppNormalizedConfig, chain: WebpackChain): {
5
5
  info: (file: {
@@ -13,14 +13,4 @@ export declare function createPublicPattern(appContext: IAppContext, config: App
13
13
  noErrorOnMissing: boolean;
14
14
  transform: (content: Buffer, absoluteFrom: string) => string | Buffer;
15
15
  };
16
- export declare function createUploadPattern<B extends Bundler>(appContext: IAppContext, config: AppNormalizedConfig<B>): {
17
- info: (file: {
18
- sourceFilename: string;
19
- }) => {
20
- minimized: boolean;
21
- };
22
- from: string;
23
- to: string;
24
- context: string;
25
- noErrorOnMissing: boolean;
26
- };
16
+ export declare function createUploadPattern<B extends Bundler>(appContext: IAppContext, config: AppNormalizedConfig<B>): CopyPluginOptions['patterns']['0'];
@@ -1,4 +1,2 @@
1
- import { BuilderInstance } from '@modern-js/builder';
2
- import { BuilderWebpackProvider } from '@modern-js/builder-webpack-provider';
3
1
  import { BuilderOptions } from '../shared';
4
- export declare function createWebpackBuilderForModern(options: BuilderOptions<'webpack'>): Promise<BuilderInstance<BuilderWebpackProvider>>;
2
+ export declare function createWebpackBuilderForModern(options: BuilderOptions<'webpack'>): Promise<import("@modern-js/uni-builder").UniBuilderInstance>;
@@ -1,3 +1,4 @@
1
- import type { BuilderTarget, CreateBuilderOptions } from '@modern-js/builder-shared';
1
+ import type { CreateUniBuilderOptions } from '@modern-js/uni-builder';
2
+ import type { RsbuildTarget } from '@rsbuild/shared';
2
3
  import type { IAppContext } from '@modern-js/core';
3
- export declare function createBuilderOptions(target: BuilderTarget | BuilderTarget[], appContext: IAppContext): CreateBuilderOptions;
4
+ export declare function createBuilderOptions(target: RsbuildTarget | RsbuildTarget[], appContext: IAppContext): Omit<CreateUniBuilderOptions, 'bundlerType' | 'config'>;
@@ -1,2 +1,2 @@
1
1
  import type { Bundler, IAppContext, AppNormalizedConfig } from '../../types';
2
- export declare function createBuilderProviderConfig<B extends Bundler>(resolveConfig: AppNormalizedConfig<B>, appContext: IAppContext): AppNormalizedConfig<B>;
2
+ export declare function createBuilderProviderConfig<B extends Bundler>(resolveConfig: AppNormalizedConfig<B>, appContext: IAppContext): Omit<AppNormalizedConfig<B>, 'plugins'>;
@@ -1,3 +1,3 @@
1
- import type { BuilderTarget } from '@modern-js/builder-shared';
1
+ import type { RsbuildTarget } from '@rsbuild/shared';
2
2
  import type { AppNormalizedConfig } from '../../types';
3
- export declare function getBuilderTargets(normalizedConfig: AppNormalizedConfig<'shared'>): BuilderTarget[];
3
+ export declare function getBuilderTargets(normalizedConfig: AppNormalizedConfig<'shared'>): RsbuildTarget[];
@@ -1,12 +1,10 @@
1
- import type { BuilderProvider, BuilderInstance } from '@modern-js/builder-shared';
1
+ import { UniBuilderInstance } from '@modern-js/uni-builder';
2
+ import { BundlerType } from '@rsbuild/shared';
2
3
  import { BuilderOptions } from '../shared';
3
4
  import { Bundler } from '../../types';
4
- export type GenerateProvider = (c: {
5
- builderConfig: any;
6
- }) => BuilderProvider;
7
5
  /**
8
6
  * @param options BuilderOptions
9
- * @param generateProvider GenerateProvider
7
+ * @param bundlerType BundlerType
10
8
  * @returns BuilderInstance
11
9
  */
12
- export declare function generateBuilder<B extends Bundler>(options: BuilderOptions<B>, generateProvider: GenerateProvider): Promise<BuilderInstance<BuilderProvider>>;
10
+ export declare function generateBuilder<B extends Bundler>(options: BuilderOptions<B>, bundlerType: BundlerType): Promise<UniBuilderInstance>;
@@ -1 +1 @@
1
- export declare function createBuilderGenerator(bundler: 'webpack' | 'rspack'): Promise<typeof import("./builder-rspack").createRspackBuilderForModern | typeof import("./builder-webpack").createWebpackBuilderForModern>;
1
+ export declare function createBuilderGenerator(bundler: 'webpack' | 'rspack'): Promise<typeof import("./builder-rspack").createRspackBuilderForModern>;
@@ -1,3 +1,2 @@
1
- import { BuilderPlugin } from '@modern-js/builder-shared';
2
- import type { BuilderPluginAPI } from '../types';
3
- export declare const builderPluginAdapterBasic: () => BuilderPlugin<BuilderPluginAPI>;
1
+ import { RsbuildPlugin } from '@rsbuild/shared';
2
+ export declare const builderPluginAdapterBasic: () => RsbuildPlugin;
@@ -1,4 +1,4 @@
1
- import { BuilderPlugin } from '@modern-js/builder-shared';
1
+ import { RsbuildPlugin } from '@rsbuild/shared';
2
2
  import { Bundler } from '../../../types';
3
- import type { BuilderOptions, BuilderPluginAPI } from '../types';
4
- export declare const builderPluginAdapterHtml: <B extends Bundler>(options: BuilderOptions<B>) => BuilderPlugin<BuilderPluginAPI>;
3
+ import type { BuilderOptions } from '../types';
4
+ export declare const builderPluginAdapterHtml: <B extends Bundler>(options: BuilderOptions<B>) => RsbuildPlugin;
@@ -1,4 +1,4 @@
1
- import { BuilderPlugin } from '@modern-js/builder-shared';
1
+ import { RsbuildPlugin } from '@rsbuild/shared';
2
2
  import type { Bundler } from '../../../types';
3
- import type { BuilderOptions, BuilderPluginAPI } from '../types';
4
- export declare const builderPluginAdapterSSR: <B extends Bundler>(options: BuilderOptions<B>) => BuilderPlugin<BuilderPluginAPI>;
3
+ import type { BuilderOptions } from '../types';
4
+ export declare const builderPluginAdapterSSR: <B extends Bundler>(options: BuilderOptions<B>) => RsbuildPlugin;
@@ -1,6 +1,4 @@
1
- import type { webpack } from '@modern-js/builder-webpack-provider';
2
- import type { Rspack } from '@modern-js/builder-rspack-provider';
3
- import type HtmlWebpackPlugin from '@modern-js/builder-webpack-provider/html-webpack-plugin';
1
+ import type { Rspack, webpack, HtmlWebpackPlugin } from '@modern-js/uni-builder';
4
2
  export declare class HtmlAsyncChunkPlugin {
5
3
  name: string;
6
4
  htmlWebpackPlugin: typeof HtmlWebpackPlugin;
@@ -1,6 +1,4 @@
1
- import type { webpack } from '@modern-js/builder-webpack-provider';
2
- import type { Rspack } from '@modern-js/builder-rspack-provider';
3
- import type HtmlWebpackPlugin from '@modern-js/builder-webpack-provider/html-webpack-plugin';
1
+ import type { Rspack, webpack, HtmlWebpackPlugin } from '@modern-js/uni-builder';
4
2
  export declare class BottomTemplatePlugin {
5
3
  htmlWebpackPlugin: typeof HtmlWebpackPlugin;
6
4
  bottomTemplateReg: RegExp;
@@ -1,7 +1,5 @@
1
- import type { webpack } from '@modern-js/builder-webpack-provider';
2
- import type { Rspack } from '@modern-js/builder-rspack-provider';
3
- import type HtmlWebpackPlugin from '@modern-js/builder-webpack-provider/html-webpack-plugin';
4
- import type { ScriptLoading } from '@modern-js/builder-shared';
1
+ import type { Rspack, webpack, HtmlWebpackPlugin } from '@modern-js/uni-builder';
2
+ import type { ScriptLoading } from '@rsbuild/shared';
5
3
  export interface RouteAssets {
6
4
  [routeId: string]: {
7
5
  chunkIds?: (string | number)[];
@@ -12,7 +10,7 @@ export interface RouteAssets {
12
10
  type Compiler = webpack.Compiler | Rspack.Compiler;
13
11
  type Options = {
14
12
  HtmlBundlerPlugin: typeof HtmlWebpackPlugin;
15
- staticJsDir: string;
13
+ staticJsDir?: string;
16
14
  enableInlineRouteManifests: boolean;
17
15
  disableFilenameHash?: boolean;
18
16
  scriptLoading?: ScriptLoading;
@@ -1,4 +1,3 @@
1
- import type { webpack } from '@modern-js/builder-webpack-provider';
2
- import type { Rspack } from '@modern-js/builder-rspack-provider';
1
+ import type { webpack, Rspack } from '@modern-js/uni-builder';
3
2
  declare function loader(this: webpack.LoaderContext<void> | Rspack.LoaderContext): string;
4
3
  export default loader;