Core: Expose entire webpack package to addons, not just compiler

This commit is contained in:
Michael Shilman 2021-05-24 13:26:28 +08:00
parent 74079bcb61
commit bd86e6c575
6 changed files with 10 additions and 6 deletions

View File

@ -21,7 +21,8 @@ export const executor = {
get: async (options: Options) => {
const version = ((await options.presets.apply('webpackVersion')) || '4') as string;
const webpackInstance =
(await options.presets.apply<typeof webpackType>('webpackInstance')) || webpackReal;
(await options.presets.apply<{ default: typeof webpackType }>('webpackInstance'))?.default ||
webpackReal;
checkWebpackVersion({ version }, '4', 'builder-webpack4');
return webpackInstance;
},

View File

@ -1,4 +1,4 @@
import webpackReal from 'webpack';
import * as webpackReal from 'webpack';
import { logger } from '@storybook/node-logger';
import { loadCustomWebpackConfig } from '@storybook/core-common';
import { createDefaultWebpackConfig } from '../preview/base-webpack.config';

View File

@ -40,7 +40,8 @@ export const executor = {
get: async (options: Options) => {
const version = ((await options.presets.apply('webpackVersion')) || '5') as string;
const webpackInstance =
(await options.presets.apply<typeof webpack>('webpackInstance')) || webpack;
(await options.presets.apply<{ default: typeof webpack }>('webpackInstance'))?.default ||
webpack;
checkWebpackVersion({ version }, '5', 'builder-webpack5');
return webpackInstance;
},

View File

@ -1,4 +1,4 @@
import webpackReal from 'webpack';
import * as webpackReal from 'webpack';
import { logger } from '@storybook/node-logger';
import { loadCustomWebpackConfig, Options } from '@storybook/core-common';
import type { Configuration } from 'webpack';

View File

@ -31,7 +31,8 @@ export const executor = {
get: async (options: Options) => {
const version = ((await options.presets.apply('webpackVersion')) || '4') as string;
const webpackInstance =
(await options.presets.apply<typeof webpack>('webpackInstance')) || webpack;
(await options.presets.apply<{ default: typeof webpack }>('webpackInstance'))?.default ||
webpack;
checkWebpackVersion({ version }, '4', 'manager-webpack4');
return webpackInstance;
},

View File

@ -31,7 +31,8 @@ export const executor = {
get: async (options: Options) => {
const version = ((await options.presets.apply('webpackVersion')) || '5') as string;
const webpackInstance =
(await options.presets.apply<typeof webpack>('webpackInstance')) || webpack;
(await options.presets.apply<{ default: typeof webpack }>('webpackInstance'))?.default ||
webpack;
checkWebpackVersion({ version }, '5', 'manager-webpack5');
return webpackInstance;
},