Skip to content

Commit

Permalink
Merge pull request #20287 from storybookjs/valentin/fix-angular-15.0.…
Browse files Browse the repository at this point in the history
…4-webpack-require-issue

Support Angular 15.0.4
  • Loading branch information
ndelangen authored Dec 15, 2022
2 parents 67a0309 + 57d967d commit 970fc0d
Showing 1 changed file with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,28 @@ export default class StorybookNormalizeAngularEntryPlugin {
}

apply(compiler) {
const webpackOptions = compiler.options;
const entry =
typeof webpackOptions.entry === 'function' ? webpackOptions.entry() : webpackOptions.entry;
compiler.hooks.environment.tap(PLUGIN_NAME, () => {
const webpackOptions = compiler.options;
const entry =
typeof webpackOptions.entry === 'function' ? webpackOptions.entry() : webpackOptions.entry;

webpackOptions.entry = async () => {
const entryResult = await entry;
webpackOptions.entry = async () => {
const entryResult = await entry;

if (entryResult.main && entryResult.styles) {
return {
main: {
import: Array.from(new Set([...entryResult.main.import, ...entryResult.styles.import])),
},
};
}
if (entryResult.main && entryResult.styles) {
return {
main: {
import: Array.from(
new Set([...entryResult.main.import, ...entryResult.styles.import])
),
},
};
}

return entry;
};
});

return entry;
};
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
this.compilation = compilation;
});
Expand Down

0 comments on commit 970fc0d

Please sign in to comment.