social-embeds 0.9.4 → 0.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +15 -8
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -105,14 +105,19 @@ export const SocialEmbed = createSocialEmbed([
105
105
  ]);
106
106
  ```
107
107
 
108
- | Platforms | Gzipped |
109
- | ------------------------------------------------- | ------- |
110
- | `youtube` | 6 KB |
111
- | `youtube`, `x` | 9 KB |
112
- | `youtube`, `x`, `instagram`, `facebook`, `tiktok` | 12 KB |
113
- | the same five and `genericIframe` | 14 KB |
114
- | every platform (`<SocialEmbed>`) | 27 KB |
108
+ JavaScript added to a page in a Next.js 16 production build, gzipped:
115
109
 
110
+ | Platforms | Turbopack | webpack |
111
+ | ------------------------------------------------- | --------- | ------- |
112
+ | `youtube` | 6 KB | 7 KB |
113
+ | `youtube`, `x` | 9 KB | 10 KB |
114
+ | `youtube`, `x`, `instagram`, `facebook`, `tiktok` | 12 KB | 13 KB |
115
+ | the same five and `genericIframe` | 14 KB | 15 KB |
116
+ | every platform (`<SocialEmbed>`) | 27 KB | 27 KB |
117
+
118
+ Before 0.9.4, Next.js kept every platform in a `createSocialEmbed` component as well: about 17 KB for `youtube` alone.
119
+
120
+ - **A fixed list:** the list is set when the app is built, not per page, and a platform that is not in it is never recognised. If embed code comes from a CMS where editors can paste any platform, list every platform they use, add `genericIframe` and handle the rest with `fallback`, or use `<SocialEmbed>`.
116
121
  - **Names:** each platform is exported under its id, as in `embed.platform`: `x`, `instagram`, `threads`, `facebook`, `tiktok`, `youtube`, `telegram`, `snapchat`, `linkedin`, `reddit`, `pinterest`, `spotify`, `vimeo`, `twitch`, `dailymotion`, `bluesky`, `soundcloud`, `applemusic`, `applepodcasts`, `tumblr`, `kick`, `giphy`, `truthsocial`, `imgur`, `tenor`, `streamable`, `strava`, `flickr` and `rumble`. `genericIframe` adds [generic iframe embeds](#generic-iframe-embeds). The order of the list does not matter.
117
122
  - **The same component:** it takes the same props and renders exactly what `<SocialEmbed>` renders for the platforms it knows. Embed code of another platform goes to `fallback`, or to `onError` as `social-embeds: unrecognised embed code`; a URL of another platform is reported as `social-embeds: not a supported post URL: …`. A frame that a named platform serves never renders as a generic iframe, even when that platform is not in the list.
118
123
  - **A client module:** call `createSocialEmbed` once, at the top of a module with `'use client'`, and import the component from there. In the Next.js App Router a Server Component cannot call it, because it comes from a client module; it can render the component it returns.
@@ -121,7 +126,7 @@ export const SocialEmbed = createSocialEmbed([
121
126
 
122
127
  Each platform component takes a `url`, or an `embed` already parsed by [`social-embeds/parser`](#parser), plus the shared props and its own option props. Option props override options from the embed code.
123
128
 
124
- A platform component bundles only its own platform's parser: one component adds about 3 to 5 KB gzipped to an app (`FacebookEmbed` about 7 KB), against about 27 KB for `<SocialEmbed>`, which recognises every platform. A URL of another platform is reported as `social-embeds: not a {Platform} post URL: …`, and an `embed` of another platform as `social-embeds: expected a {Platform} embed, got {id}`.
129
+ A platform component bundles only its own platform's parser: in a Next.js 16 production build, under Turbopack or webpack, one component adds about 3 to 5.5 KB gzipped to a page (`FacebookEmbed` about 7 KB), against about 27 KB for `<SocialEmbed>`, which recognises every platform. Before 0.9.4, under Turbopack each component added at least 15 KB. A URL of another platform is reported as `social-embeds: not a {Platform} post URL: …`, and an `embed` of another platform as `social-embeds: expected a {Platform} embed, got {id}`.
125
130
 
126
131
  ```tsx
127
132
  import {
@@ -701,6 +706,8 @@ export function Embed({ html }: { html: string }) {
701
706
 
702
707
  Client navigation needs nothing extra: each platform script loads once per page, and an embed that mounts after navigation renders without loading it again. With `lazy` (the default), a page with five embeds loads no platform script until the first embed comes near the viewport, and each embed then renders only when it comes near.
703
708
 
709
+ In a Next.js 16 production build, with Turbopack (the default) or webpack, a platform component adds about 3 to 5.5 KB gzipped to a page (`FacebookEmbed` about 7 KB), a [`createSocialEmbed`](#only-the-platforms-you-use) component with five platforms about 12 to 13 KB, and `<SocialEmbed>` about 27 KB. Before 0.9.4, any one component added at least 15 KB under Turbopack. When a page's embed code comes from a CMS and can be any platform, `<SocialEmbed>` is the component that recognises all of them.
710
+
704
711
  ## Server-side fallback content
705
712
 
706
713
  - **Embed code with fallback content** (X, Instagram, Threads, Facebook SDK code with a blockquote): the server HTML contains the platform's blockquote with its whitelisted content, such as the post text, author and link. No placeholder is shown. On the client, the platform script turns it into the post.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "social-embeds",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
4
4
  "description": "Turn social media embed code or post URLs into working React components.",
5
5
  "keywords": [
6
6
  "react",
@@ -85,7 +85,7 @@
85
85
  "@testing-library/react": "16.3.3",
86
86
  "@types/react": "19.3.0",
87
87
  "@types/react-dom": "19.3.0",
88
- "es-module-lexer": "2.3.2",
88
+ "es-module-lexer": "3.0.5",
89
89
  "eslint": "10.15.0",
90
90
  "eslint-plugin-react-hooks": "7.1.1",
91
91
  "happy-dom": "21.0.4",
@@ -95,9 +95,9 @@
95
95
  "react-dom": "19.3.1",
96
96
  "tsdown": "0.23.7",
97
97
  "typescript": "6.0.3",
98
- "typescript-eslint": "8.72.2",
98
+ "typescript-eslint": "8.73.0",
99
99
  "vite": "8.3.8",
100
- "vitest": "5.1.0"
100
+ "vitest": "5.1.1"
101
101
  },
102
102
  "scripts": {
103
103
  "build": "tsdown",