{"record":{"id":"5e17e02189da859f","repo":"angular/angular-cli","slug":"prebundling-has-been-configured-but-will-not-be-us-5e17e0","errorCode":null,"errorMessage":"Prebundling has been configured but will not be used because scripts optimization is enabled.","messagePattern":"Prebundling has been configured but will not be used because scripts optimization is enabled\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/angular_devkit/build_angular/src/builders/dev-server/options.ts","lineNumber":74,"sourceCode":"  const buildTargetSpecifier = options.buildTarget ?? `::development`;\n  const buildTarget = targetFromTargetString(buildTargetSpecifier, projectName, 'build');\n\n  // Get the application builder options.\n  const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);\n  const rawBuildOptions = await context.getTargetOptions(buildTarget);\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  const buildOptions = (await context.validateOptions(rawBuildOptions, browserBuilderName)) as any;\n  const optimization = normalizeOptimization(buildOptions.optimization);\n\n  if (options.prebundle !== false && isEsbuildBased(browserBuilderName)) {\n    if (!cacheOptions.enabled) {\n      // Warn if the initial options provided by the user enable prebundling but caching is disabled\n      logger.warn(\n        'Prebundling has been configured but will not be used because caching has been disabled.',\n      );\n    } else if (optimization.scripts) {\n      // Warn if the initial options provided by the user enable prebundling but script optimization is enabled.\n      logger.warn(\n        'Prebundling has been configured but will not be used because scripts optimization is enabled.',\n      );\n    }\n  }\n\n  let inspect: false | { host?: string; port?: number } = false;\n  const inspectRaw = options.inspect;\n  if (inspectRaw === true || inspectRaw === '' || inspectRaw === 'true') {\n    inspect = {\n      host: undefined,\n      port: undefined,\n    };\n  } else if (typeof inspectRaw === 'string' && inspectRaw !== 'false') {\n    const port = +inspectRaw;\n    if (isFinite(port)) {\n      inspect = {\n        host: undefined,\n        port,","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/build_angular/src/builders/dev-server/options.ts#L56-L92","documentation":"This warning is emitted when the dev-server's prebundling is enabled but the build has script optimization turned on. Prebundled development dependencies are not compatible with optimizing scripts, so prebundling is skipped and the user is told why. Raised in `normalizeOptions` for esbuild-based builders when `optimization.scripts` is true.","triggerScenarios":"`ng serve` with esbuild-based builder where optimization resolves to scripts=true — e.g. `--optimization` on the serve command, `\"optimization\": true` or `\"optimization\": {\"scripts\": true}` in the serve/browser target options, or serve target using a production-like configuration.","commonSituations":"Serving with a production configuration (`ng serve -c production`) or passing `--optimization` to test prod behavior locally; teams that set optimization globally and are surprised the dev-server is slower.","solutions":["Remove `--optimization` / the optimization setting from the serve options so scripts stay unoptimized in dev","Explicitly set `\"prebundle\": false` in serve options if you need optimization and want to silence the warning","Use a dedicated development configuration without optimization instead of the production configuration","Accept the warning; it only affects dev-server cold-start speed"],"exampleFix":"// before\nng serve --configuration production\n// after\nng serve\n# or keep optimization but disable prebundling:\nng serve --optimization --no-prebundle","handlingStrategy":"validation","validationCode":"// detect optimization on serve options before running\nconst opts = targetOptions; // resolved serve options\nif (opts.optimization === true || (typeof opts.optimization === 'object' && opts.optimization?.scripts)) {\n  console.warn('Scripts optimization enabled: prebundling will be disabled for this serve.');\n}","typeGuard":"function isScriptsOptimized(optimization: boolean | { scripts?: boolean } | undefined): boolean {\n  return optimization === true || (typeof optimization === 'object' && optimization?.scripts === true);\n}","tryCatchPattern":null,"preventionTips":["Do not serve with the production configuration; use ng build for prod-like checks","Keep optimization out of dev-server target options","Use a dedicated serve configuration for opt-in optimization experiments","Add --no-prebundle intentionally when optimization is required"],"tags":["prebundling","optimization","dev-server","configuration"],"backgroundTag":"prebundling-scripts-optimization-conflict","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}