Slide 1

Slide 1 text

Summary of JavaScript Standard Library Proposal Tetsuharu OHZEKI @tc39_study

Slide 2

Slide 2 text

JavaScript Standard Library • https://github.com/tc39/proposal-javascript-standard-library • Stage 1 (Oct. 9th, 2019) • It’s still a dream, hope, glorious, and future • Authors & Champions • Michael Saboff (Apple) • Mattijs Hoitink (Apple) • Rename to builtin-module proposal?

Slide 3

Slide 3 text

Motivation • JavaScript doesn't have standard library mechanism • Far from “battery included” • Developer need pay a cost to bundle libraries • download cost, parsing cost, no cache across programs, etc…

Slide 4

Slide 4 text

Motivation • Extending builtins often almost always causes web- compat • @@unscopable (ES2015) • Array.prototype.contains() -> Array.prototype.includes() (ES2016) • Array.prototype.flatten() -> Array.prototype.flat() (ES2019)

Slide 5

Slide 5 text

Scope • Define a mechanism for enabling a more extensive standard library in JavaScript than is currently available • What should be included in “std library”? • Not scope • Other specs will be built on this • e.g. UUID proposal

Slide 6

Slide 6 text

Semantics • Use import statement • ModuleSpecifier starts with a prefix • Import {} from “
:”

• This distinguish standard libraries from user’s one

Slide 7

Slide 7 text

Namespace Prefix • js: • import { bar } from “js:foo”; • Other specifications can introduce an arbitrary prefix • “node:”, “web:”, “intl:”, “device:” etc… • TC39 hosts a repository to manage them?

Slide 8

Slide 8 text

Freezing Exports • All exported objects & classes are frozen • Prevents to extend by other modules • Decrease a risk of web compatibility for the future

Slide 9

Slide 9 text

Polyfilling Use Cases • Intended only these: • Add missing parts of the standard library • Update incomplete implementations • Patch broken parts of the standard library • There is a rough consensus to provide polyfill mechanism • …but details are still under considerations • For web: use Import-Maps proposals?

Slide 10

Slide 10 text

How to change the spec? • Let’s read the proposal

Slide 11

Slide 11 text

How to use from classic script? • No Proposal yet • By the meeting note of TC39 July 2019, there was a discussion about that it is required as a fundamental feature to support importing from classic script • No GitHub Issue? • IMO, I feel it’s better we should separate it to a new proposal • Anyhow, developer can use webpack/rollup to generate classic script instead of writing a classic script directly • Developer need a consensus to allow to transform them

Slide 12

Slide 12 text

Relations with Web Std? • By meeting notes of TC39, I feel there has not been concrete consensus yet • Google vs Apple for a long time……

Slide 13

Slide 13 text

Related Efforts • https://github.com/tc39/ecma262/issues/395 • https://github.com/WICG/import-maps