@bleedingdev/modern-js-app-tools-extensions 3.9.0-ultramodern.13 → 3.9.0-ultramodern.15
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/cloudflare/worker-manifest.js +13 -4
- package/dist/cjs/cloudflare/wrangler-config.js +35 -7
- package/dist/cjs/cloudflare-builder.js +235 -14
- package/dist/cjs/cloudflare-output-contract.js +31 -2
- package/dist/cjs/cloudflare-output-verifier/worker-bundles.js +10 -5
- package/dist/cjs/templates/cloudflare-entry.004-rendering-css.mjs +4 -0
- package/dist/cjs/templates/cloudflare-entry.005-worker-dispatch.mjs +46 -0
- package/dist/cjs/templates/cloudflare-entry.006-fetch-handler.mjs +9 -2
- package/dist/cjs/templates/cloudflare-worker-route-data.mjs +1069 -0
- package/dist/esm/cloudflare/worker-manifest.mjs +13 -4
- package/dist/esm/cloudflare/wrangler-config.mjs +35 -7
- package/dist/esm/cloudflare-builder.mjs +229 -17
- package/dist/esm/cloudflare-output-contract.mjs +24 -1
- package/dist/esm/cloudflare-output-verifier/worker-bundles.mjs +11 -6
- package/dist/esm/templates/cloudflare-entry.004-rendering-css.mjs +4 -0
- package/dist/esm/templates/cloudflare-entry.005-worker-dispatch.mjs +46 -0
- package/dist/esm/templates/cloudflare-entry.006-fetch-handler.mjs +9 -2
- package/dist/esm/templates/cloudflare-worker-route-data.mjs +1069 -0
- package/dist/esm-node/cloudflare/worker-manifest.mjs +13 -4
- package/dist/esm-node/cloudflare/wrangler-config.mjs +35 -7
- package/dist/esm-node/cloudflare-builder.mjs +229 -17
- package/dist/esm-node/cloudflare-output-contract.mjs +24 -1
- package/dist/esm-node/cloudflare-output-verifier/worker-bundles.mjs +11 -6
- package/dist/esm-node/templates/cloudflare-entry.004-rendering-css.mjs +4 -0
- package/dist/esm-node/templates/cloudflare-entry.005-worker-dispatch.mjs +46 -0
- package/dist/esm-node/templates/cloudflare-entry.006-fetch-handler.mjs +9 -2
- package/dist/esm-node/templates/cloudflare-worker-route-data.mjs +1069 -0
- package/dist/types/cloudflare/wrangler-config.d.ts +6 -0
- package/dist/types/cloudflare-builder.d.ts +44 -1
- package/dist/types/cloudflare-output-contract.d.ts +3 -1
- package/dist/types/cloudflare-output-verifier/worker-bundles.d.ts +2 -2
- package/dist/types/templates/cloudflare-worker-route-data.d.mts +14 -0
- package/package.json +17 -13
- package/src/cloudflare/worker-manifest.ts +19 -3
- package/src/cloudflare/wrangler-config.ts +86 -10
- package/src/cloudflare-builder.ts +447 -12
- package/src/cloudflare-output-contract.ts +34 -2
- package/src/cloudflare-output-verifier/worker-bundles.ts +27 -11
- package/src/templates/cloudflare-entry.004-rendering-css.mjs +4 -0
- package/src/templates/cloudflare-entry.005-worker-dispatch.mjs +46 -0
- package/src/templates/cloudflare-entry.006-fetch-handler.mjs +9 -2
- package/src/templates/cloudflare-worker-route-data.mjs +1069 -0
|
@@ -46,6 +46,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
46
46
|
const external_node_path_namespaceObject = require("node:path");
|
|
47
47
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
48
48
|
const utils_namespaceObject = require("@modern-js/utils");
|
|
49
|
+
const external_cloudflare_output_contract_js_namespaceObject = require("../cloudflare-output-contract.js");
|
|
49
50
|
const external_artifacts_js_namespaceObject = require("./artifacts.js");
|
|
50
51
|
const external_constants_js_namespaceObject = require("./constants.js");
|
|
51
52
|
const external_i18n_worker_js_namespaceObject = require("./i18n-worker.js");
|
|
@@ -111,13 +112,18 @@ const createWorkerManifest = async (outputDirectory, modernConfig, appContext, d
|
|
|
111
112
|
const routeSpec = await (0, external_artifacts_js_namespaceObject.readRouteSpec)(outputDirectory);
|
|
112
113
|
const routes = await Promise.all(routeSpec.routes.map(async (route)=>{
|
|
113
114
|
const worker = 'string' == typeof route.worker ? route.worker : void 0;
|
|
115
|
+
const routeDataWorker = route.isSSR && 'string' == typeof route.entryName ? `${external_constants_js_namespaceObject.WORKER_BUNDLE_DIRECTORY}/${(0, external_cloudflare_output_contract_js_namespaceObject.getCloudflareWorkerRouteDataEntryName)(route.entryName)}.js` : void 0;
|
|
116
|
+
const hasRouteDataWorker = routeDataWorker ? await utils_namespaceObject.fs.pathExists(external_node_path_default().join(outputDirectory, routeDataWorker)) : false;
|
|
114
117
|
return {
|
|
115
118
|
urlPath: route.urlPath,
|
|
116
119
|
entryName: route.entryName,
|
|
117
120
|
entryPath: route.entryPath,
|
|
118
121
|
isSSR: Boolean(route.isSSR),
|
|
119
122
|
worker,
|
|
120
|
-
workerExists: worker ? await utils_namespaceObject.fs.pathExists(external_node_path_default().join(outputDirectory, worker)) : false
|
|
123
|
+
workerExists: worker ? await utils_namespaceObject.fs.pathExists(external_node_path_default().join(outputDirectory, worker)) : false,
|
|
124
|
+
...hasRouteDataWorker ? {
|
|
125
|
+
routeDataWorker
|
|
126
|
+
} : {}
|
|
121
127
|
};
|
|
122
128
|
}));
|
|
123
129
|
const bffPrefix = modernConfig.bff?.prefix;
|
|
@@ -177,9 +183,12 @@ const createWorkerManifest = async (outputDirectory, modernConfig, appContext, d
|
|
|
177
183
|
};
|
|
178
184
|
const createWorkerModuleLoaders = (manifest)=>{
|
|
179
185
|
const imports = new Map();
|
|
180
|
-
for (const route of manifest.routeSpec.routes)
|
|
181
|
-
|
|
182
|
-
|
|
186
|
+
for (const route of manifest.routeSpec.routes)for (const worker of [
|
|
187
|
+
route.workerExists ? route.worker : void 0,
|
|
188
|
+
route.routeDataWorker
|
|
189
|
+
])if (worker) {
|
|
190
|
+
const importPath = `../${String(worker).replace(/^\/+/u, '')}`;
|
|
191
|
+
imports.set(worker, `() => import(${JSON.stringify(importPath)})`);
|
|
183
192
|
}
|
|
184
193
|
if (manifest.bff?.worker) {
|
|
185
194
|
const importPath = `../${String(manifest.bff.worker).replace(/^\/+/u, '')}`;
|
|
@@ -45,12 +45,16 @@ const external_node_path_namespaceObject = require("node:path");
|
|
|
45
45
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
46
46
|
const external_constants_js_namespaceObject = require("./constants.js");
|
|
47
47
|
const external_utils_js_namespaceObject = require("./utils.js");
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (
|
|
48
|
+
const assertSupportedCompatibilityDate = (compatibilityDate, label)=>{
|
|
49
|
+
if ('string' != typeof compatibilityDate) throw new Error(`${label} must be a YYYY-MM-DD string.`);
|
|
50
|
+
if (!external_constants_js_namespaceObject.COMPATIBILITY_DATE_PATTERN.test(compatibilityDate)) throw new Error(`${label} must use YYYY-MM-DD, received ${JSON.stringify(compatibilityDate)}.`);
|
|
51
|
+
if (compatibilityDate < external_constants_js_namespaceObject.DEFAULT_COMPATIBILITY_DATE) throw new Error(`${label} must be ${external_constants_js_namespaceObject.DEFAULT_COMPATIBILITY_DATE} or later, the date the Cloudflare worker Node.js built-in contract is verified against; received ${JSON.stringify(compatibilityDate)}.`);
|
|
52
52
|
return compatibilityDate;
|
|
53
53
|
};
|
|
54
|
+
const getCompatibilityDate = (modernConfig, wranglerCompatibilityDate)=>{
|
|
55
|
+
if (void 0 !== wranglerCompatibilityDate) return assertSupportedCompatibilityDate(wranglerCompatibilityDate, 'deploy.worker.wrangler.compatibility_date');
|
|
56
|
+
return assertSupportedCompatibilityDate(modernConfig.deploy?.worker?.compatibilityDate?.trim() || external_constants_js_namespaceObject.DEFAULT_COMPATIBILITY_DATE, 'deploy.worker.compatibilityDate');
|
|
57
|
+
};
|
|
54
58
|
const getWorkerName = (appDirectory)=>{
|
|
55
59
|
const basename = external_node_path_default().basename(appDirectory);
|
|
56
60
|
return basename.replace(/[^a-zA-Z0-9-_]/g, '-') || 'modern-cloudflare-worker';
|
|
@@ -65,11 +69,11 @@ const getConfiguredWrangler = (modernConfig)=>{
|
|
|
65
69
|
if (!(0, external_utils_js_namespaceObject.isJsonRecord)(wrangler)) throw new Error('deploy.worker.wrangler must be a JSON object.');
|
|
66
70
|
return wrangler;
|
|
67
71
|
};
|
|
68
|
-
const createWranglerCompatibilityFlags = (configuredFlags)=>{
|
|
72
|
+
const createWranglerCompatibilityFlags = (configuredFlags, label = 'deploy.worker.wrangler.compatibility_flags')=>{
|
|
69
73
|
if (void 0 === configuredFlags) return [
|
|
70
74
|
...external_constants_js_namespaceObject.REQUIRED_COMPATIBILITY_FLAGS
|
|
71
75
|
];
|
|
72
|
-
if (!Array.isArray(configuredFlags) || configuredFlags.some((flag)=>'string' != typeof flag)) throw new Error(
|
|
76
|
+
if (!Array.isArray(configuredFlags) || configuredFlags.some((flag)=>'string' != typeof flag)) throw new Error(`${label} must be an array of strings.`);
|
|
73
77
|
return [
|
|
74
78
|
...new Set([
|
|
75
79
|
...configuredFlags,
|
|
@@ -77,6 +81,26 @@ const createWranglerCompatibilityFlags = (configuredFlags)=>{
|
|
|
77
81
|
])
|
|
78
82
|
];
|
|
79
83
|
};
|
|
84
|
+
const createWranglerEnvironments = (wranglerEnv)=>{
|
|
85
|
+
if (void 0 === wranglerEnv) return;
|
|
86
|
+
if (!(0, external_utils_js_namespaceObject.isJsonRecord)(wranglerEnv)) throw new Error('deploy.worker.wrangler.env must be an object.');
|
|
87
|
+
return Object.fromEntries(Object.entries(wranglerEnv).map(([name, environment])=>{
|
|
88
|
+
const label = `deploy.worker.wrangler.env.${name}`;
|
|
89
|
+
if (!(0, external_utils_js_namespaceObject.isJsonRecord)(environment)) throw new Error(`${label} must be an object.`);
|
|
90
|
+
return [
|
|
91
|
+
name,
|
|
92
|
+
{
|
|
93
|
+
...environment,
|
|
94
|
+
...void 0 === environment.compatibility_date ? {} : {
|
|
95
|
+
compatibility_date: assertSupportedCompatibilityDate(environment.compatibility_date, `${label}.compatibility_date`)
|
|
96
|
+
},
|
|
97
|
+
...void 0 === environment.compatibility_flags ? {} : {
|
|
98
|
+
compatibility_flags: createWranglerCompatibilityFlags(environment.compatibility_flags, `${label}.compatibility_flags`)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
];
|
|
102
|
+
}));
|
|
103
|
+
};
|
|
80
104
|
const createWranglerAssetsConfig = (configuredAssets)=>{
|
|
81
105
|
if (void 0 !== configuredAssets && !(0, external_utils_js_namespaceObject.isJsonRecord)(configuredAssets)) throw new Error('deploy.worker.wrangler.assets must be an object.');
|
|
82
106
|
return {
|
|
@@ -173,17 +197,21 @@ const createWorkerManifestServiceBindings = (serviceBindings)=>{
|
|
|
173
197
|
};
|
|
174
198
|
const createWranglerConfig = (appDirectory, modernConfig)=>{
|
|
175
199
|
const wrangler = getConfiguredWrangler(modernConfig);
|
|
200
|
+
const environments = createWranglerEnvironments(wrangler.env);
|
|
176
201
|
const d1Databases = createWranglerD1Databases(modernConfig, wrangler.d1_databases);
|
|
177
202
|
const serviceBindings = createWorkerServiceBindings(modernConfig, wrangler.services);
|
|
178
203
|
const wranglerServices = createWranglerServices(serviceBindings);
|
|
179
204
|
return {
|
|
180
205
|
$schema: 'node_modules/wrangler/config-schema.json',
|
|
181
206
|
name: getConfiguredWorkerName(appDirectory, modernConfig),
|
|
182
|
-
compatibility_date: getCompatibilityDate(modernConfig),
|
|
183
207
|
...wrangler,
|
|
208
|
+
compatibility_date: getCompatibilityDate(modernConfig, wrangler.compatibility_date),
|
|
184
209
|
main: external_constants_js_namespaceObject.WORKER_ENTRY,
|
|
185
210
|
compatibility_flags: createWranglerCompatibilityFlags(wrangler.compatibility_flags),
|
|
186
211
|
assets: createWranglerAssetsConfig(wrangler.assets),
|
|
212
|
+
...void 0 === environments ? {} : {
|
|
213
|
+
env: environments
|
|
214
|
+
},
|
|
187
215
|
...void 0 === d1Databases ? {} : {
|
|
188
216
|
d1_databases: d1Databases
|
|
189
217
|
},
|
|
@@ -43,7 +43,10 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
43
43
|
applyCloudflareBuilderEnvironments: ()=>applyCloudflareBuilderEnvironments,
|
|
44
44
|
applyCloudflareWorkerMfRuntimeBoundary: ()=>applyCloudflareWorkerMfRuntimeBoundary,
|
|
45
45
|
applyCloudflareWorkerRspackConfig: ()=>applyCloudflareWorkerRspackConfig,
|
|
46
|
+
claimsByFunctionExternal: ()=>claimsByFunctionExternal,
|
|
47
|
+
createAbsentOptionalDependencyFilter: ()=>createAbsentOptionalDependencyFilter,
|
|
46
48
|
createCloudflareBuilderPlugin: ()=>createCloudflareBuilderPlugin,
|
|
49
|
+
createRequestRedirectMatcher: ()=>createRequestRedirectMatcher,
|
|
47
50
|
getCloudflareBuilderEnvironments: ()=>getCloudflareBuilderEnvironments,
|
|
48
51
|
getCloudflareWorkerRspackConfig: ()=>getCloudflareWorkerRspackConfig
|
|
49
52
|
});
|
|
@@ -60,8 +63,47 @@ const external_read_template_js_namespaceObject = require("./read-template.js");
|
|
|
60
63
|
const moduleRequire = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
|
|
61
64
|
const BFF_EFFECT_WORKER_ENTRY_NAME = '__modern_bff_effect';
|
|
62
65
|
const BFF_EFFECT_WORKER_RUNTIME_QUERY = 'modern-bff-runtime';
|
|
66
|
+
const SERVER_LOADER_COMBINED_FILE = 'server-loader-combined.js';
|
|
67
|
+
const ROUTE_SERVER_LOADERS_FILE = 'route-server-loaders.js';
|
|
68
|
+
const WORKER_ROUTE_DATA_FILE = 'cloudflare-worker-route-data.js';
|
|
69
|
+
const WORKER_ROUTE_DATA_TEMPLATE = 'cloudflare-worker-route-data.mjs';
|
|
70
|
+
const DATA_LOADER_CLIENT_TRANSFORM = /plugin-data-loader[\\/](?:.+[\\/])?loader\.[cm]?js$/u;
|
|
63
71
|
const MF_SSR_DATA_FETCH_RUNTIME_PLUGIN = '@module-federation/modern-js-v3/ssr-inject-data-fetch-function-plugin';
|
|
64
72
|
const MF_SSR_DEV_RUNTIME_PLUGIN = '@module-federation/modern-js-v3/ssr-dev-plugin';
|
|
73
|
+
const WORKER_DEPENDENCY_CONDITIONS = [
|
|
74
|
+
[
|
|
75
|
+
'esm',
|
|
76
|
+
'import'
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
'wasm',
|
|
80
|
+
'import'
|
|
81
|
+
],
|
|
82
|
+
[
|
|
83
|
+
'loaderImport',
|
|
84
|
+
'import'
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
'worker',
|
|
88
|
+
'import'
|
|
89
|
+
],
|
|
90
|
+
[
|
|
91
|
+
'commonjs',
|
|
92
|
+
'require'
|
|
93
|
+
],
|
|
94
|
+
[
|
|
95
|
+
'amd',
|
|
96
|
+
'require'
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
'loader',
|
|
100
|
+
'require'
|
|
101
|
+
],
|
|
102
|
+
[
|
|
103
|
+
'unknown',
|
|
104
|
+
'require'
|
|
105
|
+
]
|
|
106
|
+
];
|
|
65
107
|
const JS_OR_TS_EXTENSIONS = new Set([
|
|
66
108
|
'.js',
|
|
67
109
|
'.jsx',
|
|
@@ -121,19 +163,154 @@ const resolvePackageFile = (packageName, filePath, paths)=>{
|
|
|
121
163
|
const setAliasIfPresent = (alias, name, value)=>{
|
|
122
164
|
if (value) alias.set(name, value);
|
|
123
165
|
};
|
|
124
|
-
const getCloudflareWorkerNodeExternals = ()=>Object.fromEntries(
|
|
125
|
-
|
|
166
|
+
const getCloudflareWorkerNodeExternals = ()=>Object.fromEntries([
|
|
167
|
+
...external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_WORKER_NODE_BUILTINS.flatMap((builtin)=>{
|
|
168
|
+
const nodeBuiltin = `node:${builtin}`;
|
|
169
|
+
const external = `module-import ${nodeBuiltin}`;
|
|
170
|
+
return (0, external_node_module_namespaceObject.isBuiltin)(builtin) ? [
|
|
171
|
+
[
|
|
172
|
+
builtin,
|
|
173
|
+
external
|
|
174
|
+
],
|
|
175
|
+
[
|
|
176
|
+
nodeBuiltin,
|
|
177
|
+
external
|
|
178
|
+
]
|
|
179
|
+
] : [
|
|
180
|
+
[
|
|
181
|
+
nodeBuiltin,
|
|
182
|
+
external
|
|
183
|
+
]
|
|
184
|
+
];
|
|
185
|
+
}),
|
|
186
|
+
...external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_WORKER_PLATFORM_MODULES.map((platformModule)=>[
|
|
187
|
+
platformModule,
|
|
188
|
+
`module-import ${platformModule}`
|
|
189
|
+
])
|
|
190
|
+
]);
|
|
191
|
+
const getPackageNameFromRequest = (request)=>{
|
|
192
|
+
if (request.startsWith('.') || request.startsWith('/') || request.includes(':') || external_node_path_default().isAbsolute(request)) return;
|
|
193
|
+
const segments = request.split('/');
|
|
194
|
+
return request.startsWith('@') ? segments.length > 1 ? `${segments[0]}/${segments[1]}` : void 0 : segments[0];
|
|
195
|
+
};
|
|
196
|
+
const isRedirectedByAliasField = (manifest, aliasFields, request)=>aliasFields.some((field)=>{
|
|
197
|
+
let value = manifest;
|
|
198
|
+
for (const key of 'string' == typeof field ? [
|
|
199
|
+
field
|
|
200
|
+
] : field)value = value && 'object' == typeof value ? value[key] : void 0;
|
|
201
|
+
return 'object' == typeof value && null !== value && Object.hasOwn(value, request);
|
|
202
|
+
});
|
|
203
|
+
const findOwningPackageManifest = (directory, cache)=>{
|
|
204
|
+
if (cache.has(directory)) return cache.get(directory);
|
|
205
|
+
let manifest;
|
|
206
|
+
const packageJsonPath = external_node_path_default().join(directory, 'package.json');
|
|
207
|
+
if (external_node_fs_default().existsSync(packageJsonPath)) try {
|
|
208
|
+
manifest = JSON.parse(external_node_fs_default().readFileSync(packageJsonPath, 'utf-8'));
|
|
209
|
+
} catch {
|
|
210
|
+
manifest = void 0;
|
|
211
|
+
}
|
|
212
|
+
else if (external_node_path_default().dirname(directory) !== directory) manifest = findOwningPackageManifest(external_node_path_default().dirname(directory), cache);
|
|
213
|
+
cache.set(directory, manifest);
|
|
214
|
+
return manifest;
|
|
215
|
+
};
|
|
216
|
+
const isPackageInstalled = (packageName, directory, moduleDirectories)=>moduleDirectories.some((moduleDirectory)=>{
|
|
217
|
+
if (external_node_path_default().isAbsolute(moduleDirectory)) return external_node_fs_default().existsSync(external_node_path_default().join(moduleDirectory, packageName));
|
|
218
|
+
let current = directory;
|
|
219
|
+
while(true){
|
|
220
|
+
if (external_node_fs_default().existsSync(external_node_path_default().join(current, moduleDirectory, packageName))) return true;
|
|
221
|
+
const parent = external_node_path_default().dirname(current);
|
|
222
|
+
if (parent === current) return false;
|
|
223
|
+
current = parent;
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
const createAbsentOptionalDependencyFilter = (isRedirected = ()=>false, moduleDirectories = [
|
|
227
|
+
'node_modules'
|
|
228
|
+
], aliasFields = [])=>{
|
|
229
|
+
const manifests = new Map();
|
|
230
|
+
return (request, context)=>{
|
|
231
|
+
const packageName = getPackageNameFromRequest(request);
|
|
232
|
+
if (!packageName || !context || isRedirected(request)) return false;
|
|
233
|
+
const manifest = findOwningPackageManifest(context, manifests);
|
|
234
|
+
if (!manifest) return false;
|
|
235
|
+
const optional = manifest.peerDependenciesMeta?.[packageName]?.optional === true || Object.hasOwn(manifest.optionalDependencies ?? {}, packageName);
|
|
236
|
+
return optional && !isRedirectedByAliasField(manifest, aliasFields, request) && !isPackageInstalled(packageName, context, moduleDirectories);
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
const getAliasNames = (alias)=>alias ? Array.isArray(alias) ? alias.map((entry)=>entry.onlyModule ? `${entry.name}$` : entry.name) : Object.keys(alias) : [];
|
|
240
|
+
const getExternalMatchers = (externals)=>{
|
|
241
|
+
if (Array.isArray(externals)) return externals.flatMap(getExternalMatchers);
|
|
242
|
+
if ('string' == typeof externals) return [
|
|
243
|
+
(request)=>request === externals
|
|
244
|
+
];
|
|
245
|
+
if (externals instanceof RegExp) return [
|
|
246
|
+
(request)=>{
|
|
247
|
+
externals.lastIndex = 0;
|
|
248
|
+
return externals.test(request);
|
|
249
|
+
}
|
|
250
|
+
];
|
|
251
|
+
if (externals && 'object' == typeof externals) {
|
|
252
|
+
const names = new Set(Object.entries(externals).filter(([, value])=>false !== value).map(([name])=>name));
|
|
126
253
|
return [
|
|
127
|
-
|
|
128
|
-
builtin,
|
|
129
|
-
`module-import ${nodeBuiltin}`
|
|
130
|
-
],
|
|
131
|
-
[
|
|
132
|
-
nodeBuiltin,
|
|
133
|
-
`module-import ${nodeBuiltin}`
|
|
134
|
-
]
|
|
254
|
+
(request)=>names.has(request)
|
|
135
255
|
];
|
|
136
|
-
}
|
|
256
|
+
}
|
|
257
|
+
return [];
|
|
258
|
+
};
|
|
259
|
+
const createRequestRedirectMatcher = (options)=>{
|
|
260
|
+
const aliasNames = [
|
|
261
|
+
...getAliasNames(options.resolve?.alias),
|
|
262
|
+
...getAliasNames(options.resolve?.fallback)
|
|
263
|
+
];
|
|
264
|
+
const externalMatchers = getExternalMatchers(options.externals);
|
|
265
|
+
return (request)=>externalMatchers.some((matches)=>matches(request)) || aliasNames.some((name)=>name.endsWith('$') ? request === name.slice(0, -1) : request === name || request.startsWith(`${name}/`));
|
|
266
|
+
};
|
|
267
|
+
const getFunctionExternals = (externals)=>Array.isArray(externals) ? externals.flatMap(getFunctionExternals) : 'function' == typeof externals ? [
|
|
268
|
+
externals
|
|
269
|
+
] : [];
|
|
270
|
+
const callFunctionExternal = (external, data)=>new Promise((resolve, reject)=>{
|
|
271
|
+
const returned = external(data, (error, result)=>error ? reject(error) : resolve(result));
|
|
272
|
+
if (null !== returned && 'object' == typeof returned && 'function' == typeof returned.then) returned.then(resolve, reject);
|
|
273
|
+
else if (1 === external.length) resolve(returned);
|
|
274
|
+
});
|
|
275
|
+
const claimsByFunctionExternal = async (externals, data)=>{
|
|
276
|
+
for (const external of externals)try {
|
|
277
|
+
const result = await callFunctionExternal(external, data);
|
|
278
|
+
if (null != result && false !== result) return true;
|
|
279
|
+
} catch {
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
return false;
|
|
283
|
+
};
|
|
284
|
+
const PLUGIN_NAME = 'AbsentOptionalDependencyPlugin';
|
|
285
|
+
class AbsentOptionalDependencyPlugin {
|
|
286
|
+
apply(compiler) {
|
|
287
|
+
const isAbsent = createAbsentOptionalDependencyFilter(createRequestRedirectMatcher(compiler.options), compiler.options.resolve.modules, compiler.options.resolve.aliasFields);
|
|
288
|
+
const functionExternals = getFunctionExternals(compiler.options.externals);
|
|
289
|
+
compiler.hooks.normalModuleFactory.tap(PLUGIN_NAME, (factory)=>{
|
|
290
|
+
factory.hooks.beforeResolve.tapPromise(PLUGIN_NAME, async (data)=>{
|
|
291
|
+
if (!isAbsent(data.request, data.context)) return;
|
|
292
|
+
const claimed = await claimsByFunctionExternal(functionExternals, {
|
|
293
|
+
context: data.context,
|
|
294
|
+
contextInfo: {
|
|
295
|
+
issuer: data.contextInfo.issuer,
|
|
296
|
+
issuerLayer: data.contextInfo.issuerLayer ?? null
|
|
297
|
+
},
|
|
298
|
+
getResolve: (options)=>{
|
|
299
|
+
const resolver = factory.getResolver('normal', options ?? {});
|
|
300
|
+
return (context, request, callback)=>{
|
|
301
|
+
if (callback) return void resolver.resolve({}, context, request, {}, callback);
|
|
302
|
+
return new Promise((resolve, reject)=>{
|
|
303
|
+
resolver.resolve({}, context, request, {}, (error, result)=>error ? reject(error) : resolve(result || void 0));
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
},
|
|
307
|
+
request: data.request
|
|
308
|
+
});
|
|
309
|
+
return claimed ? void 0 : false;
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
137
314
|
const normalizeWorkerOutputName = (name)=>external_node_path_default().posix.normalize(name.replace(/\\/gu, '/')).toLowerCase();
|
|
138
315
|
const reserveWorkerChunkName = (baseName, reservedOutputNames)=>{
|
|
139
316
|
let name = baseName;
|
|
@@ -183,6 +360,9 @@ function applyCloudflareWorkerRspackConfig(chain, workerEntryNames) {
|
|
|
183
360
|
chain.optimization.runtimeChunk(config.optimization.runtimeChunk);
|
|
184
361
|
chain.optimization.splitChunks(config.optimization.splitChunks);
|
|
185
362
|
}
|
|
363
|
+
function removeCloudflareWorkerDataLoaderClientTransform(chain) {
|
|
364
|
+
for (const [name, rule] of Object.entries(chain.module.rules.entries() ?? {}))if (rule.uses.values().some((use)=>DATA_LOADER_CLIENT_TRANSFORM.test(String(use.get('loader'))))) chain.module.rules.delete(name);
|
|
365
|
+
}
|
|
186
366
|
function applyCloudflareWorkerMfRuntimeBoundary(chain) {
|
|
187
367
|
const runtimePlugin = (0, external_read_template_js_namespaceObject.getTemplatePath)('cloudflare-worker-mf-ssr-runtime-plugin.mjs');
|
|
188
368
|
chain.plugins.delete('plugin-module-federation');
|
|
@@ -254,11 +434,40 @@ const prependBundlerChain = (environment, handler)=>{
|
|
|
254
434
|
}
|
|
255
435
|
};
|
|
256
436
|
};
|
|
437
|
+
const createWorkerRouteDataModule = ()=>[
|
|
438
|
+
`import { routes } from './${ROUTE_SERVER_LOADERS_FILE}';`,
|
|
439
|
+
`import { createRouteDataRequestHandler } from ${JSON.stringify((0, external_read_template_js_namespaceObject.getTemplatePath)(WORKER_ROUTE_DATA_TEMPLATE))};`,
|
|
440
|
+
'',
|
|
441
|
+
`export const ${external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_ROUTE_DATA_HANDLER_EXPORT} =`,
|
|
442
|
+
' createRouteDataRequestHandler(routes);',
|
|
443
|
+
''
|
|
444
|
+
].join('\n');
|
|
445
|
+
const getWorkerRouteDataEntries = (appContext)=>{
|
|
446
|
+
const { entrypoints, internalDirectory } = appContext;
|
|
447
|
+
if (!entrypoints || !internalDirectory) return {};
|
|
448
|
+
return Object.fromEntries(entrypoints.flatMap(({ entryName })=>{
|
|
449
|
+
const entryDirectory = external_node_path_default().join(internalDirectory, entryName);
|
|
450
|
+
if (!external_node_fs_default().existsSync(external_node_path_default().join(entryDirectory, SERVER_LOADER_COMBINED_FILE)) || !external_node_fs_default().existsSync(external_node_path_default().join(entryDirectory, ROUTE_SERVER_LOADERS_FILE))) return [];
|
|
451
|
+
const routeDataFile = external_node_path_default().join(entryDirectory, WORKER_ROUTE_DATA_FILE);
|
|
452
|
+
external_node_fs_default().writeFileSync(routeDataFile, createWorkerRouteDataModule());
|
|
453
|
+
return [
|
|
454
|
+
[
|
|
455
|
+
(0, external_cloudflare_output_contract_js_namespaceObject.getCloudflareWorkerRouteDataEntryName)(entryName),
|
|
456
|
+
[
|
|
457
|
+
routeDataFile
|
|
458
|
+
]
|
|
459
|
+
]
|
|
460
|
+
];
|
|
461
|
+
}));
|
|
462
|
+
};
|
|
257
463
|
const getWorkerEntries = (environment, normalizedConfig, appContext)=>{
|
|
258
464
|
const configuredEntries = environment.source?.entry;
|
|
259
465
|
const effectApiEntry = getEffectBffEntry(normalizedConfig, appContext);
|
|
260
466
|
if (!configuredEntries && !effectApiEntry) return;
|
|
261
|
-
const entries = configuredEntries ?
|
|
467
|
+
const entries = configuredEntries ? {
|
|
468
|
+
...rewriteWorkerEntries(configuredEntries),
|
|
469
|
+
...getWorkerRouteDataEntries(appContext)
|
|
470
|
+
} : {};
|
|
262
471
|
return effectApiEntry ? {
|
|
263
472
|
...entries,
|
|
264
473
|
[BFF_EFFECT_WORKER_ENTRY_NAME]: [
|
|
@@ -291,6 +500,7 @@ const createCloudflareBundlerChain = (appContext, workerEntryNames)=>{
|
|
|
291
500
|
];
|
|
292
501
|
return (chain)=>{
|
|
293
502
|
applyCloudflareWorkerRspackConfig(chain, entryNames);
|
|
503
|
+
removeCloudflareWorkerDataLoaderClientTransform(chain);
|
|
294
504
|
chain.output.module(true).library({
|
|
295
505
|
type: 'module'
|
|
296
506
|
}).publicPath('/').chunkFormat('module').chunkLoading('import').workerChunkLoading('import');
|
|
@@ -299,10 +509,15 @@ const createCloudflareBundlerChain = (appContext, workerEntryNames)=>{
|
|
|
299
509
|
'worker',
|
|
300
510
|
'webpack',
|
|
301
511
|
(0, utils_namespaceObject.isProd)() ? 'production' : 'development',
|
|
302
|
-
'import',
|
|
303
|
-
'require',
|
|
304
512
|
'module'
|
|
305
513
|
])chain.resolve.conditionNames.add(condition);
|
|
514
|
+
for (const [dependencyType, condition] of WORKER_DEPENDENCY_CONDITIONS)chain.resolve.byDependency.set(dependencyType, {
|
|
515
|
+
conditionNames: [
|
|
516
|
+
condition,
|
|
517
|
+
'...'
|
|
518
|
+
]
|
|
519
|
+
});
|
|
520
|
+
chain.plugin('cloudflare-worker-absent-optional-dependencies').use(AbsentOptionalDependencyPlugin);
|
|
306
521
|
applyCloudflareWorkerMfRuntimeBoundary(chain);
|
|
307
522
|
if (tanstackRouterSsrServerFile) {
|
|
308
523
|
chain.resolve.alias.set('@tanstack/router-core/ssr/server$', tanstackRouterSsrServerFile);
|
|
@@ -388,14 +603,20 @@ const createCloudflareBuilderPlugin = (resolveDeployProvider = resolveStdEnvDepl
|
|
|
388
603
|
exports.applyCloudflareBuilderEnvironments = __webpack_exports__.applyCloudflareBuilderEnvironments;
|
|
389
604
|
exports.applyCloudflareWorkerMfRuntimeBoundary = __webpack_exports__.applyCloudflareWorkerMfRuntimeBoundary;
|
|
390
605
|
exports.applyCloudflareWorkerRspackConfig = __webpack_exports__.applyCloudflareWorkerRspackConfig;
|
|
606
|
+
exports.claimsByFunctionExternal = __webpack_exports__.claimsByFunctionExternal;
|
|
607
|
+
exports.createAbsentOptionalDependencyFilter = __webpack_exports__.createAbsentOptionalDependencyFilter;
|
|
391
608
|
exports.createCloudflareBuilderPlugin = __webpack_exports__.createCloudflareBuilderPlugin;
|
|
609
|
+
exports.createRequestRedirectMatcher = __webpack_exports__.createRequestRedirectMatcher;
|
|
392
610
|
exports.getCloudflareBuilderEnvironments = __webpack_exports__.getCloudflareBuilderEnvironments;
|
|
393
611
|
exports.getCloudflareWorkerRspackConfig = __webpack_exports__.getCloudflareWorkerRspackConfig;
|
|
394
612
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
395
613
|
"applyCloudflareBuilderEnvironments",
|
|
396
614
|
"applyCloudflareWorkerMfRuntimeBoundary",
|
|
397
615
|
"applyCloudflareWorkerRspackConfig",
|
|
616
|
+
"claimsByFunctionExternal",
|
|
617
|
+
"createAbsentOptionalDependencyFilter",
|
|
398
618
|
"createCloudflareBuilderPlugin",
|
|
619
|
+
"createRequestRedirectMatcher",
|
|
399
620
|
"getCloudflareBuilderEnvironments",
|
|
400
621
|
"getCloudflareWorkerRspackConfig"
|
|
401
622
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
@@ -39,15 +39,30 @@ const CLOUDFLARE_RUNTIME_TYPE = 'cloudflare-module-worker';
|
|
|
39
39
|
const CLOUDFLARE_OUTPUT_PACKAGE_TYPE = 'module';
|
|
40
40
|
const CLOUDFLARE_WORKER_PACKAGE_TYPE = 'commonjs';
|
|
41
41
|
const CLOUDFLARE_WORKER_BUNDLE_FORMAT = 'commonjs';
|
|
42
|
+
const CLOUDFLARE_ROUTE_DATA_HANDLER_EXPORT = 'handleRouteDataRequest';
|
|
43
|
+
const getCloudflareWorkerRouteDataEntryName = (entryName)=>`${entryName}-server-loaders`;
|
|
42
44
|
const CLOUDFLARE_WORKER_NODE_BUILTINS = [
|
|
45
|
+
'_http_agent',
|
|
46
|
+
'_http_client',
|
|
47
|
+
'_http_common',
|
|
48
|
+
'_http_incoming',
|
|
49
|
+
'_http_outgoing',
|
|
50
|
+
'_http_server',
|
|
51
|
+
'_tls_common',
|
|
52
|
+
'_tls_wrap',
|
|
43
53
|
'assert',
|
|
44
54
|
'assert/strict',
|
|
45
55
|
'async_hooks',
|
|
46
56
|
'buffer',
|
|
47
57
|
'child_process',
|
|
58
|
+
'cluster',
|
|
59
|
+
'console',
|
|
60
|
+
'constants',
|
|
48
61
|
'crypto',
|
|
49
62
|
'dgram',
|
|
63
|
+
'diagnostics_channel',
|
|
50
64
|
'dns',
|
|
65
|
+
'dns/promises',
|
|
51
66
|
'domain',
|
|
52
67
|
'events',
|
|
53
68
|
'fs',
|
|
@@ -56,11 +71,17 @@ const CLOUDFLARE_WORKER_NODE_BUILTINS = [
|
|
|
56
71
|
'http2',
|
|
57
72
|
'https',
|
|
58
73
|
'inspector',
|
|
74
|
+
'inspector/promises',
|
|
59
75
|
'module',
|
|
60
76
|
'net',
|
|
61
77
|
'os',
|
|
62
78
|
'path',
|
|
79
|
+
'path/posix',
|
|
80
|
+
'path/win32',
|
|
81
|
+
'perf_hooks',
|
|
63
82
|
'process',
|
|
83
|
+
'punycode',
|
|
84
|
+
'querystring',
|
|
64
85
|
'readline',
|
|
65
86
|
'readline/promises',
|
|
66
87
|
'repl',
|
|
@@ -70,6 +91,8 @@ const CLOUDFLARE_WORKER_NODE_BUILTINS = [
|
|
|
70
91
|
'stream/promises',
|
|
71
92
|
'stream/web',
|
|
72
93
|
'string_decoder',
|
|
94
|
+
'sys',
|
|
95
|
+
'test',
|
|
73
96
|
'timers',
|
|
74
97
|
'timers/promises',
|
|
75
98
|
'tls',
|
|
@@ -97,6 +120,7 @@ __webpack_require__.d(__webpack_exports__, {}, {
|
|
|
97
120
|
CLOUDFLARE_OUTPUT_PACKAGE_TYPE: CLOUDFLARE_OUTPUT_PACKAGE_TYPE,
|
|
98
121
|
CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY: CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY,
|
|
99
122
|
CLOUDFLARE_REQUIRED_COMPATIBILITY_FLAGS: CLOUDFLARE_REQUIRED_COMPATIBILITY_FLAGS,
|
|
123
|
+
CLOUDFLARE_ROUTE_DATA_HANDLER_EXPORT: CLOUDFLARE_ROUTE_DATA_HANDLER_EXPORT,
|
|
100
124
|
CLOUDFLARE_RUNTIME_TYPE: CLOUDFLARE_RUNTIME_TYPE,
|
|
101
125
|
CLOUDFLARE_WORKER_BUNDLE_DIRECTORY: CLOUDFLARE_WORKER_BUNDLE_DIRECTORY,
|
|
102
126
|
CLOUDFLARE_WORKER_BUNDLE_FORMAT: CLOUDFLARE_WORKER_BUNDLE_FORMAT,
|
|
@@ -106,13 +130,15 @@ __webpack_require__.d(__webpack_exports__, {}, {
|
|
|
106
130
|
CLOUDFLARE_WORKER_PACKAGE_FILE: CLOUDFLARE_WORKER_PACKAGE_FILE,
|
|
107
131
|
CLOUDFLARE_WORKER_PACKAGE_TYPE: CLOUDFLARE_WORKER_PACKAGE_TYPE,
|
|
108
132
|
CLOUDFLARE_WORKER_PLATFORM_MODULES: CLOUDFLARE_WORKER_PLATFORM_MODULES,
|
|
109
|
-
CLOUDFLARE_WRANGLER_CONFIG_FILE: CLOUDFLARE_WRANGLER_CONFIG_FILE
|
|
133
|
+
CLOUDFLARE_WRANGLER_CONFIG_FILE: CLOUDFLARE_WRANGLER_CONFIG_FILE,
|
|
134
|
+
getCloudflareWorkerRouteDataEntryName: getCloudflareWorkerRouteDataEntryName
|
|
110
135
|
});
|
|
111
136
|
exports.CLOUDFLARE_ASSETS_BINDING = __webpack_exports__.CLOUDFLARE_ASSETS_BINDING;
|
|
112
137
|
exports.CLOUDFLARE_OUTPUT_PACKAGE_FILE = __webpack_exports__.CLOUDFLARE_OUTPUT_PACKAGE_FILE;
|
|
113
138
|
exports.CLOUDFLARE_OUTPUT_PACKAGE_TYPE = __webpack_exports__.CLOUDFLARE_OUTPUT_PACKAGE_TYPE;
|
|
114
139
|
exports.CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY = __webpack_exports__.CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY;
|
|
115
140
|
exports.CLOUDFLARE_REQUIRED_COMPATIBILITY_FLAGS = __webpack_exports__.CLOUDFLARE_REQUIRED_COMPATIBILITY_FLAGS;
|
|
141
|
+
exports.CLOUDFLARE_ROUTE_DATA_HANDLER_EXPORT = __webpack_exports__.CLOUDFLARE_ROUTE_DATA_HANDLER_EXPORT;
|
|
116
142
|
exports.CLOUDFLARE_RUNTIME_TYPE = __webpack_exports__.CLOUDFLARE_RUNTIME_TYPE;
|
|
117
143
|
exports.CLOUDFLARE_WORKER_BUNDLE_DIRECTORY = __webpack_exports__.CLOUDFLARE_WORKER_BUNDLE_DIRECTORY;
|
|
118
144
|
exports.CLOUDFLARE_WORKER_BUNDLE_FORMAT = __webpack_exports__.CLOUDFLARE_WORKER_BUNDLE_FORMAT;
|
|
@@ -123,12 +149,14 @@ exports.CLOUDFLARE_WORKER_PACKAGE_FILE = __webpack_exports__.CLOUDFLARE_WORKER_P
|
|
|
123
149
|
exports.CLOUDFLARE_WORKER_PACKAGE_TYPE = __webpack_exports__.CLOUDFLARE_WORKER_PACKAGE_TYPE;
|
|
124
150
|
exports.CLOUDFLARE_WORKER_PLATFORM_MODULES = __webpack_exports__.CLOUDFLARE_WORKER_PLATFORM_MODULES;
|
|
125
151
|
exports.CLOUDFLARE_WRANGLER_CONFIG_FILE = __webpack_exports__.CLOUDFLARE_WRANGLER_CONFIG_FILE;
|
|
152
|
+
exports.getCloudflareWorkerRouteDataEntryName = __webpack_exports__.getCloudflareWorkerRouteDataEntryName;
|
|
126
153
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
127
154
|
"CLOUDFLARE_ASSETS_BINDING",
|
|
128
155
|
"CLOUDFLARE_OUTPUT_PACKAGE_FILE",
|
|
129
156
|
"CLOUDFLARE_OUTPUT_PACKAGE_TYPE",
|
|
130
157
|
"CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY",
|
|
131
158
|
"CLOUDFLARE_REQUIRED_COMPATIBILITY_FLAGS",
|
|
159
|
+
"CLOUDFLARE_ROUTE_DATA_HANDLER_EXPORT",
|
|
132
160
|
"CLOUDFLARE_RUNTIME_TYPE",
|
|
133
161
|
"CLOUDFLARE_WORKER_BUNDLE_DIRECTORY",
|
|
134
162
|
"CLOUDFLARE_WORKER_BUNDLE_FORMAT",
|
|
@@ -138,7 +166,8 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
138
166
|
"CLOUDFLARE_WORKER_PACKAGE_FILE",
|
|
139
167
|
"CLOUDFLARE_WORKER_PACKAGE_TYPE",
|
|
140
168
|
"CLOUDFLARE_WORKER_PLATFORM_MODULES",
|
|
141
|
-
"CLOUDFLARE_WRANGLER_CONFIG_FILE"
|
|
169
|
+
"CLOUDFLARE_WRANGLER_CONFIG_FILE",
|
|
170
|
+
"getCloudflareWorkerRouteDataEntryName"
|
|
142
171
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
143
172
|
Object.defineProperty(exports, '__esModule', {
|
|
144
173
|
value: true
|
|
@@ -55,7 +55,7 @@ const traverse_namespaceObject = require("@babel/traverse");
|
|
|
55
55
|
var traverse_default = /*#__PURE__*/ __webpack_require__.n(traverse_namespaceObject);
|
|
56
56
|
const external_cloudflare_output_contract_js_namespaceObject = require("../cloudflare-output-contract.js");
|
|
57
57
|
const external_issues_js_namespaceObject = require("./issues.js");
|
|
58
|
-
const getReferencedRouteWorkers = (manifest)=>Array.isArray(manifest?.routeSpec?.routes) ? manifest.routeSpec.routes.map((route)=>'string' == typeof route?.
|
|
58
|
+
const getReferencedRouteWorkers = (manifest, field)=>Array.isArray(manifest?.routeSpec?.routes) ? manifest.routeSpec.routes.map((route)=>'string' == typeof route?.[field] && route[field].length > 0 ? route[field] : void 0).filter((worker)=>'string' == typeof worker) : [];
|
|
59
59
|
const getEffectBffWorker = (manifest)=>manifest?.bff?.runtimeFramework === 'effect' && 'string' == typeof manifest.bff.worker ? manifest.bff.worker : void 0;
|
|
60
60
|
const getWorkerBundleReferences = (manifest)=>{
|
|
61
61
|
const effectBffWorker = getEffectBffWorker(manifest);
|
|
@@ -67,9 +67,14 @@ const getWorkerBundleReferences = (manifest)=>{
|
|
|
67
67
|
reference: effectBffWorker
|
|
68
68
|
}
|
|
69
69
|
] : [],
|
|
70
|
-
...getReferencedRouteWorkers(manifest).map((reference)=>({
|
|
70
|
+
...getReferencedRouteWorkers(manifest, 'worker').map((reference)=>({
|
|
71
71
|
kind: 'route',
|
|
72
72
|
reference
|
|
73
|
+
})),
|
|
74
|
+
...getReferencedRouteWorkers(manifest, 'routeDataWorker').map((reference)=>({
|
|
75
|
+
dispatcherExport: external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_ROUTE_DATA_HANDLER_EXPORT,
|
|
76
|
+
kind: 'route-data',
|
|
77
|
+
reference
|
|
73
78
|
}))
|
|
74
79
|
];
|
|
75
80
|
};
|
|
@@ -90,7 +95,7 @@ const resolveWorkerBundleReference = (issues, outputDirectory, reference, manife
|
|
|
90
95
|
path: workerPath
|
|
91
96
|
};
|
|
92
97
|
};
|
|
93
|
-
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.';
|
|
98
|
+
const missingWorkerBundleMessage = (reference)=>'effect-bff' === reference.kind ? 'Cloudflare Effect BFF manifest points to a missing worker bundle.' : 'route-data' === reference.kind ? 'Cloudflare route data worker manifest points to a missing worker bundle.' : 'Cloudflare route worker manifest points to a missing worker bundle.';
|
|
94
99
|
const isAstNode = (value)=>null !== value && 'object' == typeof value && 'type' in value && 'string' == typeof value.type;
|
|
95
100
|
const getNodeName = (node)=>{
|
|
96
101
|
if (!isAstNode(node)) return;
|
|
@@ -334,9 +339,9 @@ const verifyWorkerModuleClosure = async (issues, entryPath, entrySource, contrac
|
|
|
334
339
|
};
|
|
335
340
|
const verifyWorkerBundleReferences = async (issues, worker, source, contract)=>{
|
|
336
341
|
const entryAnalysis = await verifyWorkerModuleClosure(issues, worker.path, source, contract);
|
|
337
|
-
if ('
|
|
342
|
+
if ('string' == typeof worker.dispatcherExport && !entryAnalysis?.exports.has(worker.dispatcherExport)) (0, external_issues_js_namespaceObject.addIssue)(issues, {
|
|
338
343
|
code: 'invalid-worker-bundle',
|
|
339
|
-
message: 'Cloudflare Effect BFF worker bundle must expose its manifest dispatcherExport.',
|
|
344
|
+
message: 'route-data' === worker.kind ? `Cloudflare route data worker bundle must expose ${worker.dispatcherExport}.` : 'Cloudflare Effect BFF worker bundle must expose its manifest dispatcherExport.',
|
|
340
345
|
path: worker.path
|
|
341
346
|
});
|
|
342
347
|
};
|