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

Angular: Fix esm issue in combination with rxjs v6 #23405

Merged
merged 1 commit into from Jul 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

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