Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide ES5 version of the worker file #1400

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions doc/api/Miscellaneous/MultiThreading.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,3 +380,32 @@ if (currentModeInfo === null) {
console.info("We're running completely in main thread.");
}
```

## Note about ES5 Environment

By default, the Worker file will use es2017 features which should be compatible to a
majority of devices.

However, some older devices might not be compatible with it yet still compatible to the
WebWorker API (and thus the `MULTI_THREAD` feature), yet not with ES2017. For those
platforms, the RxPlayer also provide an ES5 variant of the Worker file:

- The easiest way is to just import in your application its "embedded" version, exported
through the `"rx-player/experimental/features/embeds"` path:

```js
import { EMBEDDED_WORKER_ES5 } from "rx-player/experimental/features/embeds";
```

This allows to bypass the need to store and serve separately that file.

If you would prefer more control and a smaller bundle size, you may instead consider the
other following ways to it as a separate file.

- With every release note published on GitHub as `worker.es5.js` (you should only use the
file linked to the RxPlayer's version you're using),

- It is also available as `dist/worker.es5.js` from the root directory of the project
published on npm. As such, it might already be found in your project's directory, for
example in the `node_modules` directory (most probably in `node_modules/rx-player/dist/`
depending on your project).
Comment on lines +408 to +411
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have made the choice to not build es5 build of the API because we though it's responsibility of an application to compile file with whatever tools they are using. Does building the embed worker in es5 is an exception ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the issue with the embedded worker is that it is usually not read by application bundlers (we even don't want to, as we fear those might bring syntax not authorized in a worker environment or introduce an outside scope).

I also brought another worker file in release notes, dist directory etc., as I guess applications would just use it directly without re-compiling it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I see.

137 changes: 101 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@
"ts-jest": "29.1.1",
"ts-loader": "9.5.1",
"typescript": "5.3.3",
"webpack": "5.89.0",
"webpack-cli": "5.1.4"
"webpack": "^5.90.3",
"webpack-cli": "^5.1.4"
},
"scripts-list": {
"Build a demo page (e.g. to test a code change)": {
Expand Down
Loading
Loading