When tsc Compiled to ES3

Postmortem of a production build that emitted ES3 JavaScript, why it happened, and how we fixed our component library setup.

Jul 24, 2021 · 1 min read · 97 Words · -Views -Comments · Programming
JavaScript 🇨🇳 阅读中文版
Read with AI

Choose an AI assistant

ChatGPT Open in a new tab with the article link and prompt
Claude Copy the prompt, then open Claude

Open Claude
Trouble reading the article?

If the prompt is missing, copy the full prompt below into your AI assistant. If the AI cannot read the article, paste the visible passage you want to discuss and add your question.

During a CD deployment our web bundle unexpectedly compiled to ES3, causing a blank screen in browsers.

Error screenshot

Root Cause

A shared business component library ignored the main project’s tsconfig target. Our internal build tool picks the first tsconfig it finds; the component library lacked a target, so TypeScript defaulted to ES3. Remember: TypeScript only transpiles syntax—it doesn’t polyfill.

Fix

Compile component libraries to JavaScript before publishing. This:

  1. Speeds up app builds (libraries are precompiled).
  2. Ensures libraries aren’t affected by the host project’s tsconfig.

Final Thoughts

Lesson learned—always set explicit targets or ship compiled artifacts for shared packages.

Authors
Developer, digital product enthusiast, tinkerer, sharer, open source lover