Browse Source

refactor(ui-devkit): Rename "sharedProviders" to just "providers"

Michael Bromley 2 years ago
parent
commit
fa580c1e1a

+ 5 - 5
packages/ui-devkit/src/compiler/scaffold.ts

@@ -1,5 +1,5 @@
 /* eslint-disable no-console */
-import { spawn } from 'child_process';
+import { notNullOrUndefined } from '@vendure/common/lib/shared-utils';
 import * as fs from 'fs-extra';
 import { globSync } from 'glob';
 import * as path from 'path';
@@ -29,9 +29,7 @@ import {
     isSassVariableOverridesExtension,
     isStaticAssetExtension,
     isTranslationExtension,
-    logger,
     normalizeExtensions,
-    shouldUseYarn,
 } from './utils';
 
 export async function setupScaffold(outputPath: string, extensions: Extension[]) {
@@ -208,7 +206,7 @@ ${adminUiExtensions
     .join('')}
 ${adminUiExtensions
     .map((m, i) =>
-        (m.sharedProviders ?? [])
+        (m.providers ?? [])
             .map(
                 (f, j) =>
                     `import SharedProviders_${i}_${j} from './extensions/${m.id}/${path.basename(
@@ -228,9 +226,11 @@ ${adminUiExtensions
                 .map(m => m.ngModuleName)
                 .join(', '),
         )
+        .filter(val => !!val)
         .join(', ')}],
     providers: [${adminUiExtensions
-        .map((m, i) => (m.sharedProviders ?? []).map((f, j) => `...SharedProviders_${i}_${j}`))
+        .filter(notNullOrUndefined)
+        .map((m, i) => (m.providers ?? []).map((f, j) => `...SharedProviders_${i}_${j}`))
         .join(', ')}],
 })
 export class SharedExtensionsModule {}

+ 9 - 3
packages/ui-devkit/src/compiler/types.ts

@@ -118,17 +118,23 @@ export interface AdminUiExtension
      * @description
      * One or more Angular modules which extend the default Admin UI.
      *
-     * @deprecated use `routes` instead of lazy modules, and `sharedProviders` instead of shared modules.
+     * @deprecated use `routes` instead of lazy modules, and `providers` instead of shared modules in combination
+     * with Angular standalone components.
      */
     ngModules?: Array<AdminUiExtensionSharedModule | AdminUiExtensionLazyModule>;
 
     /**
      * @description
-     * Defines an extension which contains only shared providers such as nav menu items, custom form inputs,
+     * Defines the paths to a file that exports an array of shared providers such as nav menu items, custom form inputs,
      * custom detail components, action bar items, custom history entry components.
      */
-    sharedProviders?: string[];
+    providers?: string[];
 
+    /**
+     * @description
+     * Defines routes that will be lazy-loaded at the `/extensions/` route. The filePath should point to a file
+     * relative to the `extensionPath` which exports an array of Angular route definitions.
+     */
     routes?: Array<{
         route: string;
         filePath: string;