wrangler 2.19.0 → 2.20.0

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 (39) hide show
  1. package/miniflare-dist/index.mjs +1 -1
  2. package/package.json +1 -1
  3. package/src/__tests__/configuration.test.ts +8 -0
  4. package/src/__tests__/pages/functions-build.test.ts +76 -0
  5. package/src/__tests__/pages-deployment-tail.test.ts +2 -0
  6. package/src/__tests__/publish.test.ts +1 -1
  7. package/src/__tests__/tail.test.ts +38 -7
  8. package/src/__tests__/tsconfig.tsbuildinfo +1 -1
  9. package/src/api/dev.ts +5 -0
  10. package/src/api/pages/create-worker-bundle-contents.ts +1 -0
  11. package/src/api/pages/publish.tsx +28 -12
  12. package/src/bundle.ts +28 -7
  13. package/src/config/environment.ts +7 -0
  14. package/src/config/validation.ts +27 -0
  15. package/src/create-worker-upload-form.ts +4 -0
  16. package/src/dev/dev.tsx +6 -1
  17. package/src/dev/local.tsx +4 -0
  18. package/src/dev/remote.tsx +3 -0
  19. package/src/dev/start-server.ts +50 -39
  20. package/src/dev/use-esbuild.ts +54 -42
  21. package/src/dev.tsx +9 -4
  22. package/src/entry.ts +8 -1
  23. package/src/init.ts +5 -0
  24. package/src/inspect.ts +107 -6
  25. package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -1
  26. package/src/pages/build.ts +30 -17
  27. package/src/pages/dev.ts +24 -6
  28. package/src/pages/functions/buildPlugin.ts +1 -0
  29. package/src/pages/functions/buildWorker.ts +59 -0
  30. package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
  31. package/src/publish/publish.ts +6 -1
  32. package/src/secret/index.ts +1 -0
  33. package/src/tail/createTail.ts +9 -0
  34. package/src/tail/printing.ts +10 -0
  35. package/src/traverse-module-graph.ts +1 -0
  36. package/src/utils/render.ts +1 -1
  37. package/src/worker.ts +5 -0
  38. package/wrangler-dist/cli.d.ts +12 -1
  39. package/wrangler-dist/cli.js +1296 -1084
package/src/api/dev.ts CHANGED
@@ -3,6 +3,7 @@ import { startApiDev, startDev } from "../dev";
3
3
  import { logger } from "../logger";
4
4
 
5
5
  import type { Environment } from "../config";
6
+ import type { Rule } from "../config/environment";
6
7
  import type { EnablePagesAssetsServiceBindingOptions } from "../miniflare-cli/types";
7
8
  import type { RequestInit, Response, RequestInfo } from "undici";
8
9
 
@@ -42,6 +43,9 @@ export interface UnstableDevOptions {
42
43
  bucket_name: string;
43
44
  preview_bucket_name?: string;
44
45
  }[];
46
+ processEntrypoint?: boolean;
47
+ moduleRoot?: string;
48
+ rules?: Rule[];
45
49
  logLevel?: "none" | "info" | "error" | "log" | "warn" | "debug"; // Specify logging level [choices: "debug", "info", "log", "warn", "error", "none"] [default: "log"]
46
50
  inspect?: boolean;
47
51
  local?: boolean;
@@ -150,6 +154,7 @@ export async function unstable_dev(
150
154
  },
151
155
  config: options?.config,
152
156
  env: options?.env,
157
+ processEntrypoint: !!options?.processEntrypoint,
153
158
  bundle: options?.bundle,
154
159
  compatibilityDate: options?.compatibilityDate,
155
160
  compatibilityFlags: options?.compatibilityFlags,
@@ -70,6 +70,7 @@ function createWorkerBundleFormData(workerBundle: BundleResult): FormData {
70
70
  usage_model: undefined,
71
71
  keepVars: undefined,
72
72
  logpush: undefined,
73
+ placement: undefined,
73
74
  };
74
75
 
75
76
  return createWorkerUploadForm(worker);
@@ -1,4 +1,4 @@
1
- import { existsSync, readFileSync } from "node:fs";
1
+ import { existsSync, lstatSync, readFileSync } from "node:fs";
2
2
  import { tmpdir } from "node:os";
3
3
  import { join, resolve as resolvePath } from "node:path";
4
4
  import { cwd } from "node:process";
@@ -14,6 +14,7 @@ import {
14
14
  import {
15
15
  buildRawWorker,
16
16
  checkRawWorker,
17
+ traverseAndBuildWorkerJSDirectory,
17
18
  } from "../../pages/functions/buildWorker";
18
19
  import { validateRoutes } from "../../pages/functions/routes-validation";
19
20
  import { upload } from "../../pages/upload";
@@ -65,7 +66,7 @@ interface PagesPublishOptions {
65
66
 
66
67
  /**
67
68
  * Whether to run bundling on `_worker.js` before deploying.
68
- * Default: false
69
+ * Default: true
69
70
  */
70
71
  bundle?: boolean;
71
72
 
@@ -95,9 +96,12 @@ export async function publish({
95
96
  _redirects: string | undefined,
96
97
  _routesGenerated: string | undefined,
97
98
  _routesCustom: string | undefined,
99
+ _workerJSIsDirectory = false,
98
100
  _workerJS: string | undefined;
99
101
 
100
- const workerScriptPath = resolvePath(directory, "_worker.js");
102
+ bundle = bundle ?? true;
103
+
104
+ const _workerPath = resolvePath(directory, "_worker.js");
101
105
 
102
106
  try {
103
107
  _headers = readFileSync(join(directory, "_headers"), "utf-8");
@@ -116,7 +120,10 @@ export async function publish({
116
120
  } catch {}
117
121
 
118
122
  try {
119
- _workerJS = readFileSync(workerScriptPath, "utf-8");
123
+ _workerJSIsDirectory = lstatSync(_workerPath).isDirectory();
124
+ if (!_workerJSIsDirectory) {
125
+ _workerJS = readFileSync(_workerPath, "utf-8");
126
+ }
120
127
  } catch {}
121
128
 
122
129
  // Grab the bindings from the API, we need these for shims and other such hacky inserts
@@ -240,16 +247,23 @@ export async function publish({
240
247
  * Advanced Mode
241
248
  * https://developers.cloudflare.com/pages/platform/functions/#advanced-mode
242
249
  *
243
- * When using a _worker.js file, the entire /functions directory is ignored
250
+ * When using a _worker.js file or _worker.js/ directory, the entire /functions directory is ignored
244
251
  * – this includes its routing and middleware characteristics.
245
252
  */
246
- if (_workerJS) {
253
+ if (_workerJSIsDirectory) {
254
+ workerBundle = await traverseAndBuildWorkerJSDirectory({
255
+ workerJSDirectory: _workerPath,
256
+ buildOutputDirectory: directory,
257
+ d1Databases,
258
+ nodejsCompat,
259
+ });
260
+ } else if (_workerJS) {
247
261
  if (bundle) {
248
262
  const outfile = join(tmpdir(), `./bundledWorker-${Math.random()}.mjs`);
249
263
  workerBundle = await buildRawWorker({
250
- workerScriptPath,
264
+ workerScriptPath: _workerPath,
251
265
  outfile,
252
- directory: directory ?? ".",
266
+ directory,
253
267
  local: false,
254
268
  sourcemap: true,
255
269
  watch: false,
@@ -258,17 +272,19 @@ export async function publish({
258
272
  nodejsCompat,
259
273
  });
260
274
  } else {
261
- await checkRawWorker(workerScriptPath, () => {});
262
- // TODO: Replace this with the cool new no-bundle stuff when that lands: https://github.com/cloudflare/workers-sdk/pull/2769
275
+ await checkRawWorker(_workerPath, () => {});
276
+ // TODO: Let users configure this in the future.
263
277
  workerBundle = {
264
278
  modules: [],
265
279
  dependencies: {},
266
280
  stop: undefined,
267
- resolvedEntryPointPath: workerScriptPath,
281
+ resolvedEntryPointPath: _workerPath,
268
282
  bundleType: "esm",
269
283
  };
270
284
  }
285
+ }
271
286
 
287
+ if (_workerJS || _workerJSIsDirectory) {
272
288
  const workerBundleContents = await createUploadWorkerBundleContents(
273
289
  workerBundle as BundleResult
274
290
  );
@@ -302,7 +318,7 @@ export async function publish({
302
318
  * Pages Functions
303
319
  * https://developers.cloudflare.com/pages/platform/functions/
304
320
  */
305
- if (builtFunctions && !_workerJS) {
321
+ if (builtFunctions && !_workerJS && !_workerJSIsDirectory) {
306
322
  const workerBundleContents = await createUploadWorkerBundleContents(
307
323
  workerBundle as BundleResult
308
324
  );
package/src/bundle.ts CHANGED
@@ -12,6 +12,7 @@ import type { Config } from "./config";
12
12
  import type { DurableObjectBindings } from "./config/environment";
13
13
  import type { WorkerRegistry } from "./dev-registry";
14
14
  import type { Entry } from "./entry";
15
+ import type { SourceMapMetadata } from "./inspect";
15
16
  import type { CfModule } from "./worker";
16
17
 
17
18
  export const COMMON_ESBUILD_OPTIONS = {
@@ -27,6 +28,7 @@ export type BundleResult = {
27
28
  bundleType: "esm" | "commonjs";
28
29
  stop: (() => void) | undefined;
29
30
  sourceMapPath?: string | undefined;
31
+ sourceMapMetadata?: SourceMapMetadata | undefined;
30
32
  };
31
33
 
32
34
  type StaticAssetsConfig =
@@ -77,15 +79,25 @@ export function isBuildFailure(err: unknown): err is esbuild.BuildFailure {
77
79
  * Rewrites esbuild BuildFailures for failing to resolve Node built-in modules
78
80
  * to suggest enabling Node compat as opposed to `platform: "node"`.
79
81
  */
80
- export function rewriteNodeCompatBuildFailure(err: esbuild.BuildFailure) {
82
+ export function rewriteNodeCompatBuildFailure(
83
+ err: esbuild.BuildFailure,
84
+ forPages = false
85
+ ) {
81
86
  for (const error of err.errors) {
82
87
  const match = nodeBuiltinResolveErrorText.exec(error.text);
83
88
  if (match !== null) {
89
+ const issue = `The package "${match[1]}" wasn't found on the file system but is built into node.`;
90
+
91
+ const instructionForUser = `${
92
+ forPages
93
+ ? 'Add the "nodejs_compat" compatibility flag to your Pages project'
94
+ : 'Add "node_compat = true" to your wrangler.toml file'
95
+ } to enable Node.js compatibility.`;
96
+
84
97
  error.notes = [
85
98
  {
86
99
  location: null,
87
- text: `The package "${match[1]}" wasn't found on the file system but is built into node.
88
- Add "node_compat = true" to your wrangler.toml file to enable Node compatibility.`,
100
+ text: `${issue}\n${instructionForUser}`,
89
101
  },
90
102
  ];
91
103
  }
@@ -117,6 +129,8 @@ export async function bundleWorker(
117
129
  entry: Entry,
118
130
  destination: string,
119
131
  options: {
132
+ // When `bundle` is set to false, we apply shims to the Worker, but won't pull in any imports
133
+ bundle?: boolean;
120
134
  serveAssetsFromWorker: boolean;
121
135
  assets?: StaticAssetsConfig;
122
136
  betaD1Shims?: string[];
@@ -146,9 +160,11 @@ export async function bundleWorker(
146
160
  // TODO: Rip these out https://github.com/cloudflare/workers-sdk/issues/2153
147
161
  disableModuleCollection?: boolean;
148
162
  isOutfile?: boolean;
163
+ forPages?: boolean;
149
164
  }
150
165
  ): Promise<BundleResult> {
151
166
  const {
167
+ bundle = true,
152
168
  serveAssetsFromWorker,
153
169
  betaD1Shims,
154
170
  doBindings,
@@ -176,6 +192,7 @@ export async function bundleWorker(
176
192
  plugins,
177
193
  disableModuleCollection,
178
194
  isOutfile,
195
+ forPages,
179
196
  } = options;
180
197
 
181
198
  // We create a temporary directory for any oneoff files we
@@ -350,7 +367,7 @@ export async function bundleWorker(
350
367
 
351
368
  const buildOptions: esbuild.BuildOptions & { metafile: true } = {
352
369
  entryPoints: [inputEntry.file],
353
- bundle: true,
370
+ bundle,
354
371
  absWorkingDir: entry.directory,
355
372
  outdir: destination,
356
373
  entryNames: entryName || path.parse(entry.file).name,
@@ -362,10 +379,10 @@ export async function bundleWorker(
362
379
  }
363
380
  : {}),
364
381
  inject,
365
- external: ["__STATIC_CONTENT_MANIFEST"],
382
+ external: bundle ? ["__STATIC_CONTENT_MANIFEST"] : undefined,
366
383
  format: entry.format === "modules" ? "esm" : "iife",
367
384
  target: COMMON_ESBUILD_OPTIONS.target,
368
- sourcemap: sourcemap ?? true, // this needs to use ?? to accept false
385
+ sourcemap: sourcemap ?? true,
369
386
  // Include a reference to the output folder in the sourcemap.
370
387
  // This is omitted by default, but we need it to properly resolve source paths in error output.
371
388
  sourceRoot: destination,
@@ -409,7 +426,7 @@ export async function bundleWorker(
409
426
  result = await esbuild.build(buildOptions);
410
427
  } catch (e) {
411
428
  if (!legacyNodeCompat && isBuildFailure(e))
412
- rewriteNodeCompatBuildFailure(e);
429
+ rewriteNodeCompatBuildFailure(e, forPages);
413
430
  throw e;
414
431
  }
415
432
 
@@ -455,6 +472,10 @@ export async function bundleWorker(
455
472
  bundleType,
456
473
  stop: result.stop,
457
474
  sourceMapPath,
475
+ sourceMapMetadata: {
476
+ tmpDir: tmpDir.path,
477
+ entryDirectory: entry.directory,
478
+ },
458
479
  };
459
480
  }
460
481
 
@@ -265,6 +265,13 @@ interface EnvironmentInheritable {
265
265
  * @inheritable
266
266
  */
267
267
  logpush: boolean | undefined;
268
+
269
+ /**
270
+ * Specify how the worker should be located to minimize round-trip time.
271
+ *
272
+ * More details: https://developers.cloudflare.com/workers/platform/smart-placement/
273
+ */
274
+ placement: { mode: "off" | "smart" } | undefined;
268
275
  }
269
276
 
270
277
  export type DurableObjectBindings = {
@@ -873,6 +873,32 @@ function validateRoutes(
873
873
  );
874
874
  }
875
875
 
876
+ function normalizeAndValidatePlacement(
877
+ diagnostics: Diagnostics,
878
+ topLevelEnv: Environment | undefined,
879
+ rawEnv: RawEnvironment
880
+ ): Config["placement"] {
881
+ if (rawEnv.placement) {
882
+ validateRequiredProperty(
883
+ diagnostics,
884
+ "placement",
885
+ "mode",
886
+ rawEnv.placement.mode,
887
+ "string",
888
+ ["off", "smart"]
889
+ );
890
+ }
891
+
892
+ return inheritable(
893
+ diagnostics,
894
+ topLevelEnv,
895
+ rawEnv,
896
+ "placement",
897
+ () => true,
898
+ undefined
899
+ );
900
+ }
901
+
876
902
  /**
877
903
  * Validate top-level environment configuration and return the normalized values.
878
904
  */
@@ -1060,6 +1086,7 @@ function normalizeAndValidateEnvironment(
1060
1086
  isOneOf("bundled", "unbound"),
1061
1087
  undefined
1062
1088
  ),
1089
+ placement: normalizeAndValidatePlacement(diagnostics, topLevelEnv, rawEnv),
1063
1090
  build,
1064
1091
  workers_dev,
1065
1092
  // Not inherited fields
@@ -4,6 +4,7 @@ import type {
4
4
  CfWorkerInit,
5
5
  CfModuleType,
6
6
  CfDurableObjectMigrations,
7
+ CfPlacement,
7
8
  } from "./worker.js";
8
9
 
9
10
  export function toMimeType(type: CfModuleType): string {
@@ -71,6 +72,7 @@ export interface WorkerMetadata {
71
72
  bindings: WorkerMetadataBinding[];
72
73
  keep_bindings?: WorkerMetadataBinding["type"][];
73
74
  logpush?: boolean;
75
+ placement?: CfPlacement;
74
76
  // Allow unsafe.metadata to add arbitary properties at runtime
75
77
  [key: string]: unknown;
76
78
  }
@@ -89,6 +91,7 @@ export function createWorkerUploadForm(worker: CfWorkerInit): FormData {
89
91
  compatibility_flags,
90
92
  keepVars,
91
93
  logpush,
94
+ placement,
92
95
  } = worker;
93
96
 
94
97
  let { modules } = worker;
@@ -320,6 +323,7 @@ export function createWorkerUploadForm(worker: CfWorkerInit): FormData {
320
323
  capnp_schema: bindings.logfwdr?.schema,
321
324
  ...(keepVars && { keep_bindings: ["plain_text", "json"] }),
322
325
  ...(logpush !== undefined && { logpush }),
326
+ ...(placement && { placement }),
323
327
  };
324
328
 
325
329
  if (bindings.unsafe?.metadata !== undefined) {
package/src/dev/dev.tsx CHANGED
@@ -116,6 +116,7 @@ export type DevProps = {
116
116
  initialPort: number;
117
117
  initialIp: string;
118
118
  inspectorPort: number;
119
+ processEntrypoint: boolean;
119
120
  rules: Config["rules"];
120
121
  accountId: string | undefined;
121
122
  initialMode: "local" | "remote";
@@ -187,6 +188,7 @@ function InteractiveDevSession(props: DevProps) {
187
188
  inspect: props.inspect,
188
189
  localProtocol: props.localProtocol,
189
190
  forceLocal: props.forceLocal,
191
+ worker: props.name,
190
192
  });
191
193
 
192
194
  ip = props.initialIp;
@@ -271,6 +273,7 @@ function DevSession(props: DevSessionProps) {
271
273
  entry: props.entry,
272
274
  destination: directory,
273
275
  jsxFactory: props.jsxFactory,
276
+ processEntrypoint: props.processEntrypoint,
274
277
  rules: props.rules,
275
278
  jsxFragment: props.jsxFragment,
276
279
  serveAssetsFromWorker: Boolean(
@@ -348,6 +351,7 @@ function DevSession(props: DevSessionProps) {
348
351
  experimentalLocal={props.experimentalLocal}
349
352
  accountId={props.accountId}
350
353
  experimentalLocalRemoteKv={props.experimentalLocalRemoteKv}
354
+ sourceMapPath={bundle?.sourceMapPath}
351
355
  />
352
356
  ) : (
353
357
  <Remote
@@ -526,6 +530,7 @@ function useHotkeys(props: {
526
530
  inspect: boolean;
527
531
  localProtocol: "http" | "https";
528
532
  forceLocal: boolean | undefined;
533
+ worker: string | undefined;
529
534
  }) {
530
535
  const { initial, inspectorPort, inspect, localProtocol, forceLocal } = props;
531
536
  // UGH, we should put port in context instead
@@ -558,7 +563,7 @@ function useHotkeys(props: {
558
563
  // toggle inspector
559
564
  case "d": {
560
565
  if (inspect) {
561
- await openInspector(inspectorPort);
566
+ await openInspector(inspectorPort, props.worker);
562
567
  }
563
568
  break;
564
569
  }
package/src/dev/local.tsx CHANGED
@@ -75,6 +75,7 @@ export interface LocalProps {
75
75
  experimentalLocal: boolean | undefined;
76
76
  accountId: string | undefined; // Account ID? In local mode??? :exploding_head:
77
77
  experimentalLocalRemoteKv: boolean | undefined;
78
+ sourceMapPath: string | undefined;
78
79
  }
79
80
 
80
81
  type InspectorJSON = {
@@ -95,6 +96,9 @@ export function Local(props: LocalProps) {
95
96
  inspectorUrl,
96
97
  port: props.inspectorPort,
97
98
  logToTerminal: props.experimentalLocal ?? false,
99
+ sourceMapPath: props.sourceMapPath,
100
+ name: props.name,
101
+ sourceMapMetadata: props.bundle?.sourceMapMetadata,
98
102
  });
99
103
  return null;
100
104
  }
@@ -107,6 +107,8 @@ export function Remote(props: RemoteProps) {
107
107
  logToTerminal: true,
108
108
  sourceMapPath: props.sourceMapPath,
109
109
  host: previewToken?.host,
110
+ name: props.name,
111
+ sourceMapMetadata: props.bundle?.sourceMapMetadata,
110
112
  });
111
113
 
112
114
  const errorHandler = useErrorHandler();
@@ -574,6 +576,7 @@ async function createRemoteWorkerInit(props: {
574
576
  usage_model: props.usageModel,
575
577
  keepVars: true,
576
578
  logpush: false,
579
+ placement: undefined, // no placement in dev
577
580
  };
578
581
 
579
582
  return init;
@@ -92,6 +92,7 @@ export async function startDevServer(
92
92
  entry: props.entry,
93
93
  destination: directory.name,
94
94
  jsxFactory: props.jsxFactory,
95
+ processEntrypoint: props.processEntrypoint,
95
96
  rules: props.rules,
96
97
  jsxFragment: props.jsxFragment,
97
98
  serveAssetsFromWorker: Boolean(
@@ -141,6 +142,7 @@ export async function startDevServer(
141
142
  experimentalLocal: props.experimentalLocal,
142
143
  accountId: props.accountId,
143
144
  experimentalLocalRemoteKv: props.experimentalLocalRemoteKv,
145
+ sourceMapPath: bundle?.sourceMapPath,
144
146
  });
145
147
 
146
148
  return {
@@ -205,6 +207,7 @@ async function runEsbuild({
205
207
  destination,
206
208
  jsxFactory,
207
209
  jsxFragment,
210
+ processEntrypoint,
208
211
  rules,
209
212
  assets,
210
213
  betaD1Shims,
@@ -227,6 +230,7 @@ async function runEsbuild({
227
230
  destination: string | undefined;
228
231
  jsxFactory: string | undefined;
229
232
  jsxFragment: string | undefined;
233
+ processEntrypoint: boolean;
230
234
  rules: Config["rules"];
231
235
  assets: Config["assets"];
232
236
  betaD1Shims?: string[];
@@ -247,49 +251,56 @@ async function runEsbuild({
247
251
  }): Promise<EsbuildBundle | undefined> {
248
252
  if (!destination) return;
249
253
 
250
- const {
251
- resolvedEntryPointPath,
252
- bundleType,
253
- modules,
254
- dependencies,
255
- sourceMapPath,
256
- }: Awaited<ReturnType<typeof bundleWorker>> = noBundle
257
- ? await traverseModuleGraph(entry, rules)
258
- : await bundleWorker(entry, destination, {
259
- serveAssetsFromWorker,
260
- jsxFactory,
261
- jsxFragment,
262
- rules,
263
- tsconfig,
264
- minify,
265
- legacyNodeCompat,
266
- nodejsCompat,
267
- define,
268
- checkFetch: true,
269
- assets: assets && {
270
- ...assets,
271
- // disable the cache in dev
272
- bypassCache: true,
273
- },
274
- betaD1Shims,
275
- workerDefinitions,
276
- services,
277
- firstPartyWorkerDevFacade,
278
- targetConsumer: "dev", // We are starting a dev server
279
- testScheduled,
280
- local,
281
- experimentalLocal,
282
- doBindings,
283
- });
254
+ let traverseModuleGraphResult:
255
+ | Awaited<ReturnType<typeof bundleWorker>>
256
+ | undefined;
257
+ let bundleResult: Awaited<ReturnType<typeof bundleWorker>> | undefined;
258
+ if (noBundle) {
259
+ traverseModuleGraphResult = await traverseModuleGraph(entry, rules);
260
+ }
261
+
262
+ if (processEntrypoint || !noBundle) {
263
+ bundleResult = await bundleWorker(entry, destination, {
264
+ bundle: !noBundle,
265
+ disableModuleCollection: noBundle,
266
+ serveAssetsFromWorker,
267
+ jsxFactory,
268
+ jsxFragment,
269
+ rules,
270
+ tsconfig,
271
+ minify,
272
+ legacyNodeCompat,
273
+ nodejsCompat,
274
+ define,
275
+ checkFetch: true,
276
+ assets: assets && {
277
+ ...assets,
278
+ // disable the cache in dev
279
+ bypassCache: true,
280
+ },
281
+ betaD1Shims,
282
+ workerDefinitions,
283
+ services,
284
+ firstPartyWorkerDevFacade,
285
+ targetConsumer: "dev", // We are starting a dev server
286
+ testScheduled,
287
+ local,
288
+ experimentalLocal,
289
+ doBindings,
290
+ });
291
+ }
284
292
 
285
293
  return {
286
294
  id: 0,
287
295
  entry,
288
- path: resolvedEntryPointPath,
289
- type: bundleType,
290
- modules,
291
- dependencies,
292
- sourceMapPath,
296
+ path: bundleResult?.resolvedEntryPointPath ?? entry.file,
297
+ type:
298
+ bundleResult?.bundleType ??
299
+ (entry.format === "modules" ? "esm" : "commonjs"),
300
+ modules: traverseModuleGraphResult?.modules ?? bundleResult?.modules ?? [],
301
+ dependencies: bundleResult?.dependencies ?? {},
302
+ sourceMapPath: bundleResult?.sourceMapPath,
303
+ sourceMapMetadata: bundleResult?.sourceMapMetadata,
293
304
  };
294
305
  }
295
306