@storybook/builder-webpack5 7.0.0-alpha.1 → 7.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,27 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useBaseTsSupport = exports.createBabelLoader = void 0;
6
+ exports.createBabelLoader = void 0;
7
7
 
8
8
  var _coreCommon = require("@storybook/core-common");
9
9
 
10
- /**
11
- * Returns true if the framework can use the base TS config.
12
- * @param {string} framework
13
- */
14
- var useBaseTsSupport = function (framework) {
15
- // These packages both have their own TS implementation.
16
- return !['@storybook/vue', '@storybook/angular'].includes(framework);
17
- };
18
-
19
- exports.useBaseTsSupport = useBaseTsSupport;
20
-
21
- var createBabelLoader = function (options, framework) {
10
+ var createBabelLoader = function (options, typescriptOptions) {
22
11
  return {
23
- test: useBaseTsSupport(framework) ? /\.(mjs|tsx?|jsx?)$/ : /\.(mjs|jsx?)$/,
12
+ test: typescriptOptions.skipBabel ? /\.(mjs|jsx?)$/ : /\.(mjs|tsx?|jsx?)$/,
24
13
  use: [{
25
- loader: require.resolve('babel-loader') // options,
26
-
14
+ loader: require.resolve('babel-loader'),
15
+ options: options
27
16
  }],
28
17
  include: [(0, _coreCommon.getProjectRoot)()],
29
18
  exclude: /node_modules/
@@ -27,8 +27,6 @@ var _coreCommon = require("@storybook/core-common");
27
27
 
28
28
  var _babelLoaderPreview = require("./babel-loader-preview");
29
29
 
30
- var _useBaseTsSupport = require("./useBaseTsSupport");
31
-
32
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
31
 
34
32
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -37,21 +35,23 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
37
35
 
38
36
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
39
37
 
40
- var storybookPaths = ['addons', 'api', 'channels', 'channel-postmessage', 'components', 'core-events', 'router', 'theming', 'semver', 'client-api', 'client-logger'].reduce(function (acc, sbPackage) {
38
+ var storybookPaths = _objectSpread({
39
+ global: _path.default.dirname(require.resolve(`global/package.json`))
40
+ }, ['addons', 'api', 'store', 'channels', 'channel-postmessage', 'channel-websocket', 'components', 'core-events', 'router', 'theming', 'semver', 'preview-web', 'client-api', 'client-logger'].reduce(function (acc, sbPackage) {
41
41
  return _objectSpread(_objectSpread({}, acc), {}, {
42
42
  [`@storybook/${sbPackage}`]: _path.default.dirname(require.resolve(`@storybook/${sbPackage}/package.json`))
43
43
  });
44
- }, {});
44
+ }, {}));
45
45
 
46
46
  var _default = async function _default(options) {
47
- var babelOptions = options.babelOptions,
48
- _options$outputDir = options.outputDir,
47
+ var _options$outputDir = options.outputDir,
49
48
  outputDir = _options$outputDir === void 0 ? _path.default.join('.', 'public') : _options$outputDir,
50
49
  quiet = options.quiet,
51
50
  packageJson = options.packageJson,
52
51
  configType = options.configType,
53
52
  presets = options.presets,
54
53
  previewUrl = options.previewUrl,
54
+ babelOptions = options.babelOptions,
55
55
  typescriptOptions = options.typescriptOptions,
56
56
  features = options.features,
57
57
  serverChannelUrl = options.serverChannelUrl;
@@ -72,16 +72,13 @@ var _default = async function _default(options) {
72
72
  frameworkName = _ref.name,
73
73
  frameworkOptions = _ref.options;
74
74
 
75
+ var isProd = configType === 'PRODUCTION';
75
76
  var envs = await presets.apply('env');
76
- var logLevel = await presets.apply('logLevel', undefined); // FIXME: migrate away from frameworkOptions
77
- // const frameworkOptions = await presets.apply(`${framework}Options`, {});
78
-
77
+ var logLevel = await presets.apply('logLevel', undefined);
79
78
  var headHtmlSnippet = await presets.apply('previewHead');
80
79
  var bodyHtmlSnippet = await presets.apply('previewBody');
81
80
  var template = await presets.apply('previewMainTemplate');
82
81
  var coreOptions = await presets.apply('core');
83
- var babelLoader = (0, _babelLoaderPreview.createBabelLoader)(babelOptions, frameworkName);
84
- var isProd = configType === 'PRODUCTION';
85
82
  var configs = [...(await presets.apply('config', [], options)), (0, _coreCommon.loadPreviewOrConfigFile)(options)].filter(Boolean);
86
83
  var entries = await presets.apply('entries', [], options);
87
84
  var workingDir = process.cwd();
@@ -140,7 +137,7 @@ var _default = async function _default(options) {
140
137
  }
141
138
  }
142
139
 
143
- var shouldCheckTs = (0, _useBaseTsSupport.useBaseTsSupport)(frameworkName) && typescriptOptions.check;
140
+ var shouldCheckTs = typescriptOptions.check && !typescriptOptions.skipBabel;
144
141
  var tsCheckOptions = typescriptOptions.checkOptions || {};
145
142
  return {
146
143
  name: 'preview',
@@ -203,7 +200,7 @@ var _default = async function _default(options) {
203
200
  process: require.resolve('process/browser.js')
204
201
  }), isProd ? null : new _webpack.HotModuleReplacementPlugin(), new _caseSensitivePathsWebpackPlugin.default(), quiet ? null : new _webpack.ProgressPlugin({}), shouldCheckTs ? new _forkTsCheckerWebpackPlugin.default(tsCheckOptions) : null].filter(Boolean),
205
202
  module: {
206
- rules: [babelLoader, {
203
+ rules: [(0, _babelLoaderPreview.createBabelLoader)(babelOptions, typescriptOptions), {
207
204
  test: /\.md$/,
208
205
  type: 'asset/source'
209
206
  }]
@@ -233,9 +230,7 @@ var _default = async function _default(options) {
233
230
  sourceMap: true,
234
231
  mangle: false,
235
232
  keep_fnames: true
236
- } // It looks like the types from `@types/terser-webpack-plugin` are not matching the latest version of
237
- // Webpack yet
238
-
233
+ }
239
234
  })] : []
240
235
  },
241
236
  performance: {
@@ -1,19 +1,10 @@
1
1
  import { getProjectRoot } from '@storybook/core-common';
2
- /**
3
- * Returns true if the framework can use the base TS config.
4
- * @param {string} framework
5
- */
6
-
7
- export var useBaseTsSupport = function (framework) {
8
- // These packages both have their own TS implementation.
9
- return !['@storybook/vue', '@storybook/angular'].includes(framework);
10
- };
11
- export var createBabelLoader = function (options, framework) {
2
+ export var createBabelLoader = function (options, typescriptOptions) {
12
3
  return {
13
- test: useBaseTsSupport(framework) ? /\.(mjs|tsx?|jsx?)$/ : /\.(mjs|jsx?)$/,
4
+ test: typescriptOptions.skipBabel ? /\.(mjs|jsx?)$/ : /\.(mjs|tsx?|jsx?)$/,
14
5
  use: [{
15
- loader: require.resolve('babel-loader') // options,
16
-
6
+ loader: require.resolve('babel-loader'),
7
+ options: options
17
8
  }],
18
9
  include: [getProjectRoot()],
19
10
  exclude: /node_modules/
@@ -17,21 +17,24 @@ import VirtualModulePlugin from 'webpack-virtual-modules';
17
17
  import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
18
18
  import { toRequireContextString, stringifyProcessEnvs, handlebars, interpolate, toImportFn, normalizeStories, readTemplate, loadPreviewOrConfigFile } from '@storybook/core-common';
19
19
  import { createBabelLoader } from './babel-loader-preview';
20
- import { useBaseTsSupport } from './useBaseTsSupport';
21
- var storybookPaths = ['addons', 'api', 'channels', 'channel-postmessage', 'components', 'core-events', 'router', 'theming', 'semver', 'client-api', 'client-logger'].reduce(function (acc, sbPackage) {
20
+
21
+ var storybookPaths = _objectSpread({
22
+ global: path.dirname(require.resolve(`global/package.json`))
23
+ }, ['addons', 'api', 'store', 'channels', 'channel-postmessage', 'channel-websocket', 'components', 'core-events', 'router', 'theming', 'semver', 'preview-web', 'client-api', 'client-logger'].reduce(function (acc, sbPackage) {
22
24
  return _objectSpread(_objectSpread({}, acc), {}, {
23
25
  [`@storybook/${sbPackage}`]: path.dirname(require.resolve(`@storybook/${sbPackage}/package.json`))
24
26
  });
25
- }, {});
27
+ }, {}));
28
+
26
29
  export default (async function (options) {
27
- var babelOptions = options.babelOptions,
28
- _options$outputDir = options.outputDir,
30
+ var _options$outputDir = options.outputDir,
29
31
  outputDir = _options$outputDir === void 0 ? path.join('.', 'public') : _options$outputDir,
30
32
  quiet = options.quiet,
31
33
  packageJson = options.packageJson,
32
34
  configType = options.configType,
33
35
  presets = options.presets,
34
36
  previewUrl = options.previewUrl,
37
+ babelOptions = options.babelOptions,
35
38
  typescriptOptions = options.typescriptOptions,
36
39
  features = options.features,
37
40
  serverChannelUrl = options.serverChannelUrl;
@@ -52,16 +55,13 @@ export default (async function (options) {
52
55
  frameworkName = _ref.name,
53
56
  frameworkOptions = _ref.options;
54
57
 
58
+ var isProd = configType === 'PRODUCTION';
55
59
  var envs = await presets.apply('env');
56
- var logLevel = await presets.apply('logLevel', undefined); // FIXME: migrate away from frameworkOptions
57
- // const frameworkOptions = await presets.apply(`${framework}Options`, {});
58
-
60
+ var logLevel = await presets.apply('logLevel', undefined);
59
61
  var headHtmlSnippet = await presets.apply('previewHead');
60
62
  var bodyHtmlSnippet = await presets.apply('previewBody');
61
63
  var template = await presets.apply('previewMainTemplate');
62
64
  var coreOptions = await presets.apply('core');
63
- var babelLoader = createBabelLoader(babelOptions, frameworkName);
64
- var isProd = configType === 'PRODUCTION';
65
65
  var configs = [...(await presets.apply('config', [], options)), loadPreviewOrConfigFile(options)].filter(Boolean);
66
66
  var entries = await presets.apply('entries', [], options);
67
67
  var workingDir = process.cwd();
@@ -115,7 +115,7 @@ export default (async function (options) {
115
115
  }
116
116
  }
117
117
 
118
- var shouldCheckTs = useBaseTsSupport(frameworkName) && typescriptOptions.check;
118
+ var shouldCheckTs = typescriptOptions.check && !typescriptOptions.skipBabel;
119
119
  var tsCheckOptions = typescriptOptions.checkOptions || {};
120
120
  return {
121
121
  name: 'preview',
@@ -178,7 +178,7 @@ export default (async function (options) {
178
178
  process: require.resolve('process/browser.js')
179
179
  }), isProd ? null : new HotModuleReplacementPlugin(), new CaseSensitivePathsPlugin(), quiet ? null : new ProgressPlugin({}), shouldCheckTs ? new ForkTsCheckerWebpackPlugin(tsCheckOptions) : null].filter(Boolean),
180
180
  module: {
181
- rules: [babelLoader, {
181
+ rules: [createBabelLoader(babelOptions, typescriptOptions), {
182
182
  test: /\.md$/,
183
183
  type: 'asset/source'
184
184
  }]
@@ -208,9 +208,7 @@ export default (async function (options) {
208
208
  sourceMap: true,
209
209
  mangle: false,
210
210
  keep_fnames: true
211
- } // It looks like the types from `@types/terser-webpack-plugin` are not matching the latest version of
212
- // Webpack yet
213
-
211
+ }
214
212
  })] : []
215
213
  },
216
214
  performance: {
@@ -1,12 +1,9 @@
1
- /**
2
- * Returns true if the framework can use the base TS config.
3
- * @param {string} framework
4
- */
5
- export declare const useBaseTsSupport: (framework: string) => boolean;
6
- export declare const createBabelLoader: (options: any, framework: string) => {
1
+ import { TypescriptOptions } from '../types';
2
+ export declare const createBabelLoader: (options: any, typescriptOptions: TypescriptOptions) => {
7
3
  test: RegExp;
8
4
  use: {
9
5
  loader: string;
6
+ options: any;
10
7
  }[];
11
8
  include: string[];
12
9
  exclude: RegExp;
@@ -1,4 +1,7 @@
1
1
  import type { Configuration } from 'webpack';
2
2
  import type { Options } from '@storybook/core-common';
3
- declare const _default: (options: Options & Record<string, any>) => Promise<Configuration>;
3
+ import type { TypescriptOptions } from '../types';
4
+ declare const _default: (options: Options & Record<string, any> & {
5
+ typescriptOptions: TypescriptOptions;
6
+ }) => Promise<Configuration>;
4
7
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/builder-webpack5",
3
- "version": "7.0.0-alpha.1",
3
+ "version": "7.0.0-alpha.2",
4
4
  "description": "Storybook framework-agnostic API",
5
5
  "keywords": [
6
6
  "storybook"
@@ -33,22 +33,23 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@babel/core": "^7.12.10",
36
- "@storybook/addons": "7.0.0-alpha.1",
37
- "@storybook/api": "7.0.0-alpha.1",
38
- "@storybook/channel-postmessage": "7.0.0-alpha.1",
39
- "@storybook/channels": "7.0.0-alpha.1",
40
- "@storybook/client-api": "7.0.0-alpha.1",
41
- "@storybook/client-logger": "7.0.0-alpha.1",
42
- "@storybook/components": "7.0.0-alpha.1",
43
- "@storybook/core-common": "7.0.0-alpha.1",
44
- "@storybook/core-events": "7.0.0-alpha.1",
45
- "@storybook/core-webpack": "7.0.0-alpha.1",
46
- "@storybook/node-logger": "7.0.0-alpha.1",
47
- "@storybook/preview-web": "7.0.0-alpha.1",
48
- "@storybook/router": "7.0.0-alpha.1",
36
+ "@storybook/addons": "7.0.0-alpha.2",
37
+ "@storybook/api": "7.0.0-alpha.2",
38
+ "@storybook/channel-postmessage": "7.0.0-alpha.2",
39
+ "@storybook/channel-websocket": "7.0.0-alpha.2",
40
+ "@storybook/channels": "7.0.0-alpha.2",
41
+ "@storybook/client-api": "7.0.0-alpha.2",
42
+ "@storybook/client-logger": "7.0.0-alpha.2",
43
+ "@storybook/components": "7.0.0-alpha.2",
44
+ "@storybook/core-common": "7.0.0-alpha.2",
45
+ "@storybook/core-events": "7.0.0-alpha.2",
46
+ "@storybook/core-webpack": "7.0.0-alpha.2",
47
+ "@storybook/node-logger": "7.0.0-alpha.2",
48
+ "@storybook/preview-web": "7.0.0-alpha.2",
49
+ "@storybook/router": "7.0.0-alpha.2",
49
50
  "@storybook/semver": "^7.3.2",
50
- "@storybook/store": "7.0.0-alpha.1",
51
- "@storybook/theming": "7.0.0-alpha.1",
51
+ "@storybook/store": "7.0.0-alpha.2",
52
+ "@storybook/theming": "7.0.0-alpha.2",
52
53
  "@types/node": "^14.0.10 || ^16.0.0",
53
54
  "babel-loader": "^8.2.5",
54
55
  "babel-plugin-named-exports-order": "^0.0.2",
@@ -59,6 +60,7 @@
59
60
  "fork-ts-checker-webpack-plugin": "^7.2.8",
60
61
  "glob": "^7.1.6",
61
62
  "glob-promise": "^3.4.0",
63
+ "global": "^4.4.0",
62
64
  "html-webpack-plugin": "^5.5.0",
63
65
  "path-browserify": "^1.0.1",
64
66
  "process": "^0.11.10",
@@ -91,5 +93,5 @@
91
93
  "publishConfig": {
92
94
  "access": "public"
93
95
  },
94
- "gitHead": "b90b85210f66da59656c2ef58b0910b156256bea"
96
+ "gitHead": "44920e2b6bd51981bac5124743c29fb9f5517e44"
95
97
  }
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useBaseTsSupport = void 0;
7
-
8
- /**
9
- * Returns true if the framework can use the base TS config.
10
- * @param {string} framework
11
- */
12
- var useBaseTsSupport = function (framework) {
13
- // These packages both have their own TS implementation.
14
- return !['@storybook/vue', '@storybook/angular'].includes(framework);
15
- };
16
-
17
- exports.useBaseTsSupport = useBaseTsSupport;
@@ -1,8 +0,0 @@
1
- /**
2
- * Returns true if the framework can use the base TS config.
3
- * @param {string} framework
4
- */
5
- export var useBaseTsSupport = function (framework) {
6
- // These packages both have their own TS implementation.
7
- return !['@storybook/vue', '@storybook/angular'].includes(framework);
8
- };
@@ -1,5 +0,0 @@
1
- /**
2
- * Returns true if the framework can use the base TS config.
3
- * @param {string} framework
4
- */
5
- export declare const useBaseTsSupport: (framework: string) => boolean;