0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-27 22:59:51 -05:00

fix(loaders): always create plugin instance with new (#3052)

* class plugin transpile with babel contains a function '_classCallCheck',
* will throw an error when a class is invoked without 'new'
* see: https://babeljs.io/docs/en/babel-plugin-transform-classes#examples
This commit is contained in:
Xingwang Liao 2022-03-10 02:45:21 +08:00 committed by GitHub
parent b69333778d
commit 31d661c7bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'@verdaccio/loaders': patch
---
always create plugin instance with new

View file

@ -121,7 +121,7 @@ export function loadPlugin<T extends IPlugin<T>>(
try {
plugin = isES6(plugin)
? new plugin.default(mergeConfig(config, pluginConfigs[pluginId]), params)
: plugin(pluginConfigs[pluginId], params);
: new plugin(pluginConfigs[pluginId], params);
} catch (error: any) {
plugin = null;
logger.error({ error, pluginId }, 'error loading a plugin @{pluginId}: @{error}');