Skip to content

Commit

Permalink
fix: ES5 support
Browse files Browse the repository at this point in the history
It seems that at least one package (`debug`) doesn't
provide code transpiled to ES5 through node_modules.
Since it by default imports from src/, a resolve alias
is added to point to the dist/debug.js file instead.

A new ES5 target is also added at `dist/es5`.

closes: AxisCommunications#158
  • Loading branch information
steabert committed Jun 29, 2019
1 parent e061389 commit c19f743
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 2 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ stream transforms for Node & the Web.
The primary purpose is to deal with RTP streams in a browser without
the need to use plugins or Flash, but relying on the [Media Source Extensions](https://www.w3.org/TR/media-source/) standard, which is supported in all modern browsers.

_Note for IE11 users_: if you want to build the library yourself for IE11 instead
of using the provided bundle, you need import from `dist/es5` with the following fix in webpack:

```
alias: {
debug: 'debug/dist/debug.js',
},
```

You can look at the `webpack.config.js` to see how it's used for building the bundle.

## Structure

The library contains a collection of components that can be connected
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
"lint": "tslint --project tsconfig.json --format stylish",
"test": "jest --coverage",
"verify": "yarn lint && yarn test",
"build": "yarn build:esm && yarn build:cjs && yarn build:bundle",
"build": "yarn build:esm && yarn build:cjs && yarn build:es5 && yarn build:bundle",
"build:esm": "tsc -p tsconfig.json",
"build:cjs": "tsc -p tsconfig.cjs.json",
"build:es5": "tsc -p tsconfig.es5.json",
"build:bundle": "webpack",
"rtsp": "rtsp-ws-server/start.sh",
"dev": "webpack --mode development --watch",
Expand Down
22 changes: 22 additions & 0 deletions tsconfig.es5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
/* Include Typescript declaration files */
"declaration": true,

/* Basic Options */
"target": "es5",
"downlevelIteration": true,
"module": "es2015",
"outDir": "./dist/es5",
"skipLibCheck": true,
"sourceMap": true,

/* Strict Type-Checking Options */
"strict": true,

/* Module Resolution Options */
"moduleResolution": "node",
"esModuleInterop": true
},
"include": ["lib/**/*"]
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
/* Include Typescript declaration files */
"declaration": true,

/* Basic Options */
"target": "es2015",
"module": "es2015",
Expand Down
6 changes: 6 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ module.exports = {
},
resolve: {
extensions: ['.ts', '.js'],
// The debug packages resolves to src/debug.js by default
// which doesn't work on IE11 (it's not ES5), but it seems
// that the dist/debug.js file does work.
alias: {
debug: 'debug/dist/debug.js',
},
},
module: {
rules: [
Expand Down

0 comments on commit c19f743

Please sign in to comment.