diff --git a/README.md b/README.md index 55ce5923..b259c839 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ [![npm version](https://badge.fury.io/js/next-translate.svg)](https://badge.fury.io/js/next-translate) [![PRs Welcome][badge-prwelcome]][prwelcome] - - + + follow on Twitter @@ -118,10 +118,14 @@ If for some reason you use a `getInitialProps` in your `_app.js` file, then the ### Add next-translate plugin +The `next-translate-plugin` is a tool that allows developers to efficiently handle translations on a page-by-page basis during the build process. It is distinct from the `next-translate` package, which allows developers to access the translations in the code where it is needed. The plugin works by parsing all pages, searching for the translations and rewriting the page file adding the translations to it. This makes the plugin a more efficient and flexible solution for handling translations within a Next.js application. It is recommended to install the plugin as a devDependency. + +- `yarn add next-translate-plugin -D` + In your **next.config.js** file: ```js -const nextTranslate = require('next-translate') +const nextTranslate = require('next-translate-plugin') module.exports = nextTranslate() ``` @@ -129,7 +133,7 @@ module.exports = nextTranslate() Or if you already have **next.config.js** file and want to keep the changes in it, pass the config object to the `nextTranslate()`. For example for webpack you could do it like this: ```js -const nextTranslate = require('next-translate') +const nextTranslate = require('next-translate-plugin') module.exports = nextTranslate({ webpack: (config, { isServer, webpack }) => { @@ -914,7 +918,7 @@ yarn create next-app --example with-next-translate with-next-translate-app This demo is in this repository: -- `git clone git@github.com:vinissimus/next-translate.git` +- `git clone git@github.com:aralroca/next-translate.git` - `cd next-translate` - `yarn && yarn example:basic` @@ -924,7 +928,7 @@ Similar than the basic demo but with some extras: TypeScript, Webpack 5, MDX, wi This demo is in this repository: -- `git clone git@github.com:vinissimus/next-translate.git` +- `git clone git@github.com:aralroca/next-translate.git` - `cd next-translate` - `yarn && yarn example:complex` @@ -936,7 +940,7 @@ Similar than the basic example but loading the page namespaces manually deactiva This demo is in this repository: -- `git clone git@github.com:vinissimus/next-translate.git` +- `git clone git@github.com:aralroca/next-translate.git` - `cd next-translate` - `yarn && yarn example:without-loader` diff --git a/__tests__/__snapshots__/templateWithHoc.test.js.snap b/__tests__/__snapshots__/templateWithHoc.test.js.snap deleted file mode 100644 index accf35e1..00000000 --- a/__tests__/__snapshots__/templateWithHoc.test.js.snap +++ /dev/null @@ -1,451 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`templateWithHoc exporting a arrow function with Hoc skipInitialProps: false 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __appWithI18n from \\"next-translate/appWithI18n\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -import someHoc from \\"whatever\\"; -const __Next_Translate__Page__88d9831a00__ = someHoc(() => { - return
Hello world
; -}); - -export default __appWithI18n(__Next_Translate__Page__88d9831a00__, { - ...__i18nConfig, - isLoader: true, - skipInitialProps: false, - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then((m) => m.default), -}); -" -`; - -exports[`templateWithHoc exporting a arrow function with Hoc skipInitialProps: true 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __appWithI18n from \\"next-translate/appWithI18n\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -import someHoc from \\"whatever\\"; -const __Next_Translate__Page__88d9831a00__ = someHoc(() => { - return
Hello world
; -}); - -export default __appWithI18n(__Next_Translate__Page__88d9831a00__, { - ...__i18nConfig, - isLoader: true, - skipInitialProps: true, - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then((m) => m.default), -}); -" -`; - -exports[`templateWithHoc exporting a arrow function with getInitialProps skipInitialProps: false 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __appWithI18n from \\"next-translate/appWithI18n\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -const Page = () =>
Hello world
; -Page.getInitialProps = () => ({}); -const __Next_Translate__Page__88d9831a00__ = Page; - -export default __appWithI18n(__Next_Translate__Page__88d9831a00__, { - ...__i18nConfig, - isLoader: true, - skipInitialProps: false, - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then((m) => m.default), -}); -" -`; - -exports[`templateWithHoc exporting a arrow function with getInitialProps skipInitialProps: true 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __appWithI18n from \\"next-translate/appWithI18n\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -const Page = () =>
Hello world
; -Page.getInitialProps = () => ({}); -const __Next_Translate__Page__88d9831a00__ = Page; - -export default __appWithI18n(__Next_Translate__Page__88d9831a00__, { - ...__i18nConfig, - isLoader: true, - skipInitialProps: true, - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then((m) => m.default), -}); -" -`; - -exports[`templateWithHoc exporting a class with a getInitialProps static | exporting apart skipInitialProps: false 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __appWithI18n from \\"next-translate/appWithI18n\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -import React from \\"react\\"; -class Page extends React.Component { - static getInitialProps() { - return {}; - } - render() { - return
Hello world
; - } -} -const __Next_Translate__Page__88d9831a00__ = Page; - -export default __appWithI18n(__Next_Translate__Page__88d9831a00__, { - ...__i18nConfig, - isLoader: true, - skipInitialProps: false, - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then((m) => m.default), -}); -" -`; - -exports[`templateWithHoc exporting a class with a getInitialProps static | exporting apart skipInitialProps: true 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __appWithI18n from \\"next-translate/appWithI18n\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -import React from \\"react\\"; -class Page extends React.Component { - static getInitialProps() { - return {}; - } - render() { - return
Hello world
; - } -} -const __Next_Translate__Page__88d9831a00__ = Page; - -export default __appWithI18n(__Next_Translate__Page__88d9831a00__, { - ...__i18nConfig, - isLoader: true, - skipInitialProps: true, - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then((m) => m.default), -}); -" -`; - -exports[`templateWithHoc exporting a class with a getInitialProps static outside + one commented before skipInitialProps: false 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __appWithI18n from \\"next-translate/appWithI18n\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -import React from \\"react\\"; -/* -export default class FakePage extends React.Component { - render() { - return
Hello world
- } -} */ -class Page extends React.Component { - render() { - return
Hello world
; - } -} -// FakePage.getInitialProps = () => ({}) -/* - Page.getInitialProps = () => ({}) -*/ -Page.getInitialProps = () => ({}); - -export default __appWithI18n(Page, { - ...__i18nConfig, - isLoader: true, - skipInitialProps: false, - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then((m) => m.default), -}); -" -`; - -exports[`templateWithHoc exporting a class with a getInitialProps static outside + one commented before skipInitialProps: true 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __appWithI18n from \\"next-translate/appWithI18n\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -import React from \\"react\\"; -/* -export default class FakePage extends React.Component { - render() { - return
Hello world
- } -} */ -class Page extends React.Component { - render() { - return
Hello world
; - } -} -// FakePage.getInitialProps = () => ({}) -/* - Page.getInitialProps = () => ({}) -*/ -Page.getInitialProps = () => ({}); - -export default __appWithI18n(Page, { - ...__i18nConfig, - isLoader: true, - skipInitialProps: true, - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then((m) => m.default), -}); -" -`; - -exports[`templateWithHoc exporting a class with a getInitialProps static outside skipInitialProps: false 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __appWithI18n from \\"next-translate/appWithI18n\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -import React from \\"react\\"; -class Page extends React.Component { - render() { - return
Hello world
; - } -} -Page.getInitialProps = () => ({}); - -export default __appWithI18n(Page, { - ...__i18nConfig, - isLoader: true, - skipInitialProps: false, - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then((m) => m.default), -}); -" -`; - -exports[`templateWithHoc exporting a class with a getInitialProps static outside skipInitialProps: true 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __appWithI18n from \\"next-translate/appWithI18n\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -import React from \\"react\\"; -class Page extends React.Component { - render() { - return
Hello world
; - } -} -Page.getInitialProps = () => ({}); - -export default __appWithI18n(Page, { - ...__i18nConfig, - isLoader: true, - skipInitialProps: true, - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then((m) => m.default), -}); -" -`; - -exports[`templateWithHoc exporting a class with a getInitialProps static skipInitialProps: false 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __appWithI18n from \\"next-translate/appWithI18n\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -import React from \\"react\\"; -class Page extends React.Component { - static getInitialProps() { - return {}; - } - render() { - return
Hello world
; - } -} - -export default __appWithI18n(Page, { - ...__i18nConfig, - isLoader: true, - skipInitialProps: false, - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then((m) => m.default), -}); -" -`; - -exports[`templateWithHoc exporting a class with a getInitialProps static skipInitialProps: true 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __appWithI18n from \\"next-translate/appWithI18n\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -import React from \\"react\\"; -class Page extends React.Component { - static getInitialProps() { - return {}; - } - render() { - return
Hello world
; - } -} - -export default __appWithI18n(Page, { - ...__i18nConfig, - isLoader: true, - skipInitialProps: true, - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then((m) => m.default), -}); -" -`; - -exports[`templateWithHoc exporting a variable and with an existing HoC skipInitialProps: false 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __appWithI18n from \\"next-translate/appWithI18n\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -import withWrapper from \\"somewhere\\"; -function Page() { - return
Hello world
; -} -const anothervariable = withWrapper(Page); -const somevariable = anothervariable; -const __Next_Translate__Page__88d9831a00__ = somevariable; - -export default __appWithI18n(__Next_Translate__Page__88d9831a00__, { - ...__i18nConfig, - isLoader: true, - skipInitialProps: false, - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then((m) => m.default), -}); -" -`; - -exports[`templateWithHoc exporting a variable and with an existing HoC skipInitialProps: true 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __appWithI18n from \\"next-translate/appWithI18n\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -import withWrapper from \\"somewhere\\"; -function Page() { - return
Hello world
; -} -const anothervariable = withWrapper(Page); -const somevariable = anothervariable; -const __Next_Translate__Page__88d9831a00__ = somevariable; - -export default __appWithI18n(__Next_Translate__Page__88d9831a00__, { - ...__i18nConfig, - isLoader: true, - skipInitialProps: true, - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then((m) => m.default), -}); -" -`; - -exports[`templateWithHoc page with multiple commented "export default" + the correct one should do it right skipInitialProps: false 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __appWithI18n from \\"next-translate/appWithI18n\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -const Page = () =>
Hello world
; -Page.getInitialProps = () => ({}); -const __Next_Translate__Page__88d9831a00__ = Page; - -export default __appWithI18n(__Next_Translate__Page__88d9831a00__, { - ...__i18nConfig, - isLoader: true, - skipInitialProps: false, - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then((m) => m.default), -}); -" -`; - -exports[`templateWithHoc page with multiple commented "export default" + the correct one should do it right skipInitialProps: true 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __appWithI18n from \\"next-translate/appWithI18n\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -const Page = () =>
Hello world
; -Page.getInitialProps = () => ({}); -const __Next_Translate__Page__88d9831a00__ = Page; - -export default __appWithI18n(__Next_Translate__Page__88d9831a00__, { - ...__i18nConfig, - isLoader: true, - skipInitialProps: true, - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then((m) => m.default), -}); -" -`; - -exports[`templateWithHoc page without "export default" should skip any transformation skipInitialProps: false 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __appWithI18n from \\"next-translate/appWithI18n\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -const Page = () =>
Hello world
; -Page.getInitialProps = () => ({}); -const __Next_Translate__Page__88d9831a00__ = Page; - -export default __appWithI18n(__Next_Translate__Page__88d9831a00__, { - ...__i18nConfig, - isLoader: true, - skipInitialProps: false, - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then((m) => m.default), -}); -" -`; - -exports[`templateWithHoc page without "export default" should skip any transformation skipInitialProps: true 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __appWithI18n from \\"next-translate/appWithI18n\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -const Page = () =>
Hello world
; -Page.getInitialProps = () => ({}); -const __Next_Translate__Page__88d9831a00__ = Page; - -export default __appWithI18n(__Next_Translate__Page__88d9831a00__, { - ...__i18nConfig, - isLoader: true, - skipInitialProps: true, - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then((m) => m.default), -}); -" -`; diff --git a/__tests__/__snapshots__/templateWithLoader.test.js.snap b/__tests__/__snapshots__/templateWithLoader.test.js.snap deleted file mode 100644 index 767acbaa..00000000 --- a/__tests__/__snapshots__/templateWithLoader.test.js.snap +++ /dev/null @@ -1,955 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`templateWithLoader exporting as a arrow function - without loader page: /blog/[post]/[...catchall] | loader: getServerSideProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -export default () =>
Hello world
; - -async function __Next_Translate__getServerSideProps__88d9831a00__(ctx) { - return { - props: { - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/blog/[post]/[...catchall]\\", - loaderName: \\"getServerSideProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getServerSideProps__88d9831a00__ as getServerSideProps }; -" -`; - -exports[`templateWithLoader exporting as a arrow function - without loader page: /index | loader: getStaticProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -export default () =>
Hello world
; - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - return { - props: { - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; - -exports[`templateWithLoader exporting as a class - with loader page: /index | loader: getStaticProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -import React from \\"react\\"; -export default class Page extends React.Component { - render() { - return
Hello world
; - } -} -function getStaticProps() { - return { props: {} }; -} - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - const res = await getStaticProps(ctx); - return { - ...res, - props: { - ...(res.props || {}), - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; - -exports[`templateWithLoader exporting as a class in a different line - without loader page: /blog/[post]/[...catchall] | loader: getServerSideProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -import React from \\"react\\"; -class Page extends React.Component { - render() { - return
Hello world
; - } -} -const myPage = Page; -export default myPage; - -async function __Next_Translate__getServerSideProps__88d9831a00__(ctx) { - return { - props: { - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/blog/[post]/[...catchall]\\", - loaderName: \\"getServerSideProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getServerSideProps__88d9831a00__ as getServerSideProps }; -" -`; - -exports[`templateWithLoader exporting as a class in a different line - without loader page: /index | loader: getStaticProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -import React from \\"react\\"; -class Page extends React.Component { - render() { - return
Hello world
; - } -} -const myPage = Page; -export default myPage; - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - return { - props: { - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; - -exports[`templateWithLoader exporting as a function - with loader page: /index | loader: getStaticProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -export default function Page() { - return
Hello world
; -} -export function getStaticPaths() { - return {}; -} -function getStaticProps() { - return { props: {} }; -} - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - const res = await getStaticProps(ctx); - return { - ...res, - props: { - ...(res.props || {}), - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; - -exports[`templateWithLoader exporting as a function - without loader page: /blog/[post]/[...catchall] | loader: getServerSideProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -export default function Page() { - return
Hello world
; -} - -async function __Next_Translate__getServerSideProps__88d9831a00__(ctx) { - return { - props: { - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/blog/[post]/[...catchall]\\", - loaderName: \\"getServerSideProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getServerSideProps__88d9831a00__ as getServerSideProps }; -" -`; - -exports[`templateWithLoader exporting as a function - without loader page: /index | loader: getStaticProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -export default function Page() { - return
Hello world
; -} - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - return { - props: { - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; - -exports[`templateWithLoader exporting as a function in different line - with loader page: /index | loader: getServerSideProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -function Page() { - return
Hello world
; -} -function getServerSideProps() { - return { props: {} }; -} -export {}; -export default Page; - -async function __Next_Translate__getServerSideProps__88d9831a00__(ctx) { - const res = await getServerSideProps(ctx); - return { - ...res, - props: { - ...(res.props || {}), - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getServerSideProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getServerSideProps__88d9831a00__ as getServerSideProps }; -" -`; - -exports[`templateWithLoader exporting as a function in different line - without loader page: /blog/[post]/[...catchall] | loader: getServerSideProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -function Page() { - return
Hello world
; -} -export default Page; - -async function __Next_Translate__getServerSideProps__88d9831a00__(ctx) { - return { - props: { - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/blog/[post]/[...catchall]\\", - loaderName: \\"getServerSideProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getServerSideProps__88d9831a00__ as getServerSideProps }; -" -`; - -exports[`templateWithLoader exporting as a function in different line - without loader page: /index | loader: getStaticProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -function Page() { - return
Hello world
; -} -export default Page; - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - return { - props: { - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; - -exports[`templateWithLoader loader as a arrow function page: /index | loader: getStaticProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -export default function Page() { - return
Hello world
; -} -const getStaticProps = () => ({ props: {} }); -export {}; - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - const res = await getStaticProps(ctx); - return { - ...res, - props: { - ...(res.props || {}), - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; - -exports[`templateWithLoader loader as a wrapper page: /index | loader: getStaticProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -export default function Page() { - return
Hello world
; -} -const getStaticProps = wrapper.getStaticProps(() => ({ props: {} })); -export {}; - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - const res = await getStaticProps(ctx); - return { - ...res, - props: { - ...(res.props || {}), - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; - -exports[`templateWithLoader loader imported to another place page: /index | loader: getStaticProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -import getStaticProps from \\"somewhere/getStaticProps\\"; -import getStaticPaths from \\"somewhere/getStaticPaths\\"; -const config = {}; -export default function Page() { - return
Hello world
; -} -export { config, getStaticPaths }; - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - const res = await getStaticProps(ctx); - return { - ...res, - props: { - ...(res.props || {}), - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; - -exports[`templateWithLoader loader with named import to another place + rename page: /index | loader: getStaticProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -import { getStaticPropsA as getStaticProps } from \\"somewhere/getStaticProps\\"; -import { getStaticProps as getStaticPaths } from \\"somewhere/getStaticPaths\\"; -const config = {}; -export default function Page() { - return
Hello world
; -} -export { config, getStaticPaths }; - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - const res = await getStaticProps(ctx); - return { - ...res, - props: { - ...(res.props || {}), - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; - -exports[`templateWithLoader loader with named import to another place page: /index | loader: getStaticProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -import { getStaticProps } from \\"somewhere/getStaticProps\\"; -import { getStaticPaths } from \\"somewhere/getStaticPaths\\"; -const config = {}; -export default function Page() { - return
Hello world
; -} -export { config, getStaticPaths }; - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - const res = await getStaticProps(ctx); - return { - ...res, - props: { - ...(res.props || {}), - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; - -exports[`templateWithLoader loader with one named import to another place page: /index | loader: getStaticProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -import { - getStaticPaths, - getStaticProps, - config, -} from \\"somewhere/getStaticProps\\"; -export default function Page() { - const test = \\"getStaticProps\\"; - console.log(\\"This should log getStaticProps without any modification\\"); - return
Hello getStaticProps
; -} -export { config, getStaticPaths }; - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - const res = await getStaticProps(ctx); - return { - ...res, - props: { - ...(res.props || {}), - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; - -exports[`templateWithLoader should add "revalidate: 55" prop into getStaticProps page: /index | loader: getStaticProps | revalidate: 55 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -function Page() { - return
Hello world
; -} -const getStaticProps = (ctx) => ({}); -export default Page; - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - const res = await getStaticProps(ctx); - return { - revalidate: 55, - ...res, - props: { - ...(res.props || {}), - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; - -exports[`templateWithLoader should allow developers to override revalidate prop per page, by having the "default" revalidate defined before "...res" page: /index | loader: getStaticProps | revalidate: 88 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -export default function Page() { - return
Hello world
; -} -function getStaticProps() { - return { revalidate: 10, props: { prop1: \\"hello\\" } }; -} - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - const res = await getStaticProps(ctx); - return { - revalidate: 88, - ...res, - props: { - ...(res.props || {}), - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; - -exports[`templateWithLoader should ignore not exported loader page: /index | loader: getStaticProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -export default function Page() { - return
Hello world
; -} -const getStaticProps = () => ({ props: {} }); - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - return { - props: { - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; - -exports[`templateWithLoader should import and use loader exported via "export { } from ..." page: /index | loader: getStaticProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -import { loader as __Next_Translate_old_getStaticProps__88d9831a00__ } from \\"somewhere\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -function Page() { - return
Hello world
; -} -export {} from \\"somewhere\\"; -export default Page; - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - const res = await __Next_Translate_old_getStaticProps__88d9831a00__(ctx); - return { - ...res, - props: { - ...(res.props || {}), - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; - -exports[`templateWithLoader should not add "revalidate" prop into getStaticProps because revalidate < 0 page: /index | loader: getStaticProps | revalidate: -1 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -function Page() { - return
Hello world
; -} -const getStaticProps = (ctx) => ({}); -export default Page; - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - const res = await getStaticProps(ctx); - return { - ...res, - props: { - ...(res.props || {}), - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; - -exports[`templateWithLoader should not add "revalidate" prop into getStaticProps because revalidate = 0 page: /index | loader: getStaticProps | revalidate: 0 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -function Page() { - return
Hello world
; -} -const getStaticProps = (ctx) => ({}); -export default Page; - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - const res = await getStaticProps(ctx); - return { - ...res, - props: { - ...(res.props || {}), - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; - -exports[`templateWithLoader should remove exports of existing loader with "as" #1 page: /index | loader: getStaticProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -export { anotherThing }; - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - const res = await test(ctx); - return { - ...res, - props: { - ...(res.props || {}), - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; - -exports[`templateWithLoader should remove exports of existing loaders with "as" #2 page: /index | loader: getStaticProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -export {}; - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - const res = await test(ctx); - return { - ...res, - props: { - ...(res.props || {}), - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; - -exports[`templateWithLoader should remove exports of existing loaders with "as" #3 page: /index | loader: getStaticProps 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -export { something, getStaticPropsB }; - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - const res = await AgetStaticProps(ctx); - return { - ...res, - props: { - ...(res.props || {}), - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; - -exports[`templateWithLoader should use the revalidate value already present on getStaticProps arrow function page: /index | loader: getStaticProps | revalidate: 77 1`] = ` -"import __i18nConfig from \\"@next-translate-root/i18n\\"; -import __loadNamespaces from \\"next-translate/loadNamespaces\\"; -(\\"$SomeString$\\"); -$$SomeString$$ & $SomeString$ & \`$SomeString$\`; -(\\".cssClass{content:' ';\\"); -('Hello \\"world\\"'); -import { GetStaticProps } from \\"next\\"; -export default function Page() { - return
Hello world
; -} -const getStaticProps: GetStaticProps = () => { - return { revalidate: 10, props: { prop1: \\"hello\\" } }; -}; - -async function __Next_Translate__getStaticProps__88d9831a00__(ctx) { - const res = await getStaticProps(ctx); - return { - revalidate: 77, - ...res, - props: { - ...(res.props || {}), - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: \\"/index\\", - loaderName: \\"getStaticProps\\", - loadLocaleFrom: (l, n) => - import(\`@next-translate-root/locales/\${l}/\${n}\`).then( - (m) => m.default - ), - })), - }, - }; -} -export { __Next_Translate__getStaticProps__88d9831a00__ as getStaticProps }; -" -`; diff --git a/__tests__/hasHOC.test.js b/__tests__/hasHOC.test.js deleted file mode 100644 index 2a0d686b..00000000 --- a/__tests__/hasHOC.test.js +++ /dev/null @@ -1,538 +0,0 @@ -import { parseCode, hasHOC } from '../src/plugin/utils' - -describe('hasHOC', () => { - describe('HOC -> should return true', () => { - test('with -> export default somevariable (in case is it)', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - import withWrapper from 'somewhere' - - function Page() { - return
Hello world
- } - - const anothervariable = withWrapper(Page); - const somevariable = anothervariable; - - export default somevariable - ` - ) - ) - ).toBe(true) - }) - test('with -> curry config on HOC', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - import React from 'react'; - import Head from 'next/head'; - import { withUrqlClient } from 'next-urql'; - - const Index = () => { - const [result] = useQuery({ - query: '{ test }', - }); - return null - }; - - export default withUrqlClient((_ssrExchange, ctx) => ({ - url: 'http://localhost:3000/graphql', - },{ssr:true}))(Index); - ` - ) - ) - ).toBe(true) - }) - test('with -> curry config on HOC in a class', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - import React from 'react'; - import Head from 'next/head'; - import { withUrqlClient } from 'next-urql'; - - class Index { - render() { - return null - } - } - - export default withUrqlClient((_ssrExchange, ctx) => ({ - url: 'http://localhost:3000/graphql', - },{ssr:true}))(Index); - ` - ) - ) - ).toBe(true) - }) - test('with -> curry empty config on HOC', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - import React from 'react'; - import Head from 'next/head'; - import { withHOC } from 'hoc-example'; - - const Index = () => null - - export default withHOC()(Index); - ` - ) - ) - ).toBe(true) - }) - test('with -> curry config on HOC in different order', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - import React from 'react'; - import Head from 'next/head'; - import { withHOC } from 'hoc-example'; - - const Index = () => null - - export default withHOC(Index)({ someconfig: true })(); - ` - ) - ) - ).toBe(true) - }) - test('with -> curry empty config on HOC with a reference', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - import React from 'react'; - import Head from 'next/head'; - import { withHOC } from 'hoc-example'; - - const Index = () => null - - const refComp = withHOC()(Index); - - export default refComp - ` - ) - ) - ).toBe(true) - }) - test('with -> with withTranslation + another hoc', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - import withTranslation from 'next-translate/withTranslation' - import withWrapper from 'somewhere' - - function Page() { - return
Hello world
- } - - const anothervariable = withWrapper(Page); - const somevariable = anothervariable; - - export default withTranslation(somevariable) - ` - ) - ) - ).toBe(true) - }) - test('with -> export default withWrapper(Page)', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - import withWrapper from 'somewhere' - - function Page() { - return
Hello world
- } - - export default withWrapper(Page) - ` - ) - ) - ).toBe(true) - }) - }) - - describe('HOC -> should return false', () => { - test('with -> arrow function with TS type', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - import { NextPage } from 'next' - import useTranslation from 'next-translate/useTranslation' - import React from 'react' - - const NotFoundPage: NextPage = () => { - const { t } = useTranslation() - return
{t('error:page-not-found')}
- } - - export default NotFoundPage - ` - ) - ) - ).toBe(false) - }) - test('with -> any export default', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - // missing export - function Page() { - return
Hello world
- } - ` - ) - ) - ).toBe(false) - }) - test('with -> curry config on fake HOC', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - import React from 'react'; - import Head from 'next/head'; - import { withUrqlClient } from 'next-urql'; - - const Index = () => { - const [result] = useQuery({ - query: '{ test }', - }); - return null - }; - - const fakeHoc = withUrqlClient((_ssrExchange, ctx) => ({ - url: 'http://localhost:3000/graphql', - },{ssr:true}))(Index); - - export default Index - ` - ) - ) - ).toBe(false) - }) - test('with -> export default function', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - export default function Page() { - return
Hello world
- } - ` - ) - ) - ).toBe(false) - }) - test('with -> export default class', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - export default class Page { // (some comment) - render() { - return
Hello world
- } - } - ` - ) - ) - ).toBe(false) - }) - test('with -> export default function with props', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - export default function Page(Props) { - return
Hello world
- } - ` - ) - ) - ).toBe(false) - }) - test('with -> export default arrow function with props', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - export default (Props) => { - return
Hello world
- } - ` - ) - ) - ).toBe(false) - }) - test('with -> export default arrow function with destructured props', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - export default ({ title }) => { - return
Hello world
- } - ` - ) - ) - ).toBe(false) - }) - test('with -> export default Page', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - function Page() { - return
Hello world
- } - - export default Page; - ` - ) - ) - ).toBe(false) - }) - test("with -> export default somevariable (in case isn't)", () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - function Page() { - return
Hello world
- } - - const somevariable = Page - - export default somevariable; - ` - ) - ) - ).toBe(false) - }) - test('with -> export default () => {}', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - export default () => { - return
Hello world
- } - ` - ) - ) - ).toBe(false) - }) - test('with -> export default somevariable', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - function Page() { - return
Hello world
- } - - const somevariable = Page; - - export default somevariable - ` - ) - ) - ).toBe(false) - }) - test('with -> export default Page + withFakeHOC', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - import useTranslation from 'next-translate/useTranslation' - - const withFakeHOC = (C) => (p) => - - // Just for tests - function PageWithHOC() { - const { t } = useTranslation() - return
{t\`common:title\`}
- } - - export default PageWithHOC - ` - ) - ) - ).toBe(false) - }) - test('with -> with withTranslation', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - import useTranslation from 'next-translate/useTranslation' - import withTranslation from 'next-translate/withTranslation' - - const withHOC = (C) => (p) => - - // Just for tests - function PageWithHOC() { - const { t } = useTranslation() - return
{t\`common:title\`}
- } - - export default withTranslation(PageWithHOC) - ` - ) - ) - ).toBe(false) - }) - test('with -> with renamed withTranslation', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - import useTranslation from 'next-translate/useTranslation' - import justI18nHoc from 'next-translate/withTranslation' - - const withHOC = (C) => (p) => - - // Just for tests - function PageWithHOC() { - const { t } = useTranslation() - return
{t\`common:title\`}
- } - - export default justI18nHoc(PageWithHOC) - ` - ) - ) - ).toBe(false) - }) - test('with -> it has getStaticProps in a wrapper', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - import withWrapper from 'somewhere' - - function Page() { - return
Hello world
- } - - export const getStaticProps = wrapper() - ` - ) - ) - ).toBe(false) - }) - test('with -> it has getStaticProps', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - import withWrapper from 'somewhere' - - function Page() { - return
Hello world
- } - - export function getStaticProps() { - return { - props: {} - } - } - - export default withWrapper(Page) - ` - ) - ) - ).toBe(false) - }) - - test('with -> it has getStaticProps exported as {}', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - import withWrapper from 'somewhere' - - function Page() { - return
Hello world
- } - - function getStaticProps() { - return { - props: {} - } - } - - export { getStaticProps } - - export default withWrapper(Page) - ` - ) - ) - ).toBe(false) - }) - - test('with -> it has getServerSideProps', () => { - expect( - hasHOC( - parseCode( - 'jsx', - ` - import withWrapper from 'somewhere' - - function Page() { - return
Hello world
- } - - export const getServerSideProps() { - return { - props: {} - } - } - - export default withWrapper(Page) - ` - ) - ) - ).toBe(false) - }) - }) -}) diff --git a/__tests__/templateWith.utils.js b/__tests__/templateWith.utils.js deleted file mode 100644 index 40588b9f..00000000 --- a/__tests__/templateWith.utils.js +++ /dev/null @@ -1,18 +0,0 @@ -import prettier from 'prettier' - -const specialPatternsOfReplaceMethod = ["$'", '$$', '$&', '$`'] - -// take each pattern and create a string including the reversed version -// i.e. $' => '$SomeString$' -const specialPatternsCases = specialPatternsOfReplaceMethod.map( - (pattern) => `${pattern.split('').reverse().join('')}SomeString${pattern}` -) -const nestedQuotesCases = [`".cssClass{content:' ';"`, `'Hello "world"'`] - -export const specialStringsRenderer = specialPatternsCases - .concat(nestedQuotesCases) - .join('\n') - -export function clean(code) { - return prettier.format(code, { parser: 'typescript' }) -} diff --git a/__tests__/templateWithHoc.test.js b/__tests__/templateWithHoc.test.js deleted file mode 100644 index 04a65cd8..00000000 --- a/__tests__/templateWithHoc.test.js +++ /dev/null @@ -1,170 +0,0 @@ -import templateWithHoc from '../src/plugin/templateWithHoc' -import { parseCode } from '../src/plugin/utils' -import { specialStringsRenderer, clean } from './templateWith.utils' - -const tests = [ - { - describe: 'exporting a variable and with an existing HoC', - code: ` - import withWrapper from 'somewhere' - - function Page() { - return
Hello world
- } - - const anothervariable = withWrapper(Page); - const somevariable = anothervariable; - - export default somevariable - `, - cases: [{ skipInitialProps: false }, { skipInitialProps: true }], - }, - { - describe: 'exporting a class with a getInitialProps static outside', - code: ` - import React from 'react'; - - export default class Page extends React.Component { - render() { - return
Hello world
- } - } - - Page.getInitialProps = () => ({}) - `, - cases: [{ skipInitialProps: false }, { skipInitialProps: true }], - }, - { - describe: - 'exporting a class with a getInitialProps static outside + one commented before', - code: ` - import React from 'react'; - - /* - export default class FakePage extends React.Component { - render() { - return
Hello world
- } - } */ - - export default class Page extends React.Component { - render() { - return
Hello world
- } - } - - // FakePage.getInitialProps = () => ({}) - /* - Page.getInitialProps = () => ({}) - */ - Page.getInitialProps = () => ({}) - `, - cases: [{ skipInitialProps: false }, { skipInitialProps: true }], - }, - { - describe: 'exporting a class with a getInitialProps static', - code: ` - import React from 'react'; - - export default class Page extends React.Component { - static getInitialProps() { - return {} - } - - render() { - return
Hello world
- } - } - `, - cases: [{ skipInitialProps: false }, { skipInitialProps: true }], - }, - { - describe: - 'exporting a class with a getInitialProps static | exporting apart', - code: ` - import React from 'react'; - - class Page extends React.Component { - static getInitialProps() { - return {} - } - - render() { - return
Hello world
- } - } - - export default Page - `, - cases: [{ skipInitialProps: false }, { skipInitialProps: true }], - }, - { - describe: 'exporting a arrow function with Hoc', - code: ` - import someHoc from 'whatever' - - export default someHoc(() => { - return
Hello world
- }) - `, - cases: [{ skipInitialProps: false }, { skipInitialProps: true }], - }, - { - describe: 'exporting a arrow function with getInitialProps', - code: ` - const Page = () =>
Hello world
- - Page.getInitialProps = () => ({}) - - export default Page - `, - cases: [{ skipInitialProps: false }, { skipInitialProps: true }], - }, - { - describe: 'page without "export default" should skip any transformation', - code: ` - const Page = () =>
Hello world
- - Page.getInitialProps = () => ({}) - - export default Page - `, - cases: [{ skipInitialProps: false }, { skipInitialProps: true }], - }, - { - describe: - 'page with multiple commented "export default" + the correct one should do it right', - code: ` - const Page = () =>
Hello world
- - Page.getInitialProps = () => ({}) - - // export default Page - /* - export default Page - */ - export default Page - `, - cases: [{ skipInitialProps: false }, { skipInitialProps: true }], - }, -].map((t) => { - t.code = specialStringsRenderer + '\n' + t.code - return t -}) - -describe('templateWithHoc', () => { - tests.forEach((d) => { - describe(d.describe, () => { - d.cases.forEach(({ expected, debug, ...options }) => { - const fn = debug ? test.only : test - const testName = Object.entries(options).map(([k, v]) => `${k}: ${v}`) - fn(testName.join(' | '), () => { - Date.now = jest.fn(() => 587764800000) - expect( - clean(templateWithHoc(parseCode('jsx', d.code), options)) - ).toMatchSnapshot() - }) - }) - }) - }) -}) diff --git a/__tests__/templateWithLoader.test.js b/__tests__/templateWithLoader.test.js deleted file mode 100644 index af49655b..00000000 --- a/__tests__/templateWithLoader.test.js +++ /dev/null @@ -1,460 +0,0 @@ -import templateWithLoader from '../src/plugin/templateWithLoader' -import { parseCode } from '../src/plugin/utils' -import { specialStringsRenderer, clean } from './templateWith.utils' - -const tests = [ - { - describe: 'exporting as a function - with loader', - code: ` - export default function Page() { - return
Hello world
- } - - export function getStaticPaths() { - return {} - } - - export function getStaticProps(){ - return { props: {} } - } - `, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - }, - ], - }, - { - describe: 'exporting as a function - without loader', - code: ` - export default function Page() { - return
Hello world
- } - `, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - }, - { - page: '/blog/[post]/[...catchall]', - loader: 'getServerSideProps', - }, - ], - }, - { - describe: 'exporting as a arrow function - without loader', - code: `export default () =>
Hello world
`, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - }, - { - page: '/blog/[post]/[...catchall]', - loader: 'getServerSideProps', - }, - ], - }, - { - describe: 'exporting as a function in different line - with loader', - code: ` - function Page() { - return
Hello world
- } - - function getServerSideProps() { - return { props: {} } - } - - export { getServerSideProps } - export default Page - `, - cases: [ - { - page: '/index', - loader: 'getServerSideProps', - }, - ], - }, - { - describe: 'exporting as a function in different line - without loader', - code: ` - function Page() { - return
Hello world
- } - - export default Page - `, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - }, - { - page: '/blog/[post]/[...catchall]', - loader: 'getServerSideProps', - }, - ], - }, - { - describe: 'exporting as a class - with loader', - code: ` - import React from 'react' - - export default class Page extends React.Component { - render() { - return
Hello world
- } - } - - export function getStaticProps(){ - return { props: {} } - } - `, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - }, - ], - }, - { - describe: 'exporting as a class in a different line - without loader', - code: ` - import React from 'react' - - class Page extends React.Component { - render() { - return
Hello world
- } - } - - const myPage = Page - - export default myPage - `, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - }, - { - page: '/blog/[post]/[...catchall]', - loader: 'getServerSideProps', - }, - ], - }, - { - describe: 'loader as a arrow function', - code: ` - export default function Page() { - return
Hello world
- } - - const getStaticProps = () => ({ props: {} }) - export { getStaticProps } - `, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - }, - ], - }, - { - describe: 'loader as a wrapper', - code: ` - export default function Page() { - return
Hello world
- } - - const getStaticProps = wrapper.getStaticProps(() => ({ props: {} })) - export { getStaticProps } - `, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - }, - ], - }, - { - describe: 'loader imported to another place', - code: ` - import getStaticProps from 'somewhere/getStaticProps' - import getStaticPaths from 'somewhere/getStaticPaths' - - const config = {} - - export default function Page() { - return
Hello world
- } - - export { config, getStaticProps, getStaticPaths } - `, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - }, - ], - }, - { - describe: 'loader with named import to another place', - code: ` - import { getStaticProps } from 'somewhere/getStaticProps' - import { getStaticPaths } from 'somewhere/getStaticPaths' - - const config = {} - - export default function Page() { - return
Hello world
- } - - export { config, getStaticProps, getStaticPaths } - `, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - }, - ], - }, - { - describe: 'loader with one named import to another place', - code: ` - import { getStaticPaths, getStaticProps, config } from 'somewhere/getStaticProps' - - export default function Page() { - const test = 'getStaticProps' - console.log('This should log getStaticProps without any modification') - return
Hello getStaticProps
- } - - export { config, getStaticProps, getStaticPaths } - `, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - }, - ], - }, - { - describe: 'loader with named import to another place + rename', - code: ` - import { getStaticPropsA as getStaticProps } from 'somewhere/getStaticProps' - import { getStaticProps as getStaticPaths } from 'somewhere/getStaticPaths' - - const config = {} - - export default function Page() { - return
Hello world
- } - - export { config, getStaticProps, getStaticPaths } - `, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - }, - ], - }, - { - describe: 'should ignore not exported loader', - code: ` - export default function Page() { - return
Hello world
- } - - const getStaticProps = () => ({ props: {} }) - `, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - }, - ], - }, - { - describe: 'should remove exports of existing loader with "as" #1', - code: ` - export { - test as getStaticProps, - anotherThing - } - `, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - }, - ], - }, - { - describe: 'should remove exports of existing loaders with "as" #2', - code: ` - export { test as getStaticProps } - `, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - }, - ], - }, - { - describe: 'should remove exports of existing loaders with "as" #3', - code: ` - export {something,AgetStaticProps as getStaticProps, getStaticPropsB} - `, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - }, - ], - }, - { - describe: 'should import and use loader exported via "export { } from ..."', - code: ` - function Page() { - return
Hello world
- } - - export { loader as getStaticProps } from 'somewhere' - - export default Page - `, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - }, - ], - }, - { - describe: 'should add "revalidate: 55" prop into getStaticProps', - code: ` - function Page() { - return
Hello world
- } - - export const getStaticProps = (ctx) => ({}) - - export default Page - `, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - revalidate: 55, - }, - ], - }, - { - describe: - 'should not add "revalidate" prop into getStaticProps because revalidate = 0', - code: ` - function Page() { - return
Hello world
- } - - export const getStaticProps = (ctx) => ({}) - - export default Page - `, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - revalidate: 0, - }, - ], - }, - { - describe: - 'should not add "revalidate" prop into getStaticProps because revalidate < 0', - code: ` - function Page() { - return
Hello world
- } - - export const getStaticProps = (ctx) => ({}) - - export default Page - `, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - revalidate: -1, - }, - ], - }, - { - describe: - 'should allow developers to override revalidate prop per page, by having the "default" revalidate defined before "...res"', - code: ` - export default function Page() { - return
Hello world
- } - - export function getStaticProps(){ - return { revalidate:10, props: { prop1: 'hello' } } - } - `, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - revalidate: 88, - }, - ], - }, - { - describe: - 'should use the revalidate value already present on getStaticProps arrow function', - code: ` - import { GetStaticProps } from 'next' - - export default function Page() { - return
Hello world
- } - - export const getStaticProps: GetStaticProps = () => { - return { revalidate:10, props: { prop1: 'hello' } } - } - `, - cases: [ - { - page: '/index', - loader: 'getStaticProps', - revalidate: 77, - }, - ], - }, -].map((t) => { - t.code = specialStringsRenderer + '\n' + t.code - return t -}) - -describe('templateWithLoader', () => { - tests.forEach((d) => { - describe(d.describe, () => { - d.cases.forEach(({ expected, debug, ...options }) => { - const fn = debug ? test.only : test - const testName = Object.entries(options).map(([k, v]) => `${k}: ${v}`) - fn(testName.join(' | '), () => { - Date.now = jest.fn(() => 587764800000) - expect( - clean(templateWithLoader(parseCode('jsx', d.code), options)) - ).toMatchSnapshot() - }) - }) - }) - }) -}) diff --git a/__tests__/utils.test.js b/__tests__/utils.test.js deleted file mode 100644 index 1ebe3852..00000000 --- a/__tests__/utils.test.js +++ /dev/null @@ -1,73 +0,0 @@ -import { isPageToIgnore } from '../src/plugin/utils' - -describe('utils', () => { - describe('utils -> isPageToIgnore', () => { - const testPath = (path, expected) => { - const extensions = ['js', 'jsx', 'ts', 'tsx'] - extensions.forEach((extension) => { - expect(isPageToIgnore(`${path}.${extension}`)).toBe(expected) - }) - } - - test('ignores api pages', () => { - testPath('/api/test', true) - }) - - test('ignores nested api pages', () => { - testPath('/api/nested/test', true) - }) - - test('ignores _document', () => { - testPath('/_document', true) - }) - - test('ignores root middleware', () => { - expect(isPageToIgnore(`/middleware.js`)).toBe(true) - expect(isPageToIgnore(`/middleware.ts`)).toBe(true) - }) - - test('ignores _middleware', () => { - testPath('/_middleware', true) - }) - - test('ignores nested _middleware', () => { - testPath('/nested/_middleware', true) - }) - - test('ignores files in __mocks__ folder', () => { - testPath('/__mocks__/test', true) - }) - - test('ignores files in __tests__ folder', () => { - testPath('/__tests__/test', true) - }) - - test('ignores .test files', () => { - testPath('/file.test', true) - }) - - test('ignores nested .test files', () => { - testPath('/nested/file.test', true) - }) - - test('ignores .spec files', () => { - testPath('/file.spec', true) - }) - - test('ignores nested .spec files', () => { - testPath('/nested/file.spec', true) - }) - - test('does not ignore _app', () => { - testPath('_app', false) - }) - - test('does not ignore page files', () => { - testPath('index', false) - }) - - test('does not ignore nested page files', () => { - testPath('/nested/index', false) - }) - }) -}) diff --git a/build-packages.js b/build-packages.js index 14676f19..797499fc 100644 --- a/build-packages.js +++ b/build-packages.js @@ -34,4 +34,3 @@ function createPackagesFromFolder(folder, prefix, subfolder = '') { } createPackagesFromFolder(path.join(__dirname, 'src'), '../') -createPackageFromFile('loader.tsx', '../../', 'plugin/') diff --git a/docs/migration-guide-1.0.0.md b/docs/migration-guide-1.0.0.md index 7ccd202c..269833d7 100644 --- a/docs/migration-guide-1.0.0.md +++ b/docs/migration-guide-1.0.0.md @@ -2,12 +2,12 @@ This migration guide describes how to upgrade existing projects using `next-translate@0.x` to `next-translate@1.0.0`. -- [About 1.0](https://dev-blog.vinissimus.com/next-translate-1.0) -- [Release notes about 1.0](https://github.com/vinissimus/next-translate/releases/tag/1.0.0) +- [About 1.0](https://dev-blog.aralroca.com/next-translate-1.0) +- [Release notes about 1.0](https://github.com/aralroca/next-translate/releases/tag/1.0.0) - [Demo video with 1.0](https://www.youtube.com/watch?v=QnCIjjYLCfc) -- [Examples with 1.0](https://github.com/vinissimus/next-translate/tree/1.0.0/examples) +- [Examples with 1.0](https://github.com/aralroca/next-translate/tree/1.0.0/examples) -**If you are using a version prior to `0.19`, you should first [follow these steps](https://github.com/vinissimus/next-translate/releases/tag/0.19.0) to migrate to `0.19` because it has some breaking changes.** +**If you are using a version prior to `0.19`, you should first [follow these steps](https://github.com/aralroca/next-translate/releases/tag/0.19.0) to migrate to `0.19` because it has some breaking changes.** This guide is useful both if you used the **"build step"** and if you used a **`getInitialProps` on top of `_app.js`** with the `appWithI18n`, since both have been unified under the webpack loader. @@ -112,7 +112,7 @@ function MyApp({ Component, pageProps }: AppProps) { +export default MyApp ``` -8. Replace `_plural` suffixes to `_other`. We are now supporting 6 plural forms, more info [in the README](https://github.com/vinissimus/next-translate/blob/1.0.0/README.md#5-plurals). +8. Replace `_plural` suffixes to `_other`. We are now supporting 6 plural forms, more info [in the README](https://github.com/aralroca/next-translate/blob/1.0.0/README.md#5-plurals). ```diff { diff --git a/docs/migration-guide-2.0.0.md b/docs/migration-guide-2.0.0.md new file mode 100644 index 00000000..95326cad --- /dev/null +++ b/docs/migration-guide-2.0.0.md @@ -0,0 +1,22 @@ +# Migrating from next-translate v1 to v2 + +In version 2 of the **next-translate** library, we have made a significant change to the way the Webpack plugin is implemented. This change improves the library by solving many of the issues reported by users and makes it more powerful. However, it also means that two of the library's rules have been broken - it is now slightly larger and has a dependency on a specific version of the TypeScript parser. + +To address this, we have split the library into two separate packages. The main package, **[next-translate](https://github.com/aralroca/next-translate)**, is used as before and handles all of the translation functionality. The new package, **[next-translate-plugin](https://github.com/aralroca/next-translate-plugin)**, is used specifically for the Webpack plugin and should only be used in the `next.config.js` file. + +It's worth noting that by splitting the library into two packages and only using the `next-translate-plugin` in the `next.config.js` file, we are able to ensure that the extra kilobytes added by the TypeScript parser are only loaded during the build process and not included in the final bundle that is served to the client. This helps to keep the size of the final bundle as small as possible and improves the performance of your application. Additionally, by listing the `next-translate-plugin` will be installed as devDependency to reduce the extra kilobytes in the pipeline. + +To migrate your project to use version 2, you will need to make the following changes: + +- Install the **next-translate-plugin** package as a devDependency using `yarn add -D next-translate-plugin` or `npm install --save-dev next-translate-plugin` +- In your `next.config.js` file, replace `require('next-translate')` with `require('next-translate-plugin')` + +Example of `next.config.js`: + +```js +const nextTranslate = require('next-translate-plugin') + +module.exports = nextTranslate() +``` + +After making these changes, your project should be fully migrated to the latest version of next-translate diff --git a/examples/basic/next-env.d.ts b/examples/basic/next-env.d.ts new file mode 100644 index 00000000..4f11a03d --- /dev/null +++ b/examples/basic/next-env.d.ts @@ -0,0 +1,5 @@ +/// +/// + +// NOTE: This file should not be edited +// see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/examples/basic/next.config.js b/examples/basic/next.config.js index 27f12ebe..5c08f5cb 100644 --- a/examples/basic/next.config.js +++ b/examples/basic/next.config.js @@ -1,3 +1,3 @@ -const nextTranslate = require('next-translate') +const nextTranslate = require('next-translate-plugin') module.exports = nextTranslate() diff --git a/examples/basic/package.json b/examples/basic/package.json index a37b3d37..8a929510 100644 --- a/examples/basic/package.json +++ b/examples/basic/package.json @@ -8,9 +8,12 @@ "build": "next build" }, "dependencies": { - "next": "13.1.2", + "next": "13.1.3", "next-translate": "link:../../", "react": "link:../../node_modules/react", "react-dom": "link:../../node_modules/react-dom" + }, + "devDependencies": { + "next-translate-plugin": "2.0.0-canary.6" } } diff --git a/examples/basic/tsconfig.json b/examples/basic/tsconfig.json new file mode 100644 index 00000000..c9f7567c --- /dev/null +++ b/examples/basic/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "strict": false, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "incremental": true, + "esModuleInterop": true, + "module": "esnext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve" + }, + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "pages/**/*.js"], + "exclude": ["node_modules"] +} diff --git a/examples/complex/i18n.js b/examples/complex/i18n.js index 1815c75d..05c760cf 100644 --- a/examples/complex/i18n.js +++ b/examples/complex/i18n.js @@ -13,6 +13,6 @@ module.exports = { prefix: '${', suffix: '}', }, - loadLocaleFrom: (locale, namespace) => - import(`./src/translations/${namespace}_${locale}`).then((m) => m.default), + loadLocaleFrom: async (locale, namespace) => + require(`./src/translations/${namespace}_${locale}`), } diff --git a/examples/complex/next.config.js b/examples/complex/next.config.js index 91514515..140e5013 100644 --- a/examples/complex/next.config.js +++ b/examples/complex/next.config.js @@ -1,4 +1,4 @@ -const nextTranslate = require('next-translate') +const nextTranslate = require('next-translate-plugin') const withMDX = require('@next/mdx')() const withBundleAnalyzer = require('@next/bundle-analyzer')({ enabled: process.env.ANALYZE === 'true', diff --git a/examples/complex/package.json b/examples/complex/package.json index a15c4a49..77f8fefd 100644 --- a/examples/complex/package.json +++ b/examples/complex/package.json @@ -10,16 +10,18 @@ }, "dependencies": { "@mdx-js/loader": "2.2.1", - "@next/mdx": "13.1.2", - "next": "13.1.2", + "@mdx-js/react": "2.2.1", + "@next/mdx": "13.1.3", + "next": "13.1.3", "next-translate": "link:../../", "react": "link:../../node_modules/react", "react-dom": "link:../../node_modules/react-dom" }, "devDependencies": { - "@next/bundle-analyzer": "13.1.1", + "@next/bundle-analyzer": "13.1.3", "@types/node": "18.11.18", - "@types/react": "18.0.26", + "@types/react": "18.0.27", + "next-translate-plugin": "2.0.0-canary.6", "typescript": "4.9.4" }, "resolutions": { diff --git a/examples/complex/src/pages/_middleware.ts b/examples/complex/src/_middleware.ts similarity index 100% rename from examples/complex/src/pages/_middleware.ts rename to examples/complex/src/_middleware.ts diff --git a/examples/complex/src/components/header.tsx b/examples/complex/src/components/header.tsx index 5f2220ee..12615720 100644 --- a/examples/complex/src/components/header.tsx +++ b/examples/complex/src/components/header.tsx @@ -9,6 +9,7 @@ import styles from './header.module.css' export default function Header() { const { t, lang } = useTranslation() const title = t('common:title') + const headTitle = `${title} (${lang.toUpperCase()})` function changeToEn() { Router.push('/', undefined, { locale: 'en' }) @@ -17,9 +18,7 @@ export default function Header() { return ( <> - - {title} | ({lang.toUpperCase()}) - + {headTitle}
diff --git a/examples/without-loader/i18n.js b/examples/without-loader/i18n.js index 2a931f31..ab74429e 100644 --- a/examples/without-loader/i18n.js +++ b/examples/without-loader/i18n.js @@ -10,6 +10,6 @@ module.exports = { 'rgx:^/more-examples': ['more-examples'], }, // When loader === false, then loadLocaleFrom is required - loadLocaleFrom: (locale, namespace) => - import(`./locales/${locale}/${namespace}`).then((m) => m.default), + loadLocaleFrom: async (locale, namespace) => + require(`./locales/${locale}/${namespace}`), } diff --git a/examples/without-loader/next.config.js b/examples/without-loader/next.config.js index 27f12ebe..5c08f5cb 100644 --- a/examples/without-loader/next.config.js +++ b/examples/without-loader/next.config.js @@ -1,3 +1,3 @@ -const nextTranslate = require('next-translate') +const nextTranslate = require('next-translate-plugin') module.exports = nextTranslate() diff --git a/examples/without-loader/package.json b/examples/without-loader/package.json index a37b3d37..8a929510 100644 --- a/examples/without-loader/package.json +++ b/examples/without-loader/package.json @@ -8,9 +8,12 @@ "build": "next build" }, "dependencies": { - "next": "13.1.2", + "next": "13.1.3", "next-translate": "link:../../", "react": "link:../../node_modules/react", "react-dom": "link:../../node_modules/react-dom" + }, + "devDependencies": { + "next-translate-plugin": "2.0.0-canary.6" } } diff --git a/package.json b/package.json index 25354a8e..e33c358a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "next-translate", - "version": "2.0.0-canary.1", + "version": "2.0.0-canary.2", "description": "Tiny and powerful i18n tools (Next plugin + API) to translate your Next.js pages.", "license": "MIT", "keywords": [ @@ -20,7 +20,7 @@ ], "repository": { "type": "git", - "url": "https://github.com/vinissimus/next-translate.git" + "url": "https://github.com/aralroca/next-translate.git" }, "author": { "name": "Aral Roca Gòmez", @@ -31,7 +31,6 @@ "types": "./index.d.ts", "files": [ "lib", - "plugin*", "appWithI18n*", "DynamicNamespaces*", "I18nProvider*", @@ -47,12 +46,12 @@ "scripts": { "build": "yarn clean && cross-env NODE_ENV=production && yarn tsc", "clean": "yarn clean:build && yarn clean:examples", - "clean:build": "rm -rf lib plugin appWith* Dynamic* I18n* index context loadNa* setLang* Trans* useT* withT* getP* getC* *.d.ts getT transC* wrapT* types formatElements", + "clean:build": "rm -rf lib appWith* Dynamic* I18n* index context loadNa* setLang* Trans* useT* withT* getP* getC* *.d.ts getT transC* wrapT* types formatElements", "clean:examples": "rm -rf examples/**/.next && rm -rf examples/**/node_modules && rm -rf examples/**/yarn.lock", "example": "yarn example:complex", - "example:basic": "yarn build && cd examples/basic && yarn && yarn dev", - "example:complex": "yarn build && cd examples/complex && yarn && yarn dev", - "example:without-loader": "yarn build && cd examples/without-loader && yarn && yarn dev", + "example:basic": "yarn build && yarn --cwd examples/basic && yarn --cwd examples/basic dev", + "example:complex": "yarn build && yarn --cwd examples/complex && yarn --cwd examples/complex dev", + "example:without-loader": "yarn build && yarn --cwd examples/without-loader && yarn --cwd examples/without-loader dev", "format": "pretty-quick", "husky": "pretty-quick --staged && yarn test", "prepare": "husky install", @@ -60,10 +59,7 @@ "test": "cross-env NODE_ENV=test jest --env=jsdom", "test:coverage": "cross-env NODE_ENV=test jest --env=jsdom --coverage", "test:watch": "cross-env NODE_ENV=test jest --env=jsdom --watch", - "tsc": "./node_modules/typescript/bin/tsc -p tsconfig.json && ./node_modules/typescript/bin/tsc -p tsconfig-cjs.json && node build-packages.js" - }, - "dependencies": { - "typescript": "4.5.2" + "tsc": "tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && node build-packages.js" }, "devDependencies": { "@babel/cli": "7.20.7", @@ -71,9 +67,9 @@ "@babel/preset-env": "7.20.2", "@babel/preset-typescript": "7.18.6", "@testing-library/react": "13.4.0", - "@types/jest": "29.2.5", + "@types/jest": "29.2.6", "@types/node": "18.11.18", - "@types/react": "18.0.26", + "@types/react": "18.0.27", "@types/react-dom": "18.0.10", "@types/webpack": "5.28.0", "babel-jest": "29.3.1", @@ -83,13 +79,14 @@ "express": "4.18.2", "husky": "7.0.4", "jest": "27.3.1", - "next": "13.1.2", + "next": "13.1.3", "next-router-mock": "0.8.0", "prettier": "2.8.3", "pretty-quick": "3.1.3", "react": "18.2.0", "react-dom": "18.2.0", - "supertest": "6.3.3" + "supertest": "6.3.3", + "typescript": "4.9.4" }, "peerDependencies": { "next": ">= 10.0.0", @@ -101,6 +98,9 @@ "semi": false, "singleQuote": true }, + "engines": { + "node": ">=14.15.0" + }, "jest": { "roots": [ "/__tests__", diff --git a/src/index.tsx b/src/index.tsx index ebcc8cfc..5d35637d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,8 +1,6 @@ import { ReactElement, ReactNode } from 'react' import type { NextConfig } from 'next' -import nextTranslate from './plugin' - export interface TranslationQuery { [name: string]: any } @@ -125,5 +123,27 @@ declare global { } } +// TODO: Remove this in future versions > 2.0.0 +function nextTranslate(nextConfig: NextConfig = {}): NextConfig { + console.log(` + ######################################################################### + # # + # next-translate plugin in 2.0.0 is replaced by # + # next-translate-plugin package: # + # # + # > yarn add next-translate-plugin -D # + # or: # + # > npm install next-translate-plugin --save-dev # + # # + # replace in next.config.js file: # + # const nextTranslate = require('next-translate') # + # to: # + # const nextTranslate = require('next-translate-plugin') # + # # + ######################################################################### + `) + return nextConfig +} + module.exports = nextTranslate export default nextTranslate diff --git a/src/plugin/index.ts b/src/plugin/index.ts deleted file mode 100644 index 007d322c..00000000 --- a/src/plugin/index.ts +++ /dev/null @@ -1,131 +0,0 @@ -import fs from 'fs' -import path from 'path' -import type webpack from 'webpack' -import type { NextConfig } from 'next' - -import { parseFile, getDefaultExport, hasStaticName, hasHOC } from './utils' -import { LoaderOptions } from './types' -import { NextI18nConfig, I18nConfig } from '../' - -export default function nextTranslate(nextConfig: NextConfig = {}): NextConfig { - const test = /\.(tsx|ts|js|mjs|jsx)$/ - const basePath = pkgDir() - - // https://github.com/blitz-js/blitz/blob/canary/nextjs/packages/next/build/utils.ts#L54-L59 - const possiblePageDirs = [ - 'pages', - 'src/pages', - 'app/pages', - 'integrations/pages', - ] as const - - // NEXT_TRANSLATE_PATH env is supported both relative and absolute path - const translationDir = path.resolve( - path.relative(basePath, process.env.NEXT_TRANSLATE_PATH || '.') - ) - - const nextConfigI18n: NextI18nConfig = nextConfig.i18n || {} - let { - locales = nextConfigI18n.locales || [], - defaultLocale = nextConfigI18n.defaultLocale || 'en', - domains = nextConfigI18n.domains, - localeDetection = nextConfigI18n.localeDetection, - loader = true, - pagesInDir, - ...restI18n - } = require(path.join(translationDir, 'i18n')) as I18nConfig - - const nextConfigWithI18n: NextConfig = { - ...nextConfig, - i18n: { - locales, - defaultLocale, - domains, - localeDetection, - }, - } - - let hasGetInitialPropsOnAppJs = false - - if (!pagesInDir) { - for (const possiblePageDir of possiblePageDirs) { - if (fs.existsSync(path.join(basePath, possiblePageDir))) { - pagesInDir = possiblePageDir - break - } - } - } - - if (!pagesInDir || !fs.existsSync(path.join(basePath, pagesInDir))) { - // Pages folder not found, so we're not using the loader - return nextConfigWithI18n - } - - const pagesPath = path.join(basePath, pagesInDir) - const app = fs.readdirSync(pagesPath).find((page) => page.startsWith('_app.')) - - if (app) { - const appPkg = parseFile(basePath, path.join(pagesPath, app)) - const defaultExport = getDefaultExport(appPkg) - - if (defaultExport) { - const isGetInitialProps = hasStaticName( - appPkg, - defaultExport, - 'getInitialProps' - ) - hasGetInitialPropsOnAppJs = isGetInitialProps || hasHOC(appPkg) - } - } - - return { - ...nextConfigWithI18n, - webpack(conf: webpack.Configuration, options) { - const config: webpack.Configuration = - typeof nextConfig.webpack === 'function' - ? nextConfig.webpack(conf, options) - : conf - - // Creating some "slots" if they don't exist - if (!config.resolve) config.resolve = {} - if (!config.module) config.module = {} - if (!config.module.rules) config.module.rules = [] - - config.resolve.alias = { - ...(config.resolve.alias || {}), - '@next-translate-root': path.resolve(translationDir), - } - - // we give the opportunity for people to use next-translate without altering - // any document, allowing them to manually add the necessary helpers on each - // page to load the namespaces. - if (!loader) return config - - config.module.rules.push({ - test, - use: { - loader: 'next-translate/plugin/loader', - options: { - basePath, - pagesPath: path.join(pagesPath, '/'), - hasAppJs: Boolean(app), - hasGetInitialPropsOnAppJs, - hasLoadLocaleFrom: typeof restI18n.loadLocaleFrom === 'function', - extensionsRgx: restI18n.extensionsRgx || test, - revalidate: restI18n.revalidate || 0, - } as LoaderOptions, - }, - }) - - return config - }, - } -} - -function pkgDir() { - try { - return (require('pkg-dir').sync() as string) || process.cwd() - } catch (e) { - return process.cwd() - } -} diff --git a/src/plugin/loader.ts b/src/plugin/loader.ts deleted file mode 100644 index 7f13745c..00000000 --- a/src/plugin/loader.ts +++ /dev/null @@ -1,130 +0,0 @@ -import type webpack from 'webpack' - -import templateWithHoc from './templateWithHoc' -import templateWithLoader from './templateWithLoader' -import { - parseFile, - getDefaultAppJs, - getDefaultExport, - hasExportName, - hasStaticName, - isPageToIgnore, - hasHOC, -} from './utils' -import { LoaderOptions } from './types' - -export default function loader( - this: webpack.LoaderContext, - rawCode: string -) { - const { - basePath, - pagesPath, - hasAppJs, - hasGetInitialPropsOnAppJs, - hasLoadLocaleFrom, - extensionsRgx, - revalidate, - } = this.getOptions() - - // Normalize slashes in a file path to be posix/unix-like forward slashes - const normalizedPagesPath = pagesPath.replace(/\\/g, '/') - const normalizedResourcePath = this.resourcePath.replace(/\\/g, '/') - - // In case that there aren't /_app.js we want to overwrite the default _app - // to provide the I18Provider on top. - if (normalizedResourcePath.includes('node_modules/next/dist/pages/_app')) { - // There are cases that a default appjs is served even if it already has - // an appjs defined. For example when using a class extended from NextApp. - // For these cases we must not overwrite it. - if (hasAppJs) return rawCode - return getDefaultAppJs(hasLoadLocaleFrom) - } - - // Skip rest of files that are not inside /pages - if (!normalizedResourcePath.startsWith(normalizedPagesPath)) return rawCode - - const page = normalizedResourcePath.replace(normalizedPagesPath, '/') - const pageNoExt = page.replace(extensionsRgx, '') - const pagePkg = parseFile(basePath, normalizedResourcePath) - const defaultExport = getDefaultExport(pagePkg) - - // Skip any transformation if for some reason they forgot to write the - // "export default" on the page - if (!defaultExport) return rawCode - - // Skip any transformation if the page is not in raw code - // Fixes issue with Nx: https://github.com/vinissimus/next-translate/issues/677 - if (hasExportName(pagePkg, '__N_SSP') || hasExportName(pagePkg, '__N_SSG')) { - return rawCode - } - - // In case there is a getInitialProps in _app it means that we can - // reuse the existing getInitialProps on the top to load the namespaces. - // - // - Wrapping the _app.js with the HoC appWithI18n from next-translate - // - Do not make any transformation in the rest of the pages - // - // This way, the only modified file has to be the _app.js. - if (hasGetInitialPropsOnAppJs) { - return pageNoExt === '/_app' - ? templateWithHoc(pagePkg, { hasLoadLocaleFrom }) - : rawCode - } - - // In case the _app does not have getInitialProps, we can add only the - // I18nProvider to ensure that translations work inside _app.js - if (pageNoExt === '/_app') { - return templateWithHoc(pagePkg, { - skipInitialProps: true, - hasLoadLocaleFrom, - }) - } - - // There are some files that although they are inside pages, are not pages: - // _app, _document, /api... In that case, let's skip any transformation :) - if (isPageToIgnore(page)) return rawCode - - // This is where the most complicated part is, since to support automatic page - // optimization what we do is use: - // - // - getStaticProps by default - // - Use an existing page loader. For example if the page already uses - // getServerSideProps, in this case we need to overwrite it. - // - getServerSideProps for [dynamic] pages and [..catchall] @todo Review if - // is possible to change it to getStaticProps + getStaticPaths - // - getInitialProps when the page uses an external HoC (not the - // withTranslation HoC). - // This is in order to avoid issues because the getInitialProps is the only - // one that can be overwritten on a HoC. - // Use getInitialProps to load the namespaces - const isWrapperWithExternalHOC = hasHOC(pagePkg) - const isDynamicPage = page.includes('[') - const isGetStaticProps = hasExportName(pagePkg, 'getStaticProps') - const isGetStaticPaths = hasExportName(pagePkg, 'getStaticPaths') - const isGetServerSideProps = hasExportName(pagePkg, 'getServerSideProps') - const isGetInitialProps = hasStaticName( - pagePkg, - defaultExport, - 'getInitialProps' - ) - - const hasLoader = - isGetStaticProps || isGetServerSideProps || isGetInitialProps - - if (isGetInitialProps || (!hasLoader && isWrapperWithExternalHOC)) { - return templateWithHoc(pagePkg, { hasLoadLocaleFrom }) - } - - const loader = - isGetServerSideProps || (!hasLoader && isDynamicPage && !isGetStaticPaths) - ? 'getServerSideProps' - : 'getStaticProps' - - return templateWithLoader(pagePkg, { - page: pageNoExt, - loader, - hasLoadLocaleFrom, - revalidate, - }) -} diff --git a/src/plugin/templateWithHoc.ts b/src/plugin/templateWithHoc.ts deleted file mode 100644 index b4847382..00000000 --- a/src/plugin/templateWithHoc.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { interceptExport, overwriteLoadLocales } from './utils' -import { ParsedFilePkg } from './types' - -export default function templateWithHoc( - pagePkg: ParsedFilePkg, - { skipInitialProps = false, hasLoadLocaleFrom = false } = {} -) { - // Random string based on current time - const hash = Date.now().toString(16) - - // Removes export modifiers from the page - // and tells under what name we can get the old export - const pageVariableName = interceptExport( - pagePkg, - 'default', - `__Next_Translate__Page__${hash}__` - ) - - // Do not process code if there is no default export - const hasDefaultExport = Boolean(pageVariableName) - if (!hasDefaultExport) return pagePkg.getCode() - - return ` - import __i18nConfig from '@next-translate-root/i18n' - import __appWithI18n from 'next-translate/appWithI18n' - ${pagePkg.getCode()} - export default __appWithI18n(${pageVariableName}, { - ...__i18nConfig, - isLoader: true, - skipInitialProps: ${skipInitialProps}, - ${overwriteLoadLocales(hasLoadLocaleFrom)} - }); - ` -} diff --git a/src/plugin/templateWithLoader.ts b/src/plugin/templateWithLoader.ts deleted file mode 100644 index 530cf0e4..00000000 --- a/src/plugin/templateWithLoader.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { interceptExport, overwriteLoadLocales } from './utils' -import { ParsedFilePkg } from './types' - -export default function templateWithLoader( - pagePkg: ParsedFilePkg, - { - page = '', - loader = 'getStaticProps', - revalidate = 0, - hasLoadLocaleFrom = false, - } = {} -) { - // Random string based on current time - const hash = Date.now().toString(16) - - // Removes export modifiers from the loader, if any, - // and tells under what name we can get it - const oldLoaderName = interceptExport( - pagePkg, - loader, - `__Next_Translate_old_${loader}__${hash}__` - ) - - const newLoaderName = `__Next_Translate__${loader}__${hash}__` - const hasLoader = Boolean(oldLoaderName) - - return ` - import __i18nConfig from '@next-translate-root/i18n' - import __loadNamespaces from 'next-translate/loadNamespaces' - ${pagePkg.getCode()} - async function ${newLoaderName}(ctx) { - ${hasLoader ? `const res = await ${oldLoaderName}(ctx)` : ''} - return { - ${hasLoader && revalidate > 0 ? `revalidate: ${revalidate},` : ''} - ${hasLoader ? '...res,' : ''} - props: { - ${hasLoader ? '...(res.props || {}),' : ''} - ...(await __loadNamespaces({ - ...ctx, - ...__i18nConfig, - pathname: '${page}', - loaderName: '${loader}', - ${overwriteLoadLocales(hasLoadLocaleFrom)} - })) - } - } - } - export { ${newLoaderName} as ${loader} } - ` -} diff --git a/src/plugin/types.ts b/src/plugin/types.ts deleted file mode 100644 index b12b2ca6..00000000 --- a/src/plugin/types.ts +++ /dev/null @@ -1,25 +0,0 @@ -import ts from 'typescript' - -export interface LoaderOptions { - basePath: string - pagesPath: string - hasAppJs: boolean - hasGetInitialPropsOnAppJs: boolean - hasLoadLocaleFrom: boolean - extensionsRgx: RegExp - revalidate: number -} - -export type Transformer = ( - rootNode: ts.SourceFile, - context: ts.TransformationContext -) => ts.SourceFile - -export interface ParsedFilePkg { - program: ts.Program - checker: ts.TypeChecker - sourceFile: ts.SourceFile - fileSymbol?: ts.Symbol - transform: (transformer: Transformer) => void - getCode: () => string -} diff --git a/src/plugin/utils.ts b/src/plugin/utils.ts deleted file mode 100644 index 55e51ee5..00000000 --- a/src/plugin/utils.ts +++ /dev/null @@ -1,574 +0,0 @@ -import ts from 'typescript' -import { ParsedFilePkg, Transformer } from './types' - -const specFileOrFolderRgx = - /(__mocks__|__tests__)|(\.(spec|test)\.(tsx|ts|js|jsx)$)/ - -export const defaultLoader = - '(l, n) => import(`@next-translate-root/locales/${l}/${n}`).then(m => m.default)' - -export function getDefaultAppJs(hasLoadLocaleFrom: boolean) { - return ` - import i18nConfig from '@next-translate-root/i18n' - import appWithI18n from 'next-translate/appWithI18n' - - function MyApp({ Component, pageProps }) { - return - } - - export default appWithI18n(MyApp, { - ...i18nConfig, - skipInitialProps: true, - isLoader: true, - ${overwriteLoadLocales(hasLoadLocaleFrom)} - }) - ` -} - -export function overwriteLoadLocales(hasLoadLocaleFrom: boolean) { - if (hasLoadLocaleFrom) return '' - return `loadLocaleFrom: ${defaultLoader},` -} - -/** - * @param basePath - Path to the root of the target project - * @param cutDependencies - Whether to not include imports and the standard library - * @returns Compiler options - */ -export function getTsCompilerOptions( - basePath: string, - cutDependencies = false -): ts.CompilerOptions { - let options: ts.CompilerOptions - - const configPath = ts.findConfigFile( - basePath, - ts.sys.fileExists, - 'tsconfig.json' - ) - - if (!configPath) { - // Configuration file not found - most likely it is JS - options = { allowJs: true } - } else { - const readConfigFileResult = ts.readConfigFile(configPath, ts.sys.readFile) - const jsonConfig = readConfigFileResult.config - const convertResult = ts.convertCompilerOptionsFromJson( - jsonConfig.compilerOptions, - basePath - ) - - options = convertResult.options - } - - if (cutDependencies) { - // This allows us to ignore all files except those that are added explicitly. - // Including imports and standard library. - // This was done in order to speed up file analysis - options = { ...options, types: [], noResolve: true, noLib: true } - } - - return options -} - -/** - * @param program - File container [program]{@link ts.Program} - * @param filename - The name of the file inside the program - * @returns A file package that allows us to analyze and modify the code inside - */ -export function getFilePkg(program: ts.Program, filename: string) { - const checker = program.getTypeChecker() - const sourceFile = program.getSourceFile(filename)! - const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed }) - const fileSymbol = checker.getSymbolAtLocation(sourceFile) - let filePkg: ParsedFilePkg - - function transform(transformer: Transformer) { - const { sourceFile } = filePkg - const transformationResult = ts.transform(sourceFile, [ - (context) => (sourceFile) => transformer(sourceFile, context), - ]) - filePkg.sourceFile = transformationResult.transformed[0] - filePkg.fileSymbol = checker.getSymbolAtLocation(filePkg.sourceFile) - } - - function getCode() { - const { sourceFile } = filePkg - return printer.printNode(ts.EmitHint.Unspecified, sourceFile, sourceFile) - } - - filePkg = { program, checker, sourceFile, fileSymbol, transform, getCode } - return filePkg -} - -/** - * @param basePath - Path to the root of the target project - * @param filename - Path to JS/TS file - * @returns File package for further manipulations - */ -export function parseFile(basePath: string, filename: string): ParsedFilePkg { - const options = getTsCompilerOptions(basePath, true) - const program = ts.createProgram([filename], options) - return getFilePkg(program, filename) -} - -/** - * Does the same as "parseFile", but in a fake environment - * and for code directly (no file on disk, of course) - * - * @param format - Pseudo file extension - * @param code - Contents of the pseudo file - * @returns File package for further manipulations - */ -export function parseCode(format: string, code: string): ParsedFilePkg { - const options = getTsCompilerOptions('/', true) - const host = ts.createCompilerHost(options) - const filename = `source.${format}` - - host.getSourceFile = (fileName: string) => { - return ts.createSourceFile(fileName, code, ts.ScriptTarget.Latest) - } - - const program = ts.createProgram([filename], options, host) - return getFilePkg(program, filename) -} - -/** - * @param filePkg - File package - * @param node - The node for which we will get the symbol - * @returns Entity for more detailed analysis by the compiler - */ -export function getSymbol(filePkg: ParsedFilePkg, node: ts.Node) { - const location = ts.isVariableDeclaration(node) ? node.name : node - return filePkg.checker.getSymbolAtLocation(location) -} - -/** - * @param filePkg - File package - * @param moduleName - The name of the module about which we will receive information - * @returns If a module with this name was imported, then the map "export name: local name" - */ -export function getImportedNames(filePkg: ParsedFilePkg, moduleName: string) { - const importClause = filePkg.sourceFile.forEachChild((node) => { - if (ts.isImportDeclaration(node)) { - if (node.moduleSpecifier.getText().slice(1, -1) === moduleName) { - return node.importClause - } - } - return undefined - }) - - if (importClause) { - const exportedNamesToImported = new Map() - - // Default import - if (importClause.name) { - exportedNamesToImported.set('default', importClause.name) - } - - // Named imports - if (importClause.namedBindings) { - importClause.namedBindings.forEachChild((node) => { - if (ts.isImportSpecifier(node)) { - if (node.propertyName) { - // Alias is used - exportedNamesToImported.set(node.propertyName.getText(), node.name) - } else { - exportedNamesToImported.set(node.name.getText(), node.name) - } - } - }) - } - - return exportedNamesToImported - } - - // The requested module was not imported in the file - return undefined -} - -/** - * @param filePkg - File package - * @param parenthesizedExpression - Parenthesis expression - * @returns Content inside parenthesis - */ -export function resolveParenthesis( - filePkg: ParsedFilePkg, - parenthesizedExpression: ts.ParenthesizedExpression -): ts.Expression { - const content = parenthesizedExpression.expression - - if (ts.isParenthesizedExpression(content)) { - return resolveParenthesis(filePkg, content) - } else { - return content - } -} - -/** - * @param filePkg - File package - * @param identifier - Identifier whose declaration will be searched for - * @returns Deepest declaration, or last id found - */ -export function resolveIdentifier( - filePkg: ParsedFilePkg, - identifier: ts.Identifier -): ts.Declaration | ts.Identifier { - const identifierSymbol = getSymbol(filePkg, identifier) - - if (identifierSymbol && Array.isArray(identifierSymbol.declarations)) { - const identifierDeclaration = identifierSymbol.declarations[0] - - if (ts.isVariableDeclaration(identifierDeclaration)) { - let initializer = identifierDeclaration.initializer - if (initializer && ts.isParenthesizedExpression(initializer)) { - initializer = resolveParenthesis(filePkg, initializer) - } - if (initializer && ts.isIdentifier(initializer)) { - return resolveIdentifier(filePkg, initializer) - } - } - - return identifierDeclaration - } - - // Return the last found identifier if we can't find its definition - return identifier -} - -export function getNamedExport( - filePkg: ParsedFilePkg, - name: string, - resolveExport = true -) { - const { checker, fileSymbol } = filePkg - let exportContent: ts.Expression | ts.Declaration | undefined - - if (fileSymbol) { - const exportSymbol = checker.tryGetMemberInModuleExports(name, fileSymbol) - - if (exportSymbol && Array.isArray(exportSymbol.declarations)) { - const exportDeclaration = exportSymbol.declarations[0] - - if (resolveExport && ts.isExportAssignment(exportDeclaration)) { - exportContent = exportDeclaration.expression - if (ts.isParenthesizedExpression(exportContent)) { - exportContent = resolveParenthesis(filePkg, exportContent) - } - if (ts.isIdentifier(exportContent)) { - exportContent = resolveIdentifier(filePkg, exportContent) - } - } else { - exportContent = exportDeclaration - } - } - } - - return exportContent -} - -// Alias for `getNamedExport('default')` -export function getDefaultExport(filePkg: ParsedFilePkg, resolveExport = true) { - return getNamedExport(filePkg, 'default', resolveExport) -} - -export function hasExportName(filePkg: ParsedFilePkg, name: string) { - return Boolean(getNamedExport(filePkg, name, false)) -} - -export function getStaticName( - filePkg: ParsedFilePkg, - target: ts.Declaration | ts.Expression, - name: string -) { - const symbol = getSymbol(filePkg, target) - if (symbol) { - return filePkg.checker.tryGetMemberInModuleExports(name, symbol) - } - - return undefined -} - -export function hasStaticName( - filePkg: ParsedFilePkg, - target: ts.Declaration | ts.Expression, - name: string -) { - return Boolean(getStaticName(filePkg, target, name)) -} - -export function isPageToIgnore(pageFilePath: string) { - const fileName = pageFilePath.substring(pageFilePath.lastIndexOf('/') + 1) - return ( - pageFilePath.startsWith('/api/') || - pageFilePath.startsWith('/_document.') || - pageFilePath.startsWith('/middleware.') || - fileName.startsWith('_middleware.') || - specFileOrFolderRgx.test(pageFilePath) - ) -} - -export function hasHOC(filePkg: ParsedFilePkg) { - let defaultExport = getDefaultExport(filePkg) - - if ( - !defaultExport || - hasExportName(filePkg, 'getStaticProps') || - hasExportName(filePkg, 'getServerSideProps') || - hasExportName(filePkg, 'getStaticPaths') - ) { - return false - } - - if (ts.isVariableDeclaration(defaultExport) && defaultExport.initializer) { - defaultExport = defaultExport.initializer - if (ts.isParenthesizedExpression(defaultExport)) { - defaultExport = resolveParenthesis(filePkg, defaultExport) - } - if (ts.isIdentifier(defaultExport)) { - defaultExport = resolveIdentifier(filePkg, defaultExport) - } - - // If is exported normally (variable), is not a HOC - if (!ts.isCallExpression(defaultExport)) { - return false - } - } - - // If is exported normally (function or class), is not a HOC - if ( - ts.isFunctionDeclaration(defaultExport) || - ts.isClassDeclaration(defaultExport) - ) { - return false - } - - const importedNames = getImportedNames( - filePkg, - 'next-translate/withTranslation' - ) - const withTranslationId = importedNames?.get('default') - - // If the export is the result of a function call (except withTranslation), - // is a HOC - function isCallExpressionWithHOC(callExpression: ts.CallExpression): boolean { - const callable = callExpression.expression - const expressionsToVisit = [callable, ...callExpression.arguments] - - // Recursively check the callable part and its arguments - for (const expression of expressionsToVisit) { - if (ts.isCallExpression(expression)) { - return isCallExpressionWithHOC(expression) - } - - // detect: export default ``HOCed``(...) - if (ts.isIdentifier(expression)) { - const resolved = resolveIdentifier(filePkg, expression) - - // detect: const ``HOCed = withHOC(Page)``; export default HOCed(...) - if (ts.isVariableDeclaration(resolved)) { - let initializer = resolved.initializer - if (initializer && ts.isParenthesizedExpression(initializer)) { - initializer = resolveParenthesis(filePkg, initializer) - } - if (initializer && ts.isCallExpression(initializer)) { - return isCallExpressionWithHOC(initializer) - } - } - - // detect: import ``withHOC`` from '...' - if (ts.isImportClause(resolved)) { - if (resolved.name?.getText() !== withTranslationId?.getText()) { - return true - } - } - } - } - - return false - } - - if (ts.isCallExpression(defaultExport)) { - if (withTranslationId) { - return isCallExpressionWithHOC(defaultExport) - } else { - return true - } - } - - return false -} - -export function isNotExportModifier(modifier: ts.Modifier) { - const exportModifiers: ts.SyntaxKind[] = [ - ts.SyntaxKind.DefaultKeyword, - ts.SyntaxKind.ExportKeyword, - ] - return !exportModifiers.includes(modifier.kind) -} - -/** - * Removes the export modifiers from the entity and also - * makes it available locally by the given name - * - * @param filePkg - File package - * @param exportName - The name under which the entity was exported from the file - * @param defaultLocalName - The name that will be applied if the entity *does not* have its own - * @returns The name by which the entity can now be retrieved. Empty string if entity not found - */ -export function interceptExport( - filePkg: ParsedFilePkg, - exportName: string, - defaultLocalName: string -) { - const exportContent = getNamedExport(filePkg, exportName, false) - - // If the entity is already available by some name inside the module, - // then we use it to avoid problems due to renames - let finalLocalName = '' - - // Extra import statement if we need to redirect `export { ... } from '...'` - let extraImport: ts.ImportDeclaration | undefined - - // We do nothing and return an empty string if there is no such export name - if (!exportContent) return finalLocalName - - filePkg.transform((sourceFile, context) => { - function visitor(node: ts.Node): ts.Node { - // `export class A` - if (ts.isClassDeclaration(node) && node === exportContent) { - if (node.name) finalLocalName = node.name.getText() - - // Turning the class export into a regular declaration - return ts.factory.updateClassDeclaration( - node, - node.decorators, - node.modifiers?.filter(isNotExportModifier), - node.name ?? ts.factory.createIdentifier(defaultLocalName), - node.typeParameters, - node.heritageClauses, - node.members - ) - } - - // `export function fun123` - if (ts.isFunctionDeclaration(node) && node === exportContent) { - if (node.name) finalLocalName = node.name.getText() - - // Turning the function export into a regular declaration - return ts.factory.updateFunctionDeclaration( - node, - node.decorators, - node.modifiers?.filter(isNotExportModifier), - node.asteriskToken, - node.name ?? ts.factory.createIdentifier(defaultLocalName), - node.typeParameters, - node.parameters, - node.type, - node.body - ) - } - - // `export const a = 1, b = 2` - if ( - ts.isVariableStatement(node) && - ts.isVariableDeclaration(exportContent!) && - node.declarationList.declarations.includes(exportContent) - ) { - finalLocalName = exportContent.name.getText() - - // `export const a = 1` -> `const a = 1` - return ts.factory.updateVariableStatement( - node, - node.modifiers?.filter(isNotExportModifier), - node.declarationList - ) - } - - // `export { ... } [from '...']` - if ( - ts.isExportDeclaration(node) && - ts.isExportSpecifier(exportContent!) && - node.exportClause && - ts.isNamedExports(node.exportClause) - ) { - // List of names exported from the module, except for the target - const filteredSpecifiers = node.exportClause.elements.filter( - (specifier) => specifier !== exportContent - ) - - if (node.moduleSpecifier) { - // `export { ... } from '...'` - finalLocalName = defaultLocalName - extraImport = ts.factory.createImportDeclaration( - undefined, - undefined, - ts.factory.createImportClause( - node.isTypeOnly, - undefined, - ts.factory.createNamedImports([ - ts.factory.createImportSpecifier( - exportContent.isTypeOnly, - exportContent.propertyName ?? exportContent.name, - ts.factory.createIdentifier(defaultLocalName) - ), - ]) - ), - node.moduleSpecifier - ) - } else { - // `export { ... }` - const localId = exportContent.propertyName ?? exportContent.name - finalLocalName = localId.getText() - } - - // Remove target export specifier - return ts.factory.updateExportDeclaration( - node, - node.decorators, - node.modifiers, - node.isTypeOnly, - ts.factory.updateNamedExports(node.exportClause, filteredSpecifiers), - node.moduleSpecifier, - node.assertClause - ) - } - - // `export default 123` - if (ts.isExportAssignment(node) && node === exportContent) { - finalLocalName = defaultLocalName - - // If the exported expression can be placed in a variable, then we do so. - // const {finalLocalName} = {exportContent} - return ts.factory.createVariableStatement( - undefined, - ts.factory.createVariableDeclarationList( - [ - ts.factory.createVariableDeclaration( - defaultLocalName, - undefined, - undefined, - node.expression - ), - ], - ts.NodeFlags.Const - ) - ) - } - - return ts.visitEachChild(node, visitor, context) - } - return ts.visitNode(sourceFile, visitor) - }) - - if (extraImport) { - filePkg.transform((sourceFile) => { - return ts.factory.updateSourceFile(sourceFile, [ - extraImport!, - ...sourceFile.statements, - ]) - }) - } - - return finalLocalName -} diff --git a/yarn.lock b/yarn.lock index 851e2e7a..cda7ef78 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1244,75 +1244,75 @@ "@jridgewell/resolve-uri" "3.1.0" "@jridgewell/sourcemap-codec" "1.4.14" -"@next/env@13.1.2": - version "13.1.2" - resolved "https://registry.yarnpkg.com/@next/env/-/env-13.1.2.tgz#4f13e3e9d44bb17fdc1d4543827459097035f10f" - integrity sha512-PpT4UZIX66VMTqXt4HKEJ+/PwbS+tWmmhZlazaws1a+dbUA5pPdjntQ46Jvj616i3ZKN9doS9LHx3y50RLjAWg== - -"@next/swc-android-arm-eabi@13.1.2": - version "13.1.2" - resolved "https://registry.yarnpkg.com/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.1.2.tgz#eacc7757b480a8150c1aea748bf7892a4fc62f64" - integrity sha512-7mRz1owoGsbfIcdOJA3kk7KEwPZ+OvVT1z9DkR/yru4QdVLF69h/1SHy0vlUNQMxDRllabhxCfkoZCB34GOGAg== - -"@next/swc-android-arm64@13.1.2": - version "13.1.2" - resolved "https://registry.yarnpkg.com/@next/swc-android-arm64/-/swc-android-arm64-13.1.2.tgz#f3d41339b4f15852a589fe11820408572a512a27" - integrity sha512-mgjZ2eJSayovQm1LcE54BLSI4jjnnnLtq5GY5g+DdPuUiCT644gKtjZ/w2BQvuIecCqqBO+Ph9yzo/wUTq7NLg== - -"@next/swc-darwin-arm64@13.1.2": - version "13.1.2" - resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.1.2.tgz#1a20a2262aa7a250517c9a7f2efd6ac6273f8c63" - integrity sha512-RikoQqy109r2222UJlyGs4dZw2BibkfPqpeFdW5JEGv+L2PStlHID8DwyVYbmHfQ0VIBGvbf/NAUtFakAWlhwg== - -"@next/swc-darwin-x64@13.1.2": - version "13.1.2" - resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-13.1.2.tgz#242bb321676bd88f4cffa7eae3283215cd1185ce" - integrity sha512-JbDZjaTvL8gyPC5TAH6OnD4jmXPkyUxRYPvu08ZmhT/XAFBb/Cso0BdXyDax/BPCG70mimP9d3hXNKNq+A0VtQ== - -"@next/swc-freebsd-x64@13.1.2": - version "13.1.2" - resolved "https://registry.yarnpkg.com/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.1.2.tgz#9589f7f2bebfa43a744c9e41654e743b38a318b1" - integrity sha512-ax4j8VrdFQ/xc3W7Om0u1vnDxVApQHKsChBbAMynCrnycZmpbqK4MZu4ZkycT+mx2eccCiqZROpbzDbEdPosEw== - -"@next/swc-linux-arm-gnueabihf@13.1.2": - version "13.1.2" - resolved "https://registry.yarnpkg.com/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.1.2.tgz#8935b0c8f232e36c3d88cd1e1023afa8d51f7260" - integrity sha512-NcRHTesnCxnUvSJa637PQJffBBkmqi5XS/xVWGY7dI6nyJ+pC96Oj7kd+mcjnFUQI5lHKbg39qBWKtOzbezc4w== - -"@next/swc-linux-arm64-gnu@13.1.2": - version "13.1.2" - resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.1.2.tgz#3482f72e580cdfc4bbec2e55dd55d5a9bdf7038b" - integrity sha512-AxJdjocLtPrsBY4P2COSBIc3crT5bpjgGenNuINoensOlXhBkYM0aRDYZdydwXOhG+kN2ngUvfgitop9pa204w== - -"@next/swc-linux-arm64-musl@13.1.2": - version "13.1.2" - resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.1.2.tgz#3b7ca70fd813c77f618ee34a150b977cc15af9a3" - integrity sha512-JmNimDkcCRq7P5zpkdqeaSZ69qKDntEPtyIaMNWqy5M0WUJxGim0Fs6Qzxayiyvuuh9Guxks4woQ/j/ZvX/c8Q== - -"@next/swc-linux-x64-gnu@13.1.2": - version "13.1.2" - resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.1.2.tgz#51a7a889e88eb87a5ce9658842f9e8422e037ead" - integrity sha512-TsLsjZwUlgmvI42neTuIoD6K9RlXCUzqPtvIClgXxVO0um0DiZwK+M+0zX/uVXhMVphfPY2c5YeR1zFSIONY4A== - -"@next/swc-linux-x64-musl@13.1.2": - version "13.1.2" - resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.1.2.tgz#4c0dd08a6f8a7e4881c3551de29259b3cfe86e27" - integrity sha512-eSkyXgCXydEFPTkcncQOGepafedPte6JT/OofB9uvruucrrMVBagCASOuPxodWEMrlfEKSXVnExMKIlfmQMD7A== - -"@next/swc-win32-arm64-msvc@13.1.2": - version "13.1.2" - resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.1.2.tgz#589fcce82f9f7224d2399d8d7bcba9097bb50dad" - integrity sha512-DmXFaRTgt2KrV9dmRLifDJE+cYiutHVFIw5/C9BtnwXH39uf3YbPxeD98vNrtqqqZVVLXY/1ySaSIwzYnqeY9g== - -"@next/swc-win32-ia32-msvc@13.1.2": - version "13.1.2" - resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.1.2.tgz#9be05202730530631b51d7753d447dfe86095c9f" - integrity sha512-3+nBkuFs/wT+lmRVQNH5SyDT7I4vUlNPntosEaEP63FuYQdPLaxz0GvcR66MdFSFh2fsvazpe4wciOwVS4FItQ== - -"@next/swc-win32-x64-msvc@13.1.2": - version "13.1.2" - resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.1.2.tgz#c7e75033e8b8f497768c7b462ac642830141bb00" - integrity sha512-avsyveEvcvH42PvKjR4Pb8JlLttuGURr2H3ZhS2b85pHOiZ7yjH3rMUoGnNzuLMApyxYaCvd4MedPrLhnNhkog== +"@next/env@13.1.3": + version "13.1.3" + resolved "https://registry.yarnpkg.com/@next/env/-/env-13.1.3.tgz#1c29b0dab10ed02b741cb0bb07636eeb41ad5a69" + integrity sha512-ye0yvGmlzQQJnzNC7tC/ZhgRMd0s54msgrDOft1SjEG1Fbb+RBxGsalPqG3tUGuchA25z3npAtkFoAP8d2wPnw== + +"@next/swc-android-arm-eabi@13.1.3": + version "13.1.3" + resolved "https://registry.yarnpkg.com/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.1.3.tgz#f038b4e76af750b56b884997e902a6096ee367f3" + integrity sha512-kXL0z7uVUHdUkXY997oZcoz4PXWXRJq3R9x2UYz0uW8OHsZinxTW/BgyzH8nfTB/4/a0nox4fgzQRurjem3nGQ== + +"@next/swc-android-arm64@13.1.3": + version "13.1.3" + resolved "https://registry.yarnpkg.com/@next/swc-android-arm64/-/swc-android-arm64-13.1.3.tgz#e5622575187aaecea3dd34e27b6089f3a4a004d8" + integrity sha512-ZHYC5Ze+syk9mex/T5XILHox5xjJotQ5GmPqHrJpXh9AOuIZnfhNP/zeLYaOXWaJmrE55Ni56VxHgckJfpGeBw== + +"@next/swc-darwin-arm64@13.1.3": + version "13.1.3" + resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.1.3.tgz#9acb0770782d9fced9a57a8dcbc8a227ebe212e2" + integrity sha512-B8Gyx/XhoxiiD4kHjnNVPCdgvLvIeQQGE2Nq6P7gsG0t17mMcPS4Y8fh/kVJSZAu5B5bAACwYIsI5bKMFzM+Ug== + +"@next/swc-darwin-x64@13.1.3": + version "13.1.3" + resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-13.1.3.tgz#a060253ec0dfab008c296eec6654b63de2e9d4f2" + integrity sha512-SCXf0JA3tR9FcsFA53a3LWDaxoIWFoLSbN3m88cYQYQMluObxwo6SBeUD9E3F4pM0bXEeIGOh8Y6u8w0GmmGoQ== + +"@next/swc-freebsd-x64@13.1.3": + version "13.1.3" + resolved "https://registry.yarnpkg.com/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.1.3.tgz#f93f351202ed18aca3a7ea8c5e241f3a4601110e" + integrity sha512-bUf1HYF3znES0Kd75fRnVp7LXlwF3MiuTk/qh32t1VH8CHSGsJmPPtHw4ag5GgwCbIn3AwWJQgqS+jyVYj40CA== + +"@next/swc-linux-arm-gnueabihf@13.1.3": + version "13.1.3" + resolved "https://registry.yarnpkg.com/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.1.3.tgz#a8939e0d825c4063c8141879935c2f3210959d77" + integrity sha512-ibl6YbAoOVH5whhHcC3s4auSKLIzWyhRdv9M8373m8xaTWkAGtFNgbJysaTBm4M9RlePPX0G81oul9wmpkP48w== + +"@next/swc-linux-arm64-gnu@13.1.3": + version "13.1.3" + resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.1.3.tgz#97725ec5723d8d012116124ec9c3f1f60d7e0eed" + integrity sha512-ChsZxyNgAu1JHLQWZq4L6lJ4VQ4Rj30qA8VCGkr1AFiqwWabri9dc5y32zJSmqa6Ex6NVDyYCNBKUGlcUOmDtw== + +"@next/swc-linux-arm64-musl@13.1.3": + version "13.1.3" + resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.1.3.tgz#110f328eba0a04a6786726ec71357234e462962e" + integrity sha512-WoYE9I/1iEW9wldxFxhu+OZmU4IbwQQl/w5nFrgbSIyGz3g3JeaQxJOdyMggX3WOjWF9khdJ4r4ANa0TsF28DA== + +"@next/swc-linux-x64-gnu@13.1.3": + version "13.1.3" + resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.1.3.tgz#6c4704433929a981b2a97a490159e6d9d507db10" + integrity sha512-fz5j+p1MsD0Kb+vMUkHzKxzFDteqzAqtdC41NyRvyKYhAffyDsfjGB542nmtt+EdxtlpDWfH204gN6nNXDDI7w== + +"@next/swc-linux-x64-musl@13.1.3": + version "13.1.3" + resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.1.3.tgz#dd3735f672dbaa3153fb590b1320cf1e621ca853" + integrity sha512-kw98zZnIAGyElE8GqsY5oH/n/vLYWqhEHlhHlY9ZzPIhsKwybWqLTq6ZPA60fEgRm9+UoU6u7lGD9pjZhTBRvA== + +"@next/swc-win32-arm64-msvc@13.1.3": + version "13.1.3" + resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.1.3.tgz#b888dd4449310b8ec8f6470afef556de99d4d0fd" + integrity sha512-bfulLL1SkaECHnv1Oz1nLdwpMu/B/TQEzA3+XoJYoiZaKHuTrufDIr+fTUasK5l7KQmB1y8LXSMKEKVeZomeGg== + +"@next/swc-win32-ia32-msvc@13.1.3": + version "13.1.3" + resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.1.3.tgz#a24772611f02b026f4be71edffcf63740510bffa" + integrity sha512-5UwjzQWgUdKAinZgLSYB8BG5jtTUuUGBh//7EwDXf+nqfTEZ7VOaDuHWeO6MQLkuSgQOIpwL5uMJQFJY1rX69A== + +"@next/swc-win32-x64-msvc@13.1.3": + version "13.1.3" + resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.1.3.tgz#f6cb40f36a9a917e9bc5025e3ad747309180ff6a" + integrity sha512-P9fSi+/FZKGQXV4kCJg2td2jkIvDryDFZr/mn+0xfWiC/rcSov9CHK0W3qh+ZXyItLEe6dOtAdGxlTYOijHthw== "@nicolo-ribaudo/chokidar-2@2.1.8-no-fsevents.3": version "2.1.8-no-fsevents.3" @@ -1346,9 +1346,9 @@ tslib "^2.4.0" "@testing-library/dom@^8.5.0": - version "8.19.1" - resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.19.1.tgz#0e2dafd281dedb930bb235eac1045470b4129d0e" - integrity sha512-P6iIPyYQ+qH8CvGauAqanhVnjrnRe0IZFSYCeGkSRW9q3u8bdVn2NPI+lasFyVsEQn1J/IFmp5Aax41+dAP9wg== + version "8.20.0" + resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.20.0.tgz#914aa862cef0f5e89b98cc48e3445c4c921010f6" + integrity sha512-d9ULIT+a4EXLX3UU8FBjauG9NnsZHkHztXoIcTsOKoOw030fyjheN9svkTULjJxtYag9DZz5Jz5qkWZDPxTFwA== dependencies: "@babel/code-frame" "^7.10.4" "@babel/runtime" "^7.12.5" @@ -1379,12 +1379,12 @@ integrity sha512-XTIieEY+gvJ39ChLcB4If5zHtPxt3Syj5rgZR+e1ctpmK8NjPf0zFqsz4JpLJT0xla9GFDKjy8Cpu331nrmE1Q== "@types/babel__core@^7.0.0", "@types/babel__core@^7.1.14": - version "7.1.20" - resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.20.tgz#e168cdd612c92a2d335029ed62ac94c95b362359" - integrity sha512-PVb6Bg2QuscZ30FvOU7z4guG6c926D9YRvOxEaelzndpMsvP+YM74Q/dAFASpg2l6+XLalxSGxcq/lrgYWZtyQ== + version "7.20.0" + resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.0.tgz#61bc5a4cae505ce98e1e36c5445e4bee060d8891" + integrity sha512-+n8dL/9GWblDO0iU6eZAwEIJVr5DWigtle+Q6HLOrh/pdbXOhOtqzq8VPPE2zvNJzSKY4vH/z3iT3tn0A3ypiQ== dependencies: - "@babel/parser" "^7.1.0" - "@babel/types" "^7.0.0" + "@babel/parser" "^7.20.7" + "@babel/types" "^7.20.7" "@types/babel__generator" "*" "@types/babel__template" "*" "@types/babel__traverse" "*" @@ -1463,10 +1463,10 @@ dependencies: "@types/istanbul-lib-report" "*" -"@types/jest@29.2.5": - version "29.2.5" - resolved "https://registry.yarnpkg.com/@types/jest/-/jest-29.2.5.tgz#c27f41a9d6253f288d1910d3c5f09484a56b73c0" - integrity sha512-H2cSxkKgVmqNHXP7TC2L/WUorrZu8ZigyRywfVzv6EyBlxj39n4C00hjXYQWsbwqgElaj/CiAeSRmk5GoaKTgw== +"@types/jest@29.2.6": + version "29.2.6" + resolved "https://registry.yarnpkg.com/@types/jest/-/jest-29.2.6.tgz#1d43c8e533463d0437edef30b2d45d5aa3d95b0a" + integrity sha512-XEUC/Tgw3uMh6Ho8GkUtQ2lPhY5Fmgyp3TdlkTJs1W9VgNxs+Ow/x3Elh8lHQKqCbZL0AubQuqWjHVT033Hhrw== dependencies: expect "^29.0.0" pretty-format "^29.0.0" @@ -1503,10 +1503,10 @@ dependencies: "@types/react" "*" -"@types/react@*", "@types/react@18.0.26": - version "18.0.26" - resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.26.tgz#8ad59fc01fef8eaf5c74f4ea392621749f0b7917" - integrity sha512-hCR3PJQsAIXyxhTNSiDFY//LhnMZWpNNr5etoCqx/iUfGc5gXWtQR2Phl908jVR6uPXacojQWTg4qRpkxTuGug== +"@types/react@*", "@types/react@18.0.27": + version "18.0.27" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.27.tgz#d9425abe187a00f8a5ec182b010d4fd9da703b71" + integrity sha512-3vtRKHgVxu3Jp9t718R9BuzoD4NcQ8YJ5XRzsSKxNDiDonD2MXIT1TmSkenxuCycZJoQT5d2vE8LwWJxBC1gmA== dependencies: "@types/prop-types" "*" "@types/scheduler" "*" @@ -1544,9 +1544,9 @@ "@types/yargs-parser" "*" "@types/yargs@^17.0.8": - version "17.0.19" - resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.19.tgz#8dbecdc9ab48bee0cb74f6e3327de3fa0d0c98ae" - integrity sha512-cAx3qamwaYX9R0fzOIZAlFpo4A+1uBVCxqpKz9D26uTF4srRXaGTTsikQmaotCtNdbhzyUH7ft6p9ktz9s6UNQ== + version "17.0.20" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.20.tgz#107f0fcc13bd4a524e352b41c49fe88aab5c54d5" + integrity sha512-eknWrTHofQuPk2iuqDm1waA7V6xPlbgBoaaXEgYkClhLOnB0TtbW+srJaOToAgawPxPlHQzwypFA2bhZaUGP5A== dependencies: "@types/yargs-parser" "*" @@ -2339,9 +2339,9 @@ camelcase@^6.2.0: integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== caniuse-lite@^1.0.30001400, caniuse-lite@^1.0.30001406: - version "1.0.30001445" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001445.tgz#cf2d4eb93f2bcdf0310de9dd6d18be271bc0b447" - integrity sha512-8sdQIdMztYmzfTMO6KfLny878Ln9c2M0fc7EH60IjlP4Dc4PiCy7K2Vl3ITmWgOyPgVQKa5x+UP/KqFsxj4mBg== + version "1.0.30001446" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001446.tgz#6d4ba828ab19f49f9bcd14a8430d30feebf1e0c5" + integrity sha512-fEoga4PrImGcwUUGEol/PoFCSBnSkA9drgdkxXkJLsUBOnJ8rs3zDv6ApqYXGQFOyMPsjh79naWhF4DAxbF8rw== chalk@^1.1.3: version "1.1.3" @@ -2521,15 +2521,15 @@ cookie@0.5.0: resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.5.0.tgz#d1f5d71adec6558c58f389987c366aa47e994f8b" integrity sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw== -cookiejar@^2.1.3: +cookiejar@^2.1.4: version "2.1.4" resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.4.tgz#ee669c1fea2cf42dc31585469d193fef0d65771b" integrity sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw== core-js-compat@^3.25.1: - version "3.27.1" - resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.27.1.tgz#b5695eb25c602d72b1d30cbfba3cb7e5e4cf0a67" - integrity sha512-Dg91JFeCDA17FKnneN7oCMz4BkQ4TcffkgHP4OWwp9yx3pi7ubqMDXXSacfNak1PQqjc95skyt+YBLHQJnkJwA== + version "3.27.2" + resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.27.2.tgz#607c50ad6db8fd8326af0b2883ebb987be3786da" + integrity sha512-welaYuF7ZtbYKGrIy7y3eb40d37rG1FvzEOfe7hSLd2iD6duMDqUhRfSvCGyC46HhR6Y8JXXdZ2lnRUMkPBpvg== dependencies: browserslist "^4.21.4" @@ -2689,9 +2689,9 @@ diff-sequences@^29.3.1: integrity sha512-hlM3QR272NXCi4pq+N4Kok4kOp6EsgOM3ZSpJI7Da3UAs+Ttsi8MRmB6trM/lhyzUxGfOgnpkHtgqm5Q/CTcfQ== dom-accessibility-api@^0.5.9: - version "0.5.15" - resolved "https://registry.yarnpkg.com/dom-accessibility-api/-/dom-accessibility-api-0.5.15.tgz#357e74338704f36fada8b2e01a4bfc11ef436ac9" - integrity sha512-8o+oVqLQZoruQPYy3uAAQtc6YbtSiRq5aPJBhJ82YTJRHvI6ofhYAkC81WmjFTnfUbqg6T3aCglIpU9p/5e7Cw== + version "0.5.16" + resolved "https://registry.yarnpkg.com/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz#5a7429e6066eb3664d911e33fb0e45de8eb08453" + integrity sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg== domexception@^2.0.1: version "2.0.1" @@ -3017,10 +3017,10 @@ form-data@^4.0.0: combined-stream "^1.0.8" mime-types "^2.1.12" -formidable@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/formidable/-/formidable-2.1.1.tgz#81269cbea1a613240049f5f61a9d97731517414f" - integrity sha512-0EcS9wCFEzLvfiks7omJ+SiYJAiD+TzK4Pcw1UlUoGnhUxDcMKjt0P7x8wEb0u6OHu8Nb98WG3nxtlF5C7bvUQ== +formidable@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/formidable/-/formidable-2.1.2.tgz#fa973a2bec150e4ce7cac15589d7a25fc30ebd89" + integrity sha512-CM3GuJ57US06mlpQ47YcunuUZ9jpm8Vx+P2CGt2j7HpgkKZO/DJYQ0Bobim8G6PFQmK5lOqOOdUXboU+h73A4g== dependencies: dezalgo "^1.0.4" hexoid "^1.0.0" @@ -3073,9 +3073,9 @@ get-caller-file@^2.0.5: integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== get-intrinsic@^1.0.2, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.3.tgz#063c84329ad93e83893c7f4f243ef63ffa351385" - integrity sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A== + version "1.2.0" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.0.tgz#7ad1dc0535f3a2904bba075772763e5051f6d05f" + integrity sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q== dependencies: function-bind "^1.1.1" has "^1.0.3" @@ -4316,30 +4316,30 @@ next-router-mock@0.8.0: resolved "https://registry.yarnpkg.com/next-router-mock/-/next-router-mock-0.8.0.tgz#e4400b166941d2e8f2617c9b5f4091bbd916d943" integrity sha512-aw/QnDFRqGDIkC3y4mCL5HQCNK94IzIfrEYy2c17WVp6Q4V5GUarFx751Sccf8fUPdkzD2/RsldyScvNZGA8lw== -next@13.1.2: - version "13.1.2" - resolved "https://registry.yarnpkg.com/next/-/next-13.1.2.tgz#4105b0cf238bb2f58d5e12dbded8cabb9785f2d9" - integrity sha512-Rdnnb2YH///w78FEOR/IQ6TXga+qpth4OqFSem48ng1PYYKr6XBsIk1XVaRcIGM3o6iiHnun0nJvkJHDf+ICyQ== +next@13.1.3: + version "13.1.3" + resolved "https://registry.yarnpkg.com/next/-/next-13.1.3.tgz#2ba15a441fb9ef38467259fb0894623c79e938aa" + integrity sha512-ig7m7Po/F+Wp0xl+9RKYZq+PYfgVmONH6hBPVT2+jrdUmZkrqsN5ioSe4oQbCAb9tMtVr07agVdK2HFjD15Yug== dependencies: - "@next/env" "13.1.2" + "@next/env" "13.1.3" "@swc/helpers" "0.4.14" caniuse-lite "^1.0.30001406" postcss "8.4.14" styled-jsx "5.1.1" optionalDependencies: - "@next/swc-android-arm-eabi" "13.1.2" - "@next/swc-android-arm64" "13.1.2" - "@next/swc-darwin-arm64" "13.1.2" - "@next/swc-darwin-x64" "13.1.2" - "@next/swc-freebsd-x64" "13.1.2" - "@next/swc-linux-arm-gnueabihf" "13.1.2" - "@next/swc-linux-arm64-gnu" "13.1.2" - "@next/swc-linux-arm64-musl" "13.1.2" - "@next/swc-linux-x64-gnu" "13.1.2" - "@next/swc-linux-x64-musl" "13.1.2" - "@next/swc-win32-arm64-msvc" "13.1.2" - "@next/swc-win32-ia32-msvc" "13.1.2" - "@next/swc-win32-x64-msvc" "13.1.2" + "@next/swc-android-arm-eabi" "13.1.3" + "@next/swc-android-arm64" "13.1.3" + "@next/swc-darwin-arm64" "13.1.3" + "@next/swc-darwin-x64" "13.1.3" + "@next/swc-freebsd-x64" "13.1.3" + "@next/swc-linux-arm-gnueabihf" "13.1.3" + "@next/swc-linux-arm64-gnu" "13.1.3" + "@next/swc-linux-arm64-musl" "13.1.3" + "@next/swc-linux-x64-gnu" "13.1.3" + "@next/swc-linux-x64-musl" "13.1.3" + "@next/swc-win32-arm64-msvc" "13.1.3" + "@next/swc-win32-ia32-msvc" "13.1.3" + "@next/swc-win32-x64-msvc" "13.1.3" node-int64@^0.4.0: version "0.4.0" @@ -4599,9 +4599,9 @@ pump@^3.0.0: once "^1.3.1" punycode@^2.1.0, punycode@^2.1.1: - version "2.2.0" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.2.0.tgz#2092cc57cd2582c38e4e7e8bb869dc8d3148bc74" - integrity sha512-LN6QV1IJ9ZhxWTNdktaPClrNfp8xdSAYS0Zk2ddX7XsXZAxckMHPCBcHRo0cTcEIgYPRiGEkmji3Idkh2yFtYw== + version "2.3.0" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f" + integrity sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA== qs@6.11.0, qs@^6.11.0: version "6.11.0" @@ -5007,16 +5007,16 @@ styled-jsx@5.1.1: client-only "0.0.1" superagent@^8.0.5: - version "8.0.6" - resolved "https://registry.yarnpkg.com/superagent/-/superagent-8.0.6.tgz#e3fb0b3112b79b12acd605c08846253197765bf6" - integrity sha512-HqSe6DSIh3hEn6cJvCkaM1BLi466f1LHi4yubR0tpewlMpk4RUFFy35bKz8SsPBwYfIIJy5eclp+3tCYAuX0bw== + version "8.0.8" + resolved "https://registry.yarnpkg.com/superagent/-/superagent-8.0.8.tgz#345f06f552dc23f3581f2c30fda7d6ad247f146d" + integrity sha512-OpxPrqqWKOjmuomLq5pCm4LWCSFdgAQ11XVkMl7t4ie13WxWuLkdJ83ZgG2jOQeLXKwMR2p9k30hLrKGAzkPaA== dependencies: component-emitter "^1.3.0" - cookiejar "^2.1.3" + cookiejar "^2.1.4" debug "^4.3.4" fast-safe-stringify "^2.1.1" form-data "^4.0.0" - formidable "^2.1.1" + formidable "^2.1.2" methods "^1.1.2" mime "2.6.0" qs "^6.11.0" @@ -5203,10 +5203,10 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" -typescript@4.5.2: - version "4.5.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.2.tgz#8ac1fba9f52256fdb06fb89e4122fa6a346c2998" - integrity sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw== +typescript@4.9.4: + version "4.9.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.4.tgz#a2a3d2756c079abda241d75f149df9d561091e78" + integrity sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg== unicode-canonical-property-names-ecmascript@^2.0.0: version "2.0.0"