diff --git a/libs/single-spa-angular/webpack/index.spec.ts b/libs/single-spa-angular/webpack/index.spec.ts index c458ba1..3d75ce4 100644 --- a/libs/single-spa-angular/webpack/index.spec.ts +++ b/libs/single-spa-angular/webpack/index.spec.ts @@ -187,5 +187,40 @@ describe('Webpack config', () => { // Assert expect(singleSpaConfig.devtool).toEqual('source-map'); }); + + test('should not set a library name when exporting in module format', () => { + // Arrange + const customWebpackConfig = { + libraryName: 'my-library', + libraryTarget: 'module' + }; + + // Act + const singleSpaConfig = singleSpaAngularWebpack( + { ...defaultConfig }, + { customWebpackConfig }, + ); + + // Assert + expect(singleSpaConfig.output.library).toBeUndefined(); + }); + + + test('should set a library name when exporting in umd format', () => { + // Arrange + const customWebpackConfig = { + libraryName: 'my-library', + libraryTarget: 'umd' + }; + + // Act + const singleSpaConfig = singleSpaAngularWebpack( + { ...defaultConfig }, + { customWebpackConfig }, + ); + + // Assert + expect(singleSpaConfig.output.library).toBe(customWebpackConfig.libraryName); + }); }); }); diff --git a/libs/single-spa-angular/webpack/index.ts b/libs/single-spa-angular/webpack/index.ts index 0046790..b82c371 100644 --- a/libs/single-spa-angular/webpack/index.ts +++ b/libs/single-spa-angular/webpack/index.ts @@ -63,8 +63,8 @@ export default (config: any, options?: Options, extraOptions?: DefaultExtraOptio const mergedConfig = mergeConfigs(config, singleSpaConfig); - if (mergedConfig.output.libraryTarget === 'system') { - // Don't used named exports when exporting in System.register format. + if (mergedConfig.output.libraryTarget === 'system' || mergedConfig.output.libraryTarget === 'module') { + // Don't used named exports when exporting in System.register or ES Module format. delete mergedConfig.output.library; }