{"record":{"id":"12d28ee3c264e3a5","repo":"parcel-bundler/parcel","slug":"unexpected-output-file-type-ext-in-target-ta","errorCode":null,"errorMessage":"Unexpected output file type ${ext} in target \"${targetName}\"","messagePattern":"Unexpected output file type (.+?) in target \"(.+?)\"","errorType":"exception","errorClass":"ThrowableDiagnostic","httpStatus":null,"severity":"error","filePath":"packages/core/core/src/requests/TargetRequest.js","lineNumber":741,"sourceCode":"          continue;\n        }\n\n        if (\n          distEntry != null &&\n          !COMMON_TARGETS[targetName].match.test(distEntry)\n        ) {\n          let contents: string =\n            typeof pkgContents === 'string'\n              ? pkgContents\n              : // $FlowFixMe\n                JSON.stringify(pkgContents, null, '\\t');\n          // $FlowFixMe\n          let listFormat = new Intl.ListFormat('en-US', {type: 'disjunction'});\n          let extensions = listFormat.format(\n            COMMON_TARGETS[targetName].extensions,\n          );\n          let ext = path.extname(distEntry);\n          throw new ThrowableDiagnostic({\n            diagnostic: {\n              message: md`Unexpected output file type ${ext} in target \"${targetName}\"`,\n              origin: '@parcel/core',\n              codeFrames: [\n                {\n                  language: 'json',\n                  filePath: pkgFilePath ?? undefined,\n                  code: contents,\n                  codeHighlights: generateJSONCodeHighlights(contents, [\n                    {\n                      key: pointer,\n                      type: 'value',\n                      message: `File extension must be ${extensions}`,\n                    },\n                  ]),\n                },\n              ],\n              hints: [","sourceCodeStart":723,"sourceCodeEnd":759,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/core/core/src/requests/TargetRequest.js#L723-L759","documentation":"For a common named target (main/module/browser/types, defined in COMMON_TARGETS), Parcel validates that the configured `distEntry` (the output file path) has one of the expected extensions for that target type. If the extension is not in the allowed set, the build aborts with a disjunction list of allowed extensions.","triggerScenarios":"Setting a distEntry for a COMMON_TARGET whose file extension differs from the target's expected set (e.g. pointing `module` at a `.cjs` file, or `main` at a `.mjs` while expecting commonjs).","commonSituations":"Mismatched field/extension pairs in package.json (e.g. `\"main\": \"dist/index.mjs\"` without esmodule config); leftover output paths after switching build format; copy-paste of build config between projects using different module formats.","solutions":["Align the distEntry file extension with the target's expected extensions shown in the error (use one of the listed extensions).","If you intentionally want a different format, configure `targets.<name>.outputFormat` and the matching extension explicitly.","Remove the distEntry override and let Parcel infer the correct extension."],"exampleFix":"// before (package.json)\n{\n  \"module\": \"dist/index.cjs\"\n}\n\n// after\n{\n  \"module\": \"dist/index.mjs\"\n}","handlingStrategy":"validation","validationCode":"const COMMON_TARGETS = {\n  main: ['js','cjs'], module: ['mjs','js'], browser: ['js'], types: ['d.ts']\n};\nfunction assertDistEntryExt(targetName, distEntry) {\n  const ext = distEntry.split('.').pop();\n  const allowed = COMMON_TARGETS[targetName];\n  if (allowed && !allowed.includes(ext)) {\n    throw new Error(`Target ${targetName} expects .${allowed.join('|')}, got .${ext}`);\n  }\n}","typeGuard":"function isValidDistEntryForTarget(targetName, distEntry, allowed) {\n  const ext = distEntry.slice(distEntry.lastIndexOf('.') + 1);\n  return allowed.includes(ext);\n}","tryCatchPattern":"try { await parcel.run(); } catch (e) {\n  if (/Unexpected output file type/.test(e.message)) {\n    console.error('Fix the distEntry extension to match the target format.');\n  } else throw e;\n}","preventionTips":["Pair `module` with .mjs, `main` with .js/.cjs, `types` with .d.ts.","Let Parcel infer extensions by omitting distEntry where possible.","Lint package.json with a schema describing target→extension rules."],"tags":["parcel","targets","output-format","extensions","config"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}