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

Migrate to webpack v5 #1225

Closed
wants to merge 6 commits into from
Closed
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ Key | Options
`mixcloud` | `options`: Override the [default player options](https://www.mixcloud.com/developers/widget/#methods)
`dailymotion` | `params`: Override the [default player vars](https://developer.dailymotion.com/player#player-parameters)
`twitch` | `options`: Override the [default player options](https://dev.twitch.tv/docs/embed)<br />`playerId`: Override player ID for consistent server-side rendering (use with [`react-uid`](https://github.com/thearnica/react-uid))
`file` | `attributes`: Apply [element attributes](https://developer.mozilla.org/en/docs/Web/HTML/Element/video#Attributes)<br />`forceVideo`: Always render a `<video>` element<br />`forceAudio`: Always render an `<audio>` element<br />`forceHLS`: Use [hls.js](https://github.com/video-dev/hls.js) for HLS streams<br />`forceDASH`: Always use [dash.js](https://github.com/Dash-Industry-Forum/dash.js) for DASH streams<br />`forceFLV`: Always use [flv.js](https://github.com/Bilibili/flv.js)<br />`hlsOptions`: Override the [default `hls.js` options](https://github.com/video-dev/hls.js/blob/master/docs/API.md#fine-tuning)<br />`hlsVersion`: Override the [`hls.js`](https://github.com/video-dev/hls.js) version loaded from [`jsdelivr`](https://www.jsdelivr.com/package/npm/hls.js), default: `0.13.1`<br />`dashVersion`: Override the [`dash.js`](https://github.com/Dash-Industry-Forum/dash.js) version loaded from [`cdnjs`](https://cdnjs.com/libraries/dashjs), default: `2.9.2`<br />`flvVersion`: Override the [`flv.js`](https://github.com/Bilibili/flv.js) version loaded from [`jsdelivr`](https://www.jsdelivr.com/package/npm/flv.js), default: `1.5.0`
`file` | `attributes`: Apply [element attributes](https://developer.mozilla.org/en/docs/Web/HTML/Element/video#Attributes)<br />`forceVideo`: Always render a `<video>` element<br />`forceAudio`: Always render an `<audio>` element<br />`forceHLS`: Use [hls.js](https://github.com/video-dev/hls.js) for HLS streams<br />`forceDASH`: Always use [dash.js](https://github.com/Dash-Industry-Forum/dash.js) for DASH streams<br />`forceFLV`: Always use [flv.js](https://github.com/Bilibili/flv.js)<br />`hlsOptions`: Override the [default `hls.js` options](https://github.com/video-dev/hls.js/blob/master/docs/API.md#fine-tuning)<br />`hlsVersion`: Override the [`hls.js`](https://github.com/video-dev/hls.js) version loaded from [`jsdelivr`](https://www.jsdelivr.com/package/npm/hls.js), default: `1.0.2`<br />`dashVersion`: Override the [`dash.js`](https://github.com/Dash-Industry-Forum/dash.js) version loaded from [`cdnjs`](https://cdnjs.com/libraries/dashjs), default: `3.2.2`<br />`flvVersion`: Override the [`flv.js`](https://github.com/Bilibili/flv.js) version loaded from [`jsdelivr`](https://www.jsdelivr.com/package/npm/flv.js), default: `1.5.0`

### Methods

Expand Down
39 changes: 20 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"typings": "lib/index.d.ts",
"scripts": {
"clean": "rimraf lib lazy demo coverage *.d.ts",
"start": "webpack-dev-server --config webpack/config.babel.js",
"start": "webpack serve --config webpack/config.babel.js",
"lint": "standard --verbose | snazzy",
"lint:fix": "standard --fix",
"lint:ts": "ts-standard --verbose types/*.d.ts | snazzy",
Expand Down Expand Up @@ -64,42 +64,43 @@
"@babel/preset-env": "^7.9.5",
"@babel/preset-react": "^7.9.4",
"@babel/register": "^7.9.0",
"@hot-loader/react-dom": "^16.13.0",
"@types/node": "^14.0.24",
"@hot-loader/react-dom": "^17.0.1",
"@types/node": "^15.0.1",
"@types/react": "^17.0.0",
"auto-changelog": "^2.0.0",
"autoprefixer": "^9.7.6",
"autoprefixer": "^10.2.5",
"ava": "^3.6.0",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.1.0",
"babel-plugin-istanbul": "^6.0.0",
"codecov": "^3.6.5",
"cross-env": "^7.0.2",
"css-loader": "^3.5.2",
"css-loader": "^5.2.4",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"file-loader": "^6.0.0",
"html-webpack-plugin": "^4.2.0",
"mini-css-extract-plugin": "^0.9.0",
"html-webpack-plugin": "^5.3.1",
"mini-css-extract-plugin": "^1.5.1",
"nyc": "^15.0.1",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"postcss": "^8.2.13",
"postcss-advanced-variables": "^3.0.1",
"postcss-loader": "^3.0.0",
"postcss-nested": "^4.1.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"postcss-loader": "^5.2.0",
"postcss-nested": "^5.0.5",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-hot-loader": "^4.12.20",
"rimraf": "^3.0.2",
"sanitize.css": "^11.0.0",
"sanitize.css": "^12.0.1",
"screenfull": "^5.0.2",
"sinon": "^9.0.2",
"snazzy": "^8.0.0",
"standard": "^14.3.3",
"style-loader": "^1.0.0",
"ts-standard": "^9.0.0",
"sinon": "^10.0.0",
"snazzy": "^9.0.0",
"standard": "^16.0.3",
"style-loader": "^2.0.0",
"ts-standard": "^10.0.0",
"typescript": "^4.1.2",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11",
"webpack": "^5.36.1",
"webpack-cli": "^4.6.0",
"webpack-dev-server": "^3.10.3"
},
"dependencies": {
Expand Down
12 changes: 7 additions & 5 deletions src/demo/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { Component } from 'react'
import { findDOMNode } from 'react-dom'
import { hot } from 'react-hot-loader'
import screenfull from 'screenfull'

Expand All @@ -8,7 +7,7 @@ import './defaults.css'
import './range.css'
import './App.css'

import { version } from '../../package.json'
import metadata from '../../package.json'
import ReactPlayer from '../index'
import Duration from './Duration'

Expand Down Expand Up @@ -97,7 +96,7 @@ class App extends Component {
this.setState({ playing: false })
}

handleSeekMouseDown = e => {
handleSeekMouseDown = () => {
this.setState({ seeking: true })
}

Expand Down Expand Up @@ -129,7 +128,9 @@ class App extends Component {
}

handleClickFullscreen = () => {
screenfull.request(findDOMNode(this.player))
if (screenfull.isEnabled) {
screenfull.request(document.getElementById('player'))
}
}

renderLoadButton = (url, label) => {
Expand All @@ -154,6 +155,7 @@ class App extends Component {
<h1>ReactPlayer Demo</h1>
<div className='player-wrapper'>
<ReactPlayer
id='player'
ref={this.ref}
className='react-player'
width='100%'
Expand Down Expand Up @@ -414,7 +416,7 @@ class App extends Component {
</table>
</section>
<footer className='footer'>
Version <strong>{version}</strong>
Version <strong>{metadata.version}</strong>
{SEPARATOR}
<a href='https://github.com/CookPete/react-player'>GitHub</a>
{SEPARATOR}
Expand Down
4 changes: 2 additions & 2 deletions src/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ export const defaultProps = {
forceDASH: false,
forceFLV: false,
hlsOptions: {},
hlsVersion: '0.14.16',
dashVersion: '3.1.3',
hlsVersion: '1.0.2',
dashVersion: '3.2.2',
flvVersion: '1.5.0'
},
wistia: {
Expand Down
8 changes: 7 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"include": ["types/*.d.ts"]
"include": [
"types/*.d.ts"
],
"compilerOptions": {
"noImplicitAny": true,
"strictNullChecks": true
}
}
2 changes: 1 addition & 1 deletion types/base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface BaseReactPlayerProps {
pip?: boolean
stopOnUnmount?: boolean
light?: boolean | string
fallback?: ReactElement;
fallback?: ReactElement
wrapper?: any
onReady?: (player: ReactPlayer) => void
onStart?: () => void
Expand Down
16 changes: 10 additions & 6 deletions webpack/config.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const plugins = [

export default {
mode: 'development',
devtool: 'cheap-module-eval-source-map',
devtool: 'eval-cheap-module-source-map',
entry: join(PATH_SRC, 'demo', 'index'),
resolve: {
alias: {
Expand All @@ -43,11 +43,13 @@ export default {
module: {
rules: [{
test: /\.js$/,
loader: 'babel-loader',
include: PATH_SRC,
query: {
presets: [['@babel/preset-env', { modules: false }]]
}
use: [{
loader: 'babel-loader',
options: {
presets: [['@babel/preset-env', { modules: false }]]
}
}]
}, {
test: /\.css$/,
use: [
Expand All @@ -73,7 +75,9 @@ export default {
include: PATH_NODE_MODULES
}, {
test: /\.(png|jpg)$/,
loader: 'file-loader?name=assets/[hash].[ext]',
use: [{
loader: 'file-loader?name=assets/[hash].[ext]'
}],
include: PATH_ASSETS
}]
},
Expand Down
6 changes: 5 additions & 1 deletion webpack/production.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export default {
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({ sourceMap: true }),
new TerserPlugin({
terserOptions: {
sourceMap: true
}
}),
new OptimizeCSSAssetsPlugin({})
]
}
Expand Down
Loading