From cf31613d3e8cc6a71abf9b91cc45a521f249bec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Og=C3=B3rek?= Date: Thu, 22 Oct 2020 16:27:49 +0200 Subject: [PATCH 1/2] Update plugins collection based on the RFC dependency name format Based on the: https://github.com/vercel/next.js/discussions/9133 Tilde is also url-safe character, but I'm pretty sure npm doesn't allow that. As well as any non-letter or non-digit leading characters. --- packages/next/build/plugins/collect-plugins.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/next/build/plugins/collect-plugins.ts b/packages/next/build/plugins/collect-plugins.ts index ad9b4ebfc4c3..0c3d54af6596 100644 --- a/packages/next/build/plugins/collect-plugins.ts +++ b/packages/next/build/plugins/collect-plugins.ts @@ -183,8 +183,19 @@ async function _collectPlugins( // find packages with the naming convention // @next/plugin-[name] + // @/next-plugin-[name] + // next-plugin-[name] const filteredDeps = dependencies.filter((name) => { - return name.match(/^@next\/plugin/) + return ( + name.match(/^@next\/plugin-[a-z0-9\.-_]+/) || + name.match(/^next-plugin-[a-z0-9\.-_]+/) || + /** + * URL-safe characters (dot, dash, underscore), lower-case only, no leading dots or underscores. + * https://docs.npmjs.com/using-npm/scope.html + * https://docs.npmjs.com/files/package.json + */ + name.match(/^@[a-z0-9-][a-z0-9\.-_]*\/next-plugin-[a-z0-9\.-_]+/) + ) }) if (nextPluginConfigNames) { From 6f5f09c6b3ee4c9c984f2eb0df1ef22f0bdc982b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Og=C3=B3rek?= Date: Thu, 22 Oct 2020 16:35:14 +0200 Subject: [PATCH 2/2] Remove unnecessary dot escapes --- packages/next/build/plugins/collect-plugins.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/next/build/plugins/collect-plugins.ts b/packages/next/build/plugins/collect-plugins.ts index 0c3d54af6596..d894577f4a3b 100644 --- a/packages/next/build/plugins/collect-plugins.ts +++ b/packages/next/build/plugins/collect-plugins.ts @@ -187,14 +187,14 @@ async function _collectPlugins( // next-plugin-[name] const filteredDeps = dependencies.filter((name) => { return ( - name.match(/^@next\/plugin-[a-z0-9\.-_]+/) || - name.match(/^next-plugin-[a-z0-9\.-_]+/) || + name.match(/^@next\/plugin-[a-z0-9.-_]+/) || + name.match(/^next-plugin-[a-z0-9.-_]+/) || /** * URL-safe characters (dot, dash, underscore), lower-case only, no leading dots or underscores. * https://docs.npmjs.com/using-npm/scope.html * https://docs.npmjs.com/files/package.json */ - name.match(/^@[a-z0-9-][a-z0-9\.-_]*\/next-plugin-[a-z0-9\.-_]+/) + name.match(/^@[a-z0-9-][a-z0-9.-_]*\/next-plugin-[a-z0-9.-_]+/) ) })