From f997216d82480331c4a788d8b6da8d87c78c872a Mon Sep 17 00:00:00 2001 From: Ralph Date: Tue, 22 Aug 2023 21:38:32 -0700 Subject: [PATCH 1/6] Updating Third party capital version. Refactor next/third-parties to update the way components are built. --- packages/third-parties/README.md | 10 +- packages/third-parties/package.json | 3 +- .../scripts/update-third-parties.js | 121 ------------------ .../src/ThirdPartyScriptEmbed.tsx | 10 +- .../src/google/GoogleMapsEmbed.tsx | 20 +++ .../third-parties/src/google/YouTubeEmbed.tsx | 35 +++++ packages/third-parties/src/google/index.tsx | 42 +----- .../third-parties/src/google/tpc-config.json | 4 - packages/third-parties/src/types/google.ts | 2 +- pnpm-lock.yaml | 8 +- .../app/google-maps-embed/page.js | 5 +- .../third-parties/app/youtube-embed/page.js | 4 +- test/e2e/app-dir/third-parties/basic.test.ts | 3 +- test/e2e/third-parties/index.test.ts | 2 +- .../third-parties/pages/google-maps-embed.js | 4 +- test/e2e/third-parties/pages/youtube-embed.js | 4 +- 16 files changed, 85 insertions(+), 192 deletions(-) delete mode 100644 packages/third-parties/scripts/update-third-parties.js create mode 100644 packages/third-parties/src/google/GoogleMapsEmbed.tsx create mode 100644 packages/third-parties/src/google/YouTubeEmbed.tsx delete mode 100644 packages/third-parties/src/google/tpc-config.json diff --git a/packages/third-parties/README.md b/packages/third-parties/README.md index 77cffc8b0c26b..f325e42a4e341 100644 --- a/packages/third-parties/README.md +++ b/packages/third-parties/README.md @@ -10,13 +10,13 @@ ### YouTube Embed -The `YoutubeEmbed` component is used to load and display a YouTube embed. This component loads faster by using [lite-youtube-embed](https://github.com/paulirish/lite-youtube-embed) under the hood. +The `YouTubeEmbed` component is used to load and display a YouTube embed. This component loads faster by using [lite-youtube-embed](https://github.com/paulirish/lite-youtube-embed) under the hood. ```js -import { YoutubeEmbed } from '@next/third-parties/google' +import { YouTubeEmbed } from '@next/third-parties/google' export default function Page() { - return + return } ``` @@ -33,8 +33,8 @@ export default function Page() { apiKey="XYZ" height={200} width="100%" - mapMode="place" - parameters="q=Brooklyn+Bridge,New+York,NY" + mode="place" + q="Brooklyn+Bridge,New+York,NY" /> ) } diff --git a/packages/third-parties/package.json b/packages/third-parties/package.json index 7490779cf980f..bfaa82bed2521 100644 --- a/packages/third-parties/package.json +++ b/packages/third-parties/package.json @@ -16,12 +16,11 @@ "scripts": { "build": "rm -rf dist && tsc -d -p tsconfig.json", "prepublishOnly": "cd ../../ && turbo run build", - "update-third-parties": "rm -rf src/**/index.tsx && node scripts/update-third-parties", "dev": "tsc -d -w -p tsconfig.json", "typescript": "tsec --noEmit -p tsconfig.json" }, "dependencies": { - "third-party-capital": "1.0.17" + "third-party-capital": "1.0.20" }, "devDependencies": { "next": "13.4.20-canary.2", diff --git a/packages/third-parties/scripts/update-third-parties.js b/packages/third-parties/scripts/update-third-parties.js deleted file mode 100644 index 5f7ed1b30e571..0000000000000 --- a/packages/third-parties/scripts/update-third-parties.js +++ /dev/null @@ -1,121 +0,0 @@ -const fs = require('fs/promises') -const path = require('path') -const AllThirdParties = require('third-party-capital') -// eslint-disable-next-line import/no-extraneous-dependencies -const prettier = require('prettier') -// eslint-disable-next-line import/no-extraneous-dependencies -const { outdent } = require('outdent') - -const scriptStrategy = { - server: 'beforeInteractive', - client: 'afterInteractive', - idle: 'lazyOnload', - worker: 'worker', -} - -const SRC = path.join(__dirname, '../src') -const CONFIG_FILE_NAME = 'tpc-config.json' - -function generateComponent(thirdParty) { - let thirdPartyFunctions = '' - - const insertScripts = (id, scripts, stylesheets) => { - let props = '' - - if (stylesheets?.length > 0) { - // TODO: Remove ts-ignore after new