Skip to content

Commit

Permalink
support ES module format
Browse files Browse the repository at this point in the history
  • Loading branch information
manbearwiz committed Nov 25, 2024
1 parent 905f446 commit 0c3e756
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
35 changes: 35 additions & 0 deletions libs/single-spa-angular/webpack/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
4 changes: 2 additions & 2 deletions libs/single-spa-angular/webpack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 0c3e756

Please sign in to comment.