Skip to content

Commit

Permalink
concat mixed configuration for webpack externals
Browse files Browse the repository at this point in the history
  • Loading branch information
vstefanovic97 committed Jan 17, 2022
1 parent e8053f0 commit 4f9584f
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions packages/ember-auto-import/ts/webpack.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import type { Configuration, Compiler, RuleSetRule, Stats } from 'webpack';
import type {
Configuration,
Compiler,
RuleSetRule,
Stats,
ExternalItem,
} from 'webpack';
import { join, dirname } from 'path';
import { mergeWith, flatten, zip } from 'lodash';
import { writeFileSync, realpathSync } from 'fs';
Expand Down Expand Up @@ -195,7 +201,7 @@ export default class WebpackBundler extends Plugin implements Bundler {
],
},
node: false,
externals: this.externalsHandler,
externals: [this.externalsHandler],
};

mergeConfig(
Expand Down Expand Up @@ -242,7 +248,7 @@ export default class WebpackBundler extends Plugin implements Bundler {
}

@Memoize()
private get externalsHandler(): Configuration['externals'] {
private get externalsHandler(): ExternalItem {
let packageCache = PackageCache.shared(
'ember-auto-import',
this.opts.appRoot
Expand Down Expand Up @@ -437,6 +443,14 @@ function combine(objValue: any, srcValue: any, key: string) {
return eitherPattern(objValue, srcValue);
}

if (key === 'externals') {
if (typeof objValue === 'undefined') {
return [srcValue];
} else if (!Array.isArray(srcValue)) {
return [...objValue, srcValue];
}
}

// arrays concat
if (Array.isArray(objValue)) {
return objValue.concat(srcValue);
Expand Down

0 comments on commit 4f9584f

Please sign in to comment.