@bleedingdev/modern-js-app-tools 3.5.0-ultramodern.4 → 3.5.0-ultramodern.41

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 (159) hide show
  1. package/dist/cjs/builder/generator/getBuilderEnvironments.js +1 -0
  2. package/dist/cjs/builder/shared/builderPlugins/adapterPrecompress.js +13 -4
  3. package/dist/cjs/builder/shared/lazyCompilation.js +2 -10
  4. package/dist/cjs/commands/index.js +0 -4
  5. package/dist/cjs/index.js +37 -66
  6. package/dist/cjs/plugins/backend-federation/codegen.js +209 -0
  7. package/dist/cjs/plugins/backend-federation/config.js +217 -0
  8. package/dist/cjs/plugins/backend-federation/emit.js +139 -0
  9. package/dist/cjs/plugins/backendFederationBuild.js +53 -0
  10. package/dist/cjs/plugins/deploy/index.js +4 -4
  11. package/dist/cjs/plugins/deploy/platforms/cloudflare/artifacts.js +127 -0
  12. package/dist/cjs/plugins/deploy/platforms/cloudflare/constants.js +137 -0
  13. package/dist/cjs/plugins/deploy/platforms/cloudflare/delivery-unit.js +121 -0
  14. package/dist/cjs/plugins/deploy/platforms/cloudflare/i18n-worker.js +135 -0
  15. package/dist/cjs/plugins/deploy/platforms/cloudflare/index.js +126 -0
  16. package/dist/cjs/plugins/deploy/platforms/cloudflare/security-policies.js +205 -0
  17. package/dist/cjs/plugins/deploy/platforms/cloudflare/types.js +18 -0
  18. package/dist/cjs/plugins/deploy/platforms/cloudflare/utils.js +66 -0
  19. package/dist/cjs/plugins/deploy/platforms/cloudflare/worker-manifest.js +178 -0
  20. package/dist/cjs/plugins/deploy/platforms/cloudflare/wrangler-config.js +189 -0
  21. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-contract.js +91 -0
  22. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-plan.js +93 -0
  23. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/identity.js +83 -0
  24. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/index.js +184 -0
  25. package/dist/cjs/{baseline.js → plugins/deploy/platforms/cloudflare-output-verifier/issues.js} +19 -10
  26. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/manifest.js +83 -0
  27. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.js +149 -0
  28. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.js +131 -0
  29. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +22 -0
  30. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +0 -0
  31. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +0 -0
  32. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +0 -0
  33. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +0 -0
  34. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +32 -0
  35. package/dist/esm/builder/generator/getBuilderEnvironments.mjs +1 -0
  36. package/dist/esm/builder/shared/builderPlugins/adapterPrecompress.mjs +13 -4
  37. package/dist/esm/builder/shared/lazyCompilation.mjs +1 -3
  38. package/dist/esm/commands/index.mjs +0 -1
  39. package/dist/esm/index.mjs +3 -4
  40. package/dist/esm/plugins/analyze/getHtmlTemplate.mjs +2 -2
  41. package/dist/esm/plugins/analyze/isDefaultExportFunction.mjs +2 -2
  42. package/dist/esm/plugins/backend-federation/codegen.mjs +158 -0
  43. package/dist/esm/plugins/backend-federation/config.mjs +141 -0
  44. package/dist/esm/plugins/backend-federation/emit.mjs +88 -0
  45. package/dist/esm/plugins/backendFederationBuild.mjs +1 -0
  46. package/dist/esm/plugins/deploy/index.mjs +1 -1
  47. package/dist/esm/plugins/deploy/platforms/cloudflare/artifacts.mjs +64 -0
  48. package/dist/esm/plugins/deploy/platforms/cloudflare/constants.mjs +33 -0
  49. package/dist/esm/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +70 -0
  50. package/dist/esm/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +97 -0
  51. package/dist/esm/plugins/deploy/platforms/cloudflare/index.mjs +78 -0
  52. package/dist/esm/plugins/deploy/platforms/cloudflare/security-policies.mjs +167 -0
  53. package/dist/esm/plugins/deploy/platforms/cloudflare/types.mjs +0 -0
  54. package/dist/esm/plugins/deploy/platforms/cloudflare/utils.mjs +12 -0
  55. package/dist/esm/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +118 -0
  56. package/dist/esm/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +135 -0
  57. package/dist/esm/plugins/deploy/platforms/cloudflare-output-contract.mjs +17 -0
  58. package/dist/esm/plugins/deploy/platforms/cloudflare-output-plan.mjs +45 -0
  59. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +45 -0
  60. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +129 -0
  61. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +10 -0
  62. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +45 -0
  63. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +97 -0
  64. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +68 -0
  65. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +22 -0
  66. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +0 -0
  67. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +0 -0
  68. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +0 -0
  69. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +0 -0
  70. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +32 -0
  71. package/dist/esm-node/builder/generator/getBuilderEnvironments.mjs +1 -0
  72. package/dist/esm-node/builder/shared/builderPlugins/adapterPrecompress.mjs +13 -4
  73. package/dist/esm-node/builder/shared/lazyCompilation.mjs +1 -3
  74. package/dist/esm-node/commands/index.mjs +0 -1
  75. package/dist/esm-node/index.mjs +3 -4
  76. package/dist/esm-node/plugins/analyze/getHtmlTemplate.mjs +2 -2
  77. package/dist/esm-node/plugins/analyze/isDefaultExportFunction.mjs +2 -2
  78. package/dist/esm-node/plugins/backend-federation/codegen.mjs +159 -0
  79. package/dist/esm-node/plugins/backend-federation/config.mjs +142 -0
  80. package/dist/esm-node/plugins/backend-federation/emit.mjs +89 -0
  81. package/dist/esm-node/plugins/backendFederationBuild.mjs +2 -0
  82. package/dist/esm-node/plugins/deploy/index.mjs +1 -1
  83. package/dist/esm-node/plugins/deploy/platforms/cloudflare/artifacts.mjs +65 -0
  84. package/dist/esm-node/plugins/deploy/platforms/cloudflare/constants.mjs +34 -0
  85. package/dist/esm-node/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +71 -0
  86. package/dist/esm-node/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +98 -0
  87. package/dist/esm-node/plugins/deploy/platforms/cloudflare/index.mjs +79 -0
  88. package/dist/esm-node/plugins/deploy/platforms/cloudflare/security-policies.mjs +168 -0
  89. package/dist/esm-node/plugins/deploy/platforms/cloudflare/types.mjs +1 -0
  90. package/dist/esm-node/plugins/deploy/platforms/cloudflare/utils.mjs +13 -0
  91. package/dist/esm-node/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +119 -0
  92. package/dist/esm-node/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +136 -0
  93. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-contract.mjs +18 -0
  94. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-plan.mjs +46 -0
  95. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +46 -0
  96. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +130 -0
  97. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +11 -0
  98. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +46 -0
  99. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +98 -0
  100. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +69 -0
  101. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +22 -0
  102. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +0 -0
  103. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +0 -0
  104. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +0 -0
  105. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +0 -0
  106. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +32 -0
  107. package/dist/types/builder/generator/createCopyPattern.d.ts +7 -5
  108. package/dist/types/builder/shared/lazyCompilation.d.ts +2 -4
  109. package/dist/types/commands/index.d.ts +0 -1
  110. package/dist/types/index.d.ts +0 -2
  111. package/dist/types/plugins/backend-federation/codegen.d.ts +83 -0
  112. package/dist/types/plugins/backend-federation/config.d.ts +103 -0
  113. package/dist/types/plugins/backend-federation/emit.d.ts +13 -0
  114. package/dist/types/plugins/backendFederationBuild.d.ts +2 -0
  115. package/dist/types/plugins/deploy/platforms/cloudflare/artifacts.d.ts +15 -0
  116. package/dist/types/plugins/deploy/platforms/cloudflare/constants.d.ts +23 -0
  117. package/dist/types/plugins/deploy/platforms/cloudflare/delivery-unit.d.ts +23 -0
  118. package/dist/types/plugins/deploy/platforms/cloudflare/i18n-worker.d.ts +22 -0
  119. package/dist/types/plugins/deploy/platforms/{cloudflare.d.ts → cloudflare/index.d.ts} +1 -1
  120. package/dist/types/plugins/deploy/platforms/cloudflare/security-policies.d.ts +51 -0
  121. package/dist/types/plugins/deploy/platforms/cloudflare/types.d.ts +5 -0
  122. package/dist/types/plugins/deploy/platforms/cloudflare/utils.d.ts +6 -0
  123. package/dist/types/plugins/deploy/platforms/cloudflare/worker-manifest.d.ts +113 -0
  124. package/dist/types/plugins/deploy/platforms/cloudflare/wrangler-config.d.ts +39 -0
  125. package/dist/types/plugins/deploy/platforms/cloudflare-output-contract.d.ts +13 -0
  126. package/dist/types/plugins/deploy/platforms/cloudflare-output-plan.d.ts +34 -0
  127. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/identity.d.ts +4 -0
  128. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/index.d.ts +18 -0
  129. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/issues.d.ts +14 -0
  130. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/manifest.d.ts +2 -0
  131. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.d.ts +6 -0
  132. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.d.ts +15 -0
  133. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.d.mts +1 -0
  134. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.d.mts +1 -0
  135. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.d.mts +1 -0
  136. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.d.mts +1 -0
  137. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.d.mts +1 -0
  138. package/dist/types/types/config/cloudflareDeploy.d.ts +22 -0
  139. package/dist/types/types/config/deploy.d.ts +15 -2
  140. package/lib/types.d.ts +2 -3
  141. package/package.json +24 -18
  142. package/dist/cjs/commands/runtime.js +0 -196
  143. package/dist/cjs/plugins/deploy/platforms/cloudflare.js +0 -540
  144. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -576
  145. package/dist/cjs/ultramodern/designSystem.js +0 -123
  146. package/dist/esm/baseline.mjs +0 -4
  147. package/dist/esm/commands/runtime.mjs +0 -146
  148. package/dist/esm/plugins/deploy/platforms/cloudflare.mjs +0 -492
  149. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -576
  150. package/dist/esm/ultramodern/designSystem.mjs +0 -73
  151. package/dist/esm-node/baseline.mjs +0 -5
  152. package/dist/esm-node/commands/runtime.mjs +0 -147
  153. package/dist/esm-node/plugins/deploy/platforms/cloudflare.mjs +0 -493
  154. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -576
  155. package/dist/esm-node/ultramodern/designSystem.mjs +0 -74
  156. package/dist/types/baseline.d.ts +0 -16
  157. package/dist/types/commands/runtime.d.ts +0 -12
  158. package/dist/types/ultramodern/designSystem.d.ts +0 -54
  159. /package/dist/types/plugins/deploy/platforms/templates/{cloudflare-entry.d.mts → cloudflare-entry.006-fetch-handler.d.mts} +0 -0
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, getters, values)=>{
14
+ var define = (defs, kind)=>{
15
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
16
+ enumerable: true,
17
+ [kind]: defs[key]
18
+ });
19
+ };
20
+ define(getters, "get");
21
+ define(values, "value");
22
+ };
23
+ })();
24
+ (()=>{
25
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
26
+ })();
27
+ (()=>{
28
+ __webpack_require__.r = (exports1)=>{
29
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
30
+ value: 'Module'
31
+ });
32
+ Object.defineProperty(exports1, '__esModule', {
33
+ value: true
34
+ });
35
+ };
36
+ })();
37
+ var __webpack_exports__ = {};
38
+ __webpack_require__.r(__webpack_exports__);
39
+ __webpack_require__.d(__webpack_exports__, {
40
+ verifyCloudflareOutputMutationPolicy: ()=>verifyCloudflareOutputMutationPolicy,
41
+ walkFiles: ()=>walkFiles
42
+ });
43
+ const promises_namespaceObject = require("node:fs/promises");
44
+ var promises_default = /*#__PURE__*/ __webpack_require__.n(promises_namespaceObject);
45
+ const external_node_path_namespaceObject = require("node:path");
46
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
47
+ const external_issues_js_namespaceObject = require("./issues.js");
48
+ const SOURCE_SCAN_FILE_PATTERN = /\.(?:[cm]?[jt]s|json)$/u;
49
+ const SOURCE_SCAN_IGNORED_DIRECTORY_NAMES = new Set([
50
+ '.codex',
51
+ '.fastcontext',
52
+ '.git',
53
+ '.mf',
54
+ '.modernjs',
55
+ '.output',
56
+ 'coverage',
57
+ 'dist',
58
+ 'dist-cloudflare',
59
+ 'node_modules',
60
+ 'repos',
61
+ 'topology'
62
+ ]);
63
+ const FORBIDDEN_MUTATION_PATTERNS = [
64
+ {
65
+ code: 'forbidden-mutation-pattern',
66
+ message: "Generated Cloudflare server worker output must not be rewritten by app scripts.",
67
+ pattern: /\.output\/server\/index\.mjs/u
68
+ },
69
+ {
70
+ code: 'forbidden-mutation-pattern',
71
+ message: "Generated Cloudflare server worker output must not be rewritten by app scripts.",
72
+ pattern: /path\.(?:join|resolve)\(\s*['"`]\.output['"`]\s*,\s*['"`]server['"`]\s*,\s*['"`]index\.mjs['"`]\s*\)/u
73
+ },
74
+ {
75
+ code: 'forbidden-mutation-pattern',
76
+ message: "Generated Cloudflare BFF worker bundles must not be rewritten by app scripts.",
77
+ pattern: /\.output\/worker\/[^'"`]*\.(?:mjs|cjs|js)/u
78
+ },
79
+ {
80
+ code: 'forbidden-mutation-pattern',
81
+ message: "Generated Cloudflare BFF worker bundles must not be rewritten by app scripts.",
82
+ pattern: /path\.(?:join|resolve)\(\s*['"`]\.output['"`]\s*,\s*['"`]worker['"`]\s*,\s*['"`][^'"`]+\.(?:mjs|cjs|js)['"`]\s*\)/u
83
+ },
84
+ {
85
+ code: 'forbidden-mutation-pattern',
86
+ message: "Drizzle entityKind worker bundle markers must be fixed in the framework toolchain, not post-build scripts.",
87
+ pattern: /replaceAll\(\s*['"`];entityKind(?:,entityKind)?;/u
88
+ },
89
+ {
90
+ code: 'forbidden-mutation-pattern',
91
+ message: "Effect BFF Cloudflare dispatch must not depend on duck-typed runtime helper probing in app scripts.",
92
+ pattern: /(?:typeof\s+[^;\n]*dispatchEffectBffRequest|['"`]dispatchEffectBffRequest['"`]\s+in\s+|\.dispatchEffectBffRequest\b)/u
93
+ },
94
+ {
95
+ code: 'forbidden-mutation-pattern',
96
+ message: "Effect BFF Cloudflare dispatch must not branch on handler.length in app scripts.",
97
+ pattern: /\bhandler\s*\.\s*length\b/u
98
+ }
99
+ ];
100
+ const pathExists = async (filePath)=>{
101
+ try {
102
+ await promises_default().access(filePath);
103
+ return true;
104
+ } catch {
105
+ return false;
106
+ }
107
+ };
108
+ const walkFiles = async (root)=>{
109
+ if (!await pathExists(root)) return [];
110
+ const entries = await promises_default().readdir(root, {
111
+ withFileTypes: true
112
+ });
113
+ const files = [];
114
+ for (const entry of entries){
115
+ if (SOURCE_SCAN_IGNORED_DIRECTORY_NAMES.has(entry.name)) continue;
116
+ const entryPath = external_node_path_default().join(root, entry.name);
117
+ if (entry.isDirectory()) {
118
+ files.push(...await walkFiles(entryPath));
119
+ continue;
120
+ }
121
+ if (SOURCE_SCAN_FILE_PATTERN.test(entry.name)) files.push(entryPath);
122
+ }
123
+ return files;
124
+ };
125
+ const verifyCloudflareOutputMutationPolicy = async (options)=>{
126
+ const issues = [];
127
+ const files = (await Promise.all(options.scanRoots.map((scanRoot)=>walkFiles(external_node_path_default().resolve(scanRoot))))).flat();
128
+ for (const file of files){
129
+ const source = await promises_default().readFile(file, 'utf-8');
130
+ for (const forbidden of FORBIDDEN_MUTATION_PATTERNS)if (forbidden.pattern.test(source)) (0, external_issues_js_namespaceObject.addIssue)(issues, {
131
+ code: forbidden.code,
132
+ message: forbidden.message,
133
+ path: file
134
+ });
135
+ }
136
+ return {
137
+ ok: 0 === issues.length,
138
+ issues
139
+ };
140
+ };
141
+ exports.verifyCloudflareOutputMutationPolicy = __webpack_exports__.verifyCloudflareOutputMutationPolicy;
142
+ exports.walkFiles = __webpack_exports__.walkFiles;
143
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
144
+ "verifyCloudflareOutputMutationPolicy",
145
+ "walkFiles"
146
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
147
+ Object.defineProperty(exports, '__esModule', {
148
+ value: true
149
+ });
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, getters, values)=>{
14
+ var define = (defs, kind)=>{
15
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
16
+ enumerable: true,
17
+ [kind]: defs[key]
18
+ });
19
+ };
20
+ define(getters, "get");
21
+ define(values, "value");
22
+ };
23
+ })();
24
+ (()=>{
25
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
26
+ })();
27
+ (()=>{
28
+ __webpack_require__.r = (exports1)=>{
29
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
30
+ value: 'Module'
31
+ });
32
+ Object.defineProperty(exports1, '__esModule', {
33
+ value: true
34
+ });
35
+ };
36
+ })();
37
+ var __webpack_exports__ = {};
38
+ __webpack_require__.r(__webpack_exports__);
39
+ __webpack_require__.d(__webpack_exports__, {
40
+ getEffectBffWorker: ()=>getEffectBffWorker,
41
+ getWorkerBundleReferences: ()=>getWorkerBundleReferences,
42
+ missingWorkerBundleMessage: ()=>missingWorkerBundleMessage,
43
+ resolveWorkerBundleReference: ()=>resolveWorkerBundleReference,
44
+ verifyWorkerBundleReferences: ()=>verifyWorkerBundleReferences,
45
+ verifyWorkerImport: ()=>verifyWorkerImport
46
+ });
47
+ const external_node_path_namespaceObject = require("node:path");
48
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
49
+ const external_node_url_namespaceObject = require("node:url");
50
+ const external_cloudflare_output_contract_js_namespaceObject = require("../cloudflare-output-contract.js");
51
+ const external_issues_js_namespaceObject = require("./issues.js");
52
+ const getReferencedRouteWorkers = (manifest)=>Array.isArray(manifest?.routeSpec?.routes) ? manifest.routeSpec.routes.map((route)=>'string' == typeof route?.worker && route.worker.length > 0 ? route.worker : void 0).filter((worker)=>'string' == typeof worker) : [];
53
+ const getEffectBffWorker = (manifest)=>manifest?.bff?.runtimeFramework === 'effect' && 'string' == typeof manifest.bff.worker ? manifest.bff.worker : void 0;
54
+ const getWorkerBundleReferences = (manifest)=>{
55
+ const effectBffWorker = getEffectBffWorker(manifest);
56
+ return [
57
+ ...effectBffWorker ? [
58
+ {
59
+ kind: 'effect-bff',
60
+ reference: effectBffWorker
61
+ }
62
+ ] : [],
63
+ ...getReferencedRouteWorkers(manifest).map((reference)=>({
64
+ kind: 'route',
65
+ reference
66
+ }))
67
+ ];
68
+ };
69
+ const resolveWorkerBundleReference = (issues, outputDirectory, reference, manifestPath)=>{
70
+ const workerRoot = external_node_path_default().resolve(outputDirectory, external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_WORKER_BUNDLE_DIRECTORY);
71
+ const workerPath = external_node_path_default().resolve(outputDirectory, reference.reference);
72
+ const relativeToWorkerRoot = external_node_path_default().relative(workerRoot, workerPath);
73
+ if (external_node_path_default().isAbsolute(reference.reference) || relativeToWorkerRoot.startsWith('..') || external_node_path_default().isAbsolute(relativeToWorkerRoot)) {
74
+ (0, external_issues_js_namespaceObject.addIssue)(issues, {
75
+ code: 'invalid-manifest',
76
+ message: 'Cloudflare output manifest worker bundle references must stay under worker/.',
77
+ path: manifestPath
78
+ });
79
+ return null;
80
+ }
81
+ return {
82
+ ...reference,
83
+ path: workerPath
84
+ };
85
+ };
86
+ const missingWorkerBundleMessage = (reference)=>'effect-bff' === reference.kind ? 'Cloudflare Effect BFF manifest points to a missing worker bundle.' : 'Cloudflare route worker manifest points to a missing worker bundle.';
87
+ const FORBIDDEN_WORKER_BUNDLE_REFERENCE_PATTERNS = [
88
+ /\.\.\/server\//u,
89
+ /\.output\/server\//u,
90
+ /server\/index\.mjs/u
91
+ ];
92
+ const verifyWorkerBundleReferences = (issues, worker, source)=>{
93
+ if (FORBIDDEN_WORKER_BUNDLE_REFERENCE_PATTERNS.some((pattern)=>pattern.test(source))) (0, external_issues_js_namespaceObject.addIssue)(issues, {
94
+ code: 'invalid-worker-bundle',
95
+ message: 'Cloudflare worker bundles must not reference framework-owned server output paths.',
96
+ path: worker.path
97
+ });
98
+ };
99
+ const verifyWorkerImport = async (issues, entryPath)=>{
100
+ try {
101
+ const worker = (await import(`${(0, external_node_url_namespaceObject.pathToFileURL)(entryPath).href}?t=${Date.now()}`)).default;
102
+ if (!worker || 'function' != typeof worker.fetch) (0, external_issues_js_namespaceObject.addIssue)(issues, {
103
+ code: 'worker-import-failed',
104
+ message: 'Cloudflare server entry must default-export a Worker with fetch.',
105
+ path: entryPath
106
+ });
107
+ } catch (error) {
108
+ (0, external_issues_js_namespaceObject.addIssue)(issues, {
109
+ code: 'worker-import-failed',
110
+ message: `Cloudflare server entry could not be imported: ${error instanceof Error ? error.message : String(error)}`,
111
+ path: entryPath
112
+ });
113
+ }
114
+ };
115
+ exports.getEffectBffWorker = __webpack_exports__.getEffectBffWorker;
116
+ exports.getWorkerBundleReferences = __webpack_exports__.getWorkerBundleReferences;
117
+ exports.missingWorkerBundleMessage = __webpack_exports__.missingWorkerBundleMessage;
118
+ exports.resolveWorkerBundleReference = __webpack_exports__.resolveWorkerBundleReference;
119
+ exports.verifyWorkerBundleReferences = __webpack_exports__.verifyWorkerBundleReferences;
120
+ exports.verifyWorkerImport = __webpack_exports__.verifyWorkerImport;
121
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
122
+ "getEffectBffWorker",
123
+ "getWorkerBundleReferences",
124
+ "missingWorkerBundleMessage",
125
+ "resolveWorkerBundleReference",
126
+ "verifyWorkerBundleReferences",
127
+ "verifyWorkerImport"
128
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
129
+ Object.defineProperty(exports, '__esModule', {
130
+ value: true
131
+ });
@@ -0,0 +1,22 @@
1
+ const MODERN_WORKER_MANIFEST = p_workerManifest;
2
+ p_workerModuleLoaders;
3
+ new Map();
4
+ new Map();
5
+ new Map();
6
+ const CORS_POLICY = MODERN_WORKER_MANIFEST.security?.cors || {};
7
+ CORS_POLICY.assets;
8
+ (CORS_POLICY.allowedOrigins || []).map((origin)=>String(origin).toLowerCase());
9
+ (CORS_POLICY.allowedMethods?.length ? CORS_POLICY.allowedMethods : [
10
+ 'GET',
11
+ 'HEAD',
12
+ 'POST',
13
+ 'PUT',
14
+ 'PATCH',
15
+ 'DELETE',
16
+ 'OPTIONS'
17
+ ]).join(', ');
18
+ (CORS_POLICY.allowedHeaders?.length ? CORS_POLICY.allowedHeaders : [
19
+ '*'
20
+ ]).join(', ');
21
+ globalThis.__dirname ??= '/';
22
+ globalThis.__filename ??= '/index.js';
@@ -0,0 +1,32 @@
1
+ export default {
2
+ async fetch (request, env, ctx) {
3
+ const corsPreflightResponse = await createCorsPreflightResponse(request, env);
4
+ if (corsPreflightResponse) return finalizeResponseForRequest(corsPreflightResponse, request);
5
+ const bffResponse = await dispatchBffRequest(request, env);
6
+ if (bffResponse) return finalizeResponseForRequest(withAppCorsHeaders(bffResponse, request), request);
7
+ const serviceBindingResponse = await dispatchServiceBindingRequest(request, env);
8
+ if (serviceBindingResponse) return finalizeResponseForRequest(withAppCorsHeaders(serviceBindingResponse, request), request);
9
+ const route = findRoute(request);
10
+ const { pathname } = new URL(request.url);
11
+ if (isAssetLikePathname(pathname) && !routeMatchesExactly(route, pathname)) {
12
+ const assetResponse = await fetchAsset(request, env);
13
+ if (assetResponse) return finalizeResponseForRequest(assetResponse, request);
14
+ return finalizeResponseForRequest(withAppCorsHeaders(new Response('Not found', {
15
+ status: 404
16
+ }), request), request);
17
+ }
18
+ const localeRedirectResponse = createLocaleRedirectResponseForRequest(route, request);
19
+ if (localeRedirectResponse) return finalizeResponseForRequest(withAppCorsHeaders(localeRedirectResponse, request), request);
20
+ if (route?.worker) {
21
+ const renderableRequest = createRenderableRequest(request);
22
+ return finalizeResponseForRequest(withAppCorsHeaders(await dispatchRouteWorker(route, renderableRequest, env, ctx), request), request);
23
+ }
24
+ const htmlResponse = await fetchRouteHtml(route, request, env);
25
+ if (htmlResponse) return finalizeResponseForRequest(htmlResponse, request);
26
+ const assetResponse = await fetchAsset(request, env);
27
+ if (assetResponse) return finalizeResponseForRequest(assetResponse, request);
28
+ return finalizeResponseForRequest(withAppCorsHeaders(new Response('Not found', {
29
+ status: 404
30
+ }), request), request);
31
+ }
32
+ };
@@ -259,6 +259,7 @@ function getBuilderEnvironments(normalizedConfig, appContext, tempBuilderConfig)
259
259
  chain.output.module(true).library({
260
260
  type: 'module'
261
261
  }).chunkFormat('module').chunkLoading('import').workerChunkLoading('import');
262
+ chain.optimization.usedExports(false).providedExports(true).innerGraph(false).sideEffects(false);
262
263
  chain.plugins.delete('plugin-module-federation');
263
264
  if (tanstackRouterSsrServerFile) {
264
265
  chain.resolve.alias.set('@tanstack/router-core/ssr/server$', tanstackRouterSsrServerFile);
@@ -30,10 +30,19 @@ const mergeCompressionOptions = (base, next)=>{
30
30
  ...base,
31
31
  ...next
32
32
  };
33
- if (base.compressionOptions || next.compressionOptions) merged.compressionOptions = {
34
- ...base.compressionOptions,
35
- ...next.compressionOptions
36
- };
33
+ if (base.compressionOptions || next.compressionOptions) {
34
+ const baseCompressionOptions = base.compressionOptions;
35
+ const nextCompressionOptions = next.compressionOptions;
36
+ const mergedCompressionOptions = {
37
+ ...baseCompressionOptions,
38
+ ...nextCompressionOptions
39
+ };
40
+ if (baseCompressionOptions?.params || nextCompressionOptions?.params) mergedCompressionOptions.params = {
41
+ ...baseCompressionOptions?.params,
42
+ ...nextCompressionOptions?.params
43
+ };
44
+ merged.compressionOptions = mergedCompressionOptions;
45
+ }
37
46
  return merged;
38
47
  };
39
48
  const resolveCodecOptions = (codecConfig, createDefaultOptions)=>{
@@ -20,7 +20,6 @@ function buildRouteEagerLazyCompilationTest(eagerRouteFiles, userTest) {
20
20
  return userTestFn(m);
21
21
  };
22
22
  }
23
- const buildSSRLazyCompilationTest = buildRouteEagerLazyCompilationTest;
24
23
  function planRouteEagerLazyCompilation(current, info) {
25
24
  if (!current) return {
26
25
  apply: false
@@ -42,5 +41,4 @@ function planRouteEagerLazyCompilation(current, info) {
42
41
  }
43
42
  };
44
43
  }
45
- const planSSRLazyCompilation = planRouteEagerLazyCompilation;
46
- export { aggregateEagerRouteComponentFiles, buildRouteEagerLazyCompilationTest, buildSSRLazyCompilationTest, collectRouteComponentFiles, normalizeModulePath, planRouteEagerLazyCompilation, planSSRLazyCompilation };
44
+ export { aggregateEagerRouteComponentFiles, buildRouteEagerLazyCompilationTest, collectRouteComponentFiles, normalizeModulePath, planRouteEagerLazyCompilation };
@@ -40,5 +40,4 @@ const infoCommand = (program, api)=>{
40
40
  await info(api, options);
41
41
  });
42
42
  };
43
- export { runtimeCommand } from "./runtime.mjs";
44
43
  export { buildCommand, deployCommand, devCommand, infoCommand, inspectCommand, serverCommand };
@@ -3,11 +3,12 @@ import { getLocaleLanguage } from "@modern-js/i18n-utils/language-detector";
3
3
  import { createAsyncHook } from "@modern-js/plugin";
4
4
  import { cleanRequireCache, deprecatedCommands, emptyDir, getArgv, getCommand } from "@modern-js/utils";
5
5
  import path from "path";
6
- import { buildCommand, deployCommand, devCommand, infoCommand, inspectCommand, runtimeCommand, serverCommand } from "./commands/index.mjs";
6
+ import { buildCommand, deployCommand, devCommand, infoCommand, inspectCommand, serverCommand } from "./commands/index.mjs";
7
7
  import { compatPlugin } from "./compat/index.mjs";
8
8
  import { DEFAULT_RUNTIME_CONFIG_FILE } from "./constants.mjs";
9
9
  import { i18n } from "./locale/index.mjs";
10
10
  import analyze from "./plugins/analyze/index.mjs";
11
+ import backendFederationBuild from "./plugins/backendFederationBuild.mjs";
11
12
  import deploy from "./plugins/deploy/index.mjs";
12
13
  import initialize from "./plugins/initialize/index.mjs";
13
14
  import serverBuild from "./plugins/serverBuild.mjs";
@@ -15,10 +16,8 @@ import serverRuntime from "./plugins/serverRuntime.mjs";
15
16
  import { generateWatchFiles } from "./utils/generateWatchFiles.mjs";
16
17
  import { initAppContext } from "./utils/initAppContext.mjs";
17
18
  import { restart } from "./utils/restart.mjs";
18
- export * from "./baseline.mjs";
19
19
  export * from "./defineConfig.mjs";
20
20
  export * from "./presetUltramodern.mjs";
21
- export * from "./ultramodern/designSystem.mjs";
22
21
  export * from "./types/index.mjs";
23
22
  const appTools = ()=>({
24
23
  name: '@modern-js/app-tools',
@@ -28,6 +27,7 @@ const appTools = ()=>({
28
27
  initialize(),
29
28
  analyze(),
30
29
  serverBuild(),
30
+ backendFederationBuild(),
31
31
  deploy()
32
32
  ],
33
33
  post: [
@@ -72,7 +72,6 @@ const appTools = ()=>({
72
72
  deployCommand(program, api);
73
73
  inspectCommand(program, api);
74
74
  infoCommand(program, api);
75
- await runtimeCommand(program, api);
76
75
  deprecatedCommands(program);
77
76
  });
78
77
  api.onPrepare(async ()=>{
@@ -1,7 +1,7 @@
1
1
  import { findExists, fs } from "@modern-js/utils";
2
2
  import path from "path";
3
3
  import { HTML_PARTIALS_EXTENSIONS, HTML_PARTIALS_FOLDER } from "./constants.mjs";
4
- import * as __rspack_external__templates_mjs_4da4c6c8 from "./templates.mjs";
4
+ import * as __rspack_external__templates_mjs_ab577925 from "./templates.mjs";
5
5
  const findPartials = (dir, entryName, position)=>{
6
6
  if (fs.existsSync(dir)) {
7
7
  const base = findExists(HTML_PARTIALS_EXTENSIONS.map((ext)=>path.resolve(dir, `${position}${ext}`)));
@@ -82,7 +82,7 @@ const getHtmlTemplate = async (entrypoints, hooks, { appContext, config })=>{
82
82
  partials: getModifyHtmlPartials(partials)
83
83
  });
84
84
  const templatePath = path.resolve(internalDirectory, entryName, 'index.html');
85
- fs.outputFileSync(templatePath, __rspack_external__templates_mjs_4da4c6c8.html(partials), 'utf8');
85
+ fs.outputFileSync(templatePath, __rspack_external__templates_mjs_ab577925.html(partials), 'utf8');
86
86
  htmlTemplates[entryName] = templatePath.replace(/\\/g, '/');
87
87
  partialsByEntrypoint[entryName] = partials;
88
88
  const bottomTemplate = findPartials(htmlDir, name, "bottom");
@@ -1,8 +1,8 @@
1
1
  import { parse } from "@babel/parser";
2
2
  import traverse from "@babel/traverse";
3
3
  import fs from "fs";
4
- import * as __rspack_external__babel_types_69e65b52 from "@babel/types";
5
- const isFunction = (node)=>__rspack_external__babel_types_69e65b52.isFunctionDeclaration(node) || __rspack_external__babel_types_69e65b52.isFunctionExpression(node) || __rspack_external__babel_types_69e65b52.isArrowFunctionExpression(node);
4
+ import * as __rspack_external__babel_types_6e8337dd from "@babel/types";
5
+ const isFunction = (node)=>__rspack_external__babel_types_6e8337dd.isFunctionDeclaration(node) || __rspack_external__babel_types_6e8337dd.isFunctionExpression(node) || __rspack_external__babel_types_6e8337dd.isArrowFunctionExpression(node);
6
6
  const isDefaultExportFunction = (file)=>{
7
7
  if (!file || !fs.existsSync(file)) return false;
8
8
  const ast = parse(fs.readFileSync(file, 'utf8'), {
@@ -0,0 +1,158 @@
1
+ import node_path from "node:path";
2
+ import { BACKEND_FEDERATION_CONTRACT_VERSION, BACKEND_FEDERATION_EFFECT_EXPOSE, BACKEND_FEDERATION_NODE_ADAPTER_VERSION, BACKEND_FEDERATION_REMOTE_ENTRY_FILE, formatBackendFederationValidationErrors, validateBackendFederationManifest } from "@modern-js/utils/universal";
3
+ import { normalizeRelativePath } from "./config.mjs";
4
+ const createRelativeImportSpecifier = (fromDirectory, toFile)=>{
5
+ const relativePath = normalizeRelativePath(node_path.relative(fromDirectory, toFile));
6
+ return relativePath.startsWith('.') ? relativePath : `./${relativePath}`;
7
+ };
8
+ const createPublicPath = (containerEntry, fallbackPort)=>{
9
+ try {
10
+ return new URL('.', containerEntry).href;
11
+ } catch {
12
+ const slashIndex = containerEntry.lastIndexOf('/');
13
+ if (slashIndex >= 0) return containerEntry.slice(0, slashIndex + 1);
14
+ return `http://localhost:${fallbackPort}/`;
15
+ }
16
+ };
17
+ const createBackendRemoteEntrySource = (workspaceRoot, app, effectApiPath, entryPath)=>{
18
+ const effectApiSpecifier = createRelativeImportSpecifier(node_path.dirname(entryPath), effectApiPath);
19
+ return `// Generated by Modern.js backend federation build.
20
+ const exposedModules = {
21
+ ${JSON.stringify(BACKEND_FEDERATION_EFFECT_EXPOSE)}: () =>
22
+ import(new URL(${JSON.stringify(effectApiSpecifier)}, import.meta.url).href),
23
+ };
24
+
25
+ export const __modernjsBackendFederation = ${JSON.stringify({
26
+ buildVersion: app.buildVersion,
27
+ expose: BACKEND_FEDERATION_EFFECT_EXPOSE,
28
+ name: app.backendName,
29
+ packageName: app.packageName,
30
+ remoteType: app.remoteType,
31
+ source: normalizeRelativePath(node_path.relative(workspaceRoot, effectApiPath)),
32
+ version: app.version,
33
+ ...app.unitId ? {
34
+ unitId: app.unitId
35
+ } : {},
36
+ ...app.sourceRevision ? {
37
+ sourceRevision: app.sourceRevision
38
+ } : {}
39
+ }, null, 2)};
40
+
41
+ export function init() {}
42
+
43
+ export function get(id) {
44
+ const load = exposedModules[id];
45
+ if (!load) {
46
+ throw new Error(\`Unexpected backend federation expose: \${id}\`);
47
+ }
48
+
49
+ return async () => load();
50
+ }
51
+
52
+ export default { get, init };
53
+ `;
54
+ };
55
+ const createBackendManifest = (workspaceRoot, distDirectory, app)=>{
56
+ const sourceModule = `${app.directory}/api/effect-api.ts`;
57
+ const publicPath = createPublicPath(app.containerEntry, app.port);
58
+ const manifest = {
59
+ schemaVersion: 1,
60
+ id: app.backendName,
61
+ name: app.backendName,
62
+ version: app.version,
63
+ buildVersion: app.buildVersion,
64
+ metaData: {
65
+ name: app.backendName,
66
+ type: 'backend',
67
+ buildInfo: {
68
+ buildVersion: app.buildVersion,
69
+ buildName: app.packageName
70
+ },
71
+ remoteEntry: {
72
+ name: BACKEND_FEDERATION_REMOTE_ENTRY_FILE,
73
+ path: '',
74
+ type: app.remoteType
75
+ },
76
+ globalName: app.backendName,
77
+ publicPath,
78
+ ssrRemoteEntry: {
79
+ name: BACKEND_FEDERATION_REMOTE_ENTRY_FILE,
80
+ path: '',
81
+ type: app.remoteType
82
+ },
83
+ ssrPublicPath: publicPath
84
+ },
85
+ entry: {
86
+ file: BACKEND_FEDERATION_REMOTE_ENTRY_FILE,
87
+ path: normalizeRelativePath(node_path.relative(workspaceRoot, node_path.join(distDirectory, BACKEND_FEDERATION_REMOTE_ENTRY_FILE))),
88
+ type: app.remoteType,
89
+ url: app.containerEntry
90
+ },
91
+ exposes: [
92
+ {
93
+ id: `${app.backendName}:${BACKEND_FEDERATION_EFFECT_EXPOSE}`,
94
+ name: BACKEND_FEDERATION_EFFECT_EXPOSE,
95
+ path: '',
96
+ assets: {
97
+ js: {
98
+ async: [],
99
+ sync: [
100
+ BACKEND_FEDERATION_REMOTE_ENTRY_FILE
101
+ ]
102
+ },
103
+ css: {
104
+ async: [],
105
+ sync: []
106
+ }
107
+ }
108
+ }
109
+ ],
110
+ shared: [],
111
+ backendFederation: {
112
+ role: 'microvertical-server',
113
+ appId: app.id,
114
+ name: app.backendName,
115
+ runtimeFramework: 'effect',
116
+ strictEffectApproach: true,
117
+ contractVersion: BACKEND_FEDERATION_CONTRACT_VERSION,
118
+ nodeAdapterVersion: BACKEND_FEDERATION_NODE_ADAPTER_VERSION,
119
+ remoteType: app.remoteType,
120
+ expose: BACKEND_FEDERATION_EFFECT_EXPOSE,
121
+ manifestUrl: app.manifestUrl,
122
+ containerEntry: app.containerEntry,
123
+ source: {
124
+ module: sourceModule
125
+ },
126
+ readinessPath: `${app.apiPrefix}/${app.apiStem}/readiness`,
127
+ openapiPath: `${app.apiPrefix}/openapi.json`,
128
+ ...app.deliveryUnit ? {
129
+ deliveryUnit: app.deliveryUnit
130
+ } : {},
131
+ versionBoundary: {
132
+ invariant: 'web-and-api-same-build',
133
+ packageName: app.packageName,
134
+ version: app.version,
135
+ buildVersion: app.buildVersion,
136
+ ...app.uiManifestUrl ? {
137
+ uiManifestUrl: app.uiManifestUrl
138
+ } : {},
139
+ ...app.deliveryUnit ? {
140
+ deliveryUnit: {
141
+ unitId: app.deliveryUnit.unitId,
142
+ buildMarker: app.deliveryUnit.buildMarker,
143
+ sourceRevision: app.deliveryUnit.sourceRevision
144
+ }
145
+ } : {}
146
+ }
147
+ }
148
+ };
149
+ const validation = validateBackendFederationManifest(manifest, {
150
+ path: 'backendFederationManifest',
151
+ requireEffectExpose: true,
152
+ requireEffectRuntime: true,
153
+ requireVersionFields: true
154
+ });
155
+ if (!validation.ok) throw new Error(`[backend-federation-build] Invalid backend federation manifest: ${formatBackendFederationValidationErrors(validation.errors)}.`);
156
+ return manifest;
157
+ };
158
+ export { createBackendManifest, createBackendRemoteEntrySource };