Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't used named exports when exporting in ES Module format. #531

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading