@modern-js/app-tools 1.21.5 → 2.0.0-beta.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.
- package/CHANGELOG.md +319 -51
- package/dist/js/modern/analyze/constants.js +1 -0
- package/dist/js/modern/analyze/generateCode.js +126 -32
- package/dist/js/modern/analyze/getBundleEntry.js +7 -14
- package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +173 -0
- package/dist/js/modern/analyze/{getClientRoutes.js → getClientRoutes/getRoutesLegacy.js} +13 -58
- package/dist/js/modern/analyze/getClientRoutes/index.js +2 -0
- package/dist/js/modern/analyze/getClientRoutes/utils.js +18 -0
- package/dist/js/modern/analyze/getFileSystemEntry.js +27 -21
- package/dist/js/modern/analyze/getHtmlTemplate.js +2 -9
- package/dist/js/modern/analyze/getServerRoutes.js +15 -32
- package/dist/js/modern/analyze/index.js +81 -23
- package/dist/js/modern/analyze/isDefaultExportFunction.js +0 -4
- package/dist/js/modern/analyze/makeLegalIdentifier.js +0 -2
- package/dist/js/modern/analyze/nestedRoutes.js +102 -0
- package/dist/js/modern/analyze/templates.js +151 -12
- package/dist/js/modern/analyze/utils.js +2 -8
- package/dist/js/modern/builder/builderPlugins/compatModern.js +208 -0
- package/dist/js/modern/builder/createHtmlConfig.js +58 -0
- package/dist/js/modern/builder/createOutputConfig.js +70 -0
- package/dist/js/modern/builder/createSourceConfig.js +74 -0
- package/dist/js/modern/builder/createToolsConfig.js +87 -0
- package/dist/js/modern/builder/index.js +108 -0
- package/dist/js/modern/builder/share.js +44 -0
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +29 -0
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +33 -0
- package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +97 -0
- package/dist/js/modern/commands/build.js +16 -110
- package/dist/js/modern/commands/dev.js +12 -28
- package/dist/js/modern/commands/inspect.js +8 -66
- package/dist/js/modern/commands/start.js +2 -3
- package/dist/js/modern/index.js +17 -16
- package/dist/js/modern/locale/en.js +0 -1
- package/dist/js/modern/locale/zh.js +0 -1
- package/dist/js/modern/utils/commands.js +5 -0
- package/dist/js/modern/utils/config.js +1 -12
- package/dist/js/modern/utils/createServer.js +12 -1
- package/dist/js/modern/utils/getSpecifiedEntries.js +0 -6
- package/dist/js/modern/utils/printInstructions.js +3 -2
- package/dist/js/modern/utils/routes.js +0 -2
- package/dist/js/node/analyze/constants.js +3 -1
- package/dist/js/node/analyze/generateCode.js +123 -47
- package/dist/js/node/analyze/getBundleEntry.js +7 -20
- package/dist/js/node/analyze/getClientRoutes/getRoutes.js +181 -0
- package/dist/js/node/analyze/{getClientRoutes.js → getClientRoutes/getRoutesLegacy.js} +19 -78
- package/dist/js/node/analyze/getClientRoutes/index.js +19 -0
- package/dist/js/node/analyze/getClientRoutes/utils.js +28 -0
- package/dist/js/node/analyze/getFileSystemEntry.js +26 -28
- package/dist/js/node/analyze/getHtmlTemplate.js +2 -23
- package/dist/js/node/analyze/getServerRoutes.js +14 -40
- package/dist/js/node/analyze/index.js +81 -33
- package/dist/js/node/analyze/isDefaultExportFunction.js +0 -12
- package/dist/js/node/analyze/makeLegalIdentifier.js +0 -4
- package/dist/js/node/analyze/nestedRoutes.js +111 -0
- package/dist/js/node/analyze/templates.js +153 -21
- package/dist/js/node/analyze/utils.js +4 -20
- package/dist/js/node/builder/builderPlugins/compatModern.js +216 -0
- package/dist/js/node/builder/createHtmlConfig.js +68 -0
- package/dist/js/node/builder/createOutputConfig.js +76 -0
- package/dist/js/node/builder/createSourceConfig.js +82 -0
- package/dist/js/node/builder/createToolsConfig.js +94 -0
- package/dist/js/node/builder/index.js +117 -0
- package/dist/js/node/builder/share.js +51 -0
- package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +36 -0
- package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +40 -0
- package/dist/js/node/builder/webpackPlugins/routerPlugin.js +105 -0
- package/dist/js/node/commands/build.js +14 -121
- package/dist/js/node/commands/deploy.js +0 -2
- package/dist/js/node/commands/dev.js +10 -44
- package/dist/js/node/commands/index.js +0 -6
- package/dist/js/node/commands/inspect.js +10 -90
- package/dist/js/node/commands/start.js +2 -11
- package/dist/js/node/exports/server.js +0 -1
- package/dist/js/node/hooks.js +0 -2
- package/dist/js/node/index.js +22 -32
- package/dist/js/node/locale/en.js +0 -1
- package/dist/js/node/locale/index.js +0 -4
- package/dist/js/node/locale/zh.js +0 -1
- package/dist/js/node/utils/commands.js +12 -0
- package/dist/js/node/utils/config.js +1 -25
- package/dist/js/node/utils/createServer.js +15 -11
- package/dist/js/node/utils/getSpecifiedEntries.js +0 -9
- package/dist/js/node/utils/language.js +0 -2
- package/dist/js/node/utils/printInstructions.js +3 -6
- package/dist/js/node/utils/routes.js +0 -5
- package/dist/js/treeshaking/analyze/constants.js +16 -0
- package/dist/js/treeshaking/analyze/generateCode.js +369 -0
- package/dist/js/treeshaking/analyze/getBundleEntry.js +69 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +184 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +185 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/index.js +2 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +24 -0
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +96 -0
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +129 -0
- package/dist/js/treeshaking/analyze/getServerRoutes.js +157 -0
- package/dist/js/treeshaking/analyze/index.js +334 -0
- package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +28 -0
- package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +16 -0
- package/dist/js/treeshaking/analyze/nestedRoutes.js +165 -0
- package/dist/js/treeshaking/analyze/templates.js +170 -0
- package/dist/js/treeshaking/analyze/utils.js +88 -0
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +212 -0
- package/dist/js/treeshaking/builder/createHtmlConfig.js +59 -0
- package/dist/js/treeshaking/builder/createOutputConfig.js +70 -0
- package/dist/js/treeshaking/builder/createSourceConfig.js +88 -0
- package/dist/js/treeshaking/builder/createToolsConfig.js +85 -0
- package/dist/js/treeshaking/builder/index.js +161 -0
- package/dist/js/treeshaking/builder/share.js +46 -0
- package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +46 -0
- package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +41 -0
- package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +121 -0
- package/dist/js/treeshaking/commands/build.js +83 -0
- package/dist/js/treeshaking/commands/deploy.js +26 -0
- package/dist/js/treeshaking/commands/dev.js +124 -0
- package/dist/js/treeshaking/commands/index.js +3 -0
- package/dist/js/treeshaking/commands/inspect.js +29 -0
- package/dist/js/treeshaking/commands/start.js +69 -0
- package/dist/js/treeshaking/exports/server.js +1 -0
- package/dist/js/treeshaking/hooks.js +21 -0
- package/dist/js/treeshaking/index.js +267 -0
- package/dist/js/treeshaking/locale/en.js +34 -0
- package/dist/js/treeshaking/locale/index.js +9 -0
- package/dist/js/treeshaking/locale/zh.js +34 -0
- package/dist/js/treeshaking/utils/commands.js +5 -0
- package/dist/js/treeshaking/utils/config.js +124 -0
- package/dist/js/treeshaking/utils/createServer.js +73 -0
- package/dist/js/treeshaking/utils/getSpecifiedEntries.js +58 -0
- package/dist/js/treeshaking/utils/language.js +5 -0
- package/dist/js/treeshaking/utils/printInstructions.js +30 -0
- package/dist/js/treeshaking/utils/routes.js +29 -0
- package/dist/js/treeshaking/utils/types.js +0 -0
- package/dist/types/analyze/constants.d.ts +1 -0
- package/dist/types/analyze/generateCode.d.ts +1 -1
- package/dist/types/analyze/{getClientRoutes.d.ts → getClientRoutes/getRoutes.d.ts} +2 -7
- package/dist/types/analyze/getClientRoutes/getRoutesLegacy.d.ts +15 -0
- package/dist/types/analyze/getClientRoutes/index.d.ts +2 -0
- package/dist/types/analyze/getClientRoutes/utils.d.ts +5 -0
- package/dist/types/analyze/index.d.ts +4 -5
- package/dist/types/analyze/nestedRoutes.d.ts +5 -0
- package/dist/types/analyze/templates.d.ts +19 -3
- package/dist/types/analyze/utils.d.ts +2 -1
- package/dist/types/builder/builderPlugins/compatModern.d.ts +13 -0
- package/dist/types/builder/createHtmlConfig.d.ts +6 -0
- package/dist/types/builder/createOutputConfig.d.ts +3 -0
- package/dist/types/builder/createSourceConfig.d.ts +5 -0
- package/dist/types/builder/createToolsConfig.d.ts +13 -0
- package/dist/types/builder/index.d.ts +15 -0
- package/dist/types/builder/share.d.ts +26 -0
- package/dist/types/builder/webpackPlugins/htmlAsyncChunkPlugin.d.ts +8 -0
- package/dist/types/builder/webpackPlugins/htmlBottomTemplate.d.ts +10 -0
- package/dist/types/builder/webpackPlugins/routerPlugin.d.ts +10 -0
- package/dist/types/commands/build.d.ts +2 -1
- package/dist/types/commands/deploy.d.ts +2 -1
- package/dist/types/commands/dev.d.ts +2 -1
- package/dist/types/commands/inspect.d.ts +2 -6
- package/dist/types/commands/start.d.ts +2 -1
- package/dist/types/hooks.d.ts +15 -10
- package/dist/types/index.d.ts +4 -4
- package/dist/types/locale/en.d.ts +0 -1
- package/dist/types/locale/index.d.ts +0 -2
- package/dist/types/locale/zh.d.ts +0 -1
- package/dist/types/utils/commands.d.ts +1 -0
- package/dist/types/utils/config.d.ts +0 -1
- package/dist/types/utils/createServer.d.ts +8 -1
- package/dist/types/utils/printInstructions.d.ts +3 -2
- package/dist/types/utils/types.d.ts +2 -3
- package/package.json +25 -42
- package/dist/js/modern/utils/createCompiler.js +0 -61
- package/dist/js/node/utils/createCompiler.js +0 -81
- package/dist/types/utils/createCompiler.d.ts +0 -13
|
@@ -2,6 +2,7 @@ export declare const JS_EXTENSIONS: string[];
|
|
|
2
2
|
export declare const INDEX_FILE_NAME = "index";
|
|
3
3
|
export declare const APP_FILE_NAME = "App";
|
|
4
4
|
export declare const PAGES_DIR_NAME = "pages";
|
|
5
|
+
export declare const NESTED_ROUTES_DIR = "routes";
|
|
5
6
|
export declare const FILE_SYSTEM_ROUTES_FILE_NAME = "routes.js";
|
|
6
7
|
export declare const ENTRY_POINT_FILE_NAME = "index.js";
|
|
7
8
|
export declare const ENTRY_BOOTSTRAP_FILE_NAME = "bootstrap.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { IAppContext, NormalizedConfig, PluginAPI, ImportStatement } from '@modern-js/core';
|
|
2
2
|
import type { Entrypoint } from '@modern-js/types';
|
|
3
3
|
export declare const createImportStatements: (statements: ImportStatement[]) => string;
|
|
4
4
|
export declare const generateCode: (appContext: IAppContext, config: NormalizedConfig, entrypoints: Entrypoint[], api: PluginAPI) => Promise<void>;
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import type { Entrypoint,
|
|
2
|
-
export type { Route };
|
|
3
|
-
export interface Identifier {
|
|
4
|
-
name: string;
|
|
5
|
-
path: string;
|
|
6
|
-
}
|
|
1
|
+
import type { Entrypoint, NestedRoute, PageRoute } from '@modern-js/types';
|
|
7
2
|
export declare const getClientRoutes: ({
|
|
8
3
|
entrypoint,
|
|
9
4
|
srcDirectory,
|
|
@@ -16,4 +11,4 @@ export declare const getClientRoutes: ({
|
|
|
16
11
|
srcAlias: string;
|
|
17
12
|
internalDirectory: string;
|
|
18
13
|
internalDirAlias: string;
|
|
19
|
-
}) =>
|
|
14
|
+
}) => (NestedRoute | PageRoute)[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Entrypoint, RouteLegacy } from '@modern-js/types';
|
|
2
|
+
export type { RouteLegacy as Route };
|
|
3
|
+
export declare const getClientRoutes: ({
|
|
4
|
+
entrypoint,
|
|
5
|
+
srcDirectory,
|
|
6
|
+
srcAlias,
|
|
7
|
+
internalDirectory,
|
|
8
|
+
internalDirAlias
|
|
9
|
+
}: {
|
|
10
|
+
entrypoint: Entrypoint;
|
|
11
|
+
srcDirectory: string;
|
|
12
|
+
srcAlias: string;
|
|
13
|
+
internalDirectory: string;
|
|
14
|
+
internalDirAlias: string;
|
|
15
|
+
}) => RouteLegacy[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
declare const debug: import("@modern-js/utils/compiled/debug").Debugger;
|
|
2
|
+
export { debug };
|
|
3
|
+
export declare const findLayout: (dir: string) => string | false;
|
|
4
|
+
export declare const getRouteWeight: (route: string) => number;
|
|
5
|
+
export declare const shouldSkip: (file: string) => boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CliPlugin, RuntimePlugin, ImportStatement } from '@modern-js/core';
|
|
2
|
-
import type {
|
|
2
|
+
import type { RouteLegacy, Entrypoint, ServerRoute, HtmlPartials, NestedRoute, PageRoute } from '@modern-js/types';
|
|
3
|
+
import type { AppHooks } from '../hooks';
|
|
3
4
|
export declare const modifyEntryImports: import("@modern-js/plugin").AsyncWaterfall<{
|
|
4
5
|
imports: ImportStatement[];
|
|
5
6
|
entrypoint: Entrypoint;
|
|
@@ -23,7 +24,7 @@ export declare const modifyAsyncEntry: import("@modern-js/plugin").AsyncWaterfal
|
|
|
23
24
|
}>;
|
|
24
25
|
export declare const modifyFileSystemRoutes: import("@modern-js/plugin").AsyncWaterfall<{
|
|
25
26
|
entrypoint: Entrypoint;
|
|
26
|
-
routes:
|
|
27
|
+
routes: RouteLegacy[] | (NestedRoute | PageRoute)[];
|
|
27
28
|
}>;
|
|
28
29
|
export declare const modifyServerRoutes: import("@modern-js/plugin").AsyncWaterfall<{
|
|
29
30
|
routes: ServerRoute[];
|
|
@@ -37,7 +38,5 @@ export declare const beforeGenerateRoutes: import("@modern-js/plugin").AsyncWate
|
|
|
37
38
|
code: string;
|
|
38
39
|
}>;
|
|
39
40
|
export declare const addDefineTypes: import("@modern-js/plugin").AsyncWaterfall<void>;
|
|
40
|
-
|
|
41
|
-
declare const _default: () => CliPlugin;
|
|
42
|
-
|
|
41
|
+
declare const _default: () => CliPlugin<AppHooks>;
|
|
43
42
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RuntimePlugin } from '@modern-js/core';
|
|
2
|
-
import type { Entrypoint,
|
|
2
|
+
import type { Entrypoint, NestedRoute, PageRoute, RouteLegacy } from '@modern-js/types';
|
|
3
3
|
export declare const index: ({
|
|
4
4
|
mountId,
|
|
5
5
|
imports,
|
|
@@ -25,8 +25,24 @@ export declare const html: (partials: {
|
|
|
25
25
|
head: string[];
|
|
26
26
|
body: string[];
|
|
27
27
|
}) => string;
|
|
28
|
+
export declare const routesForServer: ({
|
|
29
|
+
routes,
|
|
30
|
+
alias
|
|
31
|
+
}: {
|
|
32
|
+
routes: (NestedRoute | PageRoute)[];
|
|
33
|
+
alias: {
|
|
34
|
+
name: string;
|
|
35
|
+
basename: string;
|
|
36
|
+
};
|
|
37
|
+
}) => string;
|
|
28
38
|
export declare const fileSystemRoutes: ({
|
|
29
|
-
routes
|
|
39
|
+
routes,
|
|
40
|
+
ssrMode,
|
|
41
|
+
nestedRoutesEntry,
|
|
42
|
+
entryName
|
|
30
43
|
}: {
|
|
31
|
-
routes:
|
|
44
|
+
routes: RouteLegacy[] | (NestedRoute | PageRoute)[];
|
|
45
|
+
ssrMode: 'string' | 'stream' | false;
|
|
46
|
+
nestedRoutesEntry?: string | undefined;
|
|
47
|
+
entryName: string;
|
|
32
48
|
}) => string;
|
|
@@ -14,4 +14,5 @@ export declare const getDefaultImports: ({
|
|
|
14
14
|
internalDirAlias: string;
|
|
15
15
|
internalDirectory: string;
|
|
16
16
|
}) => ImportStatement[];
|
|
17
|
-
export declare const isRouteComponentFile: (filePath: string) => boolean;
|
|
17
|
+
export declare const isRouteComponentFile: (filePath: string) => boolean;
|
|
18
|
+
export declare const replaceWithAlias: (base: string, filePath: string, alias: string) => string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
+
import type { BuilderPluginAPI } from '@modern-js/builder-webpack-provider';
|
|
3
|
+
import type { IAppContext, NormalizedConfig } from '@modern-js/core';
|
|
4
|
+
declare type Parameter<T extends (arg: any) => void> = Parameters<T>[0];
|
|
5
|
+
declare type FnParameter<T extends {
|
|
6
|
+
[p: string]: (arg: any) => void;
|
|
7
|
+
}> = { [P in keyof T]: Parameter<T[P]> };
|
|
8
|
+
export declare type PluginCompatModernOptions = FnParameter<Partial<Pick<BuilderPluginAPI, 'onAfterBuild' | 'onAfterCreateCompiler' | 'onAfterStartDevServer' | 'onBeforeBuild' | 'onBeforeCreateCompiler' | 'onBeforeStartDevServer' | 'onDevCompileDone' | 'onExit'>>>;
|
|
9
|
+
/**
|
|
10
|
+
* Provides default configuration consistent with `@modern-js/webpack`
|
|
11
|
+
*/
|
|
12
|
+
export declare const PluginCompatModern: (appContext: IAppContext, modernConfig: NormalizedConfig, options?: PluginCompatModernOptions) => BuilderPlugin<BuilderPluginAPI>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
|
|
2
|
+
import type { IAppContext, NormalizedConfig } from '@modern-js/core';
|
|
3
|
+
export declare function createHtmlConfig(normalizedConfig: NormalizedConfig, appContext: IAppContext): BuilderConfig['html'];
|
|
4
|
+
export declare function createBuilderAppIcon(configDir: NormalizedConfig['source']['configDir'], appContext: IAppContext): string | undefined;
|
|
5
|
+
export declare function createBuilderCrossorigin(scriptExt: NormalizedConfig['output']['scriptExt']): "anonymous" | "use-credentials" | undefined;
|
|
6
|
+
export declare function createBuilderFavicon(favicon: NormalizedConfig['output']['favicon'], configDir: NormalizedConfig['source']['configDir'], appContext: IAppContext): string | undefined;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
|
|
2
|
+
import type { IAppContext, NormalizedConfig } from '@modern-js/core';
|
|
3
|
+
export declare function createOutputConfig(normalizedConfig: NormalizedConfig, appContext: IAppContext): BuilderConfig['output'];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BuilderConfig } from '@modern-js/builder-webpack-provider';
|
|
2
|
+
import { IAppContext, NormalizedConfig } from '@modern-js/core';
|
|
3
|
+
export declare function createSourceConfig(normalizedConfig: NormalizedConfig, appContext: IAppContext): BuilderConfig['source'];
|
|
4
|
+
export declare function createBuilderInclude(include: NormalizedConfig['source']['include'], appContext: IAppContext): (string | RegExp)[];
|
|
5
|
+
export declare function createBuilderModuleScope(moduleScopes: NormalizedConfig['source']['moduleScopes']): any[] | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
|
|
2
|
+
import type { NormalizedConfig } from '@modern-js/core';
|
|
3
|
+
export declare function createToolsConfig(normalizedConfig: NormalizedConfig): BuilderConfig['tools'];
|
|
4
|
+
export declare function createBuilderTsChecker(output: NormalizedConfig['output']): false | {
|
|
5
|
+
issue: {
|
|
6
|
+
include: {
|
|
7
|
+
file: string;
|
|
8
|
+
}[];
|
|
9
|
+
exclude: {
|
|
10
|
+
file: string;
|
|
11
|
+
}[];
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BuilderInstance, BuilderTarget, CreateBuilderOptions } from '@modern-js/builder';
|
|
2
|
+
import type { IAppContext, NormalizedConfig } from '@modern-js/core';
|
|
3
|
+
import { PluginCompatModernOptions } from './builderPlugins/compatModern';
|
|
4
|
+
export declare type BuilderOptions = {
|
|
5
|
+
target?: BuilderTarget | BuilderTarget[];
|
|
6
|
+
normalizedConfig: NormalizedConfig;
|
|
7
|
+
appContext: IAppContext;
|
|
8
|
+
compatPluginConfig?: PluginCompatModernOptions;
|
|
9
|
+
};
|
|
10
|
+
export declare function createBuilderForEdenX({
|
|
11
|
+
normalizedConfig,
|
|
12
|
+
appContext,
|
|
13
|
+
compatPluginConfig
|
|
14
|
+
}: BuilderOptions): Promise<BuilderInstance>;
|
|
15
|
+
export declare function createBuilderOptions(target: BuilderTarget | BuilderTarget[], appContext: IAppContext): CreateBuilderOptions;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { WebpackChain } from '@modern-js/builder-webpack-provider';
|
|
3
|
+
import { IAppContext, NormalizedConfig } from '@modern-js/core';
|
|
4
|
+
export declare function createCopyPattern(appContext: IAppContext, config: NormalizedConfig, patternsType: 'upload' | 'public', chain?: WebpackChain): {
|
|
5
|
+
info: (file: {
|
|
6
|
+
sourceFilename: string;
|
|
7
|
+
}) => {
|
|
8
|
+
minimized: boolean;
|
|
9
|
+
};
|
|
10
|
+
from: string;
|
|
11
|
+
to: string;
|
|
12
|
+
context: string;
|
|
13
|
+
noErrorOnMissing: boolean;
|
|
14
|
+
transform: (content: Buffer, absoluteFrom: string) => string | Buffer;
|
|
15
|
+
} | {
|
|
16
|
+
info: (file: {
|
|
17
|
+
sourceFilename: string;
|
|
18
|
+
}) => {
|
|
19
|
+
minimized: boolean;
|
|
20
|
+
};
|
|
21
|
+
from: string;
|
|
22
|
+
to: string;
|
|
23
|
+
context: string;
|
|
24
|
+
noErrorOnMissing: boolean;
|
|
25
|
+
transform?: undefined;
|
|
26
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { webpack } from '@modern-js/builder-webpack-provider';
|
|
2
|
+
import type HtmlWebpackPlugin from '@modern-js/builder-webpack-provider/html-webpack-plugin';
|
|
3
|
+
export declare class HtmlAsyncChunkPlugin {
|
|
4
|
+
name: string;
|
|
5
|
+
htmlWebpackPlugin: typeof HtmlWebpackPlugin;
|
|
6
|
+
constructor(htmlWebpackPlugin: typeof HtmlWebpackPlugin);
|
|
7
|
+
apply(compiler: webpack.Compiler): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { webpack } from '@modern-js/builder-webpack-provider';
|
|
2
|
+
import type HtmlWebpackPlugin from '@modern-js/builder-webpack-provider/html-webpack-plugin';
|
|
3
|
+
export declare class BottomTemplatePlugin {
|
|
4
|
+
htmlWebpackPlugin: typeof HtmlWebpackPlugin;
|
|
5
|
+
bottomTemplateReg: RegExp;
|
|
6
|
+
bodyRegExp: RegExp;
|
|
7
|
+
name: string;
|
|
8
|
+
constructor(htmlWebpackPlugin: typeof HtmlWebpackPlugin);
|
|
9
|
+
apply(compiler: webpack.Compiler): void;
|
|
10
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { PluginAPI } from '@modern-js/core';
|
|
2
2
|
import type { BuildOptions } from '../utils/types';
|
|
3
|
-
|
|
3
|
+
import type { AppHooks } from '../hooks';
|
|
4
|
+
export declare const build: (api: PluginAPI<AppHooks>, options?: BuildOptions) => Promise<void>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { PluginAPI } from '@modern-js/core';
|
|
2
2
|
import { DevOptions } from '../utils/types';
|
|
3
|
-
|
|
3
|
+
import type { AppHooks } from '../hooks';
|
|
4
|
+
export declare const dev: (api: PluginAPI<AppHooks>, options: DevOptions) => Promise<void>;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { PluginAPI, NormalizedConfig, IAppContext } from '@modern-js/core';
|
|
1
|
+
import type { PluginAPI } from '@modern-js/core';
|
|
3
2
|
import type { InspectOptions } from '../utils/types';
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const inspect: (api: PluginAPI, options: InspectOptions) => void;
|
|
6
|
-
export declare const getTagByWebpackTarget: (webpackTarget: WebpackConfigTarget) => "client" | "modern" | "ssr";
|
|
7
|
-
export declare const printInspectResult: (webpackTarget: WebpackConfigTarget, appContext: IAppContext, resolvedConfig: NormalizedConfig, options: InspectOptions) => string;
|
|
3
|
+
export declare const inspect: (api: PluginAPI, options: InspectOptions) => Promise<any>;
|
package/dist/types/hooks.d.ts
CHANGED
|
@@ -1,37 +1,42 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { webpack } from '@modern-js/builder-webpack-provider/types';
|
|
2
2
|
export declare const beforeDev: import("@modern-js/plugin").AsyncWorkflow<void, unknown>;
|
|
3
3
|
export declare const afterDev: import("@modern-js/plugin").AsyncWorkflow<void, unknown>;
|
|
4
4
|
export declare const beforeCreateCompiler: import("@modern-js/plugin").AsyncWorkflow<{
|
|
5
|
-
|
|
5
|
+
bundlerConfigs: webpack.Configuration[];
|
|
6
6
|
}, unknown>;
|
|
7
7
|
export declare const afterCreateCompiler: import("@modern-js/plugin").AsyncWorkflow<{
|
|
8
|
-
compiler: Compiler | MultiCompiler | undefined;
|
|
8
|
+
compiler: webpack.Compiler | webpack.MultiCompiler | undefined;
|
|
9
9
|
}, unknown>;
|
|
10
10
|
export declare const beforePrintInstructions: import("@modern-js/plugin").AsyncWaterfall<{
|
|
11
11
|
instructions: string;
|
|
12
12
|
}>;
|
|
13
13
|
export declare const beforeBuild: import("@modern-js/plugin").AsyncWorkflow<{
|
|
14
|
-
|
|
14
|
+
bundlerConfigs?: webpack.Configuration[] | undefined;
|
|
15
|
+
}, unknown>;
|
|
16
|
+
export declare const afterBuild: import("@modern-js/plugin").AsyncWorkflow<{
|
|
17
|
+
stats?: webpack.Stats | webpack.MultiStats | undefined;
|
|
15
18
|
}, unknown>;
|
|
16
|
-
export declare const afterBuild: import("@modern-js/plugin").AsyncWorkflow<void, unknown>;
|
|
17
19
|
export declare const beforeDeploy: import("@modern-js/plugin").AsyncWorkflow<Record<string, any>, unknown>;
|
|
18
20
|
export declare const afterDeploy: import("@modern-js/plugin").AsyncWorkflow<Record<string, any>, unknown>;
|
|
19
21
|
export declare const hooks: {
|
|
20
22
|
beforeDev: import("@modern-js/plugin").AsyncWorkflow<void, unknown>;
|
|
21
23
|
afterDev: import("@modern-js/plugin").AsyncWorkflow<void, unknown>;
|
|
22
24
|
beforeCreateCompiler: import("@modern-js/plugin").AsyncWorkflow<{
|
|
23
|
-
|
|
25
|
+
bundlerConfigs: webpack.Configuration[];
|
|
24
26
|
}, unknown>;
|
|
25
27
|
afterCreateCompiler: import("@modern-js/plugin").AsyncWorkflow<{
|
|
26
|
-
compiler: Compiler | MultiCompiler | undefined;
|
|
28
|
+
compiler: webpack.Compiler | webpack.MultiCompiler | undefined;
|
|
27
29
|
}, unknown>;
|
|
28
30
|
beforePrintInstructions: import("@modern-js/plugin").AsyncWaterfall<{
|
|
29
31
|
instructions: string;
|
|
30
32
|
}>;
|
|
31
33
|
beforeBuild: import("@modern-js/plugin").AsyncWorkflow<{
|
|
32
|
-
|
|
34
|
+
bundlerConfigs?: webpack.Configuration[] | undefined;
|
|
35
|
+
}, unknown>;
|
|
36
|
+
afterBuild: import("@modern-js/plugin").AsyncWorkflow<{
|
|
37
|
+
stats?: webpack.Stats | webpack.MultiStats | undefined;
|
|
33
38
|
}, unknown>;
|
|
34
|
-
afterBuild: import("@modern-js/plugin").AsyncWorkflow<void, unknown>;
|
|
35
39
|
beforeDeploy: import("@modern-js/plugin").AsyncWorkflow<Record<string, any>, unknown>;
|
|
36
40
|
afterDeploy: import("@modern-js/plugin").AsyncWorkflow<Record<string, any>, unknown>;
|
|
37
|
-
};
|
|
41
|
+
};
|
|
42
|
+
export declare type AppHooks = typeof hooks;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineConfig, CliPlugin } from '@modern-js/core';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { hooks, AppHooks } from './hooks';
|
|
3
|
+
export { defineConfig, hooks };
|
|
4
|
+
export type { AppHooks, CliPlugin };
|
|
5
|
+
declare const _default: () => CliPlugin<AppHooks>;
|
|
6
6
|
export default _default;
|
|
@@ -30,7 +30,6 @@ declare const localeKeys: {
|
|
|
30
30
|
inspect: {
|
|
31
31
|
env: string;
|
|
32
32
|
output: string;
|
|
33
|
-
noConsole: string;
|
|
34
33
|
verbose: string;
|
|
35
34
|
};
|
|
36
35
|
};
|
|
@@ -64,7 +63,6 @@ declare const localeKeys: {
|
|
|
64
63
|
inspect: {
|
|
65
64
|
env: string;
|
|
66
65
|
output: string;
|
|
67
|
-
noConsole: string;
|
|
68
66
|
verbose: string;
|
|
69
67
|
};
|
|
70
68
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getCommand: () => string;
|
|
@@ -17,6 +17,5 @@ export declare const buildServerConfig: ({
|
|
|
17
17
|
*
|
|
18
18
|
* 处理循环引用的 replacer
|
|
19
19
|
*/
|
|
20
|
-
|
|
21
20
|
export declare const safeReplacer: () => (key: string, value: unknown) => unknown;
|
|
22
21
|
export declare const emitResolvedConfig: (appDirectory: string, resolvedConfig: NormalizedConfig) => Promise<void>;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { Server, ModernDevServerOptions } from '@modern-js/server';
|
|
2
|
+
import type { InternalPlugins } from '@modern-js/types';
|
|
2
3
|
export declare const getServer: () => Server | null;
|
|
3
4
|
export declare const closeServer: () => Promise<void>;
|
|
4
|
-
export declare const createServer: (options: ModernDevServerOptions) => Promise<Server>;
|
|
5
|
+
export declare const createServer: (options: ModernDevServerOptions) => Promise<Server>;
|
|
6
|
+
export declare const injectDataLoaderPlugin: (internalPlugins: InternalPlugins) => {
|
|
7
|
+
'@modern-js/plugin-data-loader': {
|
|
8
|
+
path: string;
|
|
9
|
+
forced: boolean;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type { IAppContext, NormalizedConfig, ToRunners
|
|
2
|
-
|
|
1
|
+
import type { IAppContext, NormalizedConfig, ToRunners } from '@modern-js/core';
|
|
2
|
+
import type { AppHooks } from '../hooks';
|
|
3
|
+
export declare const printInstructions: (hookRunners: ToRunners<AppHooks>, appContext: IAppContext, config: NormalizedConfig) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "
|
|
14
|
+
"version": "2.0.0-beta.1",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -55,22 +55,27 @@
|
|
|
55
55
|
"modern": "./bin/modern.js"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@babel/runtime": "^7.18.0",
|
|
59
58
|
"@babel/parser": "^7.18.0",
|
|
59
|
+
"@babel/runtime": "^7.18.0",
|
|
60
60
|
"@babel/traverse": "^7.18.0",
|
|
61
61
|
"@babel/types": "^7.18.0",
|
|
62
|
-
"@modern-js/
|
|
63
|
-
"@modern-js/
|
|
64
|
-
"@modern-js/
|
|
65
|
-
"@modern-js/
|
|
66
|
-
"@modern-js/
|
|
67
|
-
"@modern-js/
|
|
68
|
-
"@modern-js/
|
|
69
|
-
"@modern-js/
|
|
70
|
-
"@modern-js/
|
|
71
|
-
"@modern-js/
|
|
72
|
-
"@modern-js/
|
|
73
|
-
"@modern-js/
|
|
62
|
+
"@modern-js/builder": "2.0.0-beta.1",
|
|
63
|
+
"@modern-js/builder-plugin-esbuild": "2.0.0-beta.1",
|
|
64
|
+
"@modern-js/builder-plugin-node-polyfill": "2.0.0-beta.1",
|
|
65
|
+
"@modern-js/builder-shared": "2.0.0-beta.1",
|
|
66
|
+
"@modern-js/builder-webpack-provider": "2.0.0-beta.1",
|
|
67
|
+
"@modern-js/core": "2.0.0-beta.1",
|
|
68
|
+
"@modern-js/new-action": "2.0.0-beta.1",
|
|
69
|
+
"@modern-js/node-bundle-require": "2.0.0-beta.1",
|
|
70
|
+
"@modern-js/plugin": "2.0.0-beta.1",
|
|
71
|
+
"@modern-js/plugin-data-loader": "2.0.0-beta.1",
|
|
72
|
+
"@modern-js/plugin-i18n": "2.0.0-beta.1",
|
|
73
|
+
"@modern-js/plugin-lint": "2.0.0-beta.1",
|
|
74
|
+
"@modern-js/prod-server": "2.0.0-beta.1",
|
|
75
|
+
"@modern-js/server": "2.0.0-beta.1",
|
|
76
|
+
"@modern-js/types": "2.0.0-beta.1",
|
|
77
|
+
"@modern-js/upgrade": "2.0.0-beta.1",
|
|
78
|
+
"@modern-js/utils": "2.0.0-beta.1"
|
|
74
79
|
},
|
|
75
80
|
"devDependencies": {
|
|
76
81
|
"@types/babel__traverse": "^7.14.2",
|
|
@@ -78,42 +83,20 @@
|
|
|
78
83
|
"@types/node": "^14",
|
|
79
84
|
"jest": "^27",
|
|
80
85
|
"typescript": "^4",
|
|
81
|
-
"
|
|
82
|
-
"@
|
|
83
|
-
"@scripts/
|
|
86
|
+
"webpack": "^5.75.0",
|
|
87
|
+
"@modern-js/server-core": "2.0.0-beta.1",
|
|
88
|
+
"@scripts/build": "2.0.0-beta.1",
|
|
89
|
+
"@scripts/jest-config": "2.0.0-beta.1"
|
|
84
90
|
},
|
|
85
91
|
"sideEffects": false,
|
|
86
92
|
"publishConfig": {
|
|
87
93
|
"registry": "https://registry.npmjs.org/",
|
|
88
94
|
"access": "public"
|
|
89
95
|
},
|
|
90
|
-
"wireit": {
|
|
91
|
-
"build": {
|
|
92
|
-
"command": "modern build",
|
|
93
|
-
"files": [
|
|
94
|
-
"src/**/*",
|
|
95
|
-
"tsconfig.json",
|
|
96
|
-
"package.json"
|
|
97
|
-
],
|
|
98
|
-
"output": [
|
|
99
|
-
"dist/**/*"
|
|
100
|
-
]
|
|
101
|
-
},
|
|
102
|
-
"test": {
|
|
103
|
-
"command": "jest --passWithNoTests",
|
|
104
|
-
"files": [
|
|
105
|
-
"src/**/*",
|
|
106
|
-
"tsconfig.json",
|
|
107
|
-
"package.json",
|
|
108
|
-
"tests/**/*"
|
|
109
|
-
],
|
|
110
|
-
"output": []
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
96
|
"scripts": {
|
|
114
97
|
"new": "modern new",
|
|
115
98
|
"dev": "modern build --watch",
|
|
116
|
-
"build": "
|
|
117
|
-
"test": "
|
|
99
|
+
"build": "modern build",
|
|
100
|
+
"test": "jest --passWithNoTests"
|
|
118
101
|
}
|
|
119
102
|
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { webpack } from '@modern-js/webpack';
|
|
2
|
-
import { chalk, logger, formatWebpackMessages, clearConsole } from '@modern-js/utils';
|
|
3
|
-
import { printInstructions } from "./printInstructions";
|
|
4
|
-
export const createCompiler = async ({
|
|
5
|
-
api,
|
|
6
|
-
webpackConfigs,
|
|
7
|
-
// TODO: params
|
|
8
|
-
userConfig,
|
|
9
|
-
appContext
|
|
10
|
-
}) => {
|
|
11
|
-
try {
|
|
12
|
-
const hookRunners = api.useHookRunners();
|
|
13
|
-
await hookRunners.beforeCreateCompiler({
|
|
14
|
-
webpackConfigs
|
|
15
|
-
});
|
|
16
|
-
const compiler = webpack(webpackConfigs);
|
|
17
|
-
await hookRunners.afterCreateCompiler({
|
|
18
|
-
compiler
|
|
19
|
-
});
|
|
20
|
-
let isFirstCompile = true;
|
|
21
|
-
compiler.hooks.invalid.tap('invalid', () => {
|
|
22
|
-
clearConsole();
|
|
23
|
-
logger.log('Compiling...');
|
|
24
|
-
});
|
|
25
|
-
compiler.hooks.done.tap('done', async stats => {
|
|
26
|
-
const statsData = stats.toJson({
|
|
27
|
-
preset: 'errors-warnings'
|
|
28
|
-
});
|
|
29
|
-
const {
|
|
30
|
-
errors,
|
|
31
|
-
warnings
|
|
32
|
-
} = formatWebpackMessages(statsData);
|
|
33
|
-
|
|
34
|
-
if (errors.length) {
|
|
35
|
-
logger.log(chalk.red(`Failed to compile.\n`));
|
|
36
|
-
logger.log(errors.join('\n\n'));
|
|
37
|
-
logger.log();
|
|
38
|
-
} else if (process.stdout.isTTY || isFirstCompile) {
|
|
39
|
-
await hookRunners.afterDev();
|
|
40
|
-
|
|
41
|
-
if (warnings.length) {
|
|
42
|
-
logger.log(chalk.yellow(`Compiled with warnings.\n`));
|
|
43
|
-
logger.log(warnings.join('\n\n'));
|
|
44
|
-
logger.log();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
await printInstructions(hookRunners, appContext, userConfig);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
isFirstCompile = false;
|
|
51
|
-
});
|
|
52
|
-
return compiler;
|
|
53
|
-
} catch (err) {
|
|
54
|
-
logger.log(chalk.red(`Failed to compile.`));
|
|
55
|
-
logger.log();
|
|
56
|
-
logger.log(err); // FIXME: 这里最好抛出异常,执行 process.exit 的地方尽可能少或者控制在几个统一的地方比较合适
|
|
57
|
-
// eslint-disable-next-line no-process-exit
|
|
58
|
-
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
};
|