Repository navigation
Release 2.5.0: Vite 8, tests, bug fixes, SSR and TypeScript types - #46
Merged
Merged
Conversation
- Vite 3 -> 8, @vitejs/plugin-vue 3 -> 6, vite-plugin-css-injected-by-js 2 -> 5. - Regenerate package-lock.json. This removes the vulnerable dev dependencies that Dependabot reports (vite, esbuild, rollup, postcss, nanoid, js-yaml, minimatch, brace-expansion, flatted). - Rename vite.config.js to vite.config.mjs. Vite 8 loads a .js config in a package without "type": "module" as CommonJS, and the CSS plugin is ESM only. "type": "module" is not an option because it breaks require() of the UMD file. - Select the build with --mode instead of the LIB_NAME variable. This also works on Windows. - Remove the "publish" script. npm runs a script with that name after every npm publish, so it started a second publish. The new "prepack" script builds dist before npm pack and npm publish. - Add eslint-plugin-vue and eslint-plugin-import, which the avidofood ESLint config needs, and add a "lint" script. ESLint stays on 8 because eslint-config-airbnb-base does not support ESLint 9. - Add Vitest 5, @vue/test-utils and jsdom for the tests in the next commit. - Add .nvmrc (Node 24). Vite 8 and Vitest 5 need Node 20.19+ or 22.12+. - Normalize the repository URL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tests describe the current behavior of the component: rendering, responsive sources, resizing, playback and the plugin. jsdom has no media playback, so tests/setup.js stubs play(), pause() and load(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Remove the resize listener on unmount. removeEventListener got a new throttled function, so the listener stayed after every unmount. - Do not sort the sources prop in place. The array belongs to the parent. - Fade in the video in Vue 3. Vue 3 renamed the class v-enter to v-enter-from, so the fade-in did not run. - Clear the pending load timer on unmount and on a new source. Before, the timer threw a TypeError after unmount, and fast source changes loaded every source. - Handle the promise of video.play(). If the browser blocks playback (for example iOS in Low Power Mode, or an unmuted video), the poster stays visible and the component emits error with the reason. The component emits playing after playback really started. An AbortError from a new load is ignored. - Handle the ready event once per loaded video. The browser fires canplay again after the video waited for data. Before, this paused the video, and with autoplay set to false it stayed paused. - Do not emit paused for the internal pause before autoplay. - Emit error when the <source> fails, for example on a 404. The browser fires that error on the <source> element, not on the <video> element. The error event now carries the event or the play() error. - Set the type attribute only for known extensions (mp4, m4v, webm, ogv, ogg, m3u8). Before, "video.mp4?v=1.2" got "video/2" and a URL without an extension got an invalid type, so the browser skipped the video. - Rename $_innerWidth to _innerWidth, as the 2.4.0 notes already said. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The server does not know the window width. Before, the server rendered the source for a 0px window, and the browser measured the real width in beforeMount, before the hydrating render. Poster and <source> then did not match the server HTML, so Nuxt and other SSR setups showed hydration warnings. The browser also started to load the wrong video before the app hydrated. Now the server renders the video without a <source>. During hydration the first render matches the server, and the width is measured in mounted. Vue then adds the <source> with the right video, and the browser loads it by itself. A client-only app still measures in beforeMount, so its first render is unchanged. The check for hydration reads this.$.vnode.el, the same value that Vue uses to decide to hydrate. $el does not work, because it is null in dev builds at that time. The new tests also pass with the production build of Vue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
stop() pauses the video and sets it back to the start. Call play() to start it again. Before, the only way to restart a video was load(), which waits one second and shows the poster. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Add hand-written types in src/index.d.ts: props, sources, events, the player methods and the Plugin. They also register VideoBackground in GlobalComponents for template type checks. - The build copies the types to dist/index.d.ts (CommonJS) and dist/index.d.mts (ESM). Without "type": "module", TypeScript reads a .d.ts file as CommonJS, so one file for both builds would be wrong. - Add "types" conditions to "exports", a top-level "types" field and "./package.json" to "exports". - Declare vue ^3.2.0 as a peer dependency. Before, vue was only a dev dependency, so npm did not check the Vue version. The build uses createElementBlock, which Vue 3.2 introduced. - Add bugs and homepage fields. - npm test now also runs a compile check of the types with TypeScript 5.9. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This only states what Node already assumed. The UMD file is CommonJS and the ESM build uses the .mjs extension. publint suggests the field, so that Node does not have to detect the module type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Installation for Vue 3 with app.component() and app.use(). The old example used the Vue 2 API (Vue.component, Vue.use). - Vue 2 users install the 1x dist-tag (1.3.5) instead of 1.3.1. - Nuxt 3 and 4: a normal plugin works now, because the component renders on the server. <ClientOnly> stays as an option. - New sections for TypeScript, development and the stop() method. - Events: the payload of error, ready once per video, the blocked autoplay case. - Supported type attributes and the HLS limit (#44), and a custom transition duration (#29). - Replace w3schools links with MDN. - Move the changelog from the README to CHANGELOG.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A minor release: new, backward-compatible features (TypeScript types, stop(), the error payload) and bug fixes. No breaking change, see CHANGELOG.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GitHub Pages serves demo/public/build/js/app.js from master, so the demo shows the fixed fade-in after the merge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Runs lint, the tests, the type check and npm pack --dry-run on Node 22 and 24 for pushes to master and for pull requests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- babel.config.js used the Vue CLI Babel preset. The project builds with Vite and does not install @vue/cli-plugin-babel. - mix-manifest.json came from Laravel Mix, which the project no longer uses. Nothing reads the file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Prepares release 2.5.0: new build tooling, tests, bug fixes, server-side rendering, TypeScript types and
stop(). Merge with a merge commit, so that the single commits stay.Changes
npm pack --dry-runon Node 22 and 24.fade-enter-from.sourceswas sorted in place.playing.error.canplayafter buffering paused the video.video.mp4?v=1.2got the typevideo/2and never played.player.stop()(Add stop() method or get access to video object #30).errorevent carries the reason.player.play()returns a promise.exportswith separate.d.tsand.d.mtstypes.vue ^3.2.0."type": "commonjs".publishscript is removed, because npm ran it after everynpm publish.prepackbuildsdist/.babel.config.jsandmix-manifest.jsonremoved.See CHANGELOG.md for the full list.
Testing
npm run lint,npm test(55 tests and the type check),npm run buildandnpm pack --dry-runall pass in fresh clones on Node 22.12 and 24.@arethetypeswrong/clireports no problems.publintreports no errors.tscpasses with TypeScript 5.9, 6.0 and 7.0 for bundler, node16 ESM and node16 CJS resolution.vue-tscpasses for template usage.error.Notes
postcss-selector-parser, via eslint-plugin-vue 9). It is dev-only and affects only linting. The fix needs ESLint 9, and eslint-config-avidofood does not support ESLint 9 yet.🤖 Generated with Claude Code