angular/angular-cli · warning
Prebundling has been configured but will not be used because
Error message
Prebundling has been configured but will not be used because scripts optimization is enabled.
What it means
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.
Source
Thrown at packages/angular_devkit/build_angular/src/builders/dev-server/options.ts:74
const buildTargetSpecifier = options.buildTarget ?? `::development`;
const buildTarget = targetFromTargetString(buildTargetSpecifier, projectName, 'build');
// Get the application builder options.
const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);
const rawBuildOptions = await context.getTargetOptions(buildTarget);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const buildOptions = (await context.validateOptions(rawBuildOptions, browserBuilderName)) as any;
const optimization = normalizeOptimization(buildOptions.optimization);
if (options.prebundle !== false && isEsbuildBased(browserBuilderName)) {
if (!cacheOptions.enabled) {
// Warn if the initial options provided by the user enable prebundling but caching is disabled
logger.warn(
'Prebundling has been configured but will not be used because caching has been disabled.',
);
} else if (optimization.scripts) {
// Warn if the initial options provided by the user enable prebundling but script optimization is enabled.
logger.warn(
'Prebundling has been configured but will not be used because scripts optimization is enabled.',
);
}
}
let inspect: false | { host?: string; port?: number } = false;
const inspectRaw = options.inspect;
if (inspectRaw === true || inspectRaw === '' || inspectRaw === 'true') {
inspect = {
host: undefined,
port: undefined,
};
} else if (typeof inspectRaw === 'string' && inspectRaw !== 'false') {
const port = +inspectRaw;
if (isFinite(port)) {
inspect = {
host: undefined,
port,View on GitHub (pinned to bb72145f9a)
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
Example fix
// before ng serve --configuration production // after ng serve # or keep optimization but disable prebundling: ng serve --optimization --no-prebundle
Defensive patterns
Strategy: validation
Validate before calling
// detect optimization on serve options before running
const opts = targetOptions; // resolved serve options
if (opts.optimization === true || (typeof opts.optimization === 'object' && opts.optimization?.scripts)) {
console.warn('Scripts optimization enabled: prebundling will be disabled for this serve.');
} Type guard
function isScriptsOptimized(optimization: boolean | { scripts?: boolean } | undefined): boolean {
return optimization === true || (typeof optimization === 'object' && optimization?.scripts === true);
} Prevention
- 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
When it happens
Trigger: `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.
Common situations: 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.
Related errors
- Webpack Dev Server configuration was not set.
- Proxy configuration file ${proxyPath} does not exist.
- The "dev-server" builder requires a target to be specified.
- Prebundling has been configured but will not be used because
- Prebundling has been configured but will not be used because
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/5e17e02189da859f.
Report an issue: GitHub.