Skip to content

chore!: bump compilation target from ES5 to ES2017#776

Open
TrevorBurnham wants to merge 1 commit intoaws-observability:mainfrom
TrevorBurnham:target-es2017
Open

chore!: bump compilation target from ES5 to ES2017#776
TrevorBurnham wants to merge 1 commit intoaws-observability:mainfrom
TrevorBurnham:target-es2017

Conversation

@TrevorBurnham
Copy link

Closes #775

Summary

This PR removes the Babel transpilation pipeline and bumps the TypeScript/webpack compilation target from ES5 to ES2017, eliminating significant transpilation overhead from the CDN bundle.

Changes

File Change
tsconfig.json "target": "es5""es2017"
webpack/webpack.common.js Target ['web', 'es5']['web', 'es2017']; removed babel-loader pipeline entirely; simplified exclude from /node_modules\/(?!@aws-sdk)/ to /node_modules/ (see note below)
package.json Removed @babel/runtime (prod), @babel/preset-env, babel-loader, @babel/plugin-transform-runtime (dev); updated browserslist from ["defaults"] to ["Chrome >= 55", "Firefox >= 52", "Safari >= 10.1", "Edge >= 15"]

Note on the exclude pattern change: The old webpack config used exclude: /node_modules\/(?!@aws-sdk)/ to run @aws-sdk code through Babel. The new config excludes all of node_modules since Babel is removed and ts-loader only needs to process our source. The @smithy/* and @aws-crypto/* runtime dependencies already ship ES2017-compatible JS. If a future SDK version ships syntax beyond ES2017, the webpack target would need to be bumped accordingly or a loader re-added for those packages.

Bundle size impact

Metric Before (ES5) After (ES2017) Δ
Raw (minified) 160,899 B 123,723 B −37,176 B (−23.1%)
Gzipped 43,962 B 39,533 B −4,429 B (−10.1%)

The savings come from eliminating Babel's async/await state machine transforms (__awaiter/__generator), for...of iterator protocol boilerplate, and the @babel/runtime helpers.

Breaking changes

This change should be released as a new major version, for two reasons:

  1. The new syntax is not parseable by a handful of browsers (Chrome 42-54, Firefox 39-51…) that support fetch and sendBeacon. The browserslist has been updated to reflect that limitation.
  2. The new syntax may not be parseable by older bundlers, such as Webpack 4.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Remove Babel transpilation pipeline and bump TypeScript/webpack targets
from ES5 to ES2017. The entry point already gates on fetch + sendBeacon,
which guarantees ES2017+ browser support at runtime.

- tsconfig target: es5 -> es2017
- webpack target: ['web', 'es5'] -> ['web', 'es2017']
- Remove babel-loader, @babel/preset-env, @babel/plugin-transform-runtime
- Remove @babel/runtime from production dependencies
- Update browserslist to explicit minimum versions
- Bundle size reduction: -37 KB raw (-23%), -4.4 KB gzipped (-10%)

This is a breaking change for consumers using older bundlers (e.g.
Webpack 4) that do not support ES2017 input.

Refs: aws-observability#775
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Update ECMAScript target

1 participant