Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen committed Jul 15, 2022
1 parent 30fd916 commit 9d4a720
Show file tree
Hide file tree
Showing 38 changed files with 826 additions and 1,102 deletions.
4 changes: 2 additions & 2 deletions .babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ module.exports = {
shippedProposals: true,
useBuiltIns: 'usage',
targets: {
node: '10',
node: '14',
},
modules,
corejs: '3',
Expand Down Expand Up @@ -149,7 +149,7 @@ module.exports = {
shippedProposals: true,
useBuiltIns: 'usage',
targets: {
node: '10',
node: '14',
},
corejs: '3',
modules: false,
Expand Down
3 changes: 3 additions & 0 deletions addons/docs/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export async function webpack(
const sourceLoader = sourceLoaderOptions
? [
{
layer: 'storybook_source',
test: /\.(stories|story)\.[tj]sx?$/,
loader: require.resolve('@storybook/source-loader'),
options: { ...sourceLoaderOptions, inspectLocalDependencies: true },
Expand Down Expand Up @@ -104,6 +105,7 @@ export async function webpack(
rules: [
...rules,
{
layer: 'storybook_mdx',
test: /(stories|story)\.mdx$/,
use: [
{
Expand All @@ -116,6 +118,7 @@ export async function webpack(
],
},
{
layer: 'storybook_mdx',
test: /\.mdx$/,
exclude: /(stories|story)\.mdx$/,
use: [
Expand Down
2 changes: 0 additions & 2 deletions docs/snippets/common/storybook-builder-api-interface.ts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,5 @@ export interface Builder<Config, Stats> {
}) => Promise<void | Stats>;
bail: (e?: Error) => Promise<void>;
getConfig: (options: Options) => Promise<Config>;
corePresets?: string[];
overridePresets?: string[];
}
```
3 changes: 1 addition & 2 deletions examples/html-kitchen-sink/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@storybook/addon-highlight": "7.0.0-alpha.12",
"@storybook/addon-jest": "7.0.0-alpha.12",
"@storybook/addon-links": "7.0.0-alpha.12",
"@storybook/addon-postcss": "^2.0.0",
"@storybook/addon-postcss": "^3.0.0-alpha.0",
"@storybook/addon-storyshots": "7.0.0-alpha.12",
"@storybook/addon-storysource": "7.0.0-alpha.12",
"@storybook/addon-viewport": "7.0.0-alpha.12",
Expand All @@ -36,7 +36,6 @@
"format-json": "^1.0.3",
"global": "^4.4.0",
"postcss": "^8.2.4",
"postcss-color-rebeccapurple": "^6.0.0",
"storybook": "7.0.0-alpha.12"
},
"storybook": {
Expand Down
2 changes: 0 additions & 2 deletions examples/html-kitchen-sink/postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@ module.exports = {
plugins: [
// eslint-disable-next-line global-require
require('autoprefixer'),
// eslint-disable-next-line global-require
require('postcss-color-rebeccapurple'),
],
};
8 changes: 4 additions & 4 deletions lib/builder-manager/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import aliasPlugin from 'esbuild-plugin-alias';
import { renderHTML } from './utils/template';
import { definitions } from './utils/globals';
import {
BuilderBuildOptions,
BuilderBuildResult,
BuilderFunction,
BuilderStartOptions,
Expand Down Expand Up @@ -121,6 +122,8 @@ const starter: StarterFunction = async function* starterGeneratorFn({
}
});

logger.trace({ message: '=> Manager started', time: process.hrtime(startTime) });

return {
bail,
stats: {
Expand Down Expand Up @@ -211,7 +214,7 @@ export const start = async (options: BuilderStartOptions) => {
return result.value;
};

export const build = async (options: BuilderStartOptions) => {
export const build = async (options: BuilderBuildOptions) => {
asyncIterator = builder(options);
let result;

Expand All @@ -222,6 +225,3 @@ export const build = async (options: BuilderStartOptions) => {

return result.value;
};

export const corePresets: ManagerBuilder['corePresets'] = [];
export const overridePresets: ManagerBuilder['overridePresets'] = [];
1 change: 1 addition & 0 deletions lib/builder-webpack5/preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist/index');
23 changes: 6 additions & 17 deletions lib/builder-webpack5/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { logger } from '@storybook/node-logger';
import { useProgressReporting } from '@storybook/core-common';
import type { Builder, Options } from '@storybook/core-common';
import { checkWebpackVersion } from '@storybook/core-webpack';
import { createWebpackConfig } from './utils/webpack';

export * from './types';

Expand Down Expand Up @@ -39,20 +40,11 @@ export const executor = {

export const getConfig: WebpackBuilder['getConfig'] = async (options) => {
const { presets } = options;
const typescriptOptions = await presets.apply('typescript', {}, options);
const babelOptions = await presets.apply('babel', {}, { ...options, typescriptOptions });
const framework = await presets.apply<any>('framework', {}, options);

return presets.apply(
'webpack',
{},
{
...options,
babelOptions,
typescriptOptions,
frameworkOptions: typeof framework === 'string' ? {} : framework?.options,
}
) as any;

const base = await createWebpackConfig(options);
const intermediate = await presets.apply<Configuration>('webpack', base);

return presets.apply<Configuration>('webpackFinal', intermediate);
};

let asyncIterator: ReturnType<StarterFunction> | ReturnType<BuilderFunction>;
Expand Down Expand Up @@ -261,6 +253,3 @@ export const build = async (options: BuilderStartOptions) => {

return result.value;
};

export const corePresets = [require.resolve('./presets/preview-preset.js')];
export const overridePresets = [require.resolve('./presets/custom-webpack-preset.js')];
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import webpackConfig from '../preview/iframe-webpack.config';

export const webpack = async (_: unknown, options: any) => webpackConfig(options);

export const entries = async (_: unknown, options: any) => {
let result: string[] = [];

Expand Down
47 changes: 0 additions & 47 deletions lib/builder-webpack5/src/presets/custom-webpack-preset.ts

This file was deleted.

16 changes: 0 additions & 16 deletions lib/builder-webpack5/src/preview/babel-loader-preview.ts

This file was deleted.

100 changes: 0 additions & 100 deletions lib/builder-webpack5/src/preview/base-webpack.config.ts

This file was deleted.

Loading

0 comments on commit 9d4a720

Please sign in to comment.