Conversation
The shim replaced the global URL with a plain object, which breaks code that parses URLs with new URL(), such as resolveAdapterType from @videojs/react. Subclass the real URL and keep the mocked createObjectURL.
Replace the URL regexes in patterns.ts with resolveAdapterType and resolveMimeType from @videojs/react, so ReactPlayer recognizes the same sources as the Video.js v10 media components it renders. - YouTube, Vimeo, Wistia, Mux, Spotify, Twitch, TikTok and DASH sources are matched by adapter type. - Mux stream URLs ending in .m3u8 still play with hls.js. - File playback keeps AUDIO_EXTENSIONS and VIDEO_EXTENSIONS as a fallback for extensions Video.js does not recognize (m4v, m4b, weba, oga, spx, ...). Newly recognized sources: - localized Spotify URLs (open.spotify.com/intl-de/track/...) and spotify: URIs - youtube/<id> and vimeo/<id> shorthands - .flac files Breaking changes: - react-player/patterns no longer exports HLS_EXTENSIONS, DASH_EXTENSIONS, MATCH_URL_MUX, MATCH_URL_YOUTUBE, MATCH_URL_VIMEO, MATCH_URL_WISTIA, MATCH_URL_SPOTIFY, MATCH_URL_TWITCH or MATCH_URL_TIKTOK. Use resolveAdapterType from @videojs/react instead. - These URLs are no longer matched to a service player and fall back to the HTML player: youtube.com/user/..., music.youtube.com, vimeo.com/channels/..., vimeo.com/showcase/... and player.twitch.tv/?video=... BREAKING CHANGE: URL pattern exports were removed from react-player/patterns in favor of resolveAdapterType from @videojs/react, and some URLs now resolve to a different player.
Every built-in player key is a Video.js adapter type (plus html), so patterns.ts resolves a URL to its player key once and canPlay(key) compares against it, instead of a table of per-player predicates. The Mux .m3u8 -> hls.js rule and the extension fallback for the HTML player are unchanged; player selection is identical for every URL compared. Also removes canPlayFile, which handled arrays of sources that src no longer accepts.
Breaking changes:
- react-player/patterns exports canPlay as a function of the player key: canPlay.youtube(url) becomes canPlay('youtube')(url).
BREAKING CHANGE: canPlay in react-player/patterns is now canPlay(key)(url) instead of canPlay[key](url).
- test/react-player-tests.tsx was entirely commented out. - test/ReactPlayer/instanceMethods.js only had commented-out tests for the removed instance methods. - test/ReactPlayer/render.js only had skipped tests. - test/Player.tsx and test/Player.test.tsx both tested Player; merge them into Player.test.tsx.
…d tsx scripts/builder and scripts/tester wrapped esbuild in ~180 lines of option parsing. Use the tools directly instead: - build:esm: tsc emits the JS next to the declarations it already emitted (target es2019, matching the old builder default). - build:demo / start: the esbuild CLI, which supports --bundle, --splitting, --watch and --servedir itself. - test: node --test runs each test file through tsx. Test files are named *.test.* so one glob finds them. Tests now run on Node 22 without NODE_OPTIONS=--no-experimental-global-navigator: server-safe-globals defines the shims with Object.defineProperty (navigator is a getter-only global in Node 21+), loads zora before the window shim so it starts in Node mode, and stubs the few DOM APIs react-dom touches when it is loaded unbundled. Also: - Remove the unused cross-env, the deprecated codecov uploader and rimraf (rm -rf). - Bump esbuild to ~0.28 so it dedupes with tsx's copy. - CI: upload coverage with codecov/codecov-action, test on Node 18 and 22, and build on Node 18/20/22 (esbuild 0.28 needs Node 18+).
1 of 5 tasks
luwes
force-pushed
the
feat/resolve-adapter-type
branch
from
October 2, 2026 01:46
3b1ac2d to
ef45ca4
Compare
Collaborator
Author
|
Superseded by the pnpm + Vite+ tooling migration in a424322 on #2049 ( Not carried over: removing the dead tests ( |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #2050 (which is stacked on #2049), because the tests it touches only exist on the v10 branches. No changes to the published library's API or behavior.
Changes
Build and test scripts.
scripts/builderandscripts/testerwrapped esbuild in ~180 lines of option parsing. They're replaced by the tools themselves:build:esmbuilder(esbuild, per file)tsc, which already emitted the declarations (targetes2019, matching the old builder default)build:demo,startbuilderesbuildCLI (--bundle --splitting --watch --servedirare built in)testtester: bundle each file with esbuild, then run itnode --import tsx --test test/*.test.tsx test/*/*.test.*typestscbuild:esmTests
test/react-player-tests.tsx(all commented out),test/ReactPlayer/instanceMethods.js(commented-out tests for removed instance methods) andtest/ReactPlayer/render.js(onlytest.skip).test/Player.tsxintotest/Player.test.tsx; test files are now all*.test.*.NODE_OPTIONS=--no-experimental-global-navigator.server-safe-globalsdefines its shims withObject.defineProperty(navigatoris a getter-only global since Node 21), loads zora before thewindowshim, and stubs the two DOM APIs react-dom touches when loaded unbundled.Dependencies
builder,tester,cross-env(unused),codecov(deprecated uploader) andrimraf(nowrm -rf, like the existingcp -r).tsx. Bumpedesbuildto~0.28so it dedupes with tsx's copy.CI
codecov/codecov-action@v5(the README badge had no uploader). It needs aCODECOV_TOKENrepository secret; without one the step logs an error but doesn't fail the job.Testing
npm run clean && npm run build(tsc + demo),npm run lintandnpm run test:coveragepass on Node 22.19 with no flags.dist/has the same files as before (JS +.d.tsper source file,"use client"and webpack chunk-name comments preserved), andimport('react-player')works from the build.esbuild … --watch=forever --servedir=demoserves the demo.