Skip to content

Commit a35f3c5

Browse files
authored
fix: cjs interop require default pita (#1722)
* fix: cjs interop require default pita * chore: update CI / CD workflow
1 parent 1496f67 commit a35f3c5

File tree

5 files changed

+34
-14
lines changed

5 files changed

+34
-14
lines changed

.github/workflows/cd.yml

+16-4
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@ on:
1616
- minor
1717
- major
1818
- prerelease
19+
- from-package
20+
- from-git
1921
prerelease:
2022
type: choice
21-
required: false
2223
description: Pre-release
2324
options:
2425
-
2526
- canary
2627
- beta
28+
dryrun:
29+
description: 'Dry-run'
30+
type: boolean
31+
32+
run-name: Deploy ${{ inputs.version }} ${{ inputs.dryrun && '--dry-run' || '' }} ${{ inputs.prerelease && format('--prerelease {0}', inputs.prerelease) || '' }}
2733

2834
jobs:
2935
deploy:
@@ -38,11 +44,12 @@ jobs:
3844
CONVENTIONAL_GITHUB_RELEASER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3945

4046
steps:
41-
- uses: actions/checkout@v3
47+
- uses: actions/checkout@v4
4248
with:
4349
fetch-depth: 0 # Fetch all history for all tags and branches
44-
- uses: actions/setup-node@v3
50+
- uses: actions/setup-node@v4
4551
with:
52+
node-version: 20
4653
# this line is required for the setup-node action to be able to run the npm publish below.
4754
registry-url: 'https://registry.npmjs.org'
4855
- uses: fregante/setup-git-user@v1
@@ -53,4 +60,9 @@ jobs:
5360
- run: npm run build:demo
5461
- run: npm run build:dist
5562
- run: npm run build:standalone
56-
- run: npx --yes [email protected] release ${{ inputs.version }} --prerelease "${{ inputs.prerelease }}" --provenance --changelog --github-release
63+
- run: npx --yes [email protected] release ${{ inputs.version }} ${{ inputs.dryrun && '--dry-run' || '' }} ${{ inputs.prerelease && format('--prerelease {0}', inputs.prerelease) || '' }} --provenance --changelog --github-release --verbose
64+
- name: Get NPM version
65+
id: npm-version
66+
uses: martinbeentjes/[email protected]
67+
- name: Released ${{ steps.npm-version.outputs.current-version}} ✨
68+
run: echo ${{ steps.npm-version.outputs.current-version}}

.github/workflows/ci.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ jobs:
1111
node-version: [18.x]
1212

1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1515
- name: Use Node.js ${{ matrix.node-version }}
16-
uses: actions/setup-node@v3
16+
uses: actions/setup-node@v4
1717
with:
1818
node-version: ${{ matrix.node-version }}
1919
cache: npm
@@ -28,9 +28,9 @@ jobs:
2828
node-version: [18.x]
2929

3030
steps:
31-
- uses: actions/checkout@v3
31+
- uses: actions/checkout@v4
3232
- name: Use Node.js ${{ matrix.node-version }}
33-
uses: actions/setup-node@v3
33+
uses: actions/setup-node@v4
3434
with:
3535
node-version: ${{ matrix.node-version }}
3636
cache: npm
@@ -45,9 +45,9 @@ jobs:
4545
node-version: [16.x, 18.x, 20.x]
4646

4747
steps:
48-
- uses: actions/checkout@v3
48+
- uses: actions/checkout@v4
4949
- name: Use Node.js ${{ matrix.node-version }}
50-
uses: actions/setup-node@v3
50+
uses: actions/setup-node@v4
5151
with:
5252
node-version: ${{ matrix.node-version }}
5353
cache: npm

src/ReactPlayer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import React, { Component, Suspense, lazy } from 'react'
1+
import React, { Component, Suspense } from 'react'
22
import merge from 'deepmerge'
33
import memoize from 'memoize-one'
44
import isEqual from 'react-fast-compare'
55

66
import { propTypes, defaultProps } from './props'
7-
import { omit } from './utils'
7+
import { omit, lazy } from './utils'
88
import Player from './Player'
99

1010
const Preview = lazy(() => import(/* webpackChunkName: 'reactPlayerPreview' */'./Preview'))

src/players/index.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { lazy } from 'react'
2-
import { supportsWebKitPresentationMode } from '../utils'
1+
import { lazy, supportsWebKitPresentationMode } from '../utils'
32
import { canPlay, AUDIO_EXTENSIONS } from '../patterns'
43

54
export default [

src/utils.js

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1+
import React from 'react'
12
import loadScript from 'load-script'
23
import merge from 'deepmerge'
34

5+
/**
6+
* Dynamic import is supported in CJS modules but needs interop require default logic.
7+
*/
8+
export const lazy = (componentImportFn) => React.lazy(async () => {
9+
const obj = await componentImportFn()
10+
return typeof obj.default === 'function' ? obj : obj.default
11+
})
12+
413
const MATCH_START_QUERY = /[?&#](?:start|t)=([0-9hms]+)/
514
const MATCH_END_QUERY = /[?&#]end=([0-9hms]+)/
615
const MATCH_START_STAMP = /(\d+)(h|m|s)/g

0 commit comments

Comments
 (0)