Skip to content

Commit

Permalink
Only load plugins with @next prefix (#17945)
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Oct 16, 2020
1 parent cbbf9a7 commit dfcf267
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 40 deletions.
4 changes: 1 addition & 3 deletions packages/next/build/plugins/collect-plugins.ts
Expand Up @@ -182,11 +182,9 @@ async function _collectPlugins(
}

// find packages with the naming convention
// @scope/next-plugin-[name]
// @next/plugin-[name]
// next-plugin-[name]
const filteredDeps = dependencies.filter((name) => {
return name.match(/(^@next\/plugin|next-plugin-)/)

This comment has been minimized.

Copy link
@bitfrost

bitfrost Nov 5, 2020

@timneutkens Is this ever coming back for 3rd parties? (I know it has always been experimental...) We have found this feature incredible for reducing out internal boiler plate code with our own internal very simple plugins.

This comment has been minimized.

Copy link
@timneutkens

timneutkens Nov 5, 2020

Author Member

Yes, but only when the plugin system is stable in the way we want it to work, currently the implementation can lead to issues and incompatibility between versions if it's not managed from within the Next.js monorepo.

return name.match(/^@next\/plugin/)
})

if (nextPluginConfigNames) {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 1 addition & 3 deletions test/integration/next-plugins/app/package.json
@@ -1,7 +1,5 @@
{
"dependencies": {
"@next/plugin-google-analytics": "latest",
"@zeit/next-plugin-scope": "latest",
"next-plugin-normal": "latest"
"@next/plugin-google-analytics": "latest"
}
}
4 changes: 0 additions & 4 deletions test/integration/next-plugins/test/index.test.js
Expand Up @@ -44,8 +44,6 @@ function runTests() {

it('should list loaded plugins', async () => {
expect(stdout).toMatch(/loaded plugin: @next\/plugin-google-analytics/i)
expect(stdout).toMatch(/loaded plugin: @zeit\/next-plugin-scope/i)
expect(stdout).toMatch(/loaded plugin: next-plugin-normal/i)
})

it('should ignore directories in plugins', async () => {
Expand Down Expand Up @@ -111,8 +109,6 @@ describe('Next.js plugins', () => {

it('should disable auto detecting plugins when plugin config is used', async () => {
expect(stdout).toMatch(/loaded plugin: @next\/plugin-google-analytics/i)
expect(stdout).not.toMatch(/loaded plugin: @zeit\/next-plugin-scope/i)
expect(stdout).not.toMatch(/loaded plugin: next-plugin-normal/i)
})

it('should expose a plugins config', async () => {
Expand Down

0 comments on commit dfcf267

Please sign in to comment.