@modern-js/app-tools 2.54.5 → 2.55.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. package/dist/cjs/builder/generator/createBuilderOptions.js +18 -1
  2. package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +2 -2
  3. package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +2 -2
  4. package/dist/cjs/commands/index.js +2 -2
  5. package/dist/cjs/commands/serve.js +1 -0
  6. package/dist/cjs/config/default.js +2 -0
  7. package/dist/cjs/config/legacy/createSourceConfig.js +2 -1
  8. package/dist/cjs/hooks.js +2 -5
  9. package/dist/cjs/plugins/analyze/constants.js +3 -18
  10. package/dist/cjs/plugins/analyze/getFileSystemEntry.js +36 -11
  11. package/dist/cjs/plugins/analyze/index.js +7 -64
  12. package/dist/cjs/plugins/analyze/templates.js +2 -55
  13. package/dist/cjs/plugins/analyze/utils.js +0 -86
  14. package/dist/esm/builder/generator/createBuilderOptions.js +21 -1
  15. package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +1 -1
  16. package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +1 -1
  17. package/dist/esm/commands/index.js +1 -1
  18. package/dist/esm/commands/serve.js +1 -0
  19. package/dist/esm/config/default.js +2 -0
  20. package/dist/esm/config/legacy/createSourceConfig.js +2 -1
  21. package/dist/esm/hooks.js +2 -5
  22. package/dist/esm/plugins/analyze/constants.js +2 -12
  23. package/dist/esm/plugins/analyze/getFileSystemEntry.js +57 -14
  24. package/dist/esm/plugins/analyze/index.js +25 -128
  25. package/dist/esm/plugins/analyze/templates.js +1 -17
  26. package/dist/esm/plugins/analyze/utils.js +1 -87
  27. package/dist/esm-node/builder/generator/createBuilderOptions.js +18 -1
  28. package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +1 -1
  29. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +1 -1
  30. package/dist/esm-node/commands/index.js +1 -1
  31. package/dist/esm-node/commands/serve.js +1 -0
  32. package/dist/esm-node/config/default.js +2 -0
  33. package/dist/esm-node/config/legacy/createSourceConfig.js +2 -1
  34. package/dist/esm-node/hooks.js +2 -5
  35. package/dist/esm-node/plugins/analyze/constants.js +2 -12
  36. package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +37 -12
  37. package/dist/esm-node/plugins/analyze/index.js +10 -67
  38. package/dist/esm-node/plugins/analyze/templates.js +1 -52
  39. package/dist/esm-node/plugins/analyze/utils.js +1 -86
  40. package/dist/types/builder/builder-webpack/createCopyPattern.d.ts +2 -2
  41. package/dist/types/builder/generator/createBuilderOptions.d.ts +1 -2
  42. package/dist/types/builder/generator/getBuilderTargets.d.ts +1 -1
  43. package/dist/types/builder/generator/index.d.ts +1 -2
  44. package/dist/types/builder/shared/builderPlugins/adapterBasic.d.ts +1 -1
  45. package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +1 -1
  46. package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +1 -1
  47. package/dist/types/builder/shared/builderPlugins/adapterWorker.d.ts +1 -1
  48. package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +1 -1
  49. package/dist/types/commands/inspect.d.ts +1 -1
  50. package/dist/types/plugins/analyze/constants.d.ts +1 -6
  51. package/dist/types/plugins/analyze/templates.d.ts +0 -14
  52. package/dist/types/plugins/analyze/utils.d.ts +0 -11
  53. package/dist/types/types/config/source.d.ts +5 -0
  54. package/dist/types/types/hooks.d.ts +7 -27
  55. package/dist/types/types/index.d.ts +1 -1
  56. package/dist/types/types/legacyConfig/output.d.ts +1 -1
  57. package/dist/types/types/legacyConfig/source.d.ts +4 -0
  58. package/dist/types/utils/register.d.ts +1 -1
  59. package/package.json +17 -18
  60. package/dist/cjs/plugins/analyze/generateCode.js +0 -185
  61. package/dist/esm/plugins/analyze/generateCode.js +0 -296
  62. package/dist/esm-node/plugins/analyze/generateCode.js +0 -149
  63. package/dist/types/plugins/analyze/generateCode.d.ts +0 -16
@@ -24,6 +24,7 @@ const start = async (api) => {
24
24
  config: {
25
25
  ...userConfig,
26
26
  dev: userConfig.dev,
27
+ // server-core can't get RegExp & Function output.enableInlineScripts by JSON.stringy;
27
28
  output: {
28
29
  path: (_userConfig_output_distPath = userConfig.output.distPath) === null || _userConfig_output_distPath === void 0 ? void 0 : _userConfig_output_distPath.root,
29
30
  ...userConfig.output || {}
@@ -26,6 +26,7 @@ function createDefaultConfig(appContext) {
26
26
  entries: void 0,
27
27
  mainEntryName: MAIN_ENTRY_NAME,
28
28
  enableAsyncEntry: false,
29
+ enableCustomEntry: false,
29
30
  disableDefaultEntries: false,
30
31
  entriesDir: "./src",
31
32
  configDir: "./config",
@@ -98,6 +99,7 @@ function createLegacyDefaultConfig(appContext) {
98
99
  entries: void 0,
99
100
  mainEntryName: MAIN_ENTRY_NAME,
100
101
  enableAsyncEntry: false,
102
+ enableCustomEntry: false,
101
103
  disableDefaultEntries: false,
102
104
  entriesDir: "./src",
103
105
  configDir: "./config",
@@ -1,5 +1,5 @@
1
1
  function createSourceConfig(config) {
2
- const { alias, envVars, globalVars, include, moduleScopes, preEntry, entries, mainEntryName, enableAsyncEntry, disableDefaultEntries, entriesDir, configDir } = config.source;
2
+ const { alias, envVars, globalVars, include, moduleScopes, preEntry, entries, mainEntryName, enableAsyncEntry, enableCustomEntry, disableDefaultEntries, entriesDir, configDir } = config.source;
3
3
  const builderGlobalVars = globalVars || {};
4
4
  for (const envVar of envVars || []) {
5
5
  const envVarValue = process.env[envVar];
@@ -14,6 +14,7 @@ function createSourceConfig(config) {
14
14
  entries,
15
15
  mainEntryName,
16
16
  enableAsyncEntry,
17
+ enableCustomEntry,
17
18
  disableDefaultEntries,
18
19
  entriesDir,
19
20
  configDir,
@@ -1,16 +1,13 @@
1
1
  import { createAsyncWaterfall, createAsyncWorkflow, createParallelWorkflow } from "@modern-js/plugin";
2
2
  const hooks = {
3
- modifyEntryExport: createAsyncWaterfall(),
4
- modifyEntryImports: createAsyncWaterfall(),
5
- modifyEntryRuntimePlugins: createAsyncWaterfall(),
6
- modifyEntryRenderFunction: createAsyncWaterfall(),
7
- modifyAsyncEntry: createAsyncWaterfall(),
3
+ _internalRuntimePlugins: createAsyncWaterfall(),
8
4
  modifyFileSystemRoutes: createAsyncWaterfall(),
9
5
  modifyServerRoutes: createAsyncWaterfall(),
10
6
  /** add entry point info to entrypoints array */
11
7
  modifyEntrypoints: createAsyncWaterfall(),
12
8
  /** add entry type */
13
9
  checkEntryPoint: createAsyncWaterfall(),
10
+ generateEntryCode: createAsyncWorkflow(),
14
11
  htmlPartials: createAsyncWaterfall(),
15
12
  beforeGenerateRoutes: createAsyncWaterfall(),
16
13
  addDefineTypes: createAsyncWaterfall(),
@@ -1,23 +1,13 @@
1
1
  const INDEX_FILE_NAME = "index";
2
- const FILE_SYSTEM_ROUTES_FILE_NAME = "routes.js";
3
- const ENTRY_POINT_FILE_NAME = "index.jsx";
4
- const ENTRY_BOOTSTRAP_FILE_NAME = "bootstrap.jsx";
2
+ const ENTRY_FILE_NAME = "entry";
5
3
  const HTML_PARTIALS_FOLDER = "html";
6
4
  const HTML_PARTIALS_EXTENSIONS = [
7
5
  ".htm",
8
6
  ".html",
9
7
  ".ejs"
10
8
  ];
11
- const APP_CONFIG_NAME = "config";
12
- const APP_INIT_EXPORTED = "init";
13
- const APP_INIT_IMPORTED = "appInit";
14
9
  export {
15
- APP_CONFIG_NAME,
16
- APP_INIT_EXPORTED,
17
- APP_INIT_IMPORTED,
18
- ENTRY_BOOTSTRAP_FILE_NAME,
19
- ENTRY_POINT_FILE_NAME,
20
- FILE_SYSTEM_ROUTES_FILE_NAME,
10
+ ENTRY_FILE_NAME,
21
11
  HTML_PARTIALS_EXTENSIONS,
22
12
  HTML_PARTIALS_FOLDER,
23
13
  INDEX_FILE_NAME
@@ -1,19 +1,31 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
3
  import { findExists, ensureAbsolutePath, JS_EXTENSIONS } from "@modern-js/utils";
4
- import { INDEX_FILE_NAME } from "./constants";
4
+ import { ENTRY_FILE_NAME, INDEX_FILE_NAME } from "./constants";
5
5
  import { isDefaultExportFunction } from "./isDefaultExportFunction";
6
6
  const hasIndex = (dir) => findExists(JS_EXTENSIONS.map((ext) => path.resolve(dir, `${INDEX_FILE_NAME}${ext}`)));
7
- const isBundleEntry = async (hookRunners, dir) => {
8
- return (await hookRunners.checkEntryPoint({
7
+ const hasEntry = (dir) => findExists(JS_EXTENSIONS.map((ext) => path.resolve(dir, `${ENTRY_FILE_NAME}${ext}`)));
8
+ const hasServerEntry = (dir) => findExists(JS_EXTENSIONS.map((ext) => path.resolve(dir, `${ENTRY_FILE_NAME}.server${ext}`)));
9
+ const isBundleEntry = async (hookRunners, dir, enableCustomEntry) => {
10
+ const { entry } = await hookRunners.checkEntryPoint({
9
11
  path: dir,
10
12
  entry: false
11
- })).entry || hasIndex(dir);
13
+ });
14
+ if (entry) {
15
+ return entry;
16
+ }
17
+ const customEntry = hasEntry(dir);
18
+ if (enableCustomEntry && customEntry) {
19
+ return customEntry;
20
+ }
21
+ return hasIndex(dir);
12
22
  };
13
- const scanDir = (hookRunners, dirs) => Promise.all(dirs.map(async (dir) => {
23
+ const scanDir = (hookRunners, dirs, enableCustomEntry) => Promise.all(dirs.map(async (dir) => {
14
24
  const indexFile = hasIndex(dir);
15
25
  const customBootstrap = isDefaultExportFunction(indexFile) ? indexFile : false;
16
26
  const entryName = path.basename(dir);
27
+ const customEntryFile = hasEntry(dir);
28
+ const customServerEntry = hasServerEntry(dir);
17
29
  if (indexFile && !customBootstrap) {
18
30
  return {
19
31
  entryName,
@@ -32,17 +44,30 @@ const scanDir = (hookRunners, dirs) => Promise.all(dirs.map(async (dir) => {
32
44
  return {
33
45
  entryName,
34
46
  isMainEntry: false,
35
- entry: entryFile,
47
+ entry: enableCustomEntry ? customEntryFile || entryFile : entryFile,
48
+ customServerEntry,
36
49
  absoluteEntryDir: path.resolve(dir),
37
50
  isAutoMount: true,
38
- customBootstrap
51
+ customBootstrap,
52
+ customEntry: enableCustomEntry ? Boolean(customEntryFile) : false
53
+ };
54
+ }
55
+ if (enableCustomEntry && customEntryFile) {
56
+ return {
57
+ entryName,
58
+ isMainEntry: false,
59
+ entry: customEntryFile,
60
+ customServerEntry,
61
+ absoluteEntryDir: path.resolve(dir),
62
+ isAutoMount: false,
63
+ customEntry: Boolean(customEntryFile)
39
64
  };
40
65
  }
41
66
  throw Error("There is no valid entry point in the current project!");
42
67
  }));
43
68
  const getFileSystemEntry = async (hookRunners, appContext, config) => {
44
69
  const { appDirectory } = appContext;
45
- const { source: { entriesDir, disableEntryDirs } } = config;
70
+ const { source: { entriesDir, disableEntryDirs, enableCustomEntry } } = config;
46
71
  let disabledDirs = [];
47
72
  if (disableEntryDirs && Array.isArray(disableEntryDirs)) {
48
73
  disabledDirs = disableEntryDirs === null || disableEntryDirs === void 0 ? void 0 : disableEntryDirs.map((dir) => ensureAbsolutePath(appDirectory, dir));
@@ -50,19 +75,19 @@ const getFileSystemEntry = async (hookRunners, appContext, config) => {
50
75
  const src = ensureAbsolutePath(appDirectory, entriesDir || "");
51
76
  if (fs.existsSync(src)) {
52
77
  if (fs.statSync(src).isDirectory()) {
53
- if (await isBundleEntry(hookRunners, src)) {
78
+ if (await isBundleEntry(hookRunners, src, enableCustomEntry)) {
54
79
  return scanDir(hookRunners, [
55
80
  src
56
- ]);
81
+ ], enableCustomEntry);
57
82
  }
58
83
  const dirs = [];
59
84
  await Promise.all(fs.readdirSync(src).map(async (filename) => {
60
85
  const file = path.join(src, filename);
61
- if (fs.statSync(file).isDirectory() && await isBundleEntry(hookRunners, file) && !disabledDirs.includes(file)) {
86
+ if (fs.statSync(file).isDirectory() && await isBundleEntry(hookRunners, file, enableCustomEntry) && !disabledDirs.includes(file)) {
62
87
  dirs.push(file);
63
88
  }
64
89
  }));
65
- return scanDir(hookRunners, dirs);
90
+ return scanDir(hookRunners, dirs, enableCustomEntry);
66
91
  } else {
67
92
  throw Error(`source.entriesDir accept a directory.`);
68
93
  }
@@ -1,17 +1,18 @@
1
1
  import * as path from "path";
2
- import { createDebugger, findExists, fs, isApiOnly, minimist, isDevCommand, getArgv } from "@modern-js/utils";
2
+ import { createDebugger, fs, isApiOnly, minimist, isDevCommand, getArgv } from "@modern-js/utils";
3
3
  import { printInstructions } from "../../utils/printInstructions";
4
- import { generateRoutes, getPathWithoutExt } from "../../utils/routes";
4
+ import { generateRoutes } from "../../utils/routes";
5
5
  import { emitResolvedConfig } from "../../utils/config";
6
6
  import { getSelectedEntries } from "../../utils/getSelectedEntries";
7
7
  import { initialNormalizedConfig } from "../../config";
8
8
  import { createBuilderGenerator } from "../../builder";
9
- import { checkIsBuildCommands, parseModule, replaceWithAlias } from "./utils";
10
- import { APP_CONFIG_NAME, APP_INIT_EXPORTED, APP_INIT_IMPORTED } from "./constants";
11
- import { generateIndexCode } from "./generateCode";
9
+ import { checkIsBuildCommands } from "./utils";
12
10
  const debug = createDebugger("plugin-analyze");
13
11
  var analyze_default = ({ bundler }) => ({
14
12
  name: "@modern-js/plugin-analyze",
13
+ post: [
14
+ "@modern-js/runtime"
15
+ ],
15
16
  setup: (api) => {
16
17
  let pagesDir = [];
17
18
  let nestedRouteEntries = [];
@@ -42,10 +43,9 @@ var analyze_default = ({ bundler }) => ({
42
43
  api.setAppContext(appContext);
43
44
  return;
44
45
  }
45
- const [{ getBundleEntry }, { getServerRoutes }, { generateCode }, { getHtmlTemplate }] = await Promise.all([
46
+ const [{ getBundleEntry }, { getServerRoutes }, { getHtmlTemplate }] = await Promise.all([
46
47
  import("./getBundleEntry"),
47
48
  import("./getServerRoutes"),
48
- import("./generateCode"),
49
49
  import("./getHtmlTemplate")
50
50
  ]);
51
51
  const { entrypoints } = await hookRunners.modifyEntrypoints({
@@ -68,7 +68,6 @@ var analyze_default = ({ bundler }) => ({
68
68
  api.setAppContext(appContext);
69
69
  nestedRouteEntries = entrypoints.map((point) => point.nestedRoutesEntry).filter(Boolean);
70
70
  pagesDir = entrypoints.map((point) => point.entry).filter((entry) => entry && !path.extname(entry)).concat(nestedRouteEntries);
71
- const { importsStatemets } = await generateCode(appContext, resolvedConfig, entrypoints, api);
72
71
  const htmlTemplates = await getHtmlTemplate(entrypoints, api, {
73
72
  appContext,
74
73
  config: resolvedConfig
@@ -91,6 +90,9 @@ var analyze_default = ({ bundler }) => ({
91
90
  };
92
91
  api.setAppContext(appContext);
93
92
  if (checkIsBuildCommands()) {
93
+ await hookRunners.generateEntryCode({
94
+ entrypoints
95
+ });
94
96
  const normalizedConfig = api.useResolvedConfigContext();
95
97
  const createBuilderForModern = await createBuilderGenerator(bundler);
96
98
  const builder = await createBuilderForModern({
@@ -122,14 +124,6 @@ var analyze_default = ({ bundler }) => ({
122
124
  });
123
125
  builder.onBeforeCreateCompiler(async ({ bundlerConfigs }) => {
124
126
  const hookRunners2 = api.useHookRunners();
125
- await generateIndexCode({
126
- appContext,
127
- config: resolvedConfig,
128
- entrypoints,
129
- api,
130
- importsStatemets,
131
- bundlerConfigs
132
- });
133
127
  await hookRunners2.beforeCreateCompiler({
134
128
  bundlerConfigs
135
129
  });
@@ -160,57 +154,6 @@ var analyze_default = ({ bundler }) => ({
160
154
  return {
161
155
  resolved: config
162
156
  };
163
- },
164
- // This logic is not in the router plugin to avoid having to include some dependencies in the utils package
165
- async modifyEntryImports({ entrypoint, imports }) {
166
- const appContext = api.useAppContext();
167
- const { srcDirectory, internalSrcAlias } = appContext;
168
- const { fileSystemRoutes, nestedRoutesEntry } = entrypoint;
169
- if (fileSystemRoutes && nestedRoutesEntry) {
170
- const rootLayoutPath = path.join(nestedRoutesEntry, "layout");
171
- const rootLayoutFile = findExists([
172
- ".js",
173
- ".ts",
174
- ".jsx",
175
- ".tsx"
176
- ].map((ext) => `${rootLayoutPath}${ext}`));
177
- if (rootLayoutFile) {
178
- const rootLayoutBuffer = await fs.readFile(rootLayoutFile);
179
- const rootLayout = rootLayoutBuffer.toString();
180
- const [, moduleExports] = await parseModule({
181
- source: rootLayout.toString(),
182
- filename: rootLayoutFile
183
- });
184
- const hasAppConfig = moduleExports.some((e) => e.n === APP_CONFIG_NAME);
185
- const generateLayoutPath = getPathWithoutExt(replaceWithAlias(srcDirectory, rootLayoutFile, internalSrcAlias));
186
- if (hasAppConfig) {
187
- imports.push({
188
- value: generateLayoutPath,
189
- specifiers: [
190
- {
191
- imported: APP_CONFIG_NAME
192
- }
193
- ]
194
- });
195
- }
196
- const hasAppInit = moduleExports.some((e) => e.n === APP_INIT_EXPORTED);
197
- if (hasAppInit) {
198
- imports.push({
199
- value: generateLayoutPath,
200
- specifiers: [
201
- {
202
- imported: APP_INIT_EXPORTED,
203
- local: APP_INIT_IMPORTED
204
- }
205
- ]
206
- });
207
- }
208
- }
209
- }
210
- return {
211
- entrypoint,
212
- imports
213
- };
214
157
  }
215
158
  };
216
159
  }
@@ -1,52 +1,3 @@
1
- import { APP_CONFIG_NAME } from "./constants";
2
- const index = ({ mountId, imports, renderFunction: renderFunction2, exportStatement }) => `
3
- const IS_BROWSER = typeof window !== 'undefined' && window.name !== 'nodejs';
4
- const IS_REACT18 = process.env.IS_REACT18 === 'true';
5
- const MOUNT_ID = '${mountId}';
6
-
7
- ${imports}
8
-
9
- let AppWrapper = null;
10
-
11
- let root = null;
12
-
13
- function render() {
14
- ${renderFunction2}
15
- }
16
-
17
- AppWrapper = render();
18
-
19
- ${exportStatement};
20
- `;
21
- const renderFunction = ({ plugins, customBootstrap, fileSystemRoutes, customRuntimeConfig }) => {
22
- const bootstrap = "bootstrap(AppWrapper, MOUNT_ID, root, ReactDOM)";
23
- const runtimePlugins = `...(runtimeConfig?.plugins || []),`;
24
- return `
25
- const finalAppConfig = {
26
- ...App.config,
27
- ...typeof ${APP_CONFIG_NAME} === 'function' ? ${APP_CONFIG_NAME}() : {},
28
- }
29
-
30
- AppWrapper = createApp({
31
- plugins: [
32
- ${plugins.map(({ name, options, args }) => `${name}({...${options}, ...finalAppConfig?.${args || name}}),`).join("\n")}
33
- ${customRuntimeConfig ? runtimePlugins : ""}
34
- ]
35
- })(${fileSystemRoutes ? "" : `App`})
36
-
37
-
38
- if(!AppWrapper.init && typeof appInit !== 'undefined') {
39
- AppWrapper.init = appInit;
40
- }
41
-
42
-
43
- if (IS_BROWSER) {
44
- ${customBootstrap ? `customBootstrap(AppWrapper, () => ${bootstrap});` : `${bootstrap};`}
45
- }
46
-
47
- return AppWrapper
48
- `;
49
- };
50
1
  const html = (partials) => `
51
2
  <!DOCTYPE html>
52
3
  <html>
@@ -69,7 +20,5 @@ const html = (partials) => `
69
20
  </html>
70
21
  `;
71
22
  export {
72
- html,
73
- index,
74
- renderFunction
23
+ html
75
24
  };
@@ -1,9 +1,8 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
- import { isReact18, normalizeToPosixPath, getCommand, JS_EXTENSIONS } from "@modern-js/utils";
3
+ import { normalizeToPosixPath, getCommand, JS_EXTENSIONS } from "@modern-js/utils";
4
4
  import { transform } from "esbuild";
5
5
  import { parse } from "es-module-lexer";
6
- import { FILE_SYSTEM_ROUTES_FILE_NAME } from "./constants";
7
6
  const walkDirectory = (dir) => fs.readdirSync(dir).reduce((previous, filename) => {
8
7
  const filePath = path.join(dir, filename);
9
8
  if (fs.statSync(filePath).isDirectory()) {
@@ -18,89 +17,6 @@ const walkDirectory = (dir) => fs.readdirSync(dir).reduce((previous, filename) =
18
17
  ];
19
18
  }
20
19
  }, []);
21
- const getDefaultImports = ({ entrypoint, srcDirectory, appDirectory, internalSrcAlias, internalDirAlias, runtimeConfigFile, customRuntimeConfig }) => {
22
- const { entryName, fileSystemRoutes, customBootstrap, entry } = entrypoint;
23
- const imports = [
24
- {
25
- specifiers: [
26
- {
27
- local: "React"
28
- }
29
- ],
30
- value: "react"
31
- },
32
- {
33
- specifiers: [
34
- {
35
- local: "ReactDOM"
36
- }
37
- ],
38
- value: isReact18(path.join(appDirectory)) ? "react-dom/client" : "react-dom"
39
- },
40
- {
41
- specifiers: [
42
- {
43
- imported: "createApp"
44
- },
45
- {
46
- imported: "bootstrap"
47
- }
48
- ],
49
- value: "@modern-js/runtime"
50
- },
51
- customBootstrap && {
52
- specifiers: [
53
- {
54
- local: "customBootstrap"
55
- }
56
- ],
57
- value: normalizeToPosixPath(customBootstrap.replace(srcDirectory, internalSrcAlias))
58
- }
59
- ].filter(Boolean);
60
- if (fileSystemRoutes) {
61
- const route = {
62
- specifiers: [
63
- {
64
- imported: "routes"
65
- }
66
- ],
67
- value: normalizeToPosixPath(`${internalDirAlias}/${entryName}/${FILE_SYSTEM_ROUTES_FILE_NAME.replace(".js", "")}`)
68
- };
69
- if (fileSystemRoutes.globalApp) {
70
- imports.push({
71
- specifiers: [
72
- {
73
- local: "App"
74
- }
75
- ],
76
- value: normalizeToPosixPath(fileSystemRoutes.globalApp.replace(srcDirectory, internalSrcAlias))
77
- });
78
- } else {
79
- route.initialize = "const App = false;";
80
- }
81
- imports.push(route);
82
- } else {
83
- imports.push({
84
- specifiers: [
85
- {
86
- local: "App"
87
- }
88
- ],
89
- value: normalizeToPosixPath(entry.replace(srcDirectory, internalSrcAlias))
90
- });
91
- }
92
- if (customRuntimeConfig) {
93
- imports.push({
94
- specifiers: [
95
- {
96
- local: "runtimeConfig"
97
- }
98
- ],
99
- value: path.join(internalSrcAlias, runtimeConfigFile || "")
100
- });
101
- }
102
- return imports;
103
- };
104
20
  const replaceWithAlias = (base, filePath, alias) => {
105
21
  if (filePath.includes(base)) {
106
22
  return normalizeToPosixPath(path.join(alias, path.relative(base, filePath)));
@@ -144,7 +60,6 @@ const isSubDirOrEqual = (parent, child) => {
144
60
  };
145
61
  export {
146
62
  checkIsBuildCommands,
147
- getDefaultImports,
148
63
  getServerCombinedModueFile,
149
64
  isSubDirOrEqual,
150
65
  parseModule,
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { CopyPluginOptions, RspackChain } from '@modern-js/uni-builder';
2
+ import type { Rspack, RspackChain } from '@rsbuild/core';
3
3
  import type { AppNormalizedConfig, Bundler, IAppContext } from '../../types';
4
4
  export declare function createPublicPattern(appContext: IAppContext, config: AppNormalizedConfig, chain: RspackChain): {
5
5
  info: (file: {
@@ -13,4 +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>): CopyPluginOptions['patterns']['0'];
16
+ export declare function createUploadPattern<B extends Bundler>(appContext: IAppContext, config: AppNormalizedConfig<B>): Rspack.CopyRspackPluginOptions['patterns']['0'];
@@ -1,4 +1,3 @@
1
- import type { CreateUniBuilderOptions } from '@modern-js/uni-builder';
2
- import type { RsbuildTarget } from '@rsbuild/shared';
1
+ import type { RsbuildTarget, CreateUniBuilderOptions } from '@modern-js/uni-builder';
3
2
  import type { IAppContext } from '@modern-js/core';
4
3
  export declare function createBuilderOptions(target: RsbuildTarget | RsbuildTarget[], appContext: IAppContext): Omit<CreateUniBuilderOptions, 'bundlerType' | 'config'>;
@@ -1,3 +1,3 @@
1
- import type { RsbuildTarget } from '@rsbuild/shared';
1
+ import type { RsbuildTarget } from '@rsbuild/core';
2
2
  import type { AppNormalizedConfig } from '../../types';
3
3
  export declare function getBuilderTargets(normalizedConfig: AppNormalizedConfig<'shared'>): RsbuildTarget[];
@@ -1,5 +1,4 @@
1
- import { UniBuilderInstance } from '@modern-js/uni-builder';
2
- import { BundlerType } from '@rsbuild/shared';
1
+ import { type UniBuilderInstance, type BundlerType } from '@modern-js/uni-builder';
3
2
  import { BuilderOptions } from '../shared';
4
3
  import { Bundler } from '../../types';
5
4
  /**
@@ -1,2 +1,2 @@
1
- import { RsbuildPlugin } from '@rsbuild/shared';
1
+ import type { RsbuildPlugin } from '@rsbuild/core';
2
2
  export declare const builderPluginAdapterBasic: () => RsbuildPlugin;
@@ -1,4 +1,4 @@
1
- import { RsbuildPlugin } from '@rsbuild/shared';
1
+ import type { RsbuildPlugin } from '@rsbuild/core';
2
2
  import { Bundler } from '../../../types';
3
3
  import type { BuilderOptions } from '../types';
4
4
  export declare const builderPluginAdapterHtml: <B extends Bundler>(options: BuilderOptions<B>) => RsbuildPlugin;
@@ -1,4 +1,4 @@
1
- import { RsbuildPlugin } from '@rsbuild/shared';
1
+ import { RsbuildPlugin } from '@rsbuild/core';
2
2
  import type { Bundler } from '../../../types';
3
3
  import type { BuilderOptions } from '../types';
4
4
  export declare const builderPluginAdapterSSR: <B extends Bundler>(options: BuilderOptions<B>) => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
- import { RsbuildPlugin } from '@rsbuild/shared';
1
+ import type { RsbuildPlugin } from '@rsbuild/core';
2
2
  export declare const builderPluginAdapterWorker: () => RsbuildPlugin;
@@ -1,5 +1,5 @@
1
1
  import type { Rspack, webpack, HtmlWebpackPlugin } from '@modern-js/uni-builder';
2
- import type { ScriptLoading } from '@rsbuild/shared';
2
+ import type { ScriptLoading } from '@rsbuild/core';
3
3
  export interface RouteAssets {
4
4
  [routeId: string]: {
5
5
  chunkIds?: (string | number)[];
@@ -1,4 +1,4 @@
1
1
  import type { PluginAPI } from '@modern-js/core';
2
2
  import type { InspectOptions } from '../utils/types';
3
3
  import type { AppTools } from '../types';
4
- export declare const inspect: (api: PluginAPI<AppTools<'shared'>>, options: InspectOptions) => Promise<import("@rsbuild/shared").InspectConfigResult<"rspack">>;
4
+ export declare const inspect: (api: PluginAPI<AppTools<'shared'>>, options: InspectOptions) => Promise<import("@rsbuild/core").InspectConfigResult<"rspack">>;
@@ -1,9 +1,4 @@
1
1
  export declare const INDEX_FILE_NAME = "index";
2
- export declare const FILE_SYSTEM_ROUTES_FILE_NAME = "routes.js";
3
- export declare const ENTRY_POINT_FILE_NAME = "index.jsx";
4
- export declare const ENTRY_BOOTSTRAP_FILE_NAME = "bootstrap.jsx";
2
+ export declare const ENTRY_FILE_NAME = "entry";
5
3
  export declare const HTML_PARTIALS_FOLDER = "html";
6
4
  export declare const HTML_PARTIALS_EXTENSIONS: string[];
7
- export declare const APP_CONFIG_NAME = "config";
8
- export declare const APP_INIT_EXPORTED = "init";
9
- export declare const APP_INIT_IMPORTED = "appInit";
@@ -1,17 +1,3 @@
1
- import type { Entrypoint } from '@modern-js/types';
2
- import type { RuntimePlugin } from '../../types';
3
- export declare const index: ({ mountId, imports, renderFunction, exportStatement, }: {
4
- mountId: string;
5
- imports: string;
6
- exportStatement: string;
7
- renderFunction: string;
8
- }) => string;
9
- export declare const renderFunction: ({ plugins, customBootstrap, fileSystemRoutes, customRuntimeConfig, }: {
10
- plugins: RuntimePlugin[];
11
- customBootstrap?: string | false | undefined;
12
- customRuntimeConfig?: string | false | undefined;
13
- fileSystemRoutes: Entrypoint['fileSystemRoutes'];
14
- }) => string;
15
1
  export declare const html: (partials: {
16
2
  top: string[];
17
3
  head: string[];
@@ -1,15 +1,4 @@
1
- import type { Entrypoint } from '@modern-js/types';
2
- import type { ImportStatement } from '../../types';
3
1
  export declare const walkDirectory: (dir: string) => string[];
4
- export declare const getDefaultImports: ({ entrypoint, srcDirectory, appDirectory, internalSrcAlias, internalDirAlias, runtimeConfigFile, customRuntimeConfig, }: {
5
- entrypoint: Entrypoint;
6
- srcDirectory: string;
7
- appDirectory: string;
8
- internalSrcAlias: string;
9
- internalDirAlias: string;
10
- runtimeConfigFile: string | false;
11
- customRuntimeConfig: string | false;
12
- }) => ImportStatement[];
13
2
  export declare const replaceWithAlias: (base: string, filePath: string, alias: string) => string;
14
3
  export declare const parseModule: ({ source, filename, }: {
15
4
  source: string;
@@ -30,6 +30,11 @@ export interface SourceUserConfig extends NonNullable<UniBuilderConfig['source']
30
30
  * @default false
31
31
  */
32
32
  enableAsyncEntry?: boolean;
33
+ /**
34
+ * Enable use entry.tsx to custom entry
35
+ * @default false
36
+ */
37
+ enableCustomEntry?: boolean;
33
38
  /**
34
39
  * Used to disable the functionality of automatically identifying page entry points based on directory structure.
35
40
  * @default false