Skip to content

Commit

Permalink
Fix: Lazy loaded chunk has appended define externals on the begining (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
morriq authored Jun 26, 2019
1 parent aee922e commit 8f99c4d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,18 @@ class MicroservicesWebpackPlugin {
return {[fileName]: compilation.assets[fileName]};
}

const source = compilation.assets[fileName].source();
const supportAmdOnly = 'define(';

if (!source.startsWith(supportAmdOnly)) {
return {[fileName]: compilation.assets[fileName]};
}

const value = [
this.modules
.map(({ cdn, name }) => `define('${name}', ['${cdn}'], function(v) {return v;})`)
.join('\n'),
compilation.assets[fileName].source()
source
].join('\n');

return {[fileName]: new RawSource(value)};
Expand Down

1 comment on commit 8f99c4d

@wjureczka
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obraz

Please sign in to comment.