When tsc Compiled to ES3

When tsc Compiled to ES3

7月 24, 2021 · 1 分钟阅读时长 · 97 字 · -阅读 -评论

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.

Alan H
Authors
开发者,数码产品爱好者,喜欢折腾,喜欢分享,喜欢开源