@storybook/preset-react-webpack 7.0.0-alpha.0 → 7.0.0-alpha.3
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/cra-config.js +13 -22
- package/dist/cjs/framework-preset-cra.js +6 -12
- package/dist/cjs/framework-preset-react-docs.js +39 -160
- package/dist/cjs/framework-preset-react-dom-hack.js +10 -96
- package/dist/cjs/framework-preset-react.js +40 -211
- package/dist/cjs/index.js +2 -8
- package/dist/esm/framework-preset-react.js +1 -1
- package/package.json +6 -6
package/dist/cjs/cra-config.js
CHANGED
|
@@ -6,12 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getReactScriptsPath = getReactScriptsPath;
|
|
7
7
|
exports.isReactScriptsInstalled = isReactScriptsInstalled;
|
|
8
8
|
|
|
9
|
-
require("core-js/modules/es.array.join.js");
|
|
10
|
-
|
|
11
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
12
|
-
|
|
13
|
-
require("core-js/modules/es.string.match.js");
|
|
14
|
-
|
|
15
9
|
var _fs = _interopRequireDefault(require("fs"));
|
|
16
10
|
|
|
17
11
|
var _path = _interopRequireDefault(require("path"));
|
|
@@ -22,40 +16,39 @@ var _nodeLogger = require("@storybook/node-logger");
|
|
|
22
16
|
|
|
23
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
18
|
|
|
25
|
-
|
|
19
|
+
const appDirectory = _fs.default.realpathSync(process.cwd());
|
|
26
20
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
function getReactScriptsPath() {
|
|
30
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
31
|
-
noCache = _ref.noCache;
|
|
21
|
+
let reactScriptsPath;
|
|
32
22
|
|
|
23
|
+
function getReactScriptsPath({
|
|
24
|
+
noCache
|
|
25
|
+
} = {}) {
|
|
33
26
|
if (reactScriptsPath && !noCache) return reactScriptsPath;
|
|
34
27
|
|
|
35
|
-
|
|
28
|
+
let reactScriptsScriptPath = _fs.default.realpathSync(_path.default.join(appDirectory, '/node_modules/.bin/react-scripts'));
|
|
36
29
|
|
|
37
30
|
try {
|
|
38
31
|
// Note: Since there is no symlink for .bin/react-scripts on Windows
|
|
39
32
|
// we'll parse react-scripts file to find actual package path.
|
|
40
33
|
// This is important if you use fork of CRA.
|
|
41
|
-
|
|
34
|
+
const pathIsNotResolved = /node_modules[\\/]\.bin[\\/]react-scripts/i.test(reactScriptsScriptPath);
|
|
42
35
|
|
|
43
36
|
if (pathIsNotResolved) {
|
|
44
|
-
|
|
37
|
+
const content = _fs.default.readFileSync(reactScriptsScriptPath, 'utf8');
|
|
45
38
|
|
|
46
|
-
|
|
39
|
+
const packagePathMatch = content.match(/"\$basedir[\\/]([^\s]+?[\\/]bin[\\/]react-scripts\.js")/i);
|
|
47
40
|
|
|
48
41
|
if (packagePathMatch && packagePathMatch.length > 1) {
|
|
49
42
|
reactScriptsScriptPath = _path.default.join(appDirectory, '/node_modules/.bin/', packagePathMatch[1]);
|
|
50
43
|
}
|
|
51
44
|
}
|
|
52
45
|
} catch (e) {
|
|
53
|
-
_nodeLogger.logger.warn(
|
|
46
|
+
_nodeLogger.logger.warn(`Error occurred during react-scripts package path resolving: ${e}`);
|
|
54
47
|
}
|
|
55
48
|
|
|
56
49
|
reactScriptsPath = _path.default.join(reactScriptsScriptPath, '../..');
|
|
57
50
|
|
|
58
|
-
|
|
51
|
+
const scriptsPkgJson = _path.default.join(reactScriptsPath, 'package.json');
|
|
59
52
|
|
|
60
53
|
if (!_fs.default.existsSync(scriptsPkgJson)) {
|
|
61
54
|
reactScriptsPath = 'react-scripts';
|
|
@@ -64,12 +57,10 @@ function getReactScriptsPath() {
|
|
|
64
57
|
return reactScriptsPath;
|
|
65
58
|
}
|
|
66
59
|
|
|
67
|
-
function isReactScriptsInstalled() {
|
|
68
|
-
var requiredVersion = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '2.0.0';
|
|
69
|
-
|
|
60
|
+
function isReactScriptsInstalled(requiredVersion = '2.0.0') {
|
|
70
61
|
try {
|
|
71
62
|
// eslint-disable-next-line import/no-dynamic-require,global-require
|
|
72
|
-
|
|
63
|
+
const reactScriptsJson = require(_path.default.join(getReactScriptsPath(), 'package.json'));
|
|
73
64
|
|
|
74
65
|
return !_semver.default.gtr(requiredVersion, reactScriptsJson.version);
|
|
75
66
|
} catch (e) {
|
|
@@ -5,19 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.webpackFinal = void 0;
|
|
7
7
|
|
|
8
|
-
require("core-js/modules/es.object.to-string.js");
|
|
9
|
-
|
|
10
|
-
require("core-js/modules/es.function.name.js");
|
|
11
|
-
|
|
12
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
13
|
-
|
|
14
8
|
var _nodeLogger = require("@storybook/node-logger");
|
|
15
9
|
|
|
16
10
|
var _craConfig = require("./cra-config");
|
|
17
11
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
const checkForNewPreset = presetsList => {
|
|
13
|
+
const hasNewPreset = presetsList.some(preset => {
|
|
14
|
+
const presetName = typeof preset === 'string' ? preset : preset.name;
|
|
21
15
|
return /@storybook(\/|\\)preset-create-react-app/.test(presetName);
|
|
22
16
|
});
|
|
23
17
|
|
|
@@ -30,9 +24,9 @@ var checkForNewPreset = function checkForNewPreset(presetsList) {
|
|
|
30
24
|
}
|
|
31
25
|
};
|
|
32
26
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
const webpackFinal = (config, {
|
|
28
|
+
presetsList
|
|
29
|
+
}) => {
|
|
36
30
|
if ((0, _craConfig.isReactScriptsInstalled)()) {
|
|
37
31
|
checkForNewPreset(presetsList);
|
|
38
32
|
}
|
|
@@ -1,178 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.symbol.js");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.symbol.description.js");
|
|
8
|
-
|
|
9
|
-
require("core-js/modules/es.symbol.iterator.js");
|
|
10
|
-
|
|
11
|
-
require("core-js/modules/es.array.iterator.js");
|
|
12
|
-
|
|
13
|
-
require("core-js/modules/es.string.iterator.js");
|
|
14
|
-
|
|
15
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
16
|
-
|
|
17
|
-
require("core-js/modules/es.array.from.js");
|
|
18
|
-
|
|
19
|
-
require("core-js/modules/es.array.slice.js");
|
|
20
|
-
|
|
21
|
-
require("core-js/modules/es.function.name.js");
|
|
22
|
-
|
|
23
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
24
|
-
|
|
25
|
-
require("core-js/modules/es.symbol.async-iterator.js");
|
|
26
|
-
|
|
27
|
-
require("core-js/modules/es.symbol.to-string-tag.js");
|
|
28
|
-
|
|
29
|
-
require("core-js/modules/es.json.to-string-tag.js");
|
|
30
|
-
|
|
31
|
-
require("core-js/modules/es.math.to-string-tag.js");
|
|
32
|
-
|
|
33
|
-
require("core-js/modules/es.object.get-prototype-of.js");
|
|
34
|
-
|
|
35
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
36
|
-
|
|
37
3
|
Object.defineProperty(exports, "__esModule", {
|
|
38
4
|
value: true
|
|
39
5
|
});
|
|
40
6
|
exports.webpackFinal = exports.babel = void 0;
|
|
41
7
|
|
|
42
|
-
require("core-js/modules/es.object.assign.js");
|
|
43
|
-
|
|
44
|
-
require("core-js/modules/es.array.concat.js");
|
|
45
|
-
|
|
46
|
-
require("core-js/modules/es.object.to-string.js");
|
|
47
|
-
|
|
48
|
-
require("core-js/modules/es.promise.js");
|
|
49
|
-
|
|
50
8
|
var _reactDocgenTypescriptPlugin = _interopRequireDefault(require("@storybook/react-docgen-typescript-plugin"));
|
|
51
9
|
|
|
52
10
|
var _docsTools = require("@storybook/docs-tools");
|
|
53
11
|
|
|
54
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
55
13
|
|
|
56
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
var typescriptOptions, reactDocgen;
|
|
77
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
78
|
-
while (1) {
|
|
79
|
-
switch (_context.prev = _context.next) {
|
|
80
|
-
case 0:
|
|
81
|
-
if ((0, _docsTools.hasDocsOrControls)(options)) {
|
|
82
|
-
_context.next = 2;
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return _context.abrupt("return", config);
|
|
87
|
-
|
|
88
|
-
case 2:
|
|
89
|
-
_context.next = 4;
|
|
90
|
-
return options.presets.apply('typescript', {});
|
|
91
|
-
|
|
92
|
-
case 4:
|
|
93
|
-
typescriptOptions = _context.sent;
|
|
94
|
-
reactDocgen = typescriptOptions.reactDocgen;
|
|
95
|
-
|
|
96
|
-
if (!(typeof reactDocgen !== 'string')) {
|
|
97
|
-
_context.next = 8;
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return _context.abrupt("return", config);
|
|
102
|
-
|
|
103
|
-
case 8:
|
|
104
|
-
return _context.abrupt("return", Object.assign({}, config, {
|
|
105
|
-
overrides: [].concat(_toConsumableArray((config === null || config === void 0 ? void 0 : config.overrides) || []), [{
|
|
106
|
-
test: reactDocgen === 'react-docgen' ? /\.(mjs|tsx?|jsx?)$/ : /\.(mjs|jsx?)$/,
|
|
107
|
-
plugins: [[require.resolve('babel-plugin-react-docgen'), {
|
|
108
|
-
DOC_GEN_COLLECTION_NAME: 'STORYBOOK_REACT_CLASSES'
|
|
109
|
-
}]]
|
|
110
|
-
}])
|
|
111
|
-
}));
|
|
112
|
-
|
|
113
|
-
case 9:
|
|
114
|
-
case "end":
|
|
115
|
-
return _context.stop();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}, _callee);
|
|
119
|
-
}));
|
|
120
|
-
|
|
121
|
-
return function babel(_x, _x2) {
|
|
122
|
-
return _ref.apply(this, arguments);
|
|
123
|
-
};
|
|
124
|
-
}();
|
|
14
|
+
const babel = async (config, options) => {
|
|
15
|
+
if (!(0, _docsTools.hasDocsOrControls)(options)) return config;
|
|
16
|
+
const typescriptOptions = await options.presets.apply('typescript', {});
|
|
17
|
+
const {
|
|
18
|
+
reactDocgen
|
|
19
|
+
} = typescriptOptions;
|
|
20
|
+
|
|
21
|
+
if (typeof reactDocgen !== 'string') {
|
|
22
|
+
return config;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return Object.assign({}, config, {
|
|
26
|
+
overrides: [...((config === null || config === void 0 ? void 0 : config.overrides) || []), {
|
|
27
|
+
test: reactDocgen === 'react-docgen' ? /\.(mjs|tsx?|jsx?)$/ : /\.(mjs|jsx?)$/,
|
|
28
|
+
plugins: [[require.resolve('babel-plugin-react-docgen'), {
|
|
29
|
+
DOC_GEN_COLLECTION_NAME: 'STORYBOOK_REACT_CLASSES'
|
|
30
|
+
}]]
|
|
31
|
+
}]
|
|
32
|
+
});
|
|
33
|
+
};
|
|
125
34
|
|
|
126
35
|
exports.babel = babel;
|
|
127
36
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
typescriptOptions = _context2.sent;
|
|
148
|
-
reactDocgen = typescriptOptions.reactDocgen, reactDocgenTypescriptOptions = typescriptOptions.reactDocgenTypescriptOptions;
|
|
149
|
-
|
|
150
|
-
if (!(reactDocgen !== 'react-docgen-typescript')) {
|
|
151
|
-
_context2.next = 8;
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return _context2.abrupt("return", config);
|
|
156
|
-
|
|
157
|
-
case 8:
|
|
158
|
-
return _context2.abrupt("return", Object.assign({}, config, {
|
|
159
|
-
plugins: [].concat(_toConsumableArray(config.plugins), [new _reactDocgenTypescriptPlugin.default(Object.assign({}, reactDocgenTypescriptOptions, {
|
|
160
|
-
// We *need* this set so that RDT returns default values in the same format as react-docgen
|
|
161
|
-
savePropValueAsString: true
|
|
162
|
-
}))])
|
|
163
|
-
}));
|
|
164
|
-
|
|
165
|
-
case 9:
|
|
166
|
-
case "end":
|
|
167
|
-
return _context2.stop();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}, _callee2);
|
|
171
|
-
}));
|
|
172
|
-
|
|
173
|
-
return function webpackFinal(_x3, _x4) {
|
|
174
|
-
return _ref2.apply(this, arguments);
|
|
175
|
-
};
|
|
176
|
-
}();
|
|
37
|
+
const webpackFinal = async (config, options) => {
|
|
38
|
+
if (!(0, _docsTools.hasDocsOrControls)(options)) return config;
|
|
39
|
+
const typescriptOptions = await options.presets.apply('typescript', {});
|
|
40
|
+
const {
|
|
41
|
+
reactDocgen,
|
|
42
|
+
reactDocgenTypescriptOptions
|
|
43
|
+
} = typescriptOptions;
|
|
44
|
+
|
|
45
|
+
if (reactDocgen !== 'react-docgen-typescript') {
|
|
46
|
+
return config;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return Object.assign({}, config, {
|
|
50
|
+
plugins: [...config.plugins, new _reactDocgenTypescriptPlugin.default(Object.assign({}, reactDocgenTypescriptOptions, {
|
|
51
|
+
// We *need* this set so that RDT returns default values in the same format as react-docgen
|
|
52
|
+
savePropValueAsString: true
|
|
53
|
+
}))]
|
|
54
|
+
});
|
|
55
|
+
};
|
|
177
56
|
|
|
178
57
|
exports.webpackFinal = webpackFinal;
|
|
@@ -1,111 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.symbol.js");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.symbol.description.js");
|
|
8
|
-
|
|
9
|
-
require("core-js/modules/es.symbol.iterator.js");
|
|
10
|
-
|
|
11
|
-
require("core-js/modules/es.array.iterator.js");
|
|
12
|
-
|
|
13
|
-
require("core-js/modules/es.string.iterator.js");
|
|
14
|
-
|
|
15
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
16
|
-
|
|
17
|
-
require("core-js/modules/es.array.from.js");
|
|
18
|
-
|
|
19
|
-
require("core-js/modules/es.array.slice.js");
|
|
20
|
-
|
|
21
|
-
require("core-js/modules/es.function.name.js");
|
|
22
|
-
|
|
23
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
24
|
-
|
|
25
|
-
require("core-js/modules/es.symbol.async-iterator.js");
|
|
26
|
-
|
|
27
|
-
require("core-js/modules/es.symbol.to-string-tag.js");
|
|
28
|
-
|
|
29
|
-
require("core-js/modules/es.json.to-string-tag.js");
|
|
30
|
-
|
|
31
|
-
require("core-js/modules/es.math.to-string-tag.js");
|
|
32
|
-
|
|
33
|
-
require("core-js/modules/es.object.get-prototype-of.js");
|
|
34
|
-
|
|
35
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
36
|
-
|
|
37
3
|
Object.defineProperty(exports, "__esModule", {
|
|
38
4
|
value: true
|
|
39
5
|
});
|
|
40
6
|
exports.webpackFinal = void 0;
|
|
41
7
|
|
|
42
|
-
require("core-js/modules/es.object.assign.js");
|
|
43
|
-
|
|
44
|
-
require("core-js/modules/es.array.filter.js");
|
|
45
|
-
|
|
46
|
-
require("core-js/modules/es.object.to-string.js");
|
|
47
|
-
|
|
48
|
-
require("core-js/modules/es.array.concat.js");
|
|
49
|
-
|
|
50
|
-
require("core-js/modules/es.string.starts-with.js");
|
|
51
|
-
|
|
52
|
-
require("core-js/modules/es.promise.js");
|
|
53
|
-
|
|
54
8
|
var _fsExtra = require("fs-extra");
|
|
55
9
|
|
|
56
10
|
var _webpack = require("webpack");
|
|
57
11
|
|
|
58
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
59
|
-
|
|
60
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
61
|
-
|
|
62
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
63
|
-
|
|
64
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
65
|
-
|
|
66
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
67
|
-
|
|
68
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
69
|
-
|
|
70
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
71
|
-
|
|
72
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
73
|
-
|
|
74
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
75
|
-
|
|
76
12
|
// this is a hack to allow importing react-dom/client even when it's not available
|
|
77
13
|
// this should be removed once we drop support for react-dom < 18
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
case 2:
|
|
89
|
-
reactDomPkg = _context.sent;
|
|
90
|
-
return _context.abrupt("return", Object.assign({}, config, {
|
|
91
|
-
plugins: [].concat(_toConsumableArray(config.plugins), [reactDomPkg.version.startsWith('18') || reactDomPkg.version.startsWith('0.0.0') ? null : new _webpack.IgnorePlugin({
|
|
92
|
-
resourceRegExp: /react-dom\/client$/,
|
|
93
|
-
contextRegExp: /(renderers\/react|renderers\\react|@storybook\/react|@storybook\\react)/ // TODO this needs to work for both in our MONOREPO and in the user's NODE_MODULES
|
|
94
|
-
|
|
95
|
-
})]).filter(Boolean)
|
|
96
|
-
}));
|
|
97
|
-
|
|
98
|
-
case 4:
|
|
99
|
-
case "end":
|
|
100
|
-
return _context.stop();
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}, _callee);
|
|
104
|
-
}));
|
|
105
|
-
|
|
106
|
-
return function webpackFinal(_x) {
|
|
107
|
-
return _ref.apply(this, arguments);
|
|
108
|
-
};
|
|
109
|
-
}();
|
|
14
|
+
const webpackFinal = async config => {
|
|
15
|
+
const reactDomPkg = await (0, _fsExtra.readJSON)(require.resolve('react-dom/package.json'));
|
|
16
|
+
return Object.assign({}, config, {
|
|
17
|
+
plugins: [...config.plugins, reactDomPkg.version.startsWith('18') || reactDomPkg.version.startsWith('0.0.0') ? null : new _webpack.IgnorePlugin({
|
|
18
|
+
resourceRegExp: /react-dom\/client$/,
|
|
19
|
+
contextRegExp: /(renderers\/react|renderers\\react|@storybook\/react|@storybook\\react)/ // TODO this needs to work for both in our MONOREPO and in the user's NODE_MODULES
|
|
20
|
+
|
|
21
|
+
})].filter(Boolean)
|
|
22
|
+
});
|
|
23
|
+
};
|
|
110
24
|
|
|
111
25
|
exports.webpackFinal = webpackFinal;
|
|
@@ -1,58 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.symbol.js");
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.symbol.description.js");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.symbol.iterator.js");
|
|
8
|
-
|
|
9
|
-
require("core-js/modules/es.array.iterator.js");
|
|
10
|
-
|
|
11
|
-
require("core-js/modules/es.string.iterator.js");
|
|
12
|
-
|
|
13
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
14
|
-
|
|
15
|
-
require("core-js/modules/es.symbol.async-iterator.js");
|
|
16
|
-
|
|
17
|
-
require("core-js/modules/es.symbol.to-string-tag.js");
|
|
18
|
-
|
|
19
|
-
require("core-js/modules/es.json.to-string-tag.js");
|
|
20
|
-
|
|
21
|
-
require("core-js/modules/es.math.to-string-tag.js");
|
|
22
|
-
|
|
23
|
-
require("core-js/modules/es.object.get-prototype-of.js");
|
|
24
|
-
|
|
25
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
26
|
-
|
|
27
|
-
require("core-js/modules/es.array.slice.js");
|
|
28
|
-
|
|
29
|
-
require("core-js/modules/es.array.from.js");
|
|
30
|
-
|
|
31
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
32
|
-
|
|
33
3
|
Object.defineProperty(exports, "__esModule", {
|
|
34
4
|
value: true
|
|
35
5
|
});
|
|
36
6
|
exports.webpackFinal = exports.babelDefault = exports.babel = void 0;
|
|
37
7
|
|
|
38
|
-
require("core-js/modules/es.object.assign.js");
|
|
39
|
-
|
|
40
|
-
require("core-js/modules/es.array.concat.js");
|
|
41
|
-
|
|
42
|
-
require("core-js/modules/es.array.includes.js");
|
|
43
|
-
|
|
44
|
-
require("core-js/modules/es.string.includes.js");
|
|
45
|
-
|
|
46
|
-
require("core-js/modules/es.array.join.js");
|
|
47
|
-
|
|
48
|
-
require("core-js/modules/es.array.find.js");
|
|
49
|
-
|
|
50
|
-
require("core-js/modules/es.object.to-string.js");
|
|
51
|
-
|
|
52
|
-
require("core-js/modules/es.function.name.js");
|
|
53
|
-
|
|
54
|
-
require("core-js/modules/es.promise.js");
|
|
55
|
-
|
|
56
8
|
var _path = _interopRequireDefault(require("path"));
|
|
57
9
|
|
|
58
10
|
var _reactRefreshWebpackPlugin = _interopRequireDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
|
|
@@ -61,99 +13,29 @@ var _nodeLogger = require("@storybook/node-logger");
|
|
|
61
13
|
|
|
62
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
63
15
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
71
|
-
|
|
72
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
73
|
-
|
|
74
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
75
|
-
|
|
76
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
77
|
-
|
|
78
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
79
|
-
|
|
80
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
81
|
-
|
|
82
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
83
|
-
|
|
84
|
-
var useFastRefresh = /*#__PURE__*/function () {
|
|
85
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
86
|
-
var isDevelopment, framework, reactOptions;
|
|
87
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
88
|
-
while (1) {
|
|
89
|
-
switch (_context.prev = _context.next) {
|
|
90
|
-
case 0:
|
|
91
|
-
isDevelopment = options.configType === 'DEVELOPMENT';
|
|
92
|
-
_context.next = 3;
|
|
93
|
-
return options.presets.apply('framework');
|
|
94
|
-
|
|
95
|
-
case 3:
|
|
96
|
-
framework = _context.sent;
|
|
97
|
-
reactOptions = _typeof(framework) === 'object' ? framework.options : {};
|
|
98
|
-
return _context.abrupt("return", isDevelopment && (reactOptions.fastRefresh || process.env.FAST_REFRESH === 'true'));
|
|
99
|
-
|
|
100
|
-
case 6:
|
|
101
|
-
case "end":
|
|
102
|
-
return _context.stop();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}, _callee);
|
|
106
|
-
}));
|
|
107
|
-
|
|
108
|
-
return function useFastRefresh(_x) {
|
|
109
|
-
return _ref.apply(this, arguments);
|
|
110
|
-
};
|
|
111
|
-
}();
|
|
112
|
-
|
|
113
|
-
var babel = /*#__PURE__*/function () {
|
|
114
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(config, options) {
|
|
115
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
116
|
-
while (1) {
|
|
117
|
-
switch (_context2.prev = _context2.next) {
|
|
118
|
-
case 0:
|
|
119
|
-
_context2.next = 2;
|
|
120
|
-
return useFastRefresh(options);
|
|
121
|
-
|
|
122
|
-
case 2:
|
|
123
|
-
if (_context2.sent) {
|
|
124
|
-
_context2.next = 4;
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return _context2.abrupt("return", config);
|
|
129
|
-
|
|
130
|
-
case 4:
|
|
131
|
-
return _context2.abrupt("return", Object.assign({}, config, {
|
|
132
|
-
plugins: [[require.resolve('react-refresh/babel'), {}, 'storybook-react-refresh']].concat(_toConsumableArray(config.plugins || []))
|
|
133
|
-
}));
|
|
134
|
-
|
|
135
|
-
case 5:
|
|
136
|
-
case "end":
|
|
137
|
-
return _context2.stop();
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}, _callee2);
|
|
141
|
-
}));
|
|
16
|
+
const useFastRefresh = async options => {
|
|
17
|
+
const isDevelopment = options.configType === 'DEVELOPMENT';
|
|
18
|
+
const framework = await options.presets.apply('framework');
|
|
19
|
+
const reactOptions = typeof framework === 'object' ? framework.options : {};
|
|
20
|
+
return isDevelopment && (reactOptions.fastRefresh || process.env.FAST_REFRESH === 'true');
|
|
21
|
+
};
|
|
142
22
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
}()
|
|
23
|
+
const babel = async (config, options) => {
|
|
24
|
+
if (!(await useFastRefresh(options))) return config;
|
|
25
|
+
return Object.assign({}, config, {
|
|
26
|
+
plugins: [[require.resolve('react-refresh/babel'), {}, 'storybook-react-refresh'], ...(config.plugins || [])]
|
|
27
|
+
});
|
|
28
|
+
};
|
|
147
29
|
|
|
148
30
|
exports.babel = babel;
|
|
149
31
|
|
|
150
|
-
|
|
32
|
+
const storybookReactDirName = _path.default.dirname(require.resolve('@storybook/preset-react-webpack/package.json')); // TODO: improve node_modules detection
|
|
151
33
|
|
|
152
34
|
|
|
153
|
-
|
|
35
|
+
const context = storybookReactDirName.includes('node_modules') ? _path.default.join(storybookReactDirName, '../../') // Real life case, already in node_modules
|
|
154
36
|
: _path.default.join(storybookReactDirName, '../../node_modules'); // SB Monorepo
|
|
155
37
|
|
|
156
|
-
|
|
38
|
+
const hasJsxRuntime = () => {
|
|
157
39
|
try {
|
|
158
40
|
require.resolve('react/jsx-runtime', {
|
|
159
41
|
paths: [context]
|
|
@@ -165,92 +47,39 @@ var hasJsxRuntime = function hasJsxRuntime() {
|
|
|
165
47
|
}
|
|
166
48
|
};
|
|
167
49
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
} : {};
|
|
178
|
-
return _context3.abrupt("return", Object.assign({}, config, {
|
|
179
|
-
presets: [].concat(_toConsumableArray((config === null || config === void 0 ? void 0 : config.presets) || []), [[require.resolve('@babel/preset-react'), presetReactOptions], require.resolve('@babel/preset-flow')]),
|
|
180
|
-
plugins: [].concat(_toConsumableArray((config === null || config === void 0 ? void 0 : config.plugins) || []), [require.resolve('babel-plugin-add-react-displayname')])
|
|
181
|
-
}));
|
|
182
|
-
|
|
183
|
-
case 2:
|
|
184
|
-
case "end":
|
|
185
|
-
return _context3.stop();
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}, _callee3);
|
|
189
|
-
}));
|
|
190
|
-
|
|
191
|
-
return function babelDefault(_x4) {
|
|
192
|
-
return _ref3.apply(this, arguments);
|
|
193
|
-
};
|
|
194
|
-
}();
|
|
50
|
+
const babelDefault = async config => {
|
|
51
|
+
const presetReactOptions = hasJsxRuntime() ? {
|
|
52
|
+
runtime: 'automatic'
|
|
53
|
+
} : {};
|
|
54
|
+
return Object.assign({}, config, {
|
|
55
|
+
presets: [...((config === null || config === void 0 ? void 0 : config.presets) || []), [require.resolve('@babel/preset-react'), presetReactOptions]],
|
|
56
|
+
plugins: [...((config === null || config === void 0 ? void 0 : config.plugins) || []), require.resolve('babel-plugin-add-react-displayname')]
|
|
57
|
+
});
|
|
58
|
+
};
|
|
195
59
|
|
|
196
60
|
exports.babelDefault = babelDefault;
|
|
197
61
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
var hasReactRefresh;
|
|
201
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
202
|
-
while (1) {
|
|
203
|
-
switch (_context4.prev = _context4.next) {
|
|
204
|
-
case 0:
|
|
205
|
-
_context4.next = 2;
|
|
206
|
-
return useFastRefresh(options);
|
|
62
|
+
const webpackFinal = async (config, options) => {
|
|
63
|
+
if (!(await useFastRefresh(options))) return config; // matches the name of the plugin in CRA.
|
|
207
64
|
|
|
208
|
-
|
|
209
|
-
if (_context4.sent) {
|
|
210
|
-
_context4.next = 4;
|
|
211
|
-
break;
|
|
212
|
-
}
|
|
65
|
+
const hasReactRefresh = config.plugins.find(p => p.constructor.name === 'ReactRefreshPlugin');
|
|
213
66
|
|
|
214
|
-
|
|
67
|
+
if (hasReactRefresh) {
|
|
68
|
+
_nodeLogger.logger.warn("=> React refresh is already set. You don't need to set the option");
|
|
215
69
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
hasReactRefresh = config.plugins.find(function (p) {
|
|
219
|
-
return p.constructor.name === 'ReactRefreshPlugin';
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
if (!hasReactRefresh) {
|
|
223
|
-
_context4.next = 8;
|
|
224
|
-
break;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
_nodeLogger.logger.warn("=> React refresh is already set. You don't need to set the option");
|
|
228
|
-
|
|
229
|
-
return _context4.abrupt("return", config);
|
|
230
|
-
|
|
231
|
-
case 8:
|
|
232
|
-
_nodeLogger.logger.info('=> Using React fast refresh');
|
|
70
|
+
return config;
|
|
71
|
+
}
|
|
233
72
|
|
|
234
|
-
|
|
235
|
-
plugins: [].concat(_toConsumableArray(config.plugins), [// Storybook uses webpack-hot-middleware https://github.com/storybookjs/storybook/issues/14114
|
|
236
|
-
new _reactRefreshWebpackPlugin.default({
|
|
237
|
-
overlay: {
|
|
238
|
-
sockIntegration: 'whm'
|
|
239
|
-
}
|
|
240
|
-
})])
|
|
241
|
-
}));
|
|
73
|
+
_nodeLogger.logger.info('=> Using React fast refresh');
|
|
242
74
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
75
|
+
return Object.assign({}, config, {
|
|
76
|
+
plugins: [...config.plugins, // Storybook uses webpack-hot-middleware https://github.com/storybookjs/storybook/issues/14114
|
|
77
|
+
new _reactRefreshWebpackPlugin.default({
|
|
78
|
+
overlay: {
|
|
79
|
+
sockIntegration: 'whm'
|
|
247
80
|
}
|
|
248
|
-
}
|
|
249
|
-
})
|
|
250
|
-
|
|
251
|
-
return function webpackFinal(_x5, _x6) {
|
|
252
|
-
return _ref4.apply(this, arguments);
|
|
253
|
-
};
|
|
254
|
-
}();
|
|
81
|
+
})]
|
|
82
|
+
});
|
|
83
|
+
};
|
|
255
84
|
|
|
256
85
|
exports.webpackFinal = webpackFinal;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.object.to-string.js");
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.object.keys.js");
|
|
8
|
-
|
|
9
3
|
Object.defineProperty(exports, "__esModule", {
|
|
10
4
|
value: true
|
|
11
5
|
});
|
|
@@ -22,10 +16,10 @@ Object.keys(_types).forEach(function (key) {
|
|
|
22
16
|
if (key in exports && exports[key] === _types[key]) return;
|
|
23
17
|
Object.defineProperty(exports, key, {
|
|
24
18
|
enumerable: true,
|
|
25
|
-
get: function
|
|
19
|
+
get: function () {
|
|
26
20
|
return _types[key];
|
|
27
21
|
}
|
|
28
22
|
});
|
|
29
23
|
});
|
|
30
|
-
|
|
24
|
+
const addons = [require.resolve('./framework-preset-react'), require.resolve('./framework-preset-react-dom-hack'), require.resolve('./framework-preset-cra'), require.resolve('./framework-preset-react-docs')];
|
|
31
25
|
exports.addons = addons;
|
|
@@ -37,7 +37,7 @@ export const babelDefault = async config => {
|
|
|
37
37
|
runtime: 'automatic'
|
|
38
38
|
} : {};
|
|
39
39
|
return Object.assign({}, config, {
|
|
40
|
-
presets: [...(config?.presets || []), [require.resolve('@babel/preset-react'), presetReactOptions]
|
|
40
|
+
presets: [...(config?.presets || []), [require.resolve('@babel/preset-react'), presetReactOptions]],
|
|
41
41
|
plugins: [...(config?.plugins || []), require.resolve('babel-plugin-add-react-displayname')]
|
|
42
42
|
});
|
|
43
43
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/preset-react-webpack",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.3",
|
|
4
4
|
"description": "Storybook for React: Develop React Component in isolation with Hot Reloading.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"@babel/preset-flow": "^7.12.1",
|
|
37
37
|
"@babel/preset-react": "^7.12.10",
|
|
38
38
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
|
|
39
|
-
"@storybook/core-webpack": "7.0.0-alpha.
|
|
40
|
-
"@storybook/docs-tools": "7.0.0-alpha.
|
|
41
|
-
"@storybook/node-logger": "7.0.0-alpha.
|
|
42
|
-
"@storybook/react": "7.0.0-alpha.
|
|
39
|
+
"@storybook/core-webpack": "7.0.0-alpha.3",
|
|
40
|
+
"@storybook/docs-tools": "7.0.0-alpha.3",
|
|
41
|
+
"@storybook/node-logger": "7.0.0-alpha.3",
|
|
42
|
+
"@storybook/react": "7.0.0-alpha.3",
|
|
43
43
|
"@storybook/react-docgen-typescript-plugin": "1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0",
|
|
44
44
|
"@storybook/semver": "^7.3.2",
|
|
45
45
|
"@types/node": "^14.14.20 || ^16.0.0",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"publishConfig": {
|
|
76
76
|
"access": "public"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "629b056190993bcee6445471b8cb27208eb401a9"
|
|
79
79
|
}
|