Commit 210dca8d authored by Tim Neutkens's avatar Tim Neutkens Committed by Joe Haddad

Ensure we correctly decide on which packages need better interopt (#9327)

parent b9c71d37
import findUp from 'find-up' import findUp from 'find-up'
const EVENT_PLUGIN_PRESENT = 'NEXT_PACKAGE_DETECTED' const EVENT_PLUGIN_PRESENT = 'NEXT_PACKAGE_DETECTED'
type EventPackageDetected = { type NextPluginsEvent = {
packageName: string eventName: string
packageVersion: string payload: {
packageName: string
packageVersion: string
}
} }
const plugins = [
// CSS-in-JS solutions
'styled-components',
'radium',
'aphrodite',
'emotion',
'glamorous',
'glamor',
'fela',
'react-jss',
'linaria',
'typestyle',
// Modern Plugins
'@next/bundle-analyzer',
'@next/mdx',
// Legacy Plugins
'@zeit/next-bundle-analyzer',
'@zeit/next-css',
'@zeit/next-less',
'@zeit/next-mdx',
'@zeit/next-preact',
'@zeit/next-sass',
'@zeit/next-source-maps',
'@zeit/next-stylus',
'@zeit/next-typescript',
'@zeit/next-workers',
// Community Plugins
'next-env',
'next-offline',
'next-optimized-images',
'next-runtime-dotenv',
'next-progressbar',
'next-transpile-modules',
'next-react-svg',
'@weco/next-plugin-transpile-modules',
'next-images',
'next-videos',
'next-compose-plugins',
'next-build-id',
'next-routes',
'next-router',
'next-mdx-enhanced',
'next-docify',
'next-i18next',
'next-redux-saga',
'nookies',
'next-aws-lambda',
'serverless-nextjs-plugin',
'next-plugin-styled-icons',
'@ematipico/terraform-nextjs-plugin',
'next-mui-helper',
'nextjs-mui-helper',
'next-router-events',
'@moxy/next-runtime-env',
'next-session',
'next-apollo',
'next-minimal-routes',
'next-router-components',
'next-page-loading-bar',
'next-flexible-routes',
'next-apollo-hoc',
'routex.js',
'nextron',
'next-ga',
'nextjs-redirect',
'next-mobx-wrapper',
'next-ym',
'next-contentful',
'f-next-ga',
'next-plugin-yaml',
'data-prefetch-link',
'next-helpers',
'next-plugin-modernizr',
'nextjs-wp',
'nextjs-middleware',
'nextscript',
'next-fbq',
'next-analytics',
'@engineerapart/nextscript',
'next-data-link',
'@blunck/next-alias',
'@blunck/next-html',
'next-universal-redirect',
'create-next-app-lite',
'next-babel-minify',
'@rpominov/reason-next',
'create-next-library',
'nextscriptnew',
'nextjs-sitemap-generator',
'@dmartss/with-nprogress',
'create-react-next-app',
'hapi-nextjs',
'@cotype/serverless-next',
'nextjs-auth-hoc',
'@preco21/next-fonts',
'@dmartss/next-hoc',
'@xiphe/serverless-nextjs-plugin',
'@yellowiki/next-nprogress',
'@hashicorp/next-prebuild',
'next-i18next2.0',
'@futpib/next-ga',
'next-url-prettifier',
'next-plugin-custom-babel-config',
'fastify-nextjs',
'@yolkai/next-routes',
'trovit-next-routes',
'next-routify',
'wtp-next-routes',
'@whatoplay/next-routes',
'@ninetynine/next-routes',
'electron-next',
'@palmabit/sacajawea',
'advanced-next-routes',
'next-useragent',
'next-routes-with-locale',
'next-cookie',
'next-i18n-routes',
'next-graphql-react',
'next-flash-messages',
'next-manifest',
'next-purgecss',
'next-theme-webpack-plugin',
'next-serverless',
'connected-next-router',
'cookies-next',
'bs-next-alt',
'bs-next',
'next-redux',
'next-awesome-typescript',
'next-applicationinsights',
'next-routes-2',
'next-spa',
'next-precache',
'next-dynamic-routes',
'next-lambda',
'next-workbox',
'next-inferno',
'next-isserver',
'@alicd/next-locale-provider',
'shower-next',
'next-md',
'@primer/next',
'next-pages',
'amplify-next',
'create-next-app',
'neutron',
'react-intl',
'react-intl-universal',
'@lingui/react',
'@apollo/react-ssr',
]
export async function eventNextPlugins( export async function eventNextPlugins(
dir: string dir: string
): Promise<Array<{ eventName: string; payload: EventPackageDetected }>> { ): Promise<Array<NextPluginsEvent>> {
try { try {
const packageJsonPath = await findUp('package.json', { cwd: dir }) const packageJsonPath = await findUp('package.json', { cwd: dir })
if (!packageJsonPath) { if (!packageJsonPath) {
...@@ -168,23 +19,29 @@ export async function eventNextPlugins( ...@@ -168,23 +19,29 @@ export async function eventNextPlugins(
} }
const { dependencies = {}, devDependencies = {} } = require(packageJsonPath) const { dependencies = {}, devDependencies = {} } = require(packageJsonPath)
return (plugins
.map(plugin => { const deps = { ...devDependencies, ...dependencies }
const version = dependencies[plugin] || devDependencies[plugin]
if (version) { return Object.keys(deps).reduce(
return { pluginName: plugin, pluginVersion: version } (events: NextPluginsEvent[], plugin: string): NextPluginsEvent[] => {
const version = deps[plugin]
// Don't add deps without a version set
if (!version) {
return events
} }
})
.filter(Boolean) as { events.push({
pluginName: string eventName: EVENT_PLUGIN_PRESENT,
pluginVersion: string payload: {
}[]).map(({ pluginName, pluginVersion }) => ({ packageName: plugin,
eventName: EVENT_PLUGIN_PRESENT, packageVersion: version,
payload: { },
packageName: pluginName, })
packageVersion: pluginVersion,
} as EventPackageDetected, return events
})) },
[]
)
} catch (_) { } catch (_) {
return [] return []
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment