@bleedingdev/modern-js-app-tools 3.2.0-ultramodern.5 → 3.2.0-ultramodern.51
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/dist/cjs/builder/generator/getBuilderEnvironments.js +143 -8
- package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +41 -5
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +3 -1
- package/dist/cjs/plugins/deploy/index.js +17 -6
- package/dist/cjs/plugins/deploy/platforms/cloudflare.js +220 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.mjs +258 -0
- package/dist/cjs/rsbuild.js +3 -0
- package/dist/esm/builder/generator/getBuilderEnvironments.mjs +132 -8
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.mjs +41 -5
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.mjs +3 -1
- package/dist/esm/plugins/deploy/index.mjs +10 -4
- package/dist/esm/plugins/deploy/platforms/cloudflare.mjs +176 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.mjs +258 -0
- package/dist/esm/rsbuild.mjs +5 -2
- package/dist/esm-node/builder/generator/getBuilderEnvironments.mjs +134 -9
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.mjs +41 -5
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.mjs +3 -1
- package/dist/esm-node/plugins/deploy/index.mjs +10 -4
- package/dist/esm-node/plugins/deploy/platforms/cloudflare.mjs +177 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.mjs +258 -0
- package/dist/esm-node/rsbuild.mjs +5 -2
- package/dist/types/baseline.d.ts +46 -0
- package/dist/types/builder/builder-rspack/index.d.ts +2 -0
- package/dist/types/builder/generator/adapterCopy.d.ts +3 -0
- package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +3 -0
- package/dist/types/builder/generator/createCopyPattern.d.ts +16 -0
- package/dist/types/builder/generator/getBuilderEnvironments.d.ts +6 -0
- package/dist/types/builder/generator/index.d.ts +8 -0
- package/dist/types/builder/index.d.ts +3 -0
- package/dist/types/builder/shared/builderPlugins/adapterBasic.d.ts +3 -0
- package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +3 -0
- package/dist/types/builder/shared/builderPlugins/adapterPrecompress.d.ts +3 -0
- package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +3 -0
- package/dist/types/builder/shared/builderPlugins/builderHooks.d.ts +3 -0
- package/dist/types/builder/shared/builderPlugins/index.d.ts +5 -0
- package/dist/types/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.d.ts +7 -0
- package/dist/types/builder/shared/bundlerPlugins/HtmlBottomTemplate.d.ts +9 -0
- package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +32 -0
- package/dist/types/builder/shared/bundlerPlugins/index.d.ts +3 -0
- package/dist/types/builder/shared/createCopyInfo.d.ts +8 -0
- package/dist/types/builder/shared/index.d.ts +3 -0
- package/dist/types/builder/shared/loaders/serverModuleLoader.d.ts +3 -0
- package/dist/types/builder/shared/types.d.ts +6 -0
- package/dist/types/commands/build.d.ts +4 -0
- package/dist/types/commands/deploy.d.ts +3 -0
- package/dist/types/commands/dev.d.ts +9 -0
- package/dist/types/commands/index.d.ts +10 -0
- package/dist/types/commands/info.d.ts +18 -0
- package/dist/types/commands/inspect.d.ts +4 -0
- package/dist/types/commands/runtime.d.ts +11 -0
- package/dist/types/commands/serve.d.ts +8 -0
- package/dist/types/compat/hooks.d.ts +7 -0
- package/dist/types/compat/index.d.ts +2 -0
- package/dist/types/compat/utils.d.ts +13 -0
- package/dist/types/config/default.d.ts +3 -0
- package/dist/types/config/index.d.ts +2 -0
- package/dist/types/config/initialize/index.d.ts +3 -0
- package/dist/types/config/initialize/inits.d.ts +4 -0
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/defineConfig.d.ts +11 -0
- package/dist/types/esm/register-esm.d.mts +5 -0
- package/dist/types/esm/ts-paths-loader.d.mts +6 -0
- package/dist/types/exports/server.d.ts +1 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/locale/en.d.ts +44 -0
- package/dist/types/locale/index.d.ts +3 -0
- package/dist/types/locale/zh.d.ts +44 -0
- package/dist/types/plugins/analyze/constants.d.ts +3 -0
- package/dist/types/plugins/analyze/getBundleEntry.d.ts +4 -0
- package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +7 -0
- package/dist/types/plugins/analyze/getHtmlTemplate.d.ts +27 -0
- package/dist/types/plugins/analyze/getServerRoutes.d.ts +8 -0
- package/dist/types/plugins/analyze/index.d.ts +3 -0
- package/dist/types/plugins/analyze/isDefaultExportFunction.d.ts +1 -0
- package/dist/types/plugins/analyze/templates.d.ts +5 -0
- package/dist/types/plugins/analyze/utils.d.ts +10 -0
- package/dist/types/plugins/deploy/index.d.ts +6 -0
- package/dist/types/plugins/deploy/platforms/cloudflare.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/gh-pages.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/netlify.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/node.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/platform.d.ts +17 -0
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.d.mts +4 -0
- package/dist/types/plugins/deploy/platforms/templates/netlify-entry.d.cts +2 -0
- package/dist/types/plugins/deploy/platforms/templates/netlify-entry.d.mts +2 -0
- package/dist/types/plugins/deploy/platforms/templates/node-entry.d.cts +1 -0
- package/dist/types/plugins/deploy/platforms/templates/node-entry.d.mts +1 -0
- package/dist/types/plugins/deploy/platforms/templates/vercel-entry.d.cts +2 -0
- package/dist/types/plugins/deploy/platforms/templates/vercel-entry.d.mts +2 -0
- package/dist/types/plugins/deploy/platforms/vercel.d.ts +2 -0
- package/dist/types/plugins/deploy/types.d.ts +3 -0
- package/dist/types/plugins/deploy/utils/generator.d.ts +24 -0
- package/dist/types/plugins/deploy/utils/index.d.ts +16 -0
- package/dist/types/plugins/initialize/index.d.ts +3 -0
- package/dist/types/plugins/serverBuild.d.ts +3 -0
- package/dist/types/plugins/serverRuntime.d.ts +3 -0
- package/dist/types/presetUltramodern.d.ts +6 -0
- package/dist/types/rsbuild.d.ts +12 -0
- package/dist/types/run/index.d.ts +20 -0
- package/dist/types/types/config/deploy.d.ts +46 -0
- package/dist/types/types/config/dev.d.ts +55 -0
- package/dist/types/types/config/experiments.d.ts +3 -0
- package/dist/types/types/config/html.d.ts +3 -0
- package/dist/types/types/config/index.d.ts +48 -0
- package/dist/types/types/config/output.d.ts +61 -0
- package/dist/types/types/config/performance.d.ts +3 -0
- package/dist/types/types/config/resolve.d.ts +2 -0
- package/dist/types/types/config/security.d.ts +2 -0
- package/dist/types/types/config/source.d.ts +61 -0
- package/dist/types/types/config/testing.d.ts +8 -0
- package/dist/types/types/config/tools.d.ts +21 -0
- package/dist/types/types/index.d.ts +10 -0
- package/dist/types/types/plugin.d.ts +114 -0
- package/dist/types/types/utils.d.ts +1 -0
- package/dist/types/ultramodern/designSystem.d.ts +54 -0
- package/dist/types/utils/config.d.ts +2 -0
- package/dist/types/utils/createServer.d.ts +5 -0
- package/dist/types/utils/env.d.ts +2 -0
- package/dist/types/utils/generateWatchFiles.d.ts +2 -0
- package/dist/types/utils/getConfigFile.d.ts +1 -0
- package/dist/types/utils/getSelectedEntries.d.ts +5 -0
- package/dist/types/utils/initAppContext.d.ts +31 -0
- package/dist/types/utils/loadPlugins.d.ts +13 -0
- package/dist/types/utils/printInstructions.d.ts +3 -0
- package/dist/types/utils/register.d.ts +19 -0
- package/dist/types/utils/restart.d.ts +2 -0
- package/dist/types/utils/routes.d.ts +4 -0
- package/dist/types/utils/types.d.ts +49 -0
- package/package.json +15 -15
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ProdServerOptions } from '@modern-js/prod-server';
|
|
2
|
+
import type { AppToolsNormalizedConfig } from '../../../types';
|
|
3
|
+
import type { AppToolsContext } from '../../../types/plugin';
|
|
4
|
+
export declare const serverAppContextTemplate: (appContext: AppToolsContext) => {
|
|
5
|
+
sharedDirectory: string;
|
|
6
|
+
apiDirectory: string;
|
|
7
|
+
lambdaDirectory: string;
|
|
8
|
+
metaName: any;
|
|
9
|
+
bffRuntimeFramework: any;
|
|
10
|
+
};
|
|
11
|
+
export type PluginItem = [string, Record<string, any> | undefined];
|
|
12
|
+
export declare const genPluginImportsCode: (plugins: PluginItem[], isESM?: boolean) => string;
|
|
13
|
+
export declare const getPluginsCode: (plugins: PluginItem[]) => string;
|
|
14
|
+
export declare const getServerConfigPath: (meta: string) => string;
|
|
15
|
+
export interface GenerateHandlerOptions {
|
|
16
|
+
template: string;
|
|
17
|
+
appContext: AppToolsContext;
|
|
18
|
+
config: AppToolsNormalizedConfig;
|
|
19
|
+
serverConfig?: Partial<ProdServerOptions>;
|
|
20
|
+
genAppContextTemplate?: typeof serverAppContextTemplate;
|
|
21
|
+
genPluginImports?: typeof genPluginImportsCode;
|
|
22
|
+
isESM?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare const generateHandler: ({ template, appContext, config, serverConfig: modifyServerConfig, genAppContextTemplate, genPluginImports, isESM, }: GenerateHandlerOptions) => Promise<string>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type ServerAppContext = {
|
|
2
|
+
sharedDirectory: string;
|
|
3
|
+
apiDirectory: string;
|
|
4
|
+
lambdaDirectory: string;
|
|
5
|
+
metaName: string;
|
|
6
|
+
bffRuntimeFramework: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const normalizePath: (filePath: string) => string;
|
|
9
|
+
export declare const getProjectUsage: (appDirectory: string, distDirectory: string, metaName: string) => {
|
|
10
|
+
useSSR: boolean;
|
|
11
|
+
useAPI: boolean;
|
|
12
|
+
useWebServer: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare const getTemplatePath: (file: string) => string;
|
|
15
|
+
export declare const readTemplate: (file: string) => Promise<any>;
|
|
16
|
+
export declare const resolveESMDependency: (entry: string) => Promise<string | undefined>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type AppBaselineOptions } from './baseline';
|
|
2
|
+
import type { AppUserConfig } from './types';
|
|
3
|
+
export interface PresetUltramodernOptions extends AppBaselineOptions {
|
|
4
|
+
}
|
|
5
|
+
export declare const createPresetUltramodernConfig: (options?: PresetUltramodernOptions) => AppUserConfig;
|
|
6
|
+
export declare const presetUltramodern: (config: AppUserConfig, options?: PresetUltramodernOptions) => AppUserConfig;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AppUserConfig } from './types';
|
|
2
|
+
type ResolveModernRsbuildConfigOptions = {
|
|
3
|
+
command: string;
|
|
4
|
+
configPath?: string;
|
|
5
|
+
cwd?: string;
|
|
6
|
+
metaName?: string;
|
|
7
|
+
modifyModernConfig?: (config: AppUserConfig) => AppUserConfig | Promise<AppUserConfig>;
|
|
8
|
+
};
|
|
9
|
+
export declare function resolveModernRsbuildConfig(options: ResolveModernRsbuildConfigOptions): Promise<{
|
|
10
|
+
rsbuildConfig: any;
|
|
11
|
+
}>;
|
|
12
|
+
export type { ResolveModernRsbuildConfigOptions };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { InternalPlugins } from '@modern-js/types';
|
|
2
|
+
import { handleSetupResult } from '../compat/hooks';
|
|
3
|
+
export interface RunOptions {
|
|
4
|
+
cwd?: string;
|
|
5
|
+
configFile?: string;
|
|
6
|
+
metaName?: string;
|
|
7
|
+
statePluginName?: string;
|
|
8
|
+
internalPlugins?: InternalPlugins;
|
|
9
|
+
initialLog?: string;
|
|
10
|
+
version: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function createRunOptions({ cwd, initialLog, metaName, version, internalPlugins, configFile, }: RunOptions): Promise<{
|
|
13
|
+
cwd: string | undefined;
|
|
14
|
+
initialLog: string;
|
|
15
|
+
configFile: string;
|
|
16
|
+
metaName: string;
|
|
17
|
+
internalPlugins: any;
|
|
18
|
+
handleSetupResult: typeof handleSetupResult;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function run(options: RunOptions): Promise<void>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface MicroFrontend {
|
|
2
|
+
/**
|
|
3
|
+
* Specifies whether to enable the HTML entry.
|
|
4
|
+
* When set to `true`, the current child application will be externalized for `react` and `react-dom`.
|
|
5
|
+
* @default true
|
|
6
|
+
*/
|
|
7
|
+
enableHtmlEntry?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Specifies whether to use the external base library.
|
|
10
|
+
* @default false
|
|
11
|
+
*/
|
|
12
|
+
externalBasicLibrary?: boolean;
|
|
13
|
+
moduleApp?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Runtime compatibility digest exposed in remote contracts (manifest / remote entry).
|
|
16
|
+
*/
|
|
17
|
+
runtimeDigest?: string;
|
|
18
|
+
/**
|
|
19
|
+
* SRI-style integrity token for the remote entry contract.
|
|
20
|
+
* Example: `sha256-<base64Digest>`.
|
|
21
|
+
*/
|
|
22
|
+
integrity?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Opaque attestation token exposed in remote runtime metadata.
|
|
25
|
+
* Can be validated by the host via runtime `remoteTrust.attestations`.
|
|
26
|
+
*/
|
|
27
|
+
attestation?: string;
|
|
28
|
+
}
|
|
29
|
+
export type DeployTarget = 'node' | 'vercel' | 'netlify' | 'ghPages' | 'cloudflare';
|
|
30
|
+
export interface DeployUserConfig {
|
|
31
|
+
/**
|
|
32
|
+
* Selects the deploy output preset.
|
|
33
|
+
* `MODERNJS_DEPLOY` still overrides provider auto-detection when set.
|
|
34
|
+
* @default node
|
|
35
|
+
*/
|
|
36
|
+
target?: DeployTarget;
|
|
37
|
+
/**
|
|
38
|
+
* Used to configure micro-frontend sub-application information.
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
microFrontend?: boolean | MicroFrontend;
|
|
42
|
+
worker?: {
|
|
43
|
+
name?: string;
|
|
44
|
+
ssr?: boolean;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { BuilderConfig } from '@modern-js/builder';
|
|
2
|
+
import type { CorsOptions, SetupMiddlewares } from '@modern-js/server';
|
|
3
|
+
import type { ServerConfig } from '@rsbuild/core';
|
|
4
|
+
type BuilderDevConfig = NonNullable<BuilderConfig['dev']>;
|
|
5
|
+
export type DevProxyOptions = string | Record<string, string>;
|
|
6
|
+
export interface DevServerUserConfig {
|
|
7
|
+
/**
|
|
8
|
+
* Configure CORS for the dev server.
|
|
9
|
+
* - object: enable CORS with the specified options.
|
|
10
|
+
* - true: enable CORS with default options (allow all origins, not recommended).
|
|
11
|
+
* - false: disable CORS.
|
|
12
|
+
* @default
|
|
13
|
+
* ```js
|
|
14
|
+
* { origin: defaultAllowedOrigins }
|
|
15
|
+
* ```
|
|
16
|
+
* where `defaultAllowedOrigins` includes:
|
|
17
|
+
* - `localhost`
|
|
18
|
+
* - `127.0.0.1`
|
|
19
|
+
*
|
|
20
|
+
* @link https://github.com/expressjs/cors
|
|
21
|
+
*/
|
|
22
|
+
cors?: boolean | CorsOptions;
|
|
23
|
+
/**
|
|
24
|
+
* Whether to enable gzip compression for served static assets.
|
|
25
|
+
*/
|
|
26
|
+
compress?: ServerConfig['compress'];
|
|
27
|
+
/**
|
|
28
|
+
* Adds headers to all responses.
|
|
29
|
+
*/
|
|
30
|
+
headers?: ServerConfig['headers'];
|
|
31
|
+
/**
|
|
32
|
+
* The index.html page will likely have to be served in place of any 404 responses.
|
|
33
|
+
*/
|
|
34
|
+
historyApiFallback?: ServerConfig['historyApiFallback'];
|
|
35
|
+
/**
|
|
36
|
+
* Proxying some URLs.
|
|
37
|
+
*/
|
|
38
|
+
proxy?: ServerConfig['proxy'];
|
|
39
|
+
/**
|
|
40
|
+
* Whether to watch files change in directories such as `mock/`, `server/`, `api/`.
|
|
41
|
+
*/
|
|
42
|
+
watch?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* setupMiddlewares is a special field, it will not be passed to Rsbuild.
|
|
46
|
+
* Although its name is the same as in Rsbuild, it is consumed by Modern.js.
|
|
47
|
+
*/
|
|
48
|
+
export type DevUserConfig = Omit<BuilderDevConfig, 'setupMiddlewares'> & {
|
|
49
|
+
setupMiddlewares?: SetupMiddlewares;
|
|
50
|
+
/**
|
|
51
|
+
* Dev server specific options.
|
|
52
|
+
*/
|
|
53
|
+
server?: DevServerUserConfig;
|
|
54
|
+
};
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { CLIPlugin, CLIPluginExtends } from '@modern-js/plugin';
|
|
2
|
+
import type { BffUserConfig, ServerUserConfig } from '@modern-js/server-core';
|
|
3
|
+
import type { RsbuildConfig } from '@rsbuild/core';
|
|
4
|
+
import type { AppToolsExtendAPI, AppToolsExtendContext, AppToolsExtendHooks } from '../plugin';
|
|
5
|
+
import type { DeployUserConfig } from './deploy';
|
|
6
|
+
import type { DevUserConfig } from './dev';
|
|
7
|
+
import type { ExperimentsUserConfig } from './experiments';
|
|
8
|
+
import type { HtmlUserConfig } from './html';
|
|
9
|
+
import type { OutputUserConfig } from './output';
|
|
10
|
+
import type { PerformanceUserConfig } from './performance';
|
|
11
|
+
import type { ResolveUserConfig } from './resolve';
|
|
12
|
+
import type { SecurityUserConfig } from './security';
|
|
13
|
+
import type { SourceUserConfig } from './source';
|
|
14
|
+
import type { TestingUserConfig } from './testing';
|
|
15
|
+
import type { ToolsUserConfig } from './tools';
|
|
16
|
+
export * from './output';
|
|
17
|
+
export type AppToolsBuilderPlugins = NonNullable<RsbuildConfig['plugins']>;
|
|
18
|
+
export interface AppToolsUserConfig {
|
|
19
|
+
resolve?: ResolveUserConfig;
|
|
20
|
+
server?: ServerUserConfig;
|
|
21
|
+
source?: SourceUserConfig;
|
|
22
|
+
output?: OutputUserConfig;
|
|
23
|
+
experiments?: ExperimentsUserConfig;
|
|
24
|
+
/**
|
|
25
|
+
* The configuration of `bff` is provided by `bff` plugin.
|
|
26
|
+
* Please use `yarn new` or `pnpm new` to enable the corresponding capability.
|
|
27
|
+
* @requires `bff` plugin
|
|
28
|
+
*/
|
|
29
|
+
bff?: BffUserConfig;
|
|
30
|
+
dev?: DevUserConfig;
|
|
31
|
+
deploy?: DeployUserConfig;
|
|
32
|
+
html?: HtmlUserConfig;
|
|
33
|
+
tools?: ToolsUserConfig;
|
|
34
|
+
security?: SecurityUserConfig;
|
|
35
|
+
testing?: TestingUserConfig;
|
|
36
|
+
builderPlugins?: AppToolsBuilderPlugins;
|
|
37
|
+
performance?: PerformanceUserConfig;
|
|
38
|
+
environments?: RsbuildConfig['environments'];
|
|
39
|
+
splitChunks?: RsbuildConfig['splitChunks'];
|
|
40
|
+
plugins?: CliPlugin<AppTools>[];
|
|
41
|
+
}
|
|
42
|
+
interface SharedNormalizedConfig<RawConfig> {
|
|
43
|
+
cliOptions?: Record<string, any>;
|
|
44
|
+
_raw: RawConfig;
|
|
45
|
+
}
|
|
46
|
+
export type AppToolsNormalizedConfig<Config = AppToolsUserConfig> = Required<Config> & SharedNormalizedConfig<Config>;
|
|
47
|
+
export type AppTools = Required<CLIPluginExtends<AppToolsUserConfig, AppToolsNormalizedConfig, AppToolsExtendContext, AppToolsExtendAPI, AppToolsExtendHooks>>;
|
|
48
|
+
export type CliPlugin<Extends extends CLIPluginExtends> = CLIPlugin<Extends>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { BuilderConfig } from '@modern-js/builder';
|
|
2
|
+
import type { SSGConfig, SSGMultiEntryOptions } from '@modern-js/types';
|
|
3
|
+
import type CompressionPlugin from 'compression-webpack-plugin';
|
|
4
|
+
import type { UnwrapBuilderConfig } from '../utils';
|
|
5
|
+
type CompressionPluginOptions = NonNullable<ConstructorParameters<typeof CompressionPlugin>[0]>;
|
|
6
|
+
export type PrecompressCodecOptions = boolean | CompressionPluginOptions;
|
|
7
|
+
export interface PrecompressConfig {
|
|
8
|
+
/**
|
|
9
|
+
* Configure gzip precompression options.
|
|
10
|
+
* `true` means using default options.
|
|
11
|
+
* `false` means disabling gzip precompression.
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
gzip?: PrecompressCodecOptions;
|
|
15
|
+
/**
|
|
16
|
+
* Configure brotli precompression options.
|
|
17
|
+
* `true` means using default options.
|
|
18
|
+
* `false` means disabling brotli precompression.
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
brotli?: PrecompressCodecOptions;
|
|
22
|
+
}
|
|
23
|
+
export interface OutputUserConfig extends UnwrapBuilderConfig<BuilderConfig, 'output'> {
|
|
24
|
+
/**
|
|
25
|
+
* Enable SSG for self-controlled routing or conventional routing.
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
ssg?: SSGConfig;
|
|
29
|
+
/**
|
|
30
|
+
* Specify SSG configuration by entries for multi-entry apps.
|
|
31
|
+
* Takes precedence over `ssg` when provided.
|
|
32
|
+
*/
|
|
33
|
+
ssgByEntries?: SSGMultiEntryOptions;
|
|
34
|
+
/**
|
|
35
|
+
* When using convention-based routing, the framework will split js and css based on the route to load on demand.
|
|
36
|
+
* If your project does not want to split js and css based on routes, you can set this option to false.
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
splitRouteChunks?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Used to control whether to inject convention-based routing information into the HTML.
|
|
42
|
+
* @default true
|
|
43
|
+
*/
|
|
44
|
+
enableInlineRouteManifests?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Used to control whether to inject convention-based routing information into the HTML.
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
disableInlineRouteManifests?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Specify the temporary directory for framework generated files.
|
|
52
|
+
*/
|
|
53
|
+
tempDir?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Generate precompressed static assets by using compression-webpack-plugin.
|
|
56
|
+
* `true` means enabling both gzip and brotli with default options.
|
|
57
|
+
* @default true
|
|
58
|
+
*/
|
|
59
|
+
precompress?: boolean | PrecompressConfig;
|
|
60
|
+
}
|
|
61
|
+
export type { SSGConfig, SSGMultiEntryOptions, SSGRouteOptions, SSGSingleEntryOptions, } from '@modern-js/types';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { BuilderConfig } from '@modern-js/builder';
|
|
2
|
+
export type Entry = string | {
|
|
3
|
+
/**
|
|
4
|
+
* The entry file path.
|
|
5
|
+
*/
|
|
6
|
+
entry: string;
|
|
7
|
+
/**
|
|
8
|
+
* Disable framework's behavior of automatically generating entry code.
|
|
9
|
+
*/
|
|
10
|
+
disableMount?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* use src/{entryName}/entry.tsx to custom entry
|
|
13
|
+
*/
|
|
14
|
+
customEntry?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type Entries = Record<string, Entry>;
|
|
17
|
+
export interface SourceUserConfig extends NonNullable<BuilderConfig['source']> {
|
|
18
|
+
/**
|
|
19
|
+
* Add code before each page entry. It will be executed before the page code.
|
|
20
|
+
* @default []
|
|
21
|
+
*/
|
|
22
|
+
preEntry?: string | string[];
|
|
23
|
+
/**
|
|
24
|
+
* Used to configure custom page entries.
|
|
25
|
+
*/
|
|
26
|
+
entries?: Entries;
|
|
27
|
+
/**
|
|
28
|
+
* Used to configure the main entry name.
|
|
29
|
+
* @default 'main'
|
|
30
|
+
*/
|
|
31
|
+
mainEntryName?: string;
|
|
32
|
+
/**
|
|
33
|
+
* This option is used for Module Federation scenario.
|
|
34
|
+
* When this option is enabled, framework will wrap the automatically generated entry files with dynamic import.
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
enableAsyncEntry?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* When enabled, framework will inject `source.preEntry` into the top of the
|
|
40
|
+
* auto-generated entry file (`index.jsx`) and will not pass `source.preEntry`
|
|
41
|
+
* to builder config.
|
|
42
|
+
* This is useful when `source.enableAsyncEntry` is enabled and you still want
|
|
43
|
+
* preEntry to run before the real entry code.
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
enableAsyncPreEntry?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Used to disable the functionality of automatically identifying page entry points based on directory structure.
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
disableDefaultEntries?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* By default, framework scans the src directory to identify page entries.
|
|
54
|
+
* You can customize the directory used for identifying page entries with this option.
|
|
55
|
+
*/
|
|
56
|
+
entriesDir?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Customize the directory of the framework configuration files.
|
|
59
|
+
*/
|
|
60
|
+
configDir?: string;
|
|
61
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BuilderConfig } from '@modern-js/builder';
|
|
2
|
+
import type { JestConfig } from '@modern-js/types';
|
|
3
|
+
import type { UnwrapBuilderConfig } from '../utils';
|
|
4
|
+
type BuilderToolsConfig = UnwrapBuilderConfig<BuilderConfig, 'tools'>;
|
|
5
|
+
export interface ToolsUserConfig extends Omit<BuilderToolsConfig, 'swc'> {
|
|
6
|
+
/**
|
|
7
|
+
* Used to custom Jest configurations.
|
|
8
|
+
* @requires `test` plugin.
|
|
9
|
+
* The configuration of `tools.jest` is provided by `test` plugin.
|
|
10
|
+
* Please use `yarn new` or `pnpm new` to enable the corresponding capability.
|
|
11
|
+
*/
|
|
12
|
+
jest?: JestConfig | ((jestConfig: JestConfig) => JestConfig);
|
|
13
|
+
/**
|
|
14
|
+
* Used to custom SWC configurations.
|
|
15
|
+
* @requires `swc` plugin.
|
|
16
|
+
* The configuration of `swc` is provided by `swc` plugin.
|
|
17
|
+
* Please use `yarn new` or `pnpm new` to enable the corresponding capability.
|
|
18
|
+
*/
|
|
19
|
+
swc?: BuilderToolsConfig['swc'];
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CLIPluginAPI, CLIPluginExtends, RuntimePluginConfig, ServerPluginConfig } from '@modern-js/plugin';
|
|
2
|
+
import type { AppTools, AppToolsNormalizedConfig, AppToolsUserConfig } from './config';
|
|
3
|
+
export type { Rspack } from '@modern-js/builder';
|
|
4
|
+
export type { BffNormalizedConfig, BffUserConfig, LoaderContext, OnError, OnTiming, Params, RequestHandler, RequestHandlerConfig, RequestHandlerOptions, Resource, ServerNormalizedConfig, ServerUserConfig, SSR, SSRByEntries, } from '@modern-js/server-core';
|
|
5
|
+
export * from './config';
|
|
6
|
+
export type { CLIPluginExtends, RuntimePluginConfig, ServerPluginConfig };
|
|
7
|
+
export type AppUserConfig = AppToolsUserConfig;
|
|
8
|
+
export type AppNormalizedConfig = AppToolsNormalizedConfig;
|
|
9
|
+
export type AppToolsAPI = CLIPluginAPI<AppTools>;
|
|
10
|
+
export type { AppToolsContext, AppToolsExtendAPI, AppToolsExtendContext, AppToolsExtendHooks, AppToolsHooks as AppToolsFeatureHooks, } from './plugin';
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { AppContext, AsyncHook, InternalContext, PluginHook, PluginHookTap, TransformFunction } from '@modern-js/plugin';
|
|
2
|
+
import type { Hooks } from '@modern-js/plugin/cli';
|
|
3
|
+
import type { Entrypoint, HtmlPartials, HtmlTemplates, NestedRouteForCli, PageRoute, RouteLegacy, ServerPlugin, ServerRoute } from '@modern-js/types';
|
|
4
|
+
import type { getHookRunners } from '../compat/hooks';
|
|
5
|
+
import type { AppTools } from '.';
|
|
6
|
+
import type { AppToolsNormalizedConfig, AppToolsUserConfig } from './config';
|
|
7
|
+
export type AfterPrepareFn = () => Promise<void> | void;
|
|
8
|
+
export type CheckEntryPointFn = TransformFunction<{
|
|
9
|
+
path: string;
|
|
10
|
+
entry: false | string;
|
|
11
|
+
}>;
|
|
12
|
+
export type ModifyEntrypointsFn = TransformFunction<{
|
|
13
|
+
entrypoints: Entrypoint[];
|
|
14
|
+
}>;
|
|
15
|
+
export type ModifyFileSystemRoutesFn = TransformFunction<{
|
|
16
|
+
entrypoint: Entrypoint;
|
|
17
|
+
routes: RouteLegacy[] | (NestedRouteForCli | PageRoute)[];
|
|
18
|
+
}>;
|
|
19
|
+
export type DeplpoyFn = () => Promise<void> | void;
|
|
20
|
+
export type GenerateEntryCodeFn = (params: {
|
|
21
|
+
entrypoints: Entrypoint[];
|
|
22
|
+
}) => Promise<void> | void;
|
|
23
|
+
export type BeforeGenerateRoutesFn = TransformFunction<{
|
|
24
|
+
entrypoint: Entrypoint;
|
|
25
|
+
code: string;
|
|
26
|
+
}>;
|
|
27
|
+
export type BeforePrintInstructionsFn = TransformFunction<{
|
|
28
|
+
instructions: string;
|
|
29
|
+
}>;
|
|
30
|
+
export type AddRuntimeExportsFn = () => Promise<void> | void;
|
|
31
|
+
export interface AppToolsExtendAPI {
|
|
32
|
+
onAfterPrepare: PluginHookTap<AfterPrepareFn>;
|
|
33
|
+
deploy: PluginHookTap<DeplpoyFn>;
|
|
34
|
+
checkEntryPoint: PluginHookTap<CheckEntryPointFn>;
|
|
35
|
+
modifyEntrypoints: PluginHookTap<ModifyEntrypointsFn>;
|
|
36
|
+
modifyFileSystemRoutes: PluginHookTap<ModifyFileSystemRoutesFn>;
|
|
37
|
+
generateEntryCode: PluginHookTap<GenerateEntryCodeFn>;
|
|
38
|
+
onBeforeGenerateRoutes: PluginHookTap<BeforeGenerateRoutesFn>;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated
|
|
41
|
+
*/
|
|
42
|
+
onBeforePrintInstructions: PluginHookTap<BeforePrintInstructionsFn>;
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated use getAppContext instead
|
|
45
|
+
*/
|
|
46
|
+
useAppContext: () => AppToolsContext;
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated use getConfig instead
|
|
49
|
+
*/
|
|
50
|
+
useConfigContext: () => AppToolsUserConfig;
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated use getNormalizedConfig instead
|
|
53
|
+
*/
|
|
54
|
+
useResolvedConfigContext: () => AppToolsNormalizedConfig<AppToolsUserConfig>;
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated use api.xx instead
|
|
57
|
+
*/
|
|
58
|
+
useHookRunners: () => ReturnType<typeof getHookRunners>;
|
|
59
|
+
}
|
|
60
|
+
export interface AppToolsExtendHooks extends Record<string, PluginHook<(...args: any[]) => any>> {
|
|
61
|
+
onAfterPrepare: AsyncHook<AfterPrepareFn>;
|
|
62
|
+
deploy: AsyncHook<DeplpoyFn>;
|
|
63
|
+
checkEntryPoint: AsyncHook<CheckEntryPointFn>;
|
|
64
|
+
modifyEntrypoints: AsyncHook<ModifyEntrypointsFn>;
|
|
65
|
+
modifyFileSystemRoutes: AsyncHook<ModifyFileSystemRoutesFn>;
|
|
66
|
+
generateEntryCode: AsyncHook<GenerateEntryCodeFn>;
|
|
67
|
+
onBeforeGenerateRoutes: AsyncHook<BeforeGenerateRoutesFn>;
|
|
68
|
+
/**
|
|
69
|
+
* @deprecated
|
|
70
|
+
*/
|
|
71
|
+
onBeforePrintInstructions: AsyncHook<BeforePrintInstructionsFn>;
|
|
72
|
+
}
|
|
73
|
+
export interface AppToolsExtendContext {
|
|
74
|
+
metaName: string;
|
|
75
|
+
internalDirectory: string;
|
|
76
|
+
sharedDirectory: string;
|
|
77
|
+
internalDirAlias: string;
|
|
78
|
+
internalSrcAlias: string;
|
|
79
|
+
apiDirectory: string;
|
|
80
|
+
lambdaDirectory: string;
|
|
81
|
+
runtimeConfigFile: string;
|
|
82
|
+
serverPlugins: ServerPlugin[];
|
|
83
|
+
moduleType: 'module' | 'commonjs';
|
|
84
|
+
/** Information for entry points */
|
|
85
|
+
entrypoints: Entrypoint[];
|
|
86
|
+
/** Selected entry points */
|
|
87
|
+
checkedEntries: string[];
|
|
88
|
+
/** Information for server routes */
|
|
89
|
+
serverRoutes: ServerRoute[];
|
|
90
|
+
/** Whether to use api only mode */
|
|
91
|
+
apiOnly: boolean;
|
|
92
|
+
_internalContext: InternalContext<AppTools>;
|
|
93
|
+
/**
|
|
94
|
+
* Information for HTML templates by entry
|
|
95
|
+
* @private
|
|
96
|
+
*/
|
|
97
|
+
partialsByEntrypoint?: Record<string, HtmlPartials>;
|
|
98
|
+
/**
|
|
99
|
+
* Information for HTML templates
|
|
100
|
+
* @private
|
|
101
|
+
*/
|
|
102
|
+
htmlTemplates: HtmlTemplates;
|
|
103
|
+
/**
|
|
104
|
+
* @deprecated compat old plugin, default is app tools
|
|
105
|
+
*/
|
|
106
|
+
toolsType?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Identification for bff runtime framework
|
|
109
|
+
* @private
|
|
110
|
+
*/
|
|
111
|
+
bffRuntimeFramework?: 'hono' | 'effect';
|
|
112
|
+
}
|
|
113
|
+
export type AppToolsContext = AppContext<AppTools> & AppToolsExtendContext;
|
|
114
|
+
export type AppToolsHooks = Hooks<AppToolsUserConfig, AppToolsNormalizedConfig, {}, {}> & AppToolsExtendHooks;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type UnwrapBuilderConfig<Config, Key extends keyof Config> = Required<Config>[Key];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export declare const DESIGN_SYSTEM_MODES: readonly ['off', 'tokens', 'components', 'strict'];
|
|
2
|
+
export declare const DESIGN_SYSTEM_OVERRIDE_LAYERS: readonly ['brand', 'vertical', 'application'];
|
|
3
|
+
export type DesignSystemMode = (typeof DESIGN_SYSTEM_MODES)[number];
|
|
4
|
+
export type DesignSystemOverrideLayer = (typeof DESIGN_SYSTEM_OVERRIDE_LAYERS)[number];
|
|
5
|
+
export type DesignSystemTokenValue = string | number;
|
|
6
|
+
export interface DesignSystemTokenPack {
|
|
7
|
+
id: string;
|
|
8
|
+
version: string;
|
|
9
|
+
brand: string;
|
|
10
|
+
tokens: Record<string, DesignSystemTokenValue>;
|
|
11
|
+
}
|
|
12
|
+
export interface DesignSystemOverride {
|
|
13
|
+
layer: DesignSystemOverrideLayer;
|
|
14
|
+
tokens?: Record<string, DesignSystemTokenValue>;
|
|
15
|
+
reason?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface DesignSystemConsumerContract {
|
|
18
|
+
id: string;
|
|
19
|
+
requiredTokens?: string[];
|
|
20
|
+
unsupportedModes?: DesignSystemMode[];
|
|
21
|
+
tokenPackVersions?: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
export interface DesignSystemRollbackMetadata {
|
|
24
|
+
tokenPack: string;
|
|
25
|
+
version: string;
|
|
26
|
+
reason: string;
|
|
27
|
+
}
|
|
28
|
+
export interface DesignSystemPinMetadata {
|
|
29
|
+
tokenPack: string;
|
|
30
|
+
version: string;
|
|
31
|
+
rollback: DesignSystemRollbackMetadata;
|
|
32
|
+
}
|
|
33
|
+
export interface DesignSystemVerticalContract {
|
|
34
|
+
mode: DesignSystemMode;
|
|
35
|
+
tokenPack?: string;
|
|
36
|
+
overrides?: DesignSystemOverride[];
|
|
37
|
+
pin?: DesignSystemPinMetadata;
|
|
38
|
+
consumers?: DesignSystemConsumerContract[];
|
|
39
|
+
}
|
|
40
|
+
export interface DesignSystemContract {
|
|
41
|
+
tokenPacks: DesignSystemTokenPack[];
|
|
42
|
+
verticals: Record<string, DesignSystemVerticalContract>;
|
|
43
|
+
}
|
|
44
|
+
export interface DesignSystemValidationIssue {
|
|
45
|
+
path: string;
|
|
46
|
+
message: string;
|
|
47
|
+
}
|
|
48
|
+
export interface DesignSystemValidationResult {
|
|
49
|
+
valid: boolean;
|
|
50
|
+
issues: DesignSystemValidationIssue[];
|
|
51
|
+
}
|
|
52
|
+
export declare const createDesignSystemTokenPackMap: (tokenPacks: DesignSystemTokenPack[]) => Map<string, DesignSystemTokenPack>;
|
|
53
|
+
export declare const validateDesignSystemConsumerCompatibility: (vertical: DesignSystemVerticalContract, tokenPack: DesignSystemTokenPack | undefined, path?: string) => DesignSystemValidationResult;
|
|
54
|
+
export declare const validateDesignSystemContract: (contract: DesignSystemContract) => DesignSystemValidationResult;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Server } from 'node:http';
|
|
2
|
+
import type { Http2SecureServer } from 'node:http2';
|
|
3
|
+
export declare const getServer: () => Http2SecureServer<typeof import("node:http").IncomingMessage, typeof import("node:http").ServerResponse, typeof import("node:http2").Http2ServerRequest, typeof import("node:http2").Http2ServerResponse> | Server<typeof import("node:http").IncomingMessage, typeof import("node:http").ServerResponse> | null;
|
|
4
|
+
export declare const setServer: (newServer: Server | Http2SecureServer) => void;
|
|
5
|
+
export declare const closeServer: () => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getConfigFile: (configFile?: string, cwd?: string) => any;
|