react-cosmos 5.6.4 → 5.6.8

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.
Files changed (52) hide show
  1. package/config.schema.json +4 -0
  2. package/dist/config/createCosmosConfig.js +2 -2
  3. package/dist/config/index.js +6 -6
  4. package/dist/dom/DomFixtureLoader.d.ts +4 -3
  5. package/dist/dom/ErrorCatch.js +4 -4
  6. package/dist/dom/index.d.ts +3 -3
  7. package/dist/dom/renderMessage.d.ts +1 -0
  8. package/dist/fixture.js +6 -6
  9. package/dist/getFixtureUrls.js +9 -10
  10. package/dist/getFixtures.js +12 -13
  11. package/dist/getFixtures2.js +7 -7
  12. package/dist/index.js +14 -14
  13. package/dist/native.d.ts +4 -3
  14. package/dist/native.js +1 -1
  15. package/dist/plugins/httpProxy.js +1 -1
  16. package/dist/plugins/webpack/client/errorOverlay/reactErrorOverlay.js +2 -2
  17. package/dist/plugins/webpack/client/userDeps.d.ts +3 -3
  18. package/dist/plugins/webpack/client/userDeps.js +1 -1
  19. package/dist/plugins/webpack/cosmosConfig/webpack.d.ts +1 -0
  20. package/dist/plugins/webpack/cosmosConfig/webpack.js +8 -1
  21. package/dist/plugins/webpack/export.js +8 -4
  22. package/dist/plugins/webpack/webpackConfig/devServer.js +23 -21
  23. package/dist/plugins/webpack/webpackConfig/export.js +18 -17
  24. package/dist/plugins/webpack/webpackConfig/{default.d.ts → getDefaultWebpackConfig.d.ts} +0 -0
  25. package/dist/plugins/webpack/webpackConfig/{default.js → getDefaultWebpackConfig.js} +4 -4
  26. package/dist/plugins/webpack/webpackConfig/getUserWebpackConfig.d.ts +3 -0
  27. package/dist/plugins/webpack/webpackConfig/getUserWebpackConfig.js +136 -0
  28. package/dist/plugins/webpack/webpackConfig/getWebpackConfigModule.d.ts +2 -0
  29. package/dist/plugins/webpack/webpackConfig/getWebpackConfigModule.js +45 -0
  30. package/dist/plugins/webpack/webpackConfig/getWebpackConfigResolve.d.ts +4 -0
  31. package/dist/plugins/webpack/webpackConfig/getWebpackConfigResolve.js +107 -0
  32. package/dist/plugins/webpack/webpackConfig/getWebpackNodeEnv.d.ts +1 -0
  33. package/dist/plugins/webpack/webpackConfig/getWebpackNodeEnv.js +12 -0
  34. package/dist/plugins/webpack/webpackConfig/htmlPlugin.js +5 -5
  35. package/dist/plugins/webpack/webpackConfig/plugins.d.ts +5 -0
  36. package/dist/plugins/webpack/webpackConfig/plugins.js +37 -0
  37. package/dist/plugins/webpack/webpackConfig/resolveWebpackClientPath.d.ts +1 -0
  38. package/dist/plugins/webpack/webpackConfig/resolveWebpackClientPath.js +10 -0
  39. package/dist/shared/devServer/httpServer.d.ts +1 -1
  40. package/dist/shared/fs.js +3 -3
  41. package/dist/shared/playgroundHtml.js +3 -3
  42. package/dist/shared/shared.js +2 -2
  43. package/dist/shared/userDeps/getUserModules.d.ts +3 -3
  44. package/dist/shared/userDeps/getUserModules.js +5 -5
  45. package/dist/shared/userDeps/index.js +12 -12
  46. package/dist/shared/userDeps/shared.js +1 -1
  47. package/dist/shared/userDeps/userDepsTemplate.js +3 -3
  48. package/package.json +13 -13
  49. package/dist/plugins/webpack/webpackConfig/module.d.ts +0 -3
  50. package/dist/plugins/webpack/webpackConfig/module.js +0 -18
  51. package/dist/plugins/webpack/webpackConfig/shared.d.ts +0 -11
  52. package/dist/plugins/webpack/webpackConfig/shared.js +0 -254
@@ -152,6 +152,10 @@
152
152
  "hotReload": {
153
153
  "description": "Enable webpack's Hot Module Replacement. [default: true]",
154
154
  "type": "boolean"
155
+ },
156
+ "reloadOnFail": {
157
+ "description": "When using webpack's Hot Module Replacement, enable automatic location reload after webpack fails to update modules. [default: true]",
158
+ "type": "boolean"
155
159
  }
156
160
  }
157
161
  },
@@ -13,9 +13,9 @@ var _resolve = require("./resolve");
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
16
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
17
 
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
19
 
20
20
  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; }
21
21
 
@@ -3,6 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "CosmosConfig", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _shared.CosmosConfig;
10
+ }
11
+ });
6
12
  Object.defineProperty(exports, "createCosmosConfig", {
7
13
  enumerable: true,
8
14
  get: function get() {
@@ -33,12 +39,6 @@ Object.defineProperty(exports, "resolveModule", {
33
39
  return _resolve.resolveModule;
34
40
  }
35
41
  });
36
- Object.defineProperty(exports, "CosmosConfig", {
37
- enumerable: true,
38
- get: function get() {
39
- return _shared.CosmosConfig;
40
- }
41
- });
42
42
 
43
43
  var _createCosmosConfig = require("./createCosmosConfig");
44
44
 
@@ -1,7 +1,8 @@
1
- import { ReactDecoratorsByPath, ReactFixtureExportsByPath } from 'react-cosmos-shared2/react';
1
+ /// <reference types="react" />
2
+ import { ReactDecorators, ReactFixtureWrappers } from 'react-cosmos-shared2/react';
2
3
  declare type Props = {
3
- fixtures: ReactFixtureExportsByPath;
4
- decorators: ReactDecoratorsByPath;
4
+ fixtures: ReactFixtureWrappers;
5
+ decorators: ReactDecorators;
5
6
  onErrorReset?: () => unknown;
6
7
  };
7
8
  export declare function DomFixtureLoader({ fixtures, decorators, onErrorReset, }: Props): JSX.Element;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
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
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -19,15 +19,15 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
19
19
 
20
20
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
21
21
 
22
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
22
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
23
23
 
24
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
24
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
25
25
 
26
26
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
27
27
 
28
28
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
29
29
 
30
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
30
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
31
31
 
32
32
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
33
33
 
@@ -1,4 +1,4 @@
1
- import { ReactDecoratorsByPath, ReactFixtureExportsByPath } from 'react-cosmos-shared2/react';
1
+ import { ReactDecorators, ReactFixtureWrappers } from 'react-cosmos-shared2/react';
2
2
  import { DomRendererConfig } from '../shared/rendererConfig';
3
3
  import './globalErrorHandler';
4
4
  import { rendererConnect } from './rendererConnect';
@@ -6,8 +6,8 @@ import { rendererId } from './rendererId';
6
6
  export { rendererId, rendererConnect };
7
7
  declare type Args = {
8
8
  rendererConfig: DomRendererConfig;
9
- fixtures: ReactFixtureExportsByPath;
10
- decorators: ReactDecoratorsByPath;
9
+ fixtures: ReactFixtureWrappers;
10
+ decorators: ReactDecorators;
11
11
  onErrorReset?: () => unknown;
12
12
  };
13
13
  export declare function mountDomRenderer({ rendererConfig, fixtures, decorators, onErrorReset, }: Args): void;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare function renderMessage({ msg }: {
2
3
  msg: string;
3
4
  }): JSX.Element;
package/dist/fixture.js CHANGED
@@ -9,22 +9,22 @@ Object.defineProperty(exports, "FixtureContext", {
9
9
  return _FixtureLoader.FixtureContext;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "useSelect", {
12
+ Object.defineProperty(exports, "Viewport", {
13
13
  enumerable: true,
14
14
  get: function get() {
15
- return _FixtureLoader.useSelect;
15
+ return _FixtureLoader.Viewport;
16
16
  }
17
17
  });
18
- Object.defineProperty(exports, "useValue", {
18
+ Object.defineProperty(exports, "useSelect", {
19
19
  enumerable: true,
20
20
  get: function get() {
21
- return _FixtureLoader.useValue;
21
+ return _FixtureLoader.useSelect;
22
22
  }
23
23
  });
24
- Object.defineProperty(exports, "Viewport", {
24
+ Object.defineProperty(exports, "useValue", {
25
25
  enumerable: true,
26
26
  get: function get() {
27
- return _FixtureLoader.Viewport;
27
+ return _FixtureLoader.useValue;
28
28
  }
29
29
  });
30
30
 
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getFixtureUrlsSync = getFixtureUrlsSync;
7
6
  exports.getFixtureUrls = void 0;
7
+ exports.getFixtureUrlsSync = getFixtureUrlsSync;
8
8
 
9
9
  var _react = require("react-cosmos-shared2/react");
10
10
 
@@ -53,19 +53,18 @@ function getFixtureUrlsSync(_ref2) {
53
53
  }
54
54
 
55
55
  var _getUserModules = (0, _userDeps.getUserModules)(cosmosConfig),
56
- fixtureExportsByPath = _getUserModules.fixtureExportsByPath;
56
+ fixtures = _getUserModules.fixtures;
57
57
 
58
- var fixtureNamesByPath = (0, _react.getFixtureNamesByPath)(fixtureExportsByPath);
59
- Object.keys(fixtureNamesByPath).forEach(function (fixturePath) {
60
- var fixtureNames = fixtureNamesByPath[fixturePath];
58
+ var fixtureList = (0, _react.getFixtureListFromExports)(fixtures);
59
+ Object.keys(fixtureList).forEach(function (fixturePath) {
60
+ var fixtureItem = fixtureList[fixturePath];
61
61
 
62
- if (fixtureNames === null) {
62
+ if (fixtureItem.type === 'single') {
63
63
  pushFixtureUrl({
64
- path: fixturePath,
65
- name: null
64
+ path: fixturePath
66
65
  });
67
- } else {
68
- fixtureNames.forEach(function (fixtureName) {
66
+ } else if (fixtureItem.type === 'multi') {
67
+ fixtureItem.fixtureNames.forEach(function (fixtureName) {
69
68
  pushFixtureUrl({
70
69
  path: fixturePath,
71
70
  name: fixtureName
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getFixturesSync = getFixturesSync;
7
6
  exports.getFixtures = void 0;
7
+ exports.getFixturesSync = getFixturesSync;
8
8
 
9
9
  var _FixtureLoader = require("react-cosmos-shared2/FixtureLoader");
10
10
 
@@ -43,12 +43,12 @@ function getFixturesSync(_ref2) {
43
43
  var cosmosConfig = _ref2.cosmosConfig;
44
44
 
45
45
  var _getUserModules = (0, _userDeps.getUserModules)(cosmosConfig),
46
- fixtureExportsByPath = _getUserModules.fixtureExportsByPath,
47
- decoratorsByPath = _getUserModules.decoratorsByPath;
46
+ fixtures = _getUserModules.fixtures,
47
+ decorators = _getUserModules.decorators;
48
48
 
49
- var fixtures = [];
50
- Object.keys(fixtureExportsByPath).forEach(function (fixturePath) {
51
- var fixtureExport = fixtureExportsByPath[fixturePath];
49
+ var result = [];
50
+ Object.keys(fixtures).forEach(function (fixturePath) {
51
+ var fixtureExport = fixtures[fixturePath];
52
52
 
53
53
  if ((0, _react.isMultiFixture)(fixtureExport)) {
54
54
  // FIXME: Why does fixtureExport need to be cast as ReactFixtureMap when
@@ -59,23 +59,22 @@ function getFixturesSync(_ref2) {
59
59
  path: fixturePath,
60
60
  name: fixtureName
61
61
  };
62
- fixtures.push({
62
+ result.push({
63
63
  fixtureId: fixtureId,
64
- getElement: createFixtureElementGetter(multiFixtureExport[fixtureName], fixturePath, decoratorsByPath)
64
+ getElement: createFixtureElementGetter(multiFixtureExport[fixtureName], fixturePath, decorators)
65
65
  });
66
66
  });
67
67
  } else {
68
68
  var fixtureId = {
69
- path: fixturePath,
70
- name: null
69
+ path: fixturePath
71
70
  };
72
- fixtures.push({
71
+ result.push({
73
72
  fixtureId: fixtureId,
74
- getElement: createFixtureElementGetter(fixtureExport, fixturePath, decoratorsByPath)
73
+ getElement: createFixtureElementGetter(fixtureExport, fixturePath, decorators)
75
74
  });
76
75
  }
77
76
  });
78
- return fixtures;
77
+ return result;
79
78
  }
80
79
 
81
80
  function createFixtureElementGetter(fixture, fixturePath, decoratorsByPath) {
@@ -42,12 +42,12 @@ function getFixtures2(cosmosConfig) {
42
42
  var fixtureInfo = [];
43
43
 
44
44
  var _getUserModules = (0, _userDeps.getUserModules)(cosmosConfig),
45
- fixtureExportsByPath = _getUserModules.fixtureExportsByPath,
46
- decoratorsByPath = _getUserModules.decoratorsByPath;
45
+ fixtures = _getUserModules.fixtures,
46
+ decorators = _getUserModules.decorators;
47
47
 
48
- var fixtureNamesByPath = (0, _react.getFixtureNamesByPath)(fixtureExportsByPath);
48
+ var fixtureList = (0, _react.getFixtureListFromExports)(fixtures);
49
49
  var fixtureTree = (0, _fixtureTree.createFixtureTree)({
50
- fixtures: fixtureNamesByPath,
50
+ fixtures: fixtureList,
51
51
  fixturesDir: fixturesDir,
52
52
  fixtureFileSuffix: fixtureFileSuffix
53
53
  });
@@ -57,14 +57,14 @@ function getFixtures2(cosmosConfig) {
57
57
  fixtureId = _ref.fixtureId,
58
58
  name = _ref.name,
59
59
  parents = _ref.parents;
60
- var fixtureExport = fixtureExportsByPath[fixtureId.path];
61
- var fixture = fixtureId.name === null ? fixtureExport : fixtureExport[fixtureId.name];
60
+ var fixtureExport = fixtures[fixtureId.path];
61
+ var fixture = fixtureId.name === undefined ? fixtureExport : fixtureExport[fixtureId.name];
62
62
  var treePath = [].concat(_toConsumableArray(parents), [fileName]);
63
63
  if (name) treePath.push(name);
64
64
  fixtureInfo.push({
65
65
  absoluteFilePath: _path.default.join(rootDir, fixtureId.path),
66
66
  fileName: fileName,
67
- getElement: createFixtureElementGetter(fixture, fixtureId.path, decoratorsByPath),
67
+ getElement: createFixtureElementGetter(fixture, fixtureId.path, decorators),
68
68
  name: name,
69
69
  parents: parents,
70
70
  playgroundUrl: getPlaygroundUrl(cosmosConfig, fixtureId),
package/dist/index.js CHANGED
@@ -3,6 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "FixtureApi", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _getFixtures2.FixtureApi;
10
+ }
11
+ });
6
12
  Object.defineProperty(exports, "createCosmosConfig", {
7
13
  enumerable: true,
8
14
  get: function get() {
@@ -21,22 +27,22 @@ Object.defineProperty(exports, "getCosmosConfigAtPath", {
21
27
  return _config.getCosmosConfigAtPath;
22
28
  }
23
29
  });
24
- Object.defineProperty(exports, "getFixtures", {
30
+ Object.defineProperty(exports, "getFixtureUrls", {
25
31
  enumerable: true,
26
32
  get: function get() {
27
- return _getFixtures.getFixtures;
33
+ return _getFixtureUrls.getFixtureUrls;
28
34
  }
29
35
  });
30
- Object.defineProperty(exports, "getFixturesSync", {
36
+ Object.defineProperty(exports, "getFixtureUrlsSync", {
31
37
  enumerable: true,
32
38
  get: function get() {
33
- return _getFixtures.getFixturesSync;
39
+ return _getFixtureUrls.getFixtureUrlsSync;
34
40
  }
35
41
  });
36
- Object.defineProperty(exports, "FixtureApi", {
42
+ Object.defineProperty(exports, "getFixtures", {
37
43
  enumerable: true,
38
44
  get: function get() {
39
- return _getFixtures2.FixtureApi;
45
+ return _getFixtures.getFixtures;
40
46
  }
41
47
  });
42
48
  Object.defineProperty(exports, "getFixtures2", {
@@ -45,16 +51,10 @@ Object.defineProperty(exports, "getFixtures2", {
45
51
  return _getFixtures2.getFixtures2;
46
52
  }
47
53
  });
48
- Object.defineProperty(exports, "getFixtureUrls", {
49
- enumerable: true,
50
- get: function get() {
51
- return _getFixtureUrls.getFixtureUrls;
52
- }
53
- });
54
- Object.defineProperty(exports, "getFixtureUrlsSync", {
54
+ Object.defineProperty(exports, "getFixturesSync", {
55
55
  enumerable: true,
56
56
  get: function get() {
57
- return _getFixtureUrls.getFixtureUrlsSync;
57
+ return _getFixtures.getFixturesSync;
58
58
  }
59
59
  });
60
60
 
package/dist/native.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { ReactDecoratorsByPath, ReactFixtureExportsByPath } from 'react-cosmos-shared2/react';
1
+ /// <reference types="react" />
2
+ import { ReactDecorators, ReactFixtureWrappers } from 'react-cosmos-shared2/react';
2
3
  import { NativeRendererConfig } from './shared/rendererConfig';
3
4
  declare type Props = {
4
5
  rendererConfig: NativeRendererConfig;
5
- fixtures: ReactFixtureExportsByPath;
6
- decorators: ReactDecoratorsByPath;
6
+ fixtures: ReactFixtureWrappers;
7
+ decorators: ReactDecorators;
7
8
  };
8
9
  export declare function NativeFixtureLoader({ rendererConfig: { port }, fixtures, decorators, }: Props): JSX.Element;
9
10
  export {};
package/dist/native.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
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
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -7,7 +7,7 @@ exports.httpProxy = httpProxy;
7
7
 
8
8
  var _httpProxyMiddleware = require("http-proxy-middleware");
9
9
 
10
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
10
+ 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); }
11
11
 
12
12
  function httpProxy(_ref) {
13
13
  var cosmosConfig = _ref.cosmosConfig,
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
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
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.init = init;
9
8
  exports.dismiss = dismiss;
9
+ exports.init = init;
10
10
 
11
11
  var _url = require("react-cosmos-shared2/url");
12
12
 
@@ -1,5 +1,5 @@
1
- import { ReactDecoratorsByPath, ReactFixtureExportsByPath } from 'react-cosmos-shared2/react';
1
+ import { ReactDecorators, ReactFixtureWrappers } from 'react-cosmos-shared2/react';
2
2
  import { DomRendererConfig } from '../../../shared/rendererConfig';
3
3
  export declare const rendererConfig: DomRendererConfig;
4
- export declare const fixtures: ReactFixtureExportsByPath;
5
- export declare const decorators: ReactDecoratorsByPath;
4
+ export declare const fixtures: ReactFixtureWrappers;
5
+ export declare const decorators: ReactDecorators;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.decorators = exports.fixtures = exports.rendererConfig = void 0;
6
+ exports.rendererConfig = exports.fixtures = exports.decorators = void 0;
7
7
  // NOTE: Renderer data is statically injected at compile time
8
8
  var rendererConfig = {
9
9
  containerQuerySelector: null
@@ -4,6 +4,7 @@ declare type WebpackCosmosConfig = {
4
4
  overridePath: null | string;
5
5
  includeHashInOutputFilename: boolean;
6
6
  hotReload: boolean;
7
+ reloadOnFail: boolean;
7
8
  };
8
9
  export declare function createWebpackCosmosConfig(cosmosConfig: CosmosConfig): WebpackCosmosConfig;
9
10
  export {};
@@ -20,7 +20,8 @@ function createWebpackCosmosConfig(cosmosConfig) {
20
20
  configPath: getWebpackConfigPath(configInput, rootDir),
21
21
  overridePath: getWebpackOverridePath(configInput, rootDir),
22
22
  includeHashInOutputFilename: getIncludeHashInOutputFilename(configInput),
23
- hotReload: getHotReload(configInput)
23
+ hotReload: getHotReload(configInput),
24
+ reloadOnFail: getReloadOnFail(configInput)
24
25
  };
25
26
  }
26
27
 
@@ -85,4 +86,10 @@ function getHotReload(_ref4) {
85
86
  var _ref4$hotReload = _ref4.hotReload,
86
87
  hotReload = _ref4$hotReload === void 0 ? true : _ref4$hotReload;
87
88
  return hotReload;
89
+ }
90
+
91
+ function getReloadOnFail(_ref5) {
92
+ var _ref5$reloadOnFail = _ref5.reloadOnFail,
93
+ reloadOnFail = _ref5$reloadOnFail === void 0 ? true : _ref5$reloadOnFail;
94
+ return reloadOnFail;
88
95
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
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
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -11,13 +11,17 @@ var _shared = require("./shared");
11
11
 
12
12
  var _webpackConfig = require("./webpackConfig");
13
13
 
14
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
15
+
16
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
17
+
14
18
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
19
 
16
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
20
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
17
21
 
18
22
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
19
23
 
20
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
24
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
21
25
 
22
26
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
23
27
 
@@ -131,5 +135,5 @@ var WebpackCompilationError = /*#__PURE__*/function (_Error) {
131
135
  return _this;
132
136
  }
133
137
 
134
- return WebpackCompilationError;
138
+ return _createClass(WebpackCompilationError);
135
139
  }( /*#__PURE__*/_wrapNativeSuper(Error));
@@ -9,15 +9,23 @@ var _path = _interopRequireDefault(require("path"));
9
9
 
10
10
  var _webpack = require("../cosmosConfig/webpack");
11
11
 
12
+ var _getUserWebpackConfig = require("./getUserWebpackConfig");
13
+
14
+ var _getWebpackConfigResolve = require("./getWebpackConfigResolve");
15
+
16
+ var _getWebpackConfigModule = require("./getWebpackConfigModule");
17
+
12
18
  var _htmlPlugin = require("./htmlPlugin");
13
19
 
14
- var _shared = require("./shared");
20
+ var _plugins = require("./plugins");
21
+
22
+ var _resolveWebpackClientPath = require("./resolveWebpackClientPath");
15
23
 
16
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
25
 
18
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
26
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
19
27
 
20
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
28
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
21
29
 
22
30
  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; }
23
31
 
@@ -51,17 +59,15 @@ function _getDevWebpackConfig() {
51
59
  switch (_context.prev = _context.next) {
52
60
  case 0:
53
61
  _context.next = 2;
54
- return (0, _shared.getUserWebpackConfig)(cosmosConfig, userWebpack);
62
+ return (0, _getUserWebpackConfig.getUserWebpackConfig)(cosmosConfig, userWebpack);
55
63
 
56
64
  case 2:
57
65
  baseWebpackConfig = _context.sent;
58
66
  webpackConfig = _objectSpread(_objectSpread({}, baseWebpackConfig), {}, {
59
67
  entry: getEntry(cosmosConfig),
60
68
  output: getOutput(cosmosConfig),
61
- module: _objectSpread(_objectSpread({}, baseWebpackConfig.module), {}, {
62
- rules: getRules(baseWebpackConfig)
63
- }),
64
- resolve: (0, _shared.resolveLocalReactDeps)(cosmosConfig, baseWebpackConfig),
69
+ module: (0, _getWebpackConfigModule.getWebpackConfigModule)(baseWebpackConfig),
70
+ resolve: (0, _getWebpackConfigResolve.getWebpackConfigResolve)(cosmosConfig, baseWebpackConfig),
65
71
  plugins: getPlugins(cosmosConfig, baseWebpackConfig, userWebpack)
66
72
  }); // optimization.splitChunks.name = false breaks auto fixture file discovery.
67
73
  // When the splitChunks.name is set to false, existing fixtures hot reload
@@ -93,13 +99,14 @@ function _getDevWebpackConfig() {
93
99
 
94
100
  function getEntry(cosmosConfig) {
95
101
  var _createWebpackCosmosC = (0, _webpack.createWebpackCosmosConfig)(cosmosConfig),
96
- hotReload = _createWebpackCosmosC.hotReload; // The React devtools hook needs to be imported before any other module that
102
+ hotReload = _createWebpackCosmosC.hotReload,
103
+ reloadOnFail = _createWebpackCosmosC.reloadOnFail; // The React devtools hook needs to be imported before any other module that
97
104
  // might import React
98
105
 
99
106
 
100
- var devtoolsHook = (0, _shared.resolveClientPath)('reactDevtoolsHook');
101
- var clientIndex = (0, _shared.resolveClientPath)('index');
102
- return hotReload ? [devtoolsHook, getHotMiddlewareEntry(), clientIndex] : [devtoolsHook, clientIndex];
107
+ var devtoolsHook = (0, _resolveWebpackClientPath.resolveWebpackClientPath)('reactDevtoolsHook');
108
+ var clientIndex = (0, _resolveWebpackClientPath.resolveWebpackClientPath)('index');
109
+ return hotReload ? [devtoolsHook, getHotMiddlewareEntry(reloadOnFail), clientIndex] : [devtoolsHook, clientIndex];
103
110
  }
104
111
 
105
112
  function getOutput(_ref) {
@@ -115,21 +122,16 @@ function getOutput(_ref) {
115
122
  };
116
123
  }
117
124
 
118
- function getRules(baseWebpackConfig) {
119
- var existingRules = baseWebpackConfig.module && baseWebpackConfig.module.rules || [];
120
- return [].concat(_toConsumableArray(existingRules), [(0, _shared.getUserDepsLoaderRule)()]);
121
- }
122
-
123
125
  function getPlugins(cosmosConfig, baseWebpackConfig, userWebpack) {
124
126
  var existingPlugins = baseWebpackConfig.plugins || [];
125
- var globalsPlugin = (0, _shared.getGlobalsPlugin)(cosmosConfig, userWebpack, true);
127
+ var globalsPlugin = (0, _plugins.getGlobalsPlugin)(cosmosConfig, userWebpack, true);
126
128
  var noEmitErrorsPlugin = new userWebpack.NoEmitOnErrorsPlugin();
127
129
  var plugins = [].concat(_toConsumableArray(existingPlugins), [globalsPlugin, noEmitErrorsPlugin]);
128
130
 
129
131
  var _createWebpackCosmosC2 = (0, _webpack.createWebpackCosmosConfig)(cosmosConfig),
130
132
  hotReload = _createWebpackCosmosC2.hotReload;
131
133
 
132
- if (hotReload && !(0, _shared.hasPlugin)(plugins, 'HotModuleReplacementPlugin')) {
134
+ if (hotReload && !(0, _plugins.hasPlugin)(plugins, 'HotModuleReplacementPlugin')) {
133
135
  var hmrPlugin = new userWebpack.HotModuleReplacementPlugin();
134
136
  plugins = [].concat(_toConsumableArray(plugins), [hmrPlugin]);
135
137
  }
@@ -137,8 +139,8 @@ function getPlugins(cosmosConfig, baseWebpackConfig, userWebpack) {
137
139
  return (0, _htmlPlugin.ensureHtmlWebackPlugin)(cosmosConfig, plugins);
138
140
  }
139
141
 
140
- function getHotMiddlewareEntry() {
142
+ function getHotMiddlewareEntry(reloadOnFail) {
141
143
  var clientPath = require.resolve('@skidding/webpack-hot-middleware/client');
142
144
 
143
- return "".concat(clientPath, "?reload=true&overlay=false");
145
+ return "".concat(clientPath, "?reload=").concat(reloadOnFail, "&overlay=false");
144
146
  }