Skip to content

Commit

Permalink
Fix: Stop making assumption that bundle might start with 'define(' (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
morriq authored Dec 18, 2019
1 parent f0ad978 commit d75acb5
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,15 @@ class MicroservicesWebpackPlugin {
async tapAsync(compilation, callback) {
this.modules = await this.createUrlsToModules(this.modules);

const { libraryTarget } = compilation.runtimeTemplate.outputOptions;

compilation.assets = fromEntries(Object.entries(compilation.assets)
.map(([fileName, asset]) => {
if (!fileName.includes('.js')) {
if (!fileName.includes('.js') || libraryTarget !== 'amd') {
return [fileName, asset];
}

const source = asset.source();
const supportAmdOnly = 'define(';

if (!source.startsWith(supportAmdOnly)) {
return [fileName, asset];
}

const value = [
this.modules
Expand Down

0 comments on commit d75acb5

Please sign in to comment.