You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 💥 Remove the ES2018 variant, in favor of the ES2015 variant.
20
+
* 💥 Switch to [subpath exports](https://nodejs.org/api/packages.html#subpath-exports) for variants.
21
+
* Node 12 or higher is required to `import` or `require()` a variant.
22
+
* When using TypeScript, version 4.7 or higher is now required. Additionally, [`moduleResolution`](https://www.typescriptlang.org/tsconfig#moduleResolution) must be set to `"node16"`, `"nodenext"` or `"bundler"`.
23
+
* 🚀 Support [importing as ESM in Node](https://nodejs.org/api/esm.html).
24
+
* 💅 Minify all code in the published package, to reduce the download size.
25
+
* 💅 Rework `ReadableStream.from()` implementation to avoid depending on `async function*` down-leveling for ES5. ([#144](https://github.com/MattiasBuelens/web-streams-polyfill/pull/144))
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,7 @@
12
12
-`npm run test:wpt` runs the [Web Platform Tests for Streams][wpt-streams] against the generated JavaScript bundle, to verify that the polyfill's run-time behavior matches the specification.
13
13
-`npm run test:types` runs the TypeScript compiler against some reference code that uses the generated type definitions, to verify that the code successfully passes the type check.
14
14
-`npm run test:unit` runs a few unit tests in a Node environment, to verify that the polyfill also works without a browser environment.
15
+
-`npm run test:bundlers` runs integration tests with popular bundlers, to verify that they can correctly resolve and bundle the polyfill.
Version 4 restructures the library's exports to have more modern defaults, and employs modern best practices for publishing npm packages.
6
+
7
+
* The default export (i.e. `import "web-streams-polyfill"`) is now the *ponyfill* variant instead of the *polyfill* variant, to avoid modifying the global scope. If you do want to install the polyfill on the global scope, switch to
8
+
the `polyfill` variant.
9
+
* The default export uses ES2015 syntax and targets modern Node and browser environments. If you need to support ES5 environments, switch to either the `es5` or `polyfill/es5` variant.
10
+
* The polyfill variant no longer re-exports the ponyfill, so `import { ReadableStream } from "web-streams-polyfill/polyfill"` won't work. Instead, use the global `ReadableStream` variable directly after loading the polyfill, or switch to the default (non-polyfill) variant.
11
+
* The project uses [Node's subpath exports](https://nodejs.org/api/packages.html#packages_package_entry_points) to provide each variant as a [dual module (UMD/ESM)](https://nodejs.org/api/packages.html#packages_dual_commonjs_es_module_packages). You need Node 12.20.0 or higher to resolve these variants. If you're using a bundler (like webpack or Rollup), you need to make sure it's up-to-date too. If you're using TypeScript, your [`moduleResolution`](https://www.typescriptlang.org/tsconfig#moduleResolution) must be set to `"node16"`, `"nodenext"` or `"bundler"`.
12
+
13
+
Version 4 also focuses on reducing the download size of the published npm package.
14
+
15
+
* All published JavaScript code is now minified, without source maps. If you need to debug the polyfill, you can [clone it](https://github.com/MattiasBuelens/web-streams-polyfill) and [build it yourself](https://github.com/MattiasBuelens/web-streams-polyfill/blob/master/CONTRIBUTING.md).
16
+
* The ES2018 variant was removed, since it had only minor differences with the ES2015 variant. If you were using this variant, switch to the default export instead.
17
+
18
+
The following table shows how to upgrade your v3 import to their equivalent v4 import:
The `polyfill` and `ponyfill` variants work in any ES5-compatible environment that has a global `Promise`.
62
+
The `polyfill` and `ponyfill` variants work in any ES2015-compatible environment.
63
+
64
+
The `polyfill/es5` and `ponyfill/es5` variants work in any ES5-compatible environment that has a global `Promise`.
56
65
If you need to support older browsers or Node versions that do not have a native `Promise` implementation
57
66
(check the [support table][promise-support]), you must first include a `Promise` polyfill
58
67
(e.g. [promise-polyfill][promise-polyfill]).
59
68
60
-
The `polyfill/es6` and `ponyfill/es6` variants work in any ES2015-compatible environment.
61
-
62
-
The `polyfill/es2018` and `ponyfill/es2018` variants work in any ES2018-compatible environment.
63
-
64
69
[Async iterable support for `ReadableStream`][rs-asynciterator] is available in all variants, but requires an ES2018-compatible environment or a polyfill for `Symbol.asyncIterator`.
65
70
66
71
[`WritableStreamDefaultController.signal`][ws-controller-signal] is available in all variants, but requires a global `AbortController` constructor. If necessary, consider using a polyfill such as [abortcontroller-polyfill].
67
72
68
73
[Reading with a BYOB reader][mdn-byob-read] is available in all variants, but requires `ArrayBuffer.prototype.transfer()` or `structuredClone()` to exist in order to correctly transfer the given view's buffer. If not available, then the buffer won't be transferred during the read.
69
74
75
+
### Tooling compatibility
76
+
77
+
This package uses [subpath exports](https://nodejs.org/api/packages.html#subpath-exports) for its variants. As such, you need Node 12 or higher in order to `import` or `require()` such a variant.
78
+
79
+
When using TypeScript, make sure your [`moduleResolution`](https://www.typescriptlang.org/tsconfig#moduleResolution) is set to `"node16"`, `"nodenext"` or `"bundler"`.
80
+
70
81
## Compliance
71
82
72
83
The polyfill implements [version `4dc123a` (13 Nov 2023)][spec-snapshot] of the streams specification.
73
84
74
85
The polyfill is tested against the same [web platform tests][wpt] that are used by browsers to test their native implementations.
75
86
The polyfill aims to pass all tests, although it allows some exceptions for practical reasons:
76
-
* The `es2018` variant passes all of the tests.
77
-
* The `es6` variant passes the same tests as the `es2018` variant, except for the [test for the prototype of `ReadableStream`'s async iterator][wpt-async-iterator-prototype].
87
+
* The default (ES2015) variant passes all of the tests, except for the [test for the prototype of `ReadableStream`'s async iterator][wpt-async-iterator-prototype].
78
88
Retrieving the correct `%AsyncIteratorPrototype%` requires using an async generator (`async function* () {}`), which is invalid syntax before ES2018.
79
89
Instead, the polyfill [creates its own version][stub-async-iterator-prototype] which is functionally equivalent to the real prototype.
80
-
* The `es5` variant passes the same tests as the `es6` variant, except for various tests about specific characteristics of the constructors, properties and methods.
90
+
* The ES5 variant passes the same tests as the ES2015 variant, except for various tests about specific characteristics of the constructors, properties and methods.
81
91
These test failures do not affect the run-time behavior of the polyfill.
82
92
For example:
83
93
* The `name` property of down-leveled constructors is incorrect.
@@ -97,6 +107,7 @@ Thanks to these people for their work on [the original polyfill][creatorrr-polyf
0 commit comments