ampproject / ampproject/amphtml

Consider migrating AMP's infrastructure code to ES6

Open
#36,201 2 comments 1 reaction 0 assignees View on GitHub
Stale Type: Feature Request WG: infra
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

### Description

AMP's infrastructure code in `build-system/` is currently all ES5 and uses `require` to consume various packages. However, more and more packages are switching to ES6-only, and cannot be adopted in their current form. E.g. [`node-fetch`](https://github.com/node-fetch/node-fetch/commit/b50fbc105755123cad34fb0bc9d5653ecc693b8a) and [`tempy`](https://github.com/sindresorhus/tempy/commit/ca3543099409e4fb025628f00648d402b4863b46) (there are a few others, see https://github.com/ampproject/amphtml/pull/35032#issuecomment-930558568).

Migrating all code in `build-system/` to ES6 will modernize the codebase and solve the problem of not being able to use the latest version of some packages. However, the actual difficulty of doing this is unknown, since other packages may be ES5-only, and existing task implementations may need updates before they can work cleanly with ES6 packages.

The purpose of this issue is to discuss / experiment with a partial migration, and make a recommendation on how to proceed.

### Alternatives Considered

1. Remain on ES5 and don't adopt the latest version of any ES6-only package
2. Partially move to ES6 and migrate only those tasks that can actually work with ES6-only packages
3. Fully move to ES6 and find replacements for any ES5-only packages

1 is not future-proof, 2 can be done gradually (assuming it's possible), and eventually lead to 3.

### Additional Context

/cc @ampproject/wg-infra @ampproject/wg-performance @ampproject/wg-components @ampproject/wg-bento

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the ES5 code and package usage under build-system/, including the node-fetch and tempy examples and the discussion in pull request 35032. Experiment with a partial migration, check compatibility with existing packages and task implementations, and document whether partial or full migration is practical.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
build-system
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.