@bleedingdev/modern-js-ultramodern-app-tools 0.0.0 → 3.9.0-ultramodern.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/native-composition/index.js +131 -0
  3. package/dist/cjs/native-composition/preset.js +178 -0
  4. package/dist/cjs/native-composition/release-envelope-plugin.js +44 -0
  5. package/dist/cjs/native-composition/router-integration-plugin.js +55 -0
  6. package/dist/cjs/native-composition/router-runtime.js +66 -0
  7. package/dist/cjs/native-composition/rsc-disabled-plugin.js +117 -0
  8. package/dist/cjs/native-composition/server-plugin.js +50 -0
  9. package/dist/cjs/native-composition/ssr-integration-plugin.js +145 -0
  10. package/dist/cjs/native-composition/types.js +18 -0
  11. package/dist/esm/native-composition/index.mjs +71 -0
  12. package/dist/esm/native-composition/preset.mjs +126 -0
  13. package/dist/esm/native-composition/release-envelope-plugin.mjs +6 -0
  14. package/dist/esm/native-composition/router-integration-plugin.mjs +17 -0
  15. package/dist/esm/native-composition/router-runtime.mjs +26 -0
  16. package/dist/esm/native-composition/rsc-disabled-plugin.mjs +79 -0
  17. package/dist/esm/native-composition/server-plugin.mjs +1 -0
  18. package/dist/esm/native-composition/ssr-integration-plugin.mjs +104 -0
  19. package/dist/esm/native-composition/types.mjs +0 -0
  20. package/dist/esm-node/native-composition/index.mjs +72 -0
  21. package/dist/esm-node/native-composition/preset.mjs +127 -0
  22. package/dist/esm-node/native-composition/release-envelope-plugin.mjs +7 -0
  23. package/dist/esm-node/native-composition/router-integration-plugin.mjs +18 -0
  24. package/dist/esm-node/native-composition/router-runtime.mjs +27 -0
  25. package/dist/esm-node/native-composition/rsc-disabled-plugin.mjs +81 -0
  26. package/dist/esm-node/native-composition/server-plugin.mjs +2 -0
  27. package/dist/esm-node/native-composition/ssr-integration-plugin.mjs +105 -0
  28. package/dist/esm-node/native-composition/types.mjs +1 -0
  29. package/dist/types/native-composition/index.d.ts +6 -0
  30. package/dist/types/native-composition/preset.d.ts +86 -0
  31. package/dist/types/native-composition/release-envelope-plugin.d.ts +2 -0
  32. package/dist/types/native-composition/router-integration-plugin.d.ts +3 -0
  33. package/dist/types/native-composition/router-runtime.d.ts +4 -0
  34. package/dist/types/native-composition/rsc-disabled-plugin.d.ts +2 -0
  35. package/dist/types/native-composition/server-plugin.d.ts +1 -0
  36. package/dist/types/native-composition/ssr-integration-plugin.d.ts +7 -0
  37. package/dist/types/native-composition/types.d.ts +24 -0
  38. package/dist/types-esm/native-composition/index.d.mts +6 -0
  39. package/dist/types-esm/native-composition/preset.d.mts +86 -0
  40. package/dist/types-esm/native-composition/release-envelope-plugin.d.mts +2 -0
  41. package/dist/types-esm/native-composition/router-integration-plugin.d.mts +3 -0
  42. package/dist/types-esm/native-composition/router-runtime.d.mts +4 -0
  43. package/dist/types-esm/native-composition/rsc-disabled-plugin.d.mts +2 -0
  44. package/dist/types-esm/native-composition/server-plugin.d.mts +1 -0
  45. package/dist/types-esm/native-composition/ssr-integration-plugin.d.mts +7 -0
  46. package/dist/types-esm/native-composition/types.d.mts +24 -0
  47. package/package.json +100 -5
  48. package/src/native-composition/index.ts +92 -0
  49. package/src/native-composition/preset.ts +338 -0
  50. package/src/native-composition/release-envelope-plugin.ts +6 -0
  51. package/src/native-composition/router-integration-plugin.ts +20 -0
  52. package/src/native-composition/router-runtime.ts +28 -0
  53. package/src/native-composition/rsc-disabled-plugin.ts +117 -0
  54. package/src/native-composition/server-plugin.ts +1 -0
  55. package/src/native-composition/ssr-integration-plugin.ts +244 -0
  56. package/src/native-composition/types.ts +32 -0
  57. package/README.md +0 -3
@@ -0,0 +1,86 @@
1
+ import type { AppUserConfig } from './types.mjs';
2
+ export interface PresetUltramodernOptions {
3
+ /**
4
+ * Stable producer identity used by BFF cross-project clients.
5
+ * @default "app"
6
+ */
7
+ appId?: string;
8
+ /**
9
+ * Generation-time identity root for a generated delivery unit. When set, the
10
+ * preset derives one build identity from the immutable source revision and
11
+ * injects it into every browser, SSR, API, and backend bundle.
12
+ */
13
+ deliveryUnit?: {
14
+ buildMarker: string;
15
+ unitId: string;
16
+ version: string;
17
+ };
18
+ /**
19
+ * Enable BFF requestId contract by default.
20
+ * @default true
21
+ */
22
+ enableBffRequestId?: boolean;
23
+ /**
24
+ * Enable telemetry contract by default.
25
+ * Exporters are still configured separately by applications.
26
+ * @default true
27
+ */
28
+ enableTelemetry?: boolean;
29
+ /**
30
+ * Enable telemetry exporters.
31
+ *
32
+ * By default each exporter is enabled only when its endpoint is explicitly
33
+ * configured (via the matching option or environment variable), so a bare
34
+ * preset app boots in production without local collectors.
35
+ * Set `true` to force both exporters on with their default localhost
36
+ * endpoints, or `false` to disable exporters entirely.
37
+ * @default undefined (endpoint-driven)
38
+ */
39
+ enableTelemetryExporters?: boolean;
40
+ /**
41
+ * OTLP exporter endpoint. Setting it (or the environment variable)
42
+ * enables the OTLP exporter unless `enableTelemetryExporters` is `false`.
43
+ * The localhost endpoint is used only when exporters are forced on with
44
+ * `enableTelemetryExporters: true` and no endpoint was provided.
45
+ * @default process.env.MODERN_TELEMETRY_OTLP_ENDPOINT
46
+ */
47
+ otlpEndpoint?: string;
48
+ /**
49
+ * VictoriaMetrics exporter endpoint. Setting it (or the environment
50
+ * variable) enables the VictoriaMetrics exporter unless
51
+ * `enableTelemetryExporters` is `false`.
52
+ * The localhost endpoint is used only when exporters are forced on with
53
+ * `enableTelemetryExporters: true` and no endpoint was provided.
54
+ * @default process.env.MODERN_TELEMETRY_VICTORIA_ENDPOINT
55
+ */
56
+ victoriaMetricsEndpoint?: string;
57
+ /**
58
+ * Enable fail-loud startup probing for telemetry exporters.
59
+ * Probes only run for exporters that are actually enabled.
60
+ * @default false
61
+ */
62
+ telemetryFailLoudStartup?: boolean;
63
+ /**
64
+ * Enable app-level Module Federation SSR handshake by default.
65
+ * @default true
66
+ */
67
+ enableModuleFederationSSR?: boolean;
68
+ }
69
+ /**
70
+ * Materialize a fresh UltraModern preset config.
71
+ *
72
+ * This is the advanced inspection API. Use `presetUltramodern` when composing
73
+ * an application config so nested records, arrays, and hooks keep the normal
74
+ * Modern.js merge behavior.
75
+ */
76
+ export declare const createPresetUltramodernConfig: (options?: PresetUltramodernOptions) => AppUserConfig;
77
+ /**
78
+ * Compose an application config over the UltraModern preset.
79
+ *
80
+ * The application config is merged after the preset. Nested records are
81
+ * preserved, scalar values and `false` override preset values, and omitted or
82
+ * `undefined` values keep the preset value. Arrays and hooks compose in
83
+ * preset-first order. An empty record does not reset nested preset defaults;
84
+ * use the typed `PresetUltramodernOptions` opt-outs instead.
85
+ */
86
+ export declare const presetUltramodern: (config: AppUserConfig, options?: PresetUltramodernOptions) => AppUserConfig;
@@ -0,0 +1,2 @@
1
+ import type { AppTools, CliPlugin } from '@modern-js/app-tools';
2
+ export declare const ultramodernReleaseEnvelopePlugin: () => CliPlugin<AppTools>;
@@ -0,0 +1,3 @@
1
+ import type { AppTools, CliPlugin } from '@modern-js/app-tools';
2
+ /** Add fork router policy after the native and optional provider selectors. */
3
+ export declare const ultramodernRouterIntegrationPlugin: () => CliPlugin<AppTools>;
@@ -0,0 +1,4 @@
1
+ import { routerPlugin as nativeRouterPlugin } from '@modern-js/runtime/router/internal';
2
+ /** Install fork observers before the native provider registers its lifecycle. */
3
+ export declare const routerPlugin: typeof nativeRouterPlugin;
4
+ export default routerPlugin;
@@ -0,0 +1,2 @@
1
+ import type { RsbuildPlugin } from '@rsbuild/core';
2
+ export declare function rscDisabledRuntimePlugin(): RsbuildPlugin;
@@ -0,0 +1 @@
1
+ export { default } from '@modern-js/server-runtime-extensions/server-plugin';
@@ -0,0 +1,7 @@
1
+ import type { AppTools, CliPlugin } from '@modern-js/app-tools';
2
+ import type { MergedEnvironmentConfig } from '@rsbuild/core';
3
+ type EnvironmentConfigLike = Partial<Pick<MergedEnvironmentConfig, 'output' | 'source' | 'tools'>>;
4
+ export declare const shouldUseModuleFederationNodeOutput: (config: EnvironmentConfigLike) => boolean;
5
+ /** Apply fork SSR policy after native SSR defaults through Rsbuild hooks. */
6
+ export declare const ultramodernSSRIntegrationPlugin: () => CliPlugin<AppTools>;
7
+ export {};
@@ -0,0 +1,24 @@
1
+ import type { AppUserConfig as NativeAppUserConfig } from '@modern-js/app-tools';
2
+ import type { PrecompressConfig } from '@modern-js/app-tools-extensions/build-config/precompress/plugin';
3
+ import type { CloudflareDeployConfig } from '@modern-js/app-tools-extensions/config';
4
+ import type { BffRuntimeUserConfig, ServerTelemetryUserConfig } from '@modern-js/runtime-extensions/server-config';
5
+ type NativeServerConfig = NonNullable<NativeAppUserConfig['server']>;
6
+ type NativeSSRConfig = Exclude<NativeServerConfig['ssr'], boolean | undefined>;
7
+ /** Native Modern.js configuration with the fork's explicitly owned options. */
8
+ export type UltramodernAppUserConfig = Omit<NativeAppUserConfig, 'output' | 'server' | 'bff' | 'deploy'> & {
9
+ output?: Omit<NonNullable<NativeAppUserConfig['output']>, 'precompress'> & {
10
+ precompress?: boolean | PrecompressConfig;
11
+ };
12
+ server?: Omit<NativeServerConfig, 'ssr' | 'telemetry'> & {
13
+ ssr?: boolean | (NativeSSRConfig & {
14
+ moduleFederationAppSSR?: boolean;
15
+ });
16
+ telemetry?: ServerTelemetryUserConfig;
17
+ };
18
+ bff?: Omit<NonNullable<NativeAppUserConfig['bff']>, keyof BffRuntimeUserConfig> & BffRuntimeUserConfig & {
19
+ requestId?: string;
20
+ };
21
+ deploy?: NonNullable<NativeAppUserConfig['deploy']> & CloudflareDeployConfig;
22
+ };
23
+ export type AppUserConfig = UltramodernAppUserConfig;
24
+ export {};
package/package.json CHANGED
@@ -1,16 +1,111 @@
1
1
  {
2
2
  "name": "@bleedingdev/modern-js-ultramodern-app-tools",
3
- "version": "0.0.0",
4
- "description": "Package-name registration for the forthcoming UltraModern.js release. This setup version contains no runtime implementation.",
5
- "license": "MIT",
3
+ "description": "Native UltraModern.js build, preset and release plugin composition.",
4
+ "homepage": "https://github.com/BleedingDev/ultramodern.js#readme",
5
+ "bugs": {
6
+ "url": "https://github.com/BleedingDev/ultramodern.js/issues"
7
+ },
6
8
  "repository": {
7
9
  "type": "git",
8
- "url": "git+https://github.com/BleedingDev/ultramodern.js.git"
10
+ "url": "git+https://github.com/BleedingDev/ultramodern.js.git",
11
+ "directory": "packages/solutions/ultramodern-app-tools"
9
12
  },
13
+ "license": "MIT",
14
+ "version": "3.9.0-ultramodern.10",
10
15
  "files": [
11
- "README.md"
16
+ "dist",
17
+ "src"
12
18
  ],
19
+ "types": "./dist/types/native-composition/index.d.ts",
20
+ "main": "./dist/cjs/native-composition/index.js",
21
+ "exports": {
22
+ ".": {
23
+ "import": {
24
+ "types": "./dist/types-esm/native-composition/index.d.mts",
25
+ "default": "./dist/esm-node/native-composition/index.mjs"
26
+ },
27
+ "require": {
28
+ "types": "./dist/types/native-composition/index.d.ts",
29
+ "default": "./dist/cjs/native-composition/index.js"
30
+ },
31
+ "types": "./dist/types/native-composition/index.d.ts"
32
+ },
33
+ "./server-plugin": {
34
+ "node": {
35
+ "import": {
36
+ "types": "./dist/types-esm/native-composition/server-plugin.d.mts",
37
+ "default": "./dist/esm-node/native-composition/server-plugin.mjs"
38
+ },
39
+ "require": {
40
+ "types": "./dist/types/native-composition/server-plugin.d.ts",
41
+ "default": "./dist/cjs/native-composition/server-plugin.js"
42
+ }
43
+ },
44
+ "types": "./dist/types/native-composition/server-plugin.d.ts"
45
+ },
46
+ "./router-runtime": {
47
+ "node": {
48
+ "import": {
49
+ "types": "./dist/types-esm/native-composition/router-runtime.d.mts",
50
+ "default": "./dist/esm-node/native-composition/router-runtime.mjs"
51
+ },
52
+ "require": {
53
+ "types": "./dist/types/native-composition/router-runtime.d.ts",
54
+ "default": "./dist/cjs/native-composition/router-runtime.js"
55
+ }
56
+ },
57
+ "default": "./dist/esm/native-composition/router-runtime.mjs",
58
+ "types": "./dist/types-esm/native-composition/router-runtime.d.mts"
59
+ }
60
+ },
61
+ "engines": {
62
+ "node": ">=26.7.0"
63
+ },
64
+ "dependencies": {
65
+ "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.0-ultramodern.10",
66
+ "@modern-js/app-tools-extensions": "npm:@bleedingdev/modern-js-app-tools-extensions@3.9.0-ultramodern.10",
67
+ "@modern-js/i18n-integration": "npm:@bleedingdev/modern-js-i18n-integration@3.9.0-ultramodern.10",
68
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.10",
69
+ "@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.9.0-ultramodern.10",
70
+ "@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.10",
71
+ "@modern-js/runtime-renderer-extensions": "npm:@bleedingdev/modern-js-runtime-renderer-extensions@3.9.0-ultramodern.10",
72
+ "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.10",
73
+ "@modern-js/server-runtime-extensions": "npm:@bleedingdev/modern-js-server-runtime-extensions@3.9.0-ultramodern.10",
74
+ "@rsbuild/core": "2.2.3"
75
+ },
76
+ "devDependencies": {
77
+ "@modern-js/backend-federation-contracts": "npm:@bleedingdev/modern-js-backend-federation-contracts@3.9.0-ultramodern.10",
78
+ "@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.9.0-ultramodern.10",
79
+ "@modern-js/plugin-bff": "npm:@bleedingdev/modern-js-plugin-bff@3.9.0-ultramodern.10",
80
+ "@modern-js/plugin-tanstack": "npm:@bleedingdev/modern-js-plugin-tanstack@3.9.0-ultramodern.10",
81
+ "@modern-js/prod-server": "npm:@bleedingdev/modern-js-prod-server@3.9.0-ultramodern.10",
82
+ "@modern-js/server": "npm:@bleedingdev/modern-js-server@3.9.0-ultramodern.10",
83
+ "@modern-js/tsconfig": "npm:@bleedingdev/modern-js-tsconfig@3.9.0-ultramodern.10",
84
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.10",
85
+ "@rslib/core": "1.0.0",
86
+ "@scripts/rstest-config": "2.66.0",
87
+ "@types/node": "^26.4.1",
88
+ "@typescript/native-preview": "7.0.0-dev.20260707.2"
89
+ },
90
+ "sideEffects": false,
13
91
  "publishConfig": {
14
92
  "access": "public"
93
+ },
94
+ "typesVersions": {
95
+ "*": {
96
+ "server-plugin": [
97
+ "./dist/types/native-composition/server-plugin.d.ts",
98
+ "./src/native-composition/server-plugin.ts"
99
+ ],
100
+ "router-runtime": [
101
+ "./dist/types/native-composition/router-runtime.d.ts",
102
+ "./src/native-composition/router-runtime.ts"
103
+ ]
104
+ }
105
+ },
106
+ "scripts": {
107
+ "build": "rslib build && pnpm run verify:deploy-output",
108
+ "test": "rstest",
109
+ "verify:deploy-output": "node ./tests/deploy-output/verify-public-surface.mjs"
15
110
  }
16
111
  }
@@ -0,0 +1,92 @@
1
+ import { type AppTools, appTools, type CliPlugin } from '@modern-js/app-tools';
2
+ import backendFederationBuildPlugin from '@modern-js/app-tools-extensions/backend-federation-build';
3
+ import { createCloudflareBuilderPlugin } from '@modern-js/app-tools-extensions/cloudflare-builder';
4
+ import { createDeployOutputAliasesPlugin } from '@modern-js/app-tools-extensions/deploy-output/plugin';
5
+ import {
6
+ RENDERER_EXTENSIONS_PACKAGE,
7
+ SERVER_EXTENSIONS_PLUGIN_NAME,
8
+ } from '@modern-js/app-tools-extensions/policy-defaults';
9
+ import {
10
+ collectRuntimePackageModuleDirectories,
11
+ createRuntimePackageResolutionPlugin,
12
+ } from '@modern-js/app-tools-extensions/runtime-package-resolution';
13
+ import { ultramodernI18nIntegrationPlugin } from '@modern-js/i18n-integration';
14
+ import { ultramodernReleaseEnvelopePlugin } from './release-envelope-plugin';
15
+ import { ultramodernRouterIntegrationPlugin } from './router-integration-plugin';
16
+ import { rscDisabledRuntimePlugin } from './rsc-disabled-plugin';
17
+ import { ultramodernSSRIntegrationPlugin } from './ssr-integration-plugin';
18
+
19
+ export {
20
+ createPresetUltramodernConfig,
21
+ type PresetUltramodernOptions,
22
+ presetUltramodern,
23
+ } from './preset';
24
+ export { ultramodernReleaseEnvelopePlugin } from './release-envelope-plugin';
25
+ export type { AppUserConfig, UltramodernAppUserConfig } from './types';
26
+
27
+ /** Compose the fork's build and release features through native CLI plugins. */
28
+ export const ultramodernAppTools = (): CliPlugin<AppTools> => ({
29
+ name: '@modern-js/ultramodern-app-tools',
30
+ usePlugins: [
31
+ appTools(),
32
+ ultramodernI18nIntegrationPlugin(),
33
+ ultramodernRouterIntegrationPlugin(),
34
+ ultramodernSSRIntegrationPlugin(),
35
+ backendFederationBuildPlugin(),
36
+ createCloudflareBuilderPlugin(),
37
+ createDeployOutputAliasesPlugin(),
38
+ ultramodernReleaseEnvelopePlugin(),
39
+ ],
40
+ setup(api) {
41
+ // The composed runtime packages are dependencies of this package, not of
42
+ // the app that composes it. Contribute the directories that host them so
43
+ // the generated `runtime-register.js` resolves them under an isolated
44
+ // (pnpm) linker without the app having to declare them itself.
45
+ const runtimeModuleDirectories = collectRuntimePackageModuleDirectories(
46
+ [RENDERER_EXTENSIONS_PACKAGE, '@modern-js/i18n-integration'],
47
+ import.meta.url,
48
+ );
49
+
50
+ api.modifyResolvedConfig(config => {
51
+ const builderPlugins = [
52
+ ...(config.builderPlugins ?? []),
53
+ ...(runtimeModuleDirectories.length > 0
54
+ ? [createRuntimePackageResolutionPlugin(runtimeModuleDirectories)]
55
+ : []),
56
+ ...(config.server?.rsc ? [] : [rscDisabledRuntimePlugin()]),
57
+ ];
58
+ return { ...config, builderPlugins };
59
+ });
60
+ api._internalServerPlugins(({ plugins }) => {
61
+ // `appTools()` already registered the fork's server policy under its own
62
+ // specifier. An app that composes this package declares *this* package,
63
+ // so the descriptor is renamed rather than duplicated: both specifiers
64
+ // export the same server plugin, and this one is the one such an app can
65
+ // always resolve.
66
+ const name = '@modern-js/ultramodern-app-tools/server-plugin';
67
+ const renamed = plugins.map(plugin =>
68
+ plugin.name === SERVER_EXTENSIONS_PLUGIN_NAME
69
+ ? { ...plugin, name }
70
+ : plugin,
71
+ );
72
+ if (!renamed.some(plugin => plugin.name === name)) {
73
+ renamed.push({ name });
74
+ }
75
+ return { plugins: renamed };
76
+ });
77
+ api._internalRuntimePlugins(({ entrypoint, plugins }) => {
78
+ // Same story for the renderer descriptor: `appTools()` already appended
79
+ // it unless the app opted out.
80
+ if (
81
+ !plugins.some(plugin => plugin.path === RENDERER_EXTENSIONS_PACKAGE)
82
+ ) {
83
+ plugins.push({
84
+ name: 'rendererHead',
85
+ path: RENDERER_EXTENSIONS_PACKAGE,
86
+ config: {},
87
+ });
88
+ }
89
+ return { entrypoint, plugins };
90
+ });
91
+ },
92
+ });