Skip to content

Commit b9807ca

Browse files
committed
Move @mux/mux-player-react from dependencies to optional peerDependency
The wildcard `"*"` in dependencies caused consumers to silently resolve to old mux-player versions where subtitles don't load on Chrome. Now consumers who use <VideoPlayer/> must explicitly install @mux/mux-player-react (>=2.5.0), ensuring they get a working version. Consumers who don't use <VideoPlayer/> won't pull in mux at all. Other changes needed to support mux v3 in devDependencies: - Update devDependencies to ^3.11.4 - Switch moduleResolution to "Bundler" (mux v3 uses package.json exports) - Add paths mapping in CJS tsconfig (CommonJS can't use Bundler resolution) - Fix import paths to use .js extensions consistently - Enable skipLibCheck (mux v3 types reference untyped mux-embed)
1 parent b51d752 commit b9807ca

8 files changed

Lines changed: 141 additions & 61 deletions

File tree

package-lock.json

Lines changed: 120 additions & 53 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
"homepage": "https://github.com/datocms/react-datocms",
112112
"devDependencies": {
113113
"@biomejs/biome": "^1.6.3",
114-
"@mux/mux-player-react": ">=2.5.0 <3",
114+
"@mux/mux-player-react": "^3.11.4",
115115
"@types/enzyme": "^3.10.8",
116116
"@types/enzyme-to-json": "^1.5.4",
117117
"@types/jest": "^29.5.11",
@@ -147,11 +147,16 @@
147147
"tsc:esm": "tsc --project ./tsconfig.esnext.json"
148148
},
149149
"peerDependencies": {
150+
"@mux/mux-player-react": ">=2.5.0",
150151
"react": ">= 16.12.0"
151152
},
153+
"peerDependenciesMeta": {
154+
"@mux/mux-player-react": {
155+
"optional": true
156+
}
157+
},
152158
"dependencies": {
153159
"@datocms/content-link": "^0.3.13",
154-
"@mux/mux-player-react": "*",
155160
"datocms-listen": "^1.0.2",
156161
"datocms-structured-text-generic-html-renderer": "^5.0.0",
157162
"datocms-structured-text-utils": "^5.1.6",

react-extras.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ declare module 'react' {
55
fetchPriority?: 'auto' | 'low' | 'high';
66
}
77
}
8+

src/SRCImage/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// biome-ignore lint/style/useImportType: wrong warning
22
import React, { HTMLAttributeReferrerPolicy } from 'react';
3-
import type { ResponsiveImageType } from '../Image';
3+
import type { ResponsiveImageType } from '../Image/index.js';
44
import { buildRegularSource, buildWebpSource, priorityProp } from './utils.js';
55

66
export type SRCImagePropTypes = {

src/SRCImage/utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import type { ResponsiveImageType } from '../Image';
2+
import type { ResponsiveImageType } from '../Image/index.js';
33

44
export function priorityProp(
55
fetchPriority?: string,

src/useVideoPlayer/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { MuxPlayerProps } from '@mux/mux-player-react/.';
1+
import type { MuxPlayerProps } from '@mux/mux-player-react';
22

3-
import type { Video } from '../VideoPlayer';
3+
import type { Video } from '../VideoPlayer/index.js';
44

55
type Maybe<T> = T | null;
66
type Possibly<T> = Maybe<T> | undefined;

tsconfig.commonjs.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
"declaration": false,
99

1010
"module": "CommonJS",
11+
"moduleResolution": "Node",
12+
"paths": {
13+
"@mux/mux-player-react": ["./node_modules/@mux/mux-player-react/dist/types/index.d.ts"],
14+
"@mux/mux-player-react/lazy": ["./node_modules/@mux/mux-player-react/dist/types/lazy.d.ts"],
15+
"@mux/mux-player": ["./node_modules/@mux/mux-player/dist/types/index.d.ts"]
16+
},
17+
"skipLibCheck": true,
1118

1219
"isolatedModules": true
1320
}

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
"target": "ES2016",
3131

3232
// Module resolution
33-
"moduleResolution": "Node",
33+
"moduleResolution": "Bundler",
3434
"esModuleInterop": true,
3535

3636
// Type-checking
3737
"strict": true,
38-
"skipLibCheck": false,
38+
"skipLibCheck": true,
3939
"noImplicitAny": true,
4040
"resolveJsonModule": true,
4141
"strictNullChecks": true,

0 commit comments

Comments
 (0)