From 15e8c5e50b6a6fd447ac600a769f66bfe6da12ed Mon Sep 17 00:00:00 2001 From: Peter Somogyvari Date: Thu, 12 Nov 2020 12:38:29 -0800 Subject: [PATCH] fix(cmd-api-server): plugin imports via static config (env,cli,file) Depends on https://github.com/webpack/webpack/pull/11316 This has no real effect until the PR above is merged and releaed on Webpack (and then we upgrade to that release for the builds) How this fix works is explained in the linked PR in greater detail. Signed-off-by: Peter Somogyvari --- .../src/main/typescript/api-server.ts | 7 ++++++- tsconfig.json | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/cactus-cmd-api-server/src/main/typescript/api-server.ts b/packages/cactus-cmd-api-server/src/main/typescript/api-server.ts index 317386800a..ee478a690f 100644 --- a/packages/cactus-cmd-api-server/src/main/typescript/api-server.ts +++ b/packages/cactus-cmd-api-server/src/main/typescript/api-server.ts @@ -161,11 +161,16 @@ export class ApiServer { const registry = new PluginRegistry({ plugins: [] }); const { logLevel } = this.options.config; this.log.info(`Instantiated empty registry, invoking plugin factories...`); + for (const pluginImport of this.options.config.plugins) { const { packageName, options } = pluginImport; this.log.info(`Creating plugin from package: ${packageName}`, options); const pluginOptions = { ...options, logLevel, pluginRegistry: registry }; - const { createPluginFactory } = await import(packageName); + + const { + createPluginFactory, + } = require(/* webpackIgnore: true */ packageName); + const pluginFactory: PluginFactory< ICactusPlugin, any diff --git a/tsconfig.json b/tsconfig.json index 7a41d4499b..07ec0c3051 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,7 +22,7 @@ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "composite": true, /* Enable project compilation */ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ - // "removeComments": true, /* Do not emit comments to output. */ + "removeComments": false, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ // "importHelpers": true, /* Import emit helpers from 'tslib'. */ // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */