@storybook/core-server 6.4.0-rc.0 → 6.4.0-rc.4
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.
- package/dist/cjs/build-static.js +5 -3
- package/dist/cjs/utils/StoryIndexGenerator.js +13 -11
- package/dist/cjs/utils/get-manager-builder.js +6 -3
- package/dist/cjs/utils/get-preview-builder.js +13 -4
- package/dist/cjs/utils/stories-json.js +2 -1
- package/dist/esm/build-static.js +5 -3
- package/dist/esm/utils/StoryIndexGenerator.js +13 -12
- package/dist/esm/utils/get-manager-builder.js +6 -3
- package/dist/esm/utils/get-preview-builder.js +13 -4
- package/dist/esm/utils/stories-json.js +2 -1
- package/dist/modern/build-static.js +5 -3
- package/dist/modern/utils/StoryIndexGenerator.js +13 -12
- package/dist/modern/utils/get-manager-builder.js +6 -3
- package/dist/modern/utils/get-preview-builder.js +13 -4
- package/dist/modern/utils/stories-json.js +2 -1
- package/dist/ts3.4/utils/StoryIndexGenerator.d.ts +2 -0
- package/dist/ts3.4/utils/stories-json.d.ts +1 -0
- package/dist/ts3.9/utils/StoryIndexGenerator.d.ts +2 -0
- package/dist/ts3.9/utils/stories-json.d.ts +1 -0
- package/package.json +13 -13
package/dist/cjs/build-static.js
CHANGED
|
@@ -65,7 +65,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
65
65
|
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; }
|
|
66
66
|
|
|
67
67
|
async function buildStaticStandalone(options) {
|
|
68
|
-
var _options$staticDir;
|
|
68
|
+
var _options$staticDir, _core$builder;
|
|
69
69
|
|
|
70
70
|
/* eslint-disable no-param-reassign */
|
|
71
71
|
options.configType = 'PRODUCTION';
|
|
@@ -127,7 +127,8 @@ async function buildStaticStandalone(options) {
|
|
|
127
127
|
};
|
|
128
128
|
var stories = (0, _coreCommon.normalizeStories)(await presets.apply('stories'), directories);
|
|
129
129
|
await (0, _storiesJson.extractStoriesJson)(_path.default.join(options.outputDir, 'stories.json'), stories, _objectSpread(_objectSpread({}, directories), {}, {
|
|
130
|
-
storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7)
|
|
130
|
+
storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7),
|
|
131
|
+
storyStoreV7: features === null || features === void 0 ? void 0 : features.storyStoreV7
|
|
131
132
|
}));
|
|
132
133
|
}
|
|
133
134
|
|
|
@@ -142,8 +143,9 @@ async function buildStaticStandalone(options) {
|
|
|
142
143
|
}
|
|
143
144
|
|
|
144
145
|
var core = await presets.apply('core');
|
|
146
|
+
var builderName = typeof (core === null || core === void 0 ? void 0 : core.builder) === 'string' ? core.builder : core === null || core === void 0 ? void 0 : (_core$builder = core.builder) === null || _core$builder === void 0 ? void 0 : _core$builder.name;
|
|
145
147
|
|
|
146
|
-
var _ref =
|
|
148
|
+
var _ref = builderName === 'webpack5' ? await Promise.resolve().then(function () {
|
|
147
149
|
return _interopRequireWildcard(require('@storybook/manager-webpack5/prebuilt-manager'));
|
|
148
150
|
}) : await Promise.resolve().then(function () {
|
|
149
151
|
return _interopRequireWildcard(require('@storybook/manager-webpack4/prebuilt-manager'));
|
|
@@ -47,15 +47,6 @@ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(
|
|
|
47
47
|
|
|
48
48
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
49
49
|
|
|
50
|
-
function sortExtractedStories(stories, storySortParameter, fileNameOrder) {
|
|
51
|
-
var sortableStories = Object.values(stories);
|
|
52
|
-
(0, _store.sortStoriesV7)(sortableStories, storySortParameter, fileNameOrder);
|
|
53
|
-
return sortableStories.reduce(function (acc, item) {
|
|
54
|
-
acc[item.id] = item;
|
|
55
|
-
return acc;
|
|
56
|
-
}, {});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
50
|
class StoryIndexGenerator {
|
|
60
51
|
// An internal cache mapping specifiers to a set of path=><set of stories>
|
|
61
52
|
// Later, we'll combine each of these subsets together to form the full index
|
|
@@ -152,8 +143,19 @@ class StoryIndexGenerator {
|
|
|
152
143
|
storiesList.forEach(function (subStories) {
|
|
153
144
|
Object.assign(stories, subStories);
|
|
154
145
|
});
|
|
155
|
-
var
|
|
156
|
-
|
|
146
|
+
var sortableStories = Object.values(stories); // Skip sorting if we're in v6 mode because we don't have
|
|
147
|
+
// all the info we need here
|
|
148
|
+
|
|
149
|
+
if (this.options.storyStoreV7) {
|
|
150
|
+
var storySortParameter = await this.getStorySortParameter();
|
|
151
|
+
var fileNameOrder = this.storyFileNames();
|
|
152
|
+
(0, _store.sortStoriesV7)(sortableStories, storySortParameter, fileNameOrder);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return sortableStories.reduce(function (acc, item) {
|
|
156
|
+
acc[item.id] = item;
|
|
157
|
+
return acc;
|
|
158
|
+
}, {});
|
|
157
159
|
}
|
|
158
160
|
|
|
159
161
|
async getIndex() {
|
|
@@ -18,6 +18,8 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
|
|
|
18
18
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
19
|
|
|
20
20
|
async function getManagerBuilder(configDir) {
|
|
21
|
+
var _core$builder;
|
|
22
|
+
|
|
21
23
|
var main = _path.default.resolve(configDir, 'main');
|
|
22
24
|
|
|
23
25
|
var mainFile = (0, _coreCommon.getInterpretedFile)(main);
|
|
@@ -25,14 +27,15 @@ async function getManagerBuilder(configDir) {
|
|
|
25
27
|
var _ref = mainFile ? (0, _coreCommon.serverRequire)(mainFile) : {
|
|
26
28
|
core: null
|
|
27
29
|
},
|
|
28
|
-
core = _ref.core;
|
|
30
|
+
core = _ref.core;
|
|
31
|
+
|
|
32
|
+
var builderName = typeof (core === null || core === void 0 ? void 0 : core.builder) === 'string' ? core.builder : core === null || core === void 0 ? void 0 : (_core$builder = core.builder) === null || _core$builder === void 0 ? void 0 : _core$builder.name; // Builder can be any string including community builders like `storybook-builder-vite`.
|
|
29
33
|
// - For now, `webpack5` triggers `manager-webpack5`
|
|
30
34
|
// - Everything else builds with `manager-webpack4`
|
|
31
35
|
//
|
|
32
36
|
// Unlike preview builders, manager building is not pluggable!
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
var builderPackage = (core === null || core === void 0 ? void 0 : core.builder) === 'webpack5' ? require.resolve('@storybook/manager-webpack5', {
|
|
38
|
+
var builderPackage = builderName === 'webpack5' ? require.resolve('@storybook/manager-webpack5', {
|
|
36
39
|
paths: [main]
|
|
37
40
|
}) : '@storybook/manager-webpack4';
|
|
38
41
|
var managerBuilder = await Promise.resolve(`${builderPackage}`).then(function (s) {
|
|
@@ -27,10 +27,19 @@ async function getPreviewBuilder(configDir) {
|
|
|
27
27
|
},
|
|
28
28
|
core = _ref.core;
|
|
29
29
|
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
var builderPackage;
|
|
31
|
+
|
|
32
|
+
if (core) {
|
|
33
|
+
var _core$builder;
|
|
34
|
+
|
|
35
|
+
var builderName = typeof core.builder === 'string' ? core.builder : (_core$builder = core.builder) === null || _core$builder === void 0 ? void 0 : _core$builder.name;
|
|
36
|
+
builderPackage = require.resolve(['webpack4', 'webpack5'].includes(builderName) ? `@storybook/builder-${builderName}` : builderName, {
|
|
37
|
+
paths: [main]
|
|
38
|
+
});
|
|
39
|
+
} else {
|
|
40
|
+
builderPackage = require.resolve('@storybook/builder-webpack4');
|
|
41
|
+
}
|
|
42
|
+
|
|
34
43
|
var previewBuilder = await Promise.resolve(`${builderPackage}`).then(function (s) {
|
|
35
44
|
return _interopRequireWildcard(require(s));
|
|
36
45
|
});
|
|
@@ -42,7 +42,8 @@ async function useStoriesJson(router, serverChannel, options, workingDir = proce
|
|
|
42
42
|
var generator = new _StoryIndexGenerator.StoryIndexGenerator(normalizedStories, {
|
|
43
43
|
configDir: options.configDir,
|
|
44
44
|
workingDir: workingDir,
|
|
45
|
-
storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7)
|
|
45
|
+
storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7),
|
|
46
|
+
storyStoreV7: features === null || features === void 0 ? void 0 : features.storyStoreV7
|
|
46
47
|
}); // Wait until someone actually requests `stories.json` before we start generating/watching.
|
|
47
48
|
// This is mainly for testing purposes.
|
|
48
49
|
|
package/dist/esm/build-static.js
CHANGED
|
@@ -36,7 +36,7 @@ import { getPreviewBuilder } from './utils/get-preview-builder';
|
|
|
36
36
|
import { getManagerBuilder } from './utils/get-manager-builder';
|
|
37
37
|
import { extractStoriesJson } from './utils/stories-json';
|
|
38
38
|
export async function buildStaticStandalone(options) {
|
|
39
|
-
var _options$staticDir;
|
|
39
|
+
var _options$staticDir, _core$builder;
|
|
40
40
|
|
|
41
41
|
/* eslint-disable no-param-reassign */
|
|
42
42
|
options.configType = 'PRODUCTION';
|
|
@@ -98,7 +98,8 @@ export async function buildStaticStandalone(options) {
|
|
|
98
98
|
};
|
|
99
99
|
var stories = normalizeStories(await presets.apply('stories'), directories);
|
|
100
100
|
await extractStoriesJson(path.join(options.outputDir, 'stories.json'), stories, _objectSpread(_objectSpread({}, directories), {}, {
|
|
101
|
-
storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7)
|
|
101
|
+
storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7),
|
|
102
|
+
storyStoreV7: features === null || features === void 0 ? void 0 : features.storyStoreV7
|
|
102
103
|
}));
|
|
103
104
|
}
|
|
104
105
|
|
|
@@ -113,8 +114,9 @@ export async function buildStaticStandalone(options) {
|
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
var core = await presets.apply('core');
|
|
117
|
+
var builderName = typeof (core === null || core === void 0 ? void 0 : core.builder) === 'string' ? core.builder : core === null || core === void 0 ? void 0 : (_core$builder = core.builder) === null || _core$builder === void 0 ? void 0 : _core$builder.name;
|
|
116
118
|
|
|
117
|
-
var _ref =
|
|
119
|
+
var _ref = builderName === 'webpack5' ? await import('@storybook/manager-webpack5/prebuilt-manager') : await import('@storybook/manager-webpack4/prebuilt-manager'),
|
|
118
120
|
getPrebuiltDir = _ref.getPrebuiltDir;
|
|
119
121
|
|
|
120
122
|
var prebuiltDir = await getPrebuiltDir(fullOptions);
|
|
@@ -27,16 +27,6 @@ import slash from 'slash';
|
|
|
27
27
|
import { autoTitleFromSpecifier, sortStoriesV7 } from '@storybook/store';
|
|
28
28
|
import { logger } from '@storybook/node-logger';
|
|
29
29
|
import { readCsfOrMdx, getStorySortParameter } from '@storybook/csf-tools';
|
|
30
|
-
|
|
31
|
-
function sortExtractedStories(stories, storySortParameter, fileNameOrder) {
|
|
32
|
-
var sortableStories = Object.values(stories);
|
|
33
|
-
sortStoriesV7(sortableStories, storySortParameter, fileNameOrder);
|
|
34
|
-
return sortableStories.reduce(function (acc, item) {
|
|
35
|
-
acc[item.id] = item;
|
|
36
|
-
return acc;
|
|
37
|
-
}, {});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
30
|
export class StoryIndexGenerator {
|
|
41
31
|
// An internal cache mapping specifiers to a set of path=><set of stories>
|
|
42
32
|
// Later, we'll combine each of these subsets together to form the full index
|
|
@@ -129,8 +119,19 @@ export class StoryIndexGenerator {
|
|
|
129
119
|
storiesList.forEach(function (subStories) {
|
|
130
120
|
Object.assign(stories, subStories);
|
|
131
121
|
});
|
|
132
|
-
var
|
|
133
|
-
|
|
122
|
+
var sortableStories = Object.values(stories); // Skip sorting if we're in v6 mode because we don't have
|
|
123
|
+
// all the info we need here
|
|
124
|
+
|
|
125
|
+
if (this.options.storyStoreV7) {
|
|
126
|
+
var storySortParameter = await this.getStorySortParameter();
|
|
127
|
+
var fileNameOrder = this.storyFileNames();
|
|
128
|
+
sortStoriesV7(sortableStories, storySortParameter, fileNameOrder);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return sortableStories.reduce(function (acc, item) {
|
|
132
|
+
acc[item.id] = item;
|
|
133
|
+
return acc;
|
|
134
|
+
}, {});
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
async getIndex() {
|
|
@@ -2,20 +2,23 @@ import "core-js/modules/es.promise.js";
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { getInterpretedFile, serverRequire } from '@storybook/core-common';
|
|
4
4
|
export async function getManagerBuilder(configDir) {
|
|
5
|
+
var _core$builder;
|
|
6
|
+
|
|
5
7
|
var main = path.resolve(configDir, 'main');
|
|
6
8
|
var mainFile = getInterpretedFile(main);
|
|
7
9
|
|
|
8
10
|
var _ref = mainFile ? serverRequire(mainFile) : {
|
|
9
11
|
core: null
|
|
10
12
|
},
|
|
11
|
-
core = _ref.core;
|
|
13
|
+
core = _ref.core;
|
|
14
|
+
|
|
15
|
+
var builderName = typeof (core === null || core === void 0 ? void 0 : core.builder) === 'string' ? core.builder : core === null || core === void 0 ? void 0 : (_core$builder = core.builder) === null || _core$builder === void 0 ? void 0 : _core$builder.name; // Builder can be any string including community builders like `storybook-builder-vite`.
|
|
12
16
|
// - For now, `webpack5` triggers `manager-webpack5`
|
|
13
17
|
// - Everything else builds with `manager-webpack4`
|
|
14
18
|
//
|
|
15
19
|
// Unlike preview builders, manager building is not pluggable!
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
var builderPackage = (core === null || core === void 0 ? void 0 : core.builder) === 'webpack5' ? require.resolve('@storybook/manager-webpack5', {
|
|
21
|
+
var builderPackage = builderName === 'webpack5' ? require.resolve('@storybook/manager-webpack5', {
|
|
19
22
|
paths: [main]
|
|
20
23
|
}) : '@storybook/manager-webpack4';
|
|
21
24
|
var managerBuilder = await import(builderPackage);
|
|
@@ -10,10 +10,19 @@ export async function getPreviewBuilder(configDir) {
|
|
|
10
10
|
},
|
|
11
11
|
core = _ref.core;
|
|
12
12
|
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
var builderPackage;
|
|
14
|
+
|
|
15
|
+
if (core) {
|
|
16
|
+
var _core$builder;
|
|
17
|
+
|
|
18
|
+
var builderName = typeof core.builder === 'string' ? core.builder : (_core$builder = core.builder) === null || _core$builder === void 0 ? void 0 : _core$builder.name;
|
|
19
|
+
builderPackage = require.resolve(['webpack4', 'webpack5'].includes(builderName) ? `@storybook/builder-${builderName}` : builderName, {
|
|
20
|
+
paths: [main]
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
builderPackage = require.resolve('@storybook/builder-webpack4');
|
|
24
|
+
}
|
|
25
|
+
|
|
17
26
|
var previewBuilder = await import(builderPackage);
|
|
18
27
|
return previewBuilder;
|
|
19
28
|
}
|
|
@@ -21,7 +21,8 @@ export async function useStoriesJson(router, serverChannel, options, workingDir
|
|
|
21
21
|
var generator = new StoryIndexGenerator(normalizedStories, {
|
|
22
22
|
configDir: options.configDir,
|
|
23
23
|
workingDir: workingDir,
|
|
24
|
-
storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7)
|
|
24
|
+
storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7),
|
|
25
|
+
storyStoreV7: features === null || features === void 0 ? void 0 : features.storyStoreV7
|
|
25
26
|
}); // Wait until someone actually requests `stories.json` before we start generating/watching.
|
|
26
27
|
// This is mainly for testing purposes.
|
|
27
28
|
|
|
@@ -36,7 +36,7 @@ import { getPreviewBuilder } from './utils/get-preview-builder';
|
|
|
36
36
|
import { getManagerBuilder } from './utils/get-manager-builder';
|
|
37
37
|
import { extractStoriesJson } from './utils/stories-json';
|
|
38
38
|
export async function buildStaticStandalone(options) {
|
|
39
|
-
var _options$staticDir;
|
|
39
|
+
var _options$staticDir, _core$builder;
|
|
40
40
|
|
|
41
41
|
/* eslint-disable no-param-reassign */
|
|
42
42
|
options.configType = 'PRODUCTION';
|
|
@@ -98,7 +98,8 @@ export async function buildStaticStandalone(options) {
|
|
|
98
98
|
};
|
|
99
99
|
var stories = normalizeStories(await presets.apply('stories'), directories);
|
|
100
100
|
await extractStoriesJson(path.join(options.outputDir, 'stories.json'), stories, _objectSpread(_objectSpread({}, directories), {}, {
|
|
101
|
-
storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7)
|
|
101
|
+
storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7),
|
|
102
|
+
storyStoreV7: features === null || features === void 0 ? void 0 : features.storyStoreV7
|
|
102
103
|
}));
|
|
103
104
|
}
|
|
104
105
|
|
|
@@ -113,8 +114,9 @@ export async function buildStaticStandalone(options) {
|
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
var core = await presets.apply('core');
|
|
117
|
+
var builderName = typeof (core === null || core === void 0 ? void 0 : core.builder) === 'string' ? core.builder : core === null || core === void 0 ? void 0 : (_core$builder = core.builder) === null || _core$builder === void 0 ? void 0 : _core$builder.name;
|
|
116
118
|
|
|
117
|
-
var _ref =
|
|
119
|
+
var _ref = builderName === 'webpack5' ? await import('@storybook/manager-webpack5/prebuilt-manager') : await import('@storybook/manager-webpack4/prebuilt-manager'),
|
|
118
120
|
getPrebuiltDir = _ref.getPrebuiltDir;
|
|
119
121
|
|
|
120
122
|
var prebuiltDir = await getPrebuiltDir(fullOptions);
|
|
@@ -27,16 +27,6 @@ import slash from 'slash';
|
|
|
27
27
|
import { autoTitleFromSpecifier, sortStoriesV7 } from '@storybook/store';
|
|
28
28
|
import { logger } from '@storybook/node-logger';
|
|
29
29
|
import { readCsfOrMdx, getStorySortParameter } from '@storybook/csf-tools';
|
|
30
|
-
|
|
31
|
-
function sortExtractedStories(stories, storySortParameter, fileNameOrder) {
|
|
32
|
-
var sortableStories = Object.values(stories);
|
|
33
|
-
sortStoriesV7(sortableStories, storySortParameter, fileNameOrder);
|
|
34
|
-
return sortableStories.reduce(function (acc, item) {
|
|
35
|
-
acc[item.id] = item;
|
|
36
|
-
return acc;
|
|
37
|
-
}, {});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
30
|
export class StoryIndexGenerator {
|
|
41
31
|
// An internal cache mapping specifiers to a set of path=><set of stories>
|
|
42
32
|
// Later, we'll combine each of these subsets together to form the full index
|
|
@@ -129,8 +119,19 @@ export class StoryIndexGenerator {
|
|
|
129
119
|
storiesList.forEach(function (subStories) {
|
|
130
120
|
Object.assign(stories, subStories);
|
|
131
121
|
});
|
|
132
|
-
var
|
|
133
|
-
|
|
122
|
+
var sortableStories = Object.values(stories); // Skip sorting if we're in v6 mode because we don't have
|
|
123
|
+
// all the info we need here
|
|
124
|
+
|
|
125
|
+
if (this.options.storyStoreV7) {
|
|
126
|
+
var storySortParameter = await this.getStorySortParameter();
|
|
127
|
+
var fileNameOrder = this.storyFileNames();
|
|
128
|
+
sortStoriesV7(sortableStories, storySortParameter, fileNameOrder);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return sortableStories.reduce(function (acc, item) {
|
|
132
|
+
acc[item.id] = item;
|
|
133
|
+
return acc;
|
|
134
|
+
}, {});
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
async getIndex() {
|
|
@@ -2,20 +2,23 @@ import "core-js/modules/es.promise.js";
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { getInterpretedFile, serverRequire } from '@storybook/core-common';
|
|
4
4
|
export async function getManagerBuilder(configDir) {
|
|
5
|
+
var _core$builder;
|
|
6
|
+
|
|
5
7
|
var main = path.resolve(configDir, 'main');
|
|
6
8
|
var mainFile = getInterpretedFile(main);
|
|
7
9
|
|
|
8
10
|
var _ref = mainFile ? serverRequire(mainFile) : {
|
|
9
11
|
core: null
|
|
10
12
|
},
|
|
11
|
-
core = _ref.core;
|
|
13
|
+
core = _ref.core;
|
|
14
|
+
|
|
15
|
+
var builderName = typeof (core === null || core === void 0 ? void 0 : core.builder) === 'string' ? core.builder : core === null || core === void 0 ? void 0 : (_core$builder = core.builder) === null || _core$builder === void 0 ? void 0 : _core$builder.name; // Builder can be any string including community builders like `storybook-builder-vite`.
|
|
12
16
|
// - For now, `webpack5` triggers `manager-webpack5`
|
|
13
17
|
// - Everything else builds with `manager-webpack4`
|
|
14
18
|
//
|
|
15
19
|
// Unlike preview builders, manager building is not pluggable!
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
var builderPackage = (core === null || core === void 0 ? void 0 : core.builder) === 'webpack5' ? require.resolve('@storybook/manager-webpack5', {
|
|
21
|
+
var builderPackage = builderName === 'webpack5' ? require.resolve('@storybook/manager-webpack5', {
|
|
19
22
|
paths: [main]
|
|
20
23
|
}) : '@storybook/manager-webpack4';
|
|
21
24
|
var managerBuilder = await import(builderPackage);
|
|
@@ -10,10 +10,19 @@ export async function getPreviewBuilder(configDir) {
|
|
|
10
10
|
},
|
|
11
11
|
core = _ref.core;
|
|
12
12
|
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
var builderPackage;
|
|
14
|
+
|
|
15
|
+
if (core) {
|
|
16
|
+
var _core$builder;
|
|
17
|
+
|
|
18
|
+
var builderName = typeof core.builder === 'string' ? core.builder : (_core$builder = core.builder) === null || _core$builder === void 0 ? void 0 : _core$builder.name;
|
|
19
|
+
builderPackage = require.resolve(['webpack4', 'webpack5'].includes(builderName) ? `@storybook/builder-${builderName}` : builderName, {
|
|
20
|
+
paths: [main]
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
builderPackage = require.resolve('@storybook/builder-webpack4');
|
|
24
|
+
}
|
|
25
|
+
|
|
17
26
|
var previewBuilder = await import(builderPackage);
|
|
18
27
|
return previewBuilder;
|
|
19
28
|
}
|
|
@@ -21,7 +21,8 @@ export async function useStoriesJson(router, serverChannel, options, workingDir
|
|
|
21
21
|
var generator = new StoryIndexGenerator(normalizedStories, {
|
|
22
22
|
configDir: options.configDir,
|
|
23
23
|
workingDir: workingDir,
|
|
24
|
-
storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7)
|
|
24
|
+
storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7),
|
|
25
|
+
storyStoreV7: features === null || features === void 0 ? void 0 : features.storyStoreV7
|
|
25
26
|
}); // Wait until someone actually requests `stories.json` before we start generating/watching.
|
|
26
27
|
// This is mainly for testing purposes.
|
|
27
28
|
|
|
@@ -6,6 +6,7 @@ export declare class StoryIndexGenerator {
|
|
|
6
6
|
workingDir: Path;
|
|
7
7
|
configDir: Path;
|
|
8
8
|
storiesV2Compatibility: boolean;
|
|
9
|
+
storyStoreV7: boolean;
|
|
9
10
|
};
|
|
10
11
|
private storyIndexEntries;
|
|
11
12
|
private lastIndex?;
|
|
@@ -13,6 +14,7 @@ export declare class StoryIndexGenerator {
|
|
|
13
14
|
workingDir: Path;
|
|
14
15
|
configDir: Path;
|
|
15
16
|
storiesV2Compatibility: boolean;
|
|
17
|
+
storyStoreV7: boolean;
|
|
16
18
|
});
|
|
17
19
|
initialize(): Promise<void>;
|
|
18
20
|
ensureExtracted(): Promise<StoryIndex['stories'][]>;
|
|
@@ -6,5 +6,6 @@ export declare function extractStoriesJson(outputFile: string, normalizedStories
|
|
|
6
6
|
configDir: string;
|
|
7
7
|
workingDir: string;
|
|
8
8
|
storiesV2Compatibility: boolean;
|
|
9
|
+
storyStoreV7: boolean;
|
|
9
10
|
}): Promise<void>;
|
|
10
11
|
export declare function useStoriesJson(router: Router, serverChannel: ServerChannel, options: Options, workingDir?: string): Promise<void>;
|
|
@@ -6,6 +6,7 @@ export declare class StoryIndexGenerator {
|
|
|
6
6
|
workingDir: Path;
|
|
7
7
|
configDir: Path;
|
|
8
8
|
storiesV2Compatibility: boolean;
|
|
9
|
+
storyStoreV7: boolean;
|
|
9
10
|
};
|
|
10
11
|
private storyIndexEntries;
|
|
11
12
|
private lastIndex?;
|
|
@@ -13,6 +14,7 @@ export declare class StoryIndexGenerator {
|
|
|
13
14
|
workingDir: Path;
|
|
14
15
|
configDir: Path;
|
|
15
16
|
storiesV2Compatibility: boolean;
|
|
17
|
+
storyStoreV7: boolean;
|
|
16
18
|
});
|
|
17
19
|
initialize(): Promise<void>;
|
|
18
20
|
ensureExtracted(): Promise<StoryIndex['stories'][]>;
|
|
@@ -6,5 +6,6 @@ export declare function extractStoriesJson(outputFile: string, normalizedStories
|
|
|
6
6
|
configDir: string;
|
|
7
7
|
workingDir: string;
|
|
8
8
|
storiesV2Compatibility: boolean;
|
|
9
|
+
storyStoreV7: boolean;
|
|
9
10
|
}): Promise<void>;
|
|
10
11
|
export declare function useStoriesJson(router: Router, serverChannel: ServerChannel, options: Options, workingDir?: string): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/core-server",
|
|
3
|
-
"version": "6.4.0-rc.
|
|
3
|
+
"version": "6.4.0-rc.4",
|
|
4
4
|
"description": "Storybook framework-agnostic API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -41,16 +41,16 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@discoveryjs/json-ext": "^0.5.3",
|
|
44
|
-
"@storybook/builder-webpack4": "6.4.0-rc.
|
|
45
|
-
"@storybook/core-client": "6.4.0-rc.
|
|
46
|
-
"@storybook/core-common": "6.4.0-rc.
|
|
47
|
-
"@storybook/core-events": "6.4.0-rc.
|
|
44
|
+
"@storybook/builder-webpack4": "6.4.0-rc.4",
|
|
45
|
+
"@storybook/core-client": "6.4.0-rc.4",
|
|
46
|
+
"@storybook/core-common": "6.4.0-rc.4",
|
|
47
|
+
"@storybook/core-events": "6.4.0-rc.4",
|
|
48
48
|
"@storybook/csf": "0.0.2--canary.87bc651.0",
|
|
49
|
-
"@storybook/csf-tools": "6.4.0-rc.
|
|
50
|
-
"@storybook/manager-webpack4": "6.4.0-rc.
|
|
51
|
-
"@storybook/node-logger": "6.4.0-rc.
|
|
49
|
+
"@storybook/csf-tools": "6.4.0-rc.4",
|
|
50
|
+
"@storybook/manager-webpack4": "6.4.0-rc.4",
|
|
51
|
+
"@storybook/node-logger": "6.4.0-rc.4",
|
|
52
52
|
"@storybook/semver": "^7.3.2",
|
|
53
|
-
"@storybook/store": "6.4.0-rc.
|
|
53
|
+
"@storybook/store": "6.4.0-rc.4",
|
|
54
54
|
"@types/node": "^14.0.10",
|
|
55
55
|
"@types/node-fetch": "^2.5.7",
|
|
56
56
|
"@types/pretty-hrtime": "^1.0.0",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"ws": "^8.2.3"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@storybook/builder-webpack5": "6.4.0-rc.
|
|
87
|
+
"@storybook/builder-webpack5": "6.4.0-rc.4",
|
|
88
88
|
"@types/compression": "^1.7.0",
|
|
89
89
|
"@types/ip": "^1.1.0",
|
|
90
90
|
"@types/serve-favicon": "^2.5.2",
|
|
@@ -92,8 +92,8 @@
|
|
|
92
92
|
"jest-specific-snapshot": "^4.0.0"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
|
-
"@storybook/builder-webpack5": "6.4.0-rc.
|
|
96
|
-
"@storybook/manager-webpack5": "6.4.0-rc.
|
|
95
|
+
"@storybook/builder-webpack5": "6.4.0-rc.4",
|
|
96
|
+
"@storybook/manager-webpack5": "6.4.0-rc.4",
|
|
97
97
|
"react": "^16.8.0 || ^17.0.0",
|
|
98
98
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
99
99
|
},
|
|
@@ -111,6 +111,6 @@
|
|
|
111
111
|
"publishConfig": {
|
|
112
112
|
"access": "public"
|
|
113
113
|
},
|
|
114
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "43653ad69c8c10840e3f35a831ed8bd36b9c90dd",
|
|
115
115
|
"sbmodern": "dist/modern/index.js"
|
|
116
116
|
}
|