@bleedingdev/modern-js-app-tools 3.2.0-ultramodern.30 → 3.2.0-ultramodern.31

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.
@@ -180,9 +180,6 @@ function getBuilderEnvironments(normalizedConfig, appContext, tempBuilderConfig)
180
180
  outputModule: true
181
181
  }
182
182
  });
183
- chain.externalsPresets({
184
- node: true
185
- });
186
183
  chain.target('webworker');
187
184
  chain.plugins.delete('plugin-module-federation');
188
185
  if (tanstackRouterSsrServerFile) {
@@ -76,9 +76,7 @@ const createWorkerManifest = async (outputDirectory, modernConfig)=>{
76
76
  entryPath: route.entryPath,
77
77
  isSSR: Boolean(route.isSSR),
78
78
  worker,
79
- bundle: 'string' == typeof route.bundle ? route.bundle : void 0,
80
- workerExists: worker ? await utils_namespaceObject.fs.pathExists(external_node_path_default().join(outputDirectory, worker)) : false,
81
- bundleExists: 'string' == typeof route.bundle ? await utils_namespaceObject.fs.pathExists(external_node_path_default().join(outputDirectory, route.bundle)) : false
79
+ workerExists: worker ? await utils_namespaceObject.fs.pathExists(external_node_path_default().join(outputDirectory, worker)) : false
82
80
  };
83
81
  }));
84
82
  const bffPrefix = modernConfig.bff?.prefix;
@@ -120,15 +118,9 @@ const createWorkerManifest = async (outputDirectory, modernConfig)=>{
120
118
  };
121
119
  const createWorkerModuleLoaders = (manifest)=>{
122
120
  const imports = new Map();
123
- for (const route of manifest.routeSpec.routes){
124
- if (route.worker && route.workerExists) {
125
- const importPath = `../${String(route.worker).replace(/^\/+/u, '')}`;
126
- imports.set(route.worker, `() => import(${JSON.stringify(importPath)})`);
127
- }
128
- if (route.bundle && route.bundleExists) {
129
- const importPath = `../${String(route.bundle).replace(/^\/+/u, '')}`;
130
- imports.set(route.bundle, `() => import(${JSON.stringify(importPath)})`);
131
- }
121
+ for (const route of manifest.routeSpec.routes)if (route.worker && route.workerExists) {
122
+ const importPath = `../${String(route.worker).replace(/^\/+/u, '')}`;
123
+ imports.set(route.worker, `() => import(${JSON.stringify(importPath)})`);
132
124
  }
133
125
  if (manifest.bff?.worker) {
134
126
  const importPath = `../${String(manifest.bff.worker).replace(/^\/+/u, '')}`;
@@ -183,13 +175,6 @@ const createCloudflarePreset = ({ appContext, modernConfig })=>{
183
175
  if (await utils_namespaceObject.fs.pathExists(workerBundleSourceDirectory)) await utils_namespaceObject.fs.copy(workerBundleSourceDirectory, external_node_path_default().join(outputDirectory, WORKER_BUNDLE_DIRECTORY), {
184
176
  filter: (src)=>shouldCopyToWorkerBundle(src, workerBundleSourceDirectory)
185
177
  });
186
- const serverBundleSourceDirectory = external_node_path_default().join(distDirectory, SERVER_BUNDLE_DIRECTORY);
187
- if (await utils_namespaceObject.fs.pathExists(serverBundleSourceDirectory)) {
188
- await utils_namespaceObject.fs.copy(serverBundleSourceDirectory, external_node_path_default().join(outputDirectory, SERVER_BUNDLE_DIRECTORY));
189
- await utils_namespaceObject.fs.writeJSON(external_node_path_default().join(outputDirectory, SERVER_BUNDLE_DIRECTORY, 'package.json'), {
190
- type: 'commonjs'
191
- });
192
- }
193
178
  await utils_namespaceObject.fs.writeJSON(wranglerConfigPath, {
194
179
  $schema: 'node_modules/wrangler/config-schema.json',
195
180
  name: getWorkerName(appDirectory),
@@ -129,42 +129,35 @@ async function getRequestHandler(workerModule) {
129
129
  return await workerModule.requestHandler || await defaultRequestHandler || ('function' == typeof defaultExport ? defaultExport : void 0);
130
130
  }
131
131
  async function dispatchRouteWorker(route, request, env, ctx) {
132
- const candidatePaths = [
133
- route.worker,
134
- route.bundle
135
- ].filter(Boolean);
136
- let missingPath;
137
- for (const candidatePath of candidatePaths){
138
- const workerModule = await loadWorkerModule(candidatePath);
139
- if (!workerModule) {
140
- missingPath = candidatePath;
141
- continue;
142
- }
143
- const fetchHandler = getFetchHandler(workerModule);
144
- if (fetchHandler) return fetchHandler(request, env, ctx);
145
- const requestHandler = await getRequestHandler(workerModule);
146
- if ('function' == typeof requestHandler) {
147
- const requestHandlerOptions = await getRequestHandlerOptions(route, request, env);
148
- return requestHandler(request, requestHandlerOptions);
132
+ const workerPath = route.worker;
133
+ if (!workerPath) return new Response('Worker bundle not configured for SSR route', {
134
+ status: 500,
135
+ headers: {
136
+ 'content-type': 'text/plain; charset=utf-8'
149
137
  }
150
- }
151
- if (missingPath) return new Response(`Worker bundle not found: ${missingPath}`, {
138
+ });
139
+ const workerModule = await loadWorkerModule(workerPath);
140
+ if (!workerModule) return new Response(`Worker bundle not found: ${workerPath}`, {
152
141
  status: 500,
153
142
  headers: {
154
143
  'content-type': 'text/plain; charset=utf-8',
155
- 'x-modern-js-route-worker': missingPath
144
+ 'x-modern-js-route-worker': workerPath
156
145
  }
157
146
  });
158
- if (candidatePaths.length > 0) return new Response(`Worker bundle has no fetch or requestHandler export: ${candidatePaths.join(', ')}`, {
147
+ const fetchHandler = getFetchHandler(workerModule);
148
+ if (fetchHandler) return fetchHandler(request, env, ctx);
149
+ const requestHandler = await getRequestHandler(workerModule);
150
+ if ('function' == typeof requestHandler) {
151
+ const requestHandlerOptions = await getRequestHandlerOptions(route, request, env);
152
+ return requestHandler(request, requestHandlerOptions);
153
+ }
154
+ return new Response(`Worker bundle has no fetch or requestHandler export: ${workerPath}`, {
159
155
  status: 500,
160
156
  headers: {
161
157
  'content-type': 'text/plain; charset=utf-8',
162
- 'x-modern-js-route-worker': candidatePaths.join(', ')
158
+ 'x-modern-js-route-worker': workerPath
163
159
  }
164
160
  });
165
- return new Response('Route has no worker bundle', {
166
- status: 500
167
- });
168
161
  }
169
162
  function matchesPrefix(pathname, prefix) {
170
163
  if (!prefix || '/' === prefix) return true;
@@ -141,9 +141,6 @@ function getBuilderEnvironments(normalizedConfig, appContext, tempBuilderConfig)
141
141
  outputModule: true
142
142
  }
143
143
  });
144
- chain.externalsPresets({
145
- node: true
146
- });
147
144
  chain.target('webworker');
148
145
  chain.plugins.delete('plugin-module-federation');
149
146
  if (tanstackRouterSsrServerFile) {
@@ -38,9 +38,7 @@ const createWorkerManifest = async (outputDirectory, modernConfig)=>{
38
38
  entryPath: route.entryPath,
39
39
  isSSR: Boolean(route.isSSR),
40
40
  worker,
41
- bundle: 'string' == typeof route.bundle ? route.bundle : void 0,
42
- workerExists: worker ? await fs.pathExists(node_path.join(outputDirectory, worker)) : false,
43
- bundleExists: 'string' == typeof route.bundle ? await fs.pathExists(node_path.join(outputDirectory, route.bundle)) : false
41
+ workerExists: worker ? await fs.pathExists(node_path.join(outputDirectory, worker)) : false
44
42
  };
45
43
  }));
46
44
  const bffPrefix = modernConfig.bff?.prefix;
@@ -82,15 +80,9 @@ const createWorkerManifest = async (outputDirectory, modernConfig)=>{
82
80
  };
83
81
  const createWorkerModuleLoaders = (manifest)=>{
84
82
  const imports = new Map();
85
- for (const route of manifest.routeSpec.routes){
86
- if (route.worker && route.workerExists) {
87
- const importPath = `../${String(route.worker).replace(/^\/+/u, '')}`;
88
- imports.set(route.worker, `() => import(${JSON.stringify(importPath)})`);
89
- }
90
- if (route.bundle && route.bundleExists) {
91
- const importPath = `../${String(route.bundle).replace(/^\/+/u, '')}`;
92
- imports.set(route.bundle, `() => import(${JSON.stringify(importPath)})`);
93
- }
83
+ for (const route of manifest.routeSpec.routes)if (route.worker && route.workerExists) {
84
+ const importPath = `../${String(route.worker).replace(/^\/+/u, '')}`;
85
+ imports.set(route.worker, `() => import(${JSON.stringify(importPath)})`);
94
86
  }
95
87
  if (manifest.bff?.worker) {
96
88
  const importPath = `../${String(manifest.bff.worker).replace(/^\/+/u, '')}`;
@@ -145,13 +137,6 @@ const createCloudflarePreset = ({ appContext, modernConfig })=>{
145
137
  if (await fs.pathExists(workerBundleSourceDirectory)) await fs.copy(workerBundleSourceDirectory, node_path.join(outputDirectory, WORKER_BUNDLE_DIRECTORY), {
146
138
  filter: (src)=>shouldCopyToWorkerBundle(src, workerBundleSourceDirectory)
147
139
  });
148
- const serverBundleSourceDirectory = node_path.join(distDirectory, SERVER_BUNDLE_DIRECTORY);
149
- if (await fs.pathExists(serverBundleSourceDirectory)) {
150
- await fs.copy(serverBundleSourceDirectory, node_path.join(outputDirectory, SERVER_BUNDLE_DIRECTORY));
151
- await fs.writeJSON(node_path.join(outputDirectory, SERVER_BUNDLE_DIRECTORY, 'package.json'), {
152
- type: 'commonjs'
153
- });
154
- }
155
140
  await fs.writeJSON(wranglerConfigPath, {
156
141
  $schema: 'node_modules/wrangler/config-schema.json',
157
142
  name: getWorkerName(appDirectory),
@@ -129,42 +129,35 @@ async function getRequestHandler(workerModule) {
129
129
  return await workerModule.requestHandler || await defaultRequestHandler || ('function' == typeof defaultExport ? defaultExport : void 0);
130
130
  }
131
131
  async function dispatchRouteWorker(route, request, env, ctx) {
132
- const candidatePaths = [
133
- route.worker,
134
- route.bundle
135
- ].filter(Boolean);
136
- let missingPath;
137
- for (const candidatePath of candidatePaths){
138
- const workerModule = await loadWorkerModule(candidatePath);
139
- if (!workerModule) {
140
- missingPath = candidatePath;
141
- continue;
142
- }
143
- const fetchHandler = getFetchHandler(workerModule);
144
- if (fetchHandler) return fetchHandler(request, env, ctx);
145
- const requestHandler = await getRequestHandler(workerModule);
146
- if ('function' == typeof requestHandler) {
147
- const requestHandlerOptions = await getRequestHandlerOptions(route, request, env);
148
- return requestHandler(request, requestHandlerOptions);
132
+ const workerPath = route.worker;
133
+ if (!workerPath) return new Response('Worker bundle not configured for SSR route', {
134
+ status: 500,
135
+ headers: {
136
+ 'content-type': 'text/plain; charset=utf-8'
149
137
  }
150
- }
151
- if (missingPath) return new Response(`Worker bundle not found: ${missingPath}`, {
138
+ });
139
+ const workerModule = await loadWorkerModule(workerPath);
140
+ if (!workerModule) return new Response(`Worker bundle not found: ${workerPath}`, {
152
141
  status: 500,
153
142
  headers: {
154
143
  'content-type': 'text/plain; charset=utf-8',
155
- 'x-modern-js-route-worker': missingPath
144
+ 'x-modern-js-route-worker': workerPath
156
145
  }
157
146
  });
158
- if (candidatePaths.length > 0) return new Response(`Worker bundle has no fetch or requestHandler export: ${candidatePaths.join(', ')}`, {
147
+ const fetchHandler = getFetchHandler(workerModule);
148
+ if (fetchHandler) return fetchHandler(request, env, ctx);
149
+ const requestHandler = await getRequestHandler(workerModule);
150
+ if ('function' == typeof requestHandler) {
151
+ const requestHandlerOptions = await getRequestHandlerOptions(route, request, env);
152
+ return requestHandler(request, requestHandlerOptions);
153
+ }
154
+ return new Response(`Worker bundle has no fetch or requestHandler export: ${workerPath}`, {
159
155
  status: 500,
160
156
  headers: {
161
157
  'content-type': 'text/plain; charset=utf-8',
162
- 'x-modern-js-route-worker': candidatePaths.join(', ')
158
+ 'x-modern-js-route-worker': workerPath
163
159
  }
164
160
  });
165
- return new Response('Route has no worker bundle', {
166
- status: 500
167
- });
168
161
  }
169
162
  function matchesPrefix(pathname, prefix) {
170
163
  if (!prefix || '/' === prefix) return true;
@@ -143,9 +143,6 @@ function getBuilderEnvironments(normalizedConfig, appContext, tempBuilderConfig)
143
143
  outputModule: true
144
144
  }
145
145
  });
146
- chain.externalsPresets({
147
- node: true
148
- });
149
146
  chain.target('webworker');
150
147
  chain.plugins.delete('plugin-module-federation');
151
148
  if (tanstackRouterSsrServerFile) {
@@ -39,9 +39,7 @@ const createWorkerManifest = async (outputDirectory, modernConfig)=>{
39
39
  entryPath: route.entryPath,
40
40
  isSSR: Boolean(route.isSSR),
41
41
  worker,
42
- bundle: 'string' == typeof route.bundle ? route.bundle : void 0,
43
- workerExists: worker ? await fs.pathExists(node_path.join(outputDirectory, worker)) : false,
44
- bundleExists: 'string' == typeof route.bundle ? await fs.pathExists(node_path.join(outputDirectory, route.bundle)) : false
42
+ workerExists: worker ? await fs.pathExists(node_path.join(outputDirectory, worker)) : false
45
43
  };
46
44
  }));
47
45
  const bffPrefix = modernConfig.bff?.prefix;
@@ -83,15 +81,9 @@ const createWorkerManifest = async (outputDirectory, modernConfig)=>{
83
81
  };
84
82
  const createWorkerModuleLoaders = (manifest)=>{
85
83
  const imports = new Map();
86
- for (const route of manifest.routeSpec.routes){
87
- if (route.worker && route.workerExists) {
88
- const importPath = `../${String(route.worker).replace(/^\/+/u, '')}`;
89
- imports.set(route.worker, `() => import(${JSON.stringify(importPath)})`);
90
- }
91
- if (route.bundle && route.bundleExists) {
92
- const importPath = `../${String(route.bundle).replace(/^\/+/u, '')}`;
93
- imports.set(route.bundle, `() => import(${JSON.stringify(importPath)})`);
94
- }
84
+ for (const route of manifest.routeSpec.routes)if (route.worker && route.workerExists) {
85
+ const importPath = `../${String(route.worker).replace(/^\/+/u, '')}`;
86
+ imports.set(route.worker, `() => import(${JSON.stringify(importPath)})`);
95
87
  }
96
88
  if (manifest.bff?.worker) {
97
89
  const importPath = `../${String(manifest.bff.worker).replace(/^\/+/u, '')}`;
@@ -146,13 +138,6 @@ const createCloudflarePreset = ({ appContext, modernConfig })=>{
146
138
  if (await fs.pathExists(workerBundleSourceDirectory)) await fs.copy(workerBundleSourceDirectory, node_path.join(outputDirectory, WORKER_BUNDLE_DIRECTORY), {
147
139
  filter: (src)=>shouldCopyToWorkerBundle(src, workerBundleSourceDirectory)
148
140
  });
149
- const serverBundleSourceDirectory = node_path.join(distDirectory, SERVER_BUNDLE_DIRECTORY);
150
- if (await fs.pathExists(serverBundleSourceDirectory)) {
151
- await fs.copy(serverBundleSourceDirectory, node_path.join(outputDirectory, SERVER_BUNDLE_DIRECTORY));
152
- await fs.writeJSON(node_path.join(outputDirectory, SERVER_BUNDLE_DIRECTORY, 'package.json'), {
153
- type: 'commonjs'
154
- });
155
- }
156
141
  await fs.writeJSON(wranglerConfigPath, {
157
142
  $schema: 'node_modules/wrangler/config-schema.json',
158
143
  name: getWorkerName(appDirectory),
@@ -129,42 +129,35 @@ async function getRequestHandler(workerModule) {
129
129
  return await workerModule.requestHandler || await defaultRequestHandler || ('function' == typeof defaultExport ? defaultExport : void 0);
130
130
  }
131
131
  async function dispatchRouteWorker(route, request, env, ctx) {
132
- const candidatePaths = [
133
- route.worker,
134
- route.bundle
135
- ].filter(Boolean);
136
- let missingPath;
137
- for (const candidatePath of candidatePaths){
138
- const workerModule = await loadWorkerModule(candidatePath);
139
- if (!workerModule) {
140
- missingPath = candidatePath;
141
- continue;
142
- }
143
- const fetchHandler = getFetchHandler(workerModule);
144
- if (fetchHandler) return fetchHandler(request, env, ctx);
145
- const requestHandler = await getRequestHandler(workerModule);
146
- if ('function' == typeof requestHandler) {
147
- const requestHandlerOptions = await getRequestHandlerOptions(route, request, env);
148
- return requestHandler(request, requestHandlerOptions);
132
+ const workerPath = route.worker;
133
+ if (!workerPath) return new Response('Worker bundle not configured for SSR route', {
134
+ status: 500,
135
+ headers: {
136
+ 'content-type': 'text/plain; charset=utf-8'
149
137
  }
150
- }
151
- if (missingPath) return new Response(`Worker bundle not found: ${missingPath}`, {
138
+ });
139
+ const workerModule = await loadWorkerModule(workerPath);
140
+ if (!workerModule) return new Response(`Worker bundle not found: ${workerPath}`, {
152
141
  status: 500,
153
142
  headers: {
154
143
  'content-type': 'text/plain; charset=utf-8',
155
- 'x-modern-js-route-worker': missingPath
144
+ 'x-modern-js-route-worker': workerPath
156
145
  }
157
146
  });
158
- if (candidatePaths.length > 0) return new Response(`Worker bundle has no fetch or requestHandler export: ${candidatePaths.join(', ')}`, {
147
+ const fetchHandler = getFetchHandler(workerModule);
148
+ if (fetchHandler) return fetchHandler(request, env, ctx);
149
+ const requestHandler = await getRequestHandler(workerModule);
150
+ if ('function' == typeof requestHandler) {
151
+ const requestHandlerOptions = await getRequestHandlerOptions(route, request, env);
152
+ return requestHandler(request, requestHandlerOptions);
153
+ }
154
+ return new Response(`Worker bundle has no fetch or requestHandler export: ${workerPath}`, {
159
155
  status: 500,
160
156
  headers: {
161
157
  'content-type': 'text/plain; charset=utf-8',
162
- 'x-modern-js-route-worker': candidatePaths.join(', ')
158
+ 'x-modern-js-route-worker': workerPath
163
159
  }
164
160
  });
165
- return new Response('Route has no worker bundle', {
166
- status: 500
167
- });
168
161
  }
169
162
  function matchesPrefix(pathname, prefix) {
170
163
  if (!prefix || '/' === prefix) return true;
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "modern",
18
18
  "modern.js"
19
19
  ],
20
- "version": "3.2.0-ultramodern.30",
20
+ "version": "3.2.0-ultramodern.31",
21
21
  "types": "./dist/types/index.d.ts",
22
22
  "main": "./dist/cjs/index.js",
23
23
  "exports": {
@@ -98,16 +98,16 @@
98
98
  "ndepe": "^0.1.13",
99
99
  "pkg-types": "^2.3.1",
100
100
  "std-env": "4.1.0",
101
- "@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.2.0-ultramodern.30",
102
- "@modern-js/i18n-utils": "npm:@bleedingdev/modern-js-i18n-utils@3.2.0-ultramodern.30",
103
- "@modern-js/prod-server": "npm:@bleedingdev/modern-js-prod-server@3.2.0-ultramodern.30",
104
- "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.2.0-ultramodern.30",
105
- "@modern-js/server": "npm:@bleedingdev/modern-js-server@3.2.0-ultramodern.30",
106
- "@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.2.0-ultramodern.30",
107
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.30",
108
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.30",
109
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.30",
110
- "@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.2.0-ultramodern.30"
101
+ "@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.2.0-ultramodern.31",
102
+ "@modern-js/i18n-utils": "npm:@bleedingdev/modern-js-i18n-utils@3.2.0-ultramodern.31",
103
+ "@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.2.0-ultramodern.31",
104
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.31",
105
+ "@modern-js/server": "npm:@bleedingdev/modern-js-server@3.2.0-ultramodern.31",
106
+ "@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.2.0-ultramodern.31",
107
+ "@modern-js/prod-server": "npm:@bleedingdev/modern-js-prod-server@3.2.0-ultramodern.31",
108
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.31",
109
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.31",
110
+ "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.2.0-ultramodern.31"
111
111
  },
112
112
  "devDependencies": {
113
113
  "@rslib/core": "0.21.5",