{"record":{"id":"5a53898c0c2b76f0","repo":"parcel-bundler/parcel","slug":"lazy-excludes-can-only-be-provided-when-lazy-build","errorCode":null,"errorMessage":"Lazy excludes can only be provided when lazy building is enabled","messagePattern":"Lazy excludes can only be provided when lazy building is enabled","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/core/src/resolveOptions.js","lineNumber":137,"sourceCode":"    initialOptions?.defaultTargetOptions?.shouldOptimize ??\n    mode === 'production';\n\n  let publicUrl = initialOptions?.defaultTargetOptions?.publicUrl ?? '/';\n  let distDir =\n    initialOptions?.defaultTargetOptions?.distDir != null\n      ? path.resolve(inputCwd, initialOptions?.defaultTargetOptions?.distDir)\n      : undefined;\n\n  let shouldBuildLazily = initialOptions.shouldBuildLazily ?? false;\n  let lazyIncludes = compileGlobs(initialOptions.lazyIncludes ?? []);\n  if (lazyIncludes.length > 0 && !shouldBuildLazily) {\n    throw new Error(\n      'Lazy includes can only be provided when lazy building is enabled',\n    );\n  }\n  let lazyExcludes = compileGlobs(initialOptions.lazyExcludes ?? []);\n  if (lazyExcludes.length > 0 && !shouldBuildLazily) {\n    throw new Error(\n      'Lazy excludes can only be provided when lazy building is enabled',\n    );\n  }\n\n  let shouldContentHash =\n    initialOptions.shouldContentHash ?? initialOptions.mode === 'production';\n  if (shouldBuildLazily && shouldContentHash) {\n    throw new Error('Lazy bundling does not work with content hashing');\n  }\n\n  let env = {\n    ...(await loadDotEnv(\n      initialOptions.env ?? {},\n      inputFS,\n      path.join(projectRoot, 'index'),\n      projectRoot,\n    )),\n    ...process.env,","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/core/core/src/resolveOptions.js#L119-L155","documentation":"Symmetric to error 51: `lazyExcludes` globs require lazy building to be enabled. resolveOptions compiles lazyExcludes and throws if any are present while shouldBuildLazily is falsy.","triggerScenarios":"Passing `lazyExcludes` (glob patterns) without `shouldBuildLazily: true`.","commonSituations":"Adding excludes to tune lazy bundling without enabling the lazy feature; partial config migration; building options dynamically where excludes are set conditionally.","solutions":["Set `shouldBuildLazily: true` together with `lazyExcludes`.","Drop `lazyExcludes` if lazy building is not in use.","Drive both lazy flags from a single config variable."],"exampleFix":"// before\nconst parcel = new Parcel({\n  lazyExcludes: ['heavy-dep']\n});\n\n// after\nconst parcel = new Parcel({\n  shouldBuildLazily: true,\n  lazyExcludes: ['heavy-dep']\n});","handlingStrategy":"validation","validationCode":"function assertLazyExcludesRequiresFlag(opts) {\n  if ((!opts.shouldBuildLazily) && Array.isArray(opts.lazyExcludes) && opts.lazyExcludes.length > 0) {\n    throw new Error('Pass shouldBuildLazily:true when setting lazyExcludes.');\n  }\n}","typeGuard":"function lazyExcludesCoherent(o) {\n  return o.shouldBuildLazily === true || (o.lazyExcludes?.length ?? 0) === 0;\n}","tryCatchPattern":"try { new Parcel(opts); } catch (e) {\n  if (/Lazy excludes can only be provided/.test(e.message)) {\n    opts.shouldBuildLazily = true;\n    new Parcel(opts);\n  } else throw e;\n}","preventionTips":["Treat `lazyExcludes` as requiring `shouldBuildLazily`.","Use a single lazy-build toggle that drives includes, excludes, and the master flag.","Validate option coherence before invoking Parcel."],"tags":["parcel","lazy-build","options","config"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}