Skip to content

Commit

Permalink
Merge pull request #23405 from storybookjs/valentin/fix-esm-issue-in-…
Browse files Browse the repository at this point in the history
…angular

Angular: Fix esm issue in combination with rxjs v6
(cherry picked from commit 2535f02)
  • Loading branch information
valentinpalkovic authored and storybook-bot committed Jul 12, 2023
1 parent 0def7ad commit 5069978
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Configuration } from 'webpack';
import * as path from 'path';
import { Preset } from '@storybook/types';
import fs from 'fs';

import { PresetOptions } from './preset-options';
import { AngularOptions } from '../types';
Expand Down Expand Up @@ -49,10 +50,13 @@ export const runNgcc = async () => {
};

export const webpack = async (webpackConfig: Configuration, options: PresetOptions) => {
const { VERSION } = await loadEsmModule<typeof import('@angular/core')>('@angular/core');
const packageJsonPath = require.resolve('@angular/core/package.json');
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
const VERSION = packageJson.version;
const framework = await options.presets.apply<Preset>('framework');
const angularOptions = (typeof framework === 'object' ? framework.options : {}) as AngularOptions;
const isAngular16OrNewer = parseInt(VERSION.major, 10) >= 16;
const angularMajorVersion = VERSION.split('.')[0];
const isAngular16OrNewer = parseInt(angularMajorVersion, 10) >= 16;

// Default to true, if undefined
if (angularOptions.enableIvy === false) {
Expand Down

0 comments on commit 5069978

Please sign in to comment.