react-cosmos 5.7.2 → 6.0.0-alpha.0

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 (246) hide show
  1. package/bin/cosmos-export.js +4 -3
  2. package/bin/cosmos-native.js +4 -3
  3. package/bin/cosmos.js +5 -4
  4. package/config.schema.json +14 -4
  5. package/dist/index.d.ts +0 -6
  6. package/dist/index.js +0 -70
  7. package/dist/jest.d.ts +7 -0
  8. package/dist/jest.js +7 -0
  9. package/dist/{config → server/cosmosConfig}/createCosmosConfig.d.ts +1 -1
  10. package/dist/server/cosmosConfig/createCosmosConfig.js +84 -0
  11. package/dist/server/cosmosConfig/detectCosmosConfig.d.ts +2 -0
  12. package/dist/server/cosmosConfig/detectCosmosConfig.js +38 -0
  13. package/dist/{config → server/cosmosConfig}/getCosmosConfigAtPath.d.ts +1 -1
  14. package/dist/server/cosmosConfig/getCosmosConfigAtPath.js +12 -0
  15. package/dist/server/cosmosConfig/shared.d.ts +2 -0
  16. package/dist/server/cosmosConfig/shared.js +7 -0
  17. package/dist/{config/shared.d.ts → server/cosmosConfig/types.d.ts} +5 -5
  18. package/dist/server/cosmosPlugin/findCosmosPluginConfigs.d.ts +8 -0
  19. package/dist/server/cosmosPlugin/findCosmosPluginConfigs.js +14 -0
  20. package/dist/server/cosmosPlugin/pluginConfigs.d.ts +8 -0
  21. package/dist/server/cosmosPlugin/pluginConfigs.js +16 -0
  22. package/dist/server/cosmosPlugin/readCosmosPluginConfig.d.ts +8 -0
  23. package/dist/server/cosmosPlugin/readCosmosPluginConfig.js +31 -0
  24. package/dist/server/cosmosPlugin/types.d.ts +21 -0
  25. package/dist/server/devServer/corePlugins/httpProxy.d.ts +2 -0
  26. package/dist/server/devServer/corePlugins/httpProxy.js +18 -0
  27. package/dist/server/devServer/corePlugins/openFile.d.ts +2 -0
  28. package/dist/server/devServer/corePlugins/openFile.js +53 -0
  29. package/dist/server/devServer/corePlugins/pluginEndpoint.d.ts +2 -0
  30. package/dist/server/devServer/corePlugins/pluginEndpoint.js +17 -0
  31. package/dist/server/devServer/corePlugins/userDepsFile.d.ts +2 -0
  32. package/dist/server/devServer/corePlugins/userDepsFile.js +37 -0
  33. package/dist/server/devServer/expressApp.d.ts +5 -0
  34. package/dist/server/devServer/expressApp.js +21 -0
  35. package/dist/server/devServer/httpServer.d.ts +12 -0
  36. package/dist/server/devServer/httpServer.js +42 -0
  37. package/dist/{devServer → server/devServer}/messageHandler.d.ts +2 -2
  38. package/dist/server/devServer/messageHandler.js +29 -0
  39. package/dist/server/devServer/startDevServer.d.ts +2 -0
  40. package/dist/server/devServer/startDevServer.js +91 -0
  41. package/dist/server/export/generateExport.d.ts +1 -0
  42. package/dist/server/export/generateExport.js +97 -0
  43. package/dist/server/getFixtures/getFixtures.d.ts +14 -0
  44. package/dist/server/getFixtures/getFixtures.js +63 -0
  45. package/dist/server/shared/logPluginInfo.d.ts +2 -0
  46. package/dist/server/shared/logPluginInfo.js +8 -0
  47. package/dist/server/shared/playgroundHtml.d.ts +6 -0
  48. package/dist/server/shared/playgroundHtml.js +85 -0
  49. package/dist/server/shared/playgroundUrl.d.ts +2 -0
  50. package/dist/server/shared/playgroundUrl.js +6 -0
  51. package/dist/server/shared/requirePluginModule.d.ts +2 -0
  52. package/dist/server/shared/requirePluginModule.js +10 -0
  53. package/dist/server/shared/resolveUrlPath.d.ts +1 -0
  54. package/dist/server/shared/resolveUrlPath.js +12 -0
  55. package/dist/server/shared/staticPath.d.ts +1 -0
  56. package/dist/server/shared/staticPath.js +4 -0
  57. package/dist/{shared/static.d.ts → server/shared/staticServer.d.ts} +0 -1
  58. package/dist/server/shared/staticServer.js +12 -0
  59. package/dist/{shared → server}/static/index.html +1 -1
  60. package/dist/server/testHelpers/cwd.d.ts +1 -0
  61. package/dist/server/testHelpers/cwd.js +4 -0
  62. package/dist/server/testHelpers/mockConsole.d.ts +5 -0
  63. package/dist/server/testHelpers/mockConsole.js +11 -0
  64. package/dist/server/testHelpers/mockEsmRequire.js +13 -0
  65. package/dist/server/testHelpers/mockEsmResolve.d.ts +1 -0
  66. package/dist/server/testHelpers/mockEsmResolve.js +13 -0
  67. package/dist/server/testHelpers/mockEsmStaticPath.d.ts +1 -0
  68. package/dist/server/testHelpers/mockEsmStaticPath.js +7 -0
  69. package/dist/server/testHelpers/mockFetch.d.ts +2 -0
  70. package/dist/server/testHelpers/mockFetch.js +7 -0
  71. package/dist/server/testHelpers/mockFs.d.ts +5 -0
  72. package/dist/server/testHelpers/mockFs.js +64 -0
  73. package/dist/server/testHelpers/mockYargs.d.ts +2 -0
  74. package/dist/server/testHelpers/mockYargs.js +21 -0
  75. package/dist/{userDeps → server/userDeps}/findUserModulePaths.d.ts +2 -2
  76. package/dist/server/userDeps/findUserModulePaths.js +20 -0
  77. package/dist/server/userDeps/fixtureWatcher.d.ts +3 -0
  78. package/dist/server/userDeps/fixtureWatcher.js +20 -0
  79. package/dist/{userDeps → server/userDeps}/generateUserDepsModule.d.ts +3 -3
  80. package/dist/server/userDeps/generateUserDepsModule.js +18 -0
  81. package/dist/{userDeps → server/userDeps}/getUserModules.d.ts +3 -3
  82. package/dist/server/userDeps/getUserModules.js +25 -0
  83. package/dist/{userDeps → server/userDeps}/shared.d.ts +1 -1
  84. package/dist/server/userDeps/shared.js +20 -0
  85. package/dist/{userDeps → server/userDeps}/userDepsTemplate.d.ts +2 -2
  86. package/dist/server/userDeps/userDepsTemplate.js +49 -0
  87. package/dist/server/utils/cli.js +4 -0
  88. package/dist/server/utils/fs.d.ts +4 -0
  89. package/dist/server/utils/fs.js +24 -0
  90. package/dist/server/utils/isNodeError.d.ts +2 -0
  91. package/dist/server/utils/isNodeError.js +3 -0
  92. package/dist/server/utils/requireModule.d.ts +2 -0
  93. package/dist/server/utils/requireModule.js +13 -0
  94. package/dist/server/utils/requireSilent.d.ts +1 -0
  95. package/dist/server/utils/requireSilent.js +11 -0
  96. package/dist/server/utils/resolve.d.ts +2 -0
  97. package/dist/server/utils/resolve.js +14 -0
  98. package/dist/server/utils/resolveLoose.d.ts +1 -0
  99. package/dist/server/utils/resolveLoose.js +12 -0
  100. package/dist/server/utils/resolveSilent.d.ts +2 -0
  101. package/dist/server/utils/resolveSilent.js +22 -0
  102. package/dist/server/utils/slash.d.ts +1 -0
  103. package/dist/server/utils/slash.js +5 -0
  104. package/dist/server.d.ts +20 -0
  105. package/dist/server.js +20 -0
  106. package/index.d.ts +1 -1
  107. package/index.js +1 -2
  108. package/jest.d.ts +1 -0
  109. package/jest.js +1 -0
  110. package/package.json +17 -28
  111. package/server.d.ts +1 -0
  112. package/server.js +1 -0
  113. package/dist/config/createCosmosConfig.js +0 -133
  114. package/dist/config/detectCosmosConfig.d.ts +0 -2
  115. package/dist/config/detectCosmosConfig.js +0 -57
  116. package/dist/config/getCosmosConfigAtPath.js +0 -28
  117. package/dist/config/resolveModule.d.ts +0 -1
  118. package/dist/config/resolveModule.js +0 -20
  119. package/dist/config/shared.js +0 -17
  120. package/dist/devServer/app.d.ts +0 -5
  121. package/dist/devServer/app.js +0 -51
  122. package/dist/devServer/httpServer.d.ts +0 -11
  123. package/dist/devServer/httpServer.js +0 -183
  124. package/dist/devServer/messageHandler.js +0 -42
  125. package/dist/devServer/startDevServer.d.ts +0 -18
  126. package/dist/devServer/startDevServer.js +0 -209
  127. package/dist/dom/DomFixtureLoader.d.ts +0 -9
  128. package/dist/dom/DomFixtureLoader.js +0 -38
  129. package/dist/dom/ErrorCatch.d.ts +0 -15
  130. package/dist/dom/ErrorCatch.js +0 -117
  131. package/dist/dom/container.d.ts +0 -1
  132. package/dist/dom/container.js +0 -32
  133. package/dist/dom/globalErrorHandler.js +0 -14
  134. package/dist/dom/index.d.ts +0 -13
  135. package/dist/dom/index.js +0 -47
  136. package/dist/dom/renderMessage.d.ts +0 -4
  137. package/dist/dom/renderMessage.js +0 -30
  138. package/dist/dom/rendererConnect.d.ts +0 -1
  139. package/dist/dom/rendererConnect.js +0 -18
  140. package/dist/dom/rendererId.d.ts +0 -1
  141. package/dist/dom/rendererId.js +0 -26
  142. package/dist/dom/selectedFixtureId.d.ts +0 -2
  143. package/dist/dom/selectedFixtureId.js +0 -41
  144. package/dist/dom/shared.d.ts +0 -1
  145. package/dist/dom/shared.js +0 -14
  146. package/dist/export/generateExport.d.ts +0 -6
  147. package/dist/export/generateExport.js +0 -137
  148. package/dist/fixture.d.ts +0 -1
  149. package/dist/fixture.js +0 -31
  150. package/dist/generateWebExport.d.ts +0 -1
  151. package/dist/generateWebExport.js +0 -37
  152. package/dist/getFixtureUrls.d.ts +0 -8
  153. package/dist/getFixtureUrls.js +0 -97
  154. package/dist/getFixtures.d.ts +0 -13
  155. package/dist/getFixtures.js +0 -89
  156. package/dist/getFixtures2.d.ts +0 -14
  157. package/dist/getFixtures2.js +0 -117
  158. package/dist/native/NativeFixtureLoader.d.ts +0 -12
  159. package/dist/native/NativeFixtureLoader.js +0 -67
  160. package/dist/native/index.d.ts +0 -1
  161. package/dist/native/index.js +0 -25
  162. package/dist/plugins/httpProxy.d.ts +0 -2
  163. package/dist/plugins/httpProxy.js +0 -31
  164. package/dist/plugins/openFile.d.ts +0 -2
  165. package/dist/plugins/openFile.js +0 -87
  166. package/dist/plugins/userDepsFile.d.ts +0 -2
  167. package/dist/plugins/userDepsFile.js +0 -166
  168. package/dist/plugins/webpack/client/errorOverlay/index.d.ts +0 -1
  169. package/dist/plugins/webpack/client/errorOverlay/index.js +0 -16
  170. package/dist/plugins/webpack/client/errorOverlay/reactErrorOverlay.d.ts +0 -2
  171. package/dist/plugins/webpack/client/errorOverlay/reactErrorOverlay.js +0 -63
  172. package/dist/plugins/webpack/client/hmrErrorHandler.js +0 -16
  173. package/dist/plugins/webpack/client/index.d.ts +0 -6
  174. package/dist/plugins/webpack/client/index.js +0 -43
  175. package/dist/plugins/webpack/client/reactDevtoolsHook.d.ts +0 -0
  176. package/dist/plugins/webpack/client/reactDevtoolsHook.js +0 -19
  177. package/dist/plugins/webpack/client/userDeps.d.ts +0 -5
  178. package/dist/plugins/webpack/client/userDeps.js +0 -15
  179. package/dist/plugins/webpack/cosmosConfig/dom.d.ts +0 -6
  180. package/dist/plugins/webpack/cosmosConfig/dom.js +0 -19
  181. package/dist/plugins/webpack/cosmosConfig/webpack.d.ts +0 -10
  182. package/dist/plugins/webpack/cosmosConfig/webpack.js +0 -95
  183. package/dist/plugins/webpack/devServer.d.ts +0 -2
  184. package/dist/plugins/webpack/devServer.js +0 -168
  185. package/dist/plugins/webpack/export.d.ts +0 -2
  186. package/dist/plugins/webpack/export.js +0 -139
  187. package/dist/plugins/webpack/index.d.ts +0 -2
  188. package/dist/plugins/webpack/index.js +0 -21
  189. package/dist/plugins/webpack/shared.d.ts +0 -2
  190. package/dist/plugins/webpack/shared.js +0 -22
  191. package/dist/plugins/webpack/webpackConfig/getDefaultWebpackConfig.d.ts +0 -2
  192. package/dist/plugins/webpack/webpackConfig/getDefaultWebpackConfig.js +0 -152
  193. package/dist/plugins/webpack/webpackConfig/getDevWebpackConfig.d.ts +0 -3
  194. package/dist/plugins/webpack/webpackConfig/getDevWebpackConfig.js +0 -146
  195. package/dist/plugins/webpack/webpackConfig/getExportWebpackConfig.d.ts +0 -3
  196. package/dist/plugins/webpack/webpackConfig/getExportWebpackConfig.js +0 -111
  197. package/dist/plugins/webpack/webpackConfig/getUserWebpackConfig.d.ts +0 -3
  198. package/dist/plugins/webpack/webpackConfig/getUserWebpackConfig.js +0 -136
  199. package/dist/plugins/webpack/webpackConfig/getWebpackConfigModule.d.ts +0 -2
  200. package/dist/plugins/webpack/webpackConfig/getWebpackConfigModule.js +0 -45
  201. package/dist/plugins/webpack/webpackConfig/getWebpackConfigResolve.d.ts +0 -4
  202. package/dist/plugins/webpack/webpackConfig/getWebpackConfigResolve.js +0 -107
  203. package/dist/plugins/webpack/webpackConfig/getWebpackNodeEnv.d.ts +0 -1
  204. package/dist/plugins/webpack/webpackConfig/getWebpackNodeEnv.js +0 -12
  205. package/dist/plugins/webpack/webpackConfig/htmlPlugin.d.ts +0 -16
  206. package/dist/plugins/webpack/webpackConfig/htmlPlugin.js +0 -80
  207. package/dist/plugins/webpack/webpackConfig/plugins.d.ts +0 -5
  208. package/dist/plugins/webpack/webpackConfig/plugins.js +0 -37
  209. package/dist/plugins/webpack/webpackConfig/resolveWebpackClientPath.d.ts +0 -1
  210. package/dist/plugins/webpack/webpackConfig/resolveWebpackClientPath.js +0 -10
  211. package/dist/plugins/webpack/webpackConfig/userDepsLoader.js +0 -36
  212. package/dist/shared/cli.js +0 -14
  213. package/dist/shared/fs.d.ts +0 -4
  214. package/dist/shared/fs.js +0 -37
  215. package/dist/shared/playgroundHtml.d.ts +0 -6
  216. package/dist/shared/playgroundHtml.js +0 -116
  217. package/dist/shared/pluginConfigs.d.ts +0 -2
  218. package/dist/shared/pluginConfigs.js +0 -15
  219. package/dist/shared/rendererConfig.d.ts +0 -6
  220. package/dist/shared/rendererConfig.js +0 -5
  221. package/dist/shared/static.js +0 -30
  222. package/dist/shared/types.d.ts +0 -1
  223. package/dist/shared/types.js +0 -5
  224. package/dist/shared/utils.d.ts +0 -5
  225. package/dist/shared/utils.js +0 -22
  226. package/dist/startNativeServer.d.ts +0 -1
  227. package/dist/startNativeServer.js +0 -39
  228. package/dist/startWebServer.d.ts +0 -1
  229. package/dist/startWebServer.js +0 -43
  230. package/dist/userDeps/findUserModulePaths.js +0 -45
  231. package/dist/userDeps/generateUserDepsModule.js +0 -37
  232. package/dist/userDeps/getUserModules.js +0 -45
  233. package/dist/userDeps/shared.js +0 -32
  234. package/dist/userDeps/userDepsTemplate.js +0 -52
  235. package/dom.d.ts +0 -1
  236. package/dom.js +0 -2
  237. package/fixture.d.ts +0 -1
  238. package/fixture.js +0 -2
  239. package/native.d.ts +0 -1
  240. package/native.js +0 -2
  241. package/yarn-error.log +0 -13450
  242. /package/dist/{dom/globalErrorHandler.d.ts → server/cosmosConfig/types.js} +0 -0
  243. /package/dist/{plugins/webpack/client/hmrErrorHandler.d.ts → server/cosmosPlugin/types.js} +0 -0
  244. /package/dist/{shared → server}/static/favicon.ico +0 -0
  245. /package/dist/{plugins/webpack/webpackConfig/userDepsLoader.d.ts → server/testHelpers/mockEsmRequire.d.ts} +0 -0
  246. /package/dist/{shared → server/utils}/cli.d.ts +0 -0
@@ -1,3 +0,0 @@
1
- import webpack from 'webpack';
2
- import { CosmosConfig } from '../../../config/shared';
3
- export declare function getExportWebpackConfig(cosmosConfig: CosmosConfig, userWebpack: typeof webpack): Promise<webpack.Configuration>;
@@ -1,111 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getExportWebpackConfig = getExportWebpackConfig;
7
-
8
- var _path = _interopRequireDefault(require("path"));
9
-
10
- var _utils = require("../../../shared/utils");
11
-
12
- var _webpack = require("../cosmosConfig/webpack");
13
-
14
- var _getUserWebpackConfig = require("./getUserWebpackConfig");
15
-
16
- var _getWebpackConfigModule = require("./getWebpackConfigModule");
17
-
18
- var _getWebpackConfigResolve = require("./getWebpackConfigResolve");
19
-
20
- var _htmlPlugin = require("./htmlPlugin");
21
-
22
- var _plugins = require("./plugins");
23
-
24
- var _resolveWebpackClientPath = require("./resolveWebpackClientPath");
25
-
26
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
-
28
- 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; }
29
-
30
- 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; }
31
-
32
- 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; }
33
-
34
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
35
-
36
- 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."); }
37
-
38
- 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); }
39
-
40
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
41
-
42
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
43
-
44
- 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; }
45
-
46
- 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); } }
47
-
48
- 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); }); }; }
49
-
50
- function getExportWebpackConfig(_x, _x2) {
51
- return _getExportWebpackConfig.apply(this, arguments);
52
- }
53
-
54
- function _getExportWebpackConfig() {
55
- _getExportWebpackConfig = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(cosmosConfig, userWebpack) {
56
- var baseWebpackConfig;
57
- return regeneratorRuntime.wrap(function _callee$(_context) {
58
- while (1) {
59
- switch (_context.prev = _context.next) {
60
- case 0:
61
- _context.next = 2;
62
- return (0, _getUserWebpackConfig.getUserWebpackConfig)(cosmosConfig, userWebpack);
63
-
64
- case 2:
65
- baseWebpackConfig = _context.sent;
66
- return _context.abrupt("return", _objectSpread(_objectSpread({}, baseWebpackConfig), {}, {
67
- entry: getEntry(),
68
- output: getOutput(cosmosConfig),
69
- module: (0, _getWebpackConfigModule.getWebpackConfigModule)(baseWebpackConfig),
70
- resolve: (0, _getWebpackConfigResolve.getWebpackConfigResolve)(cosmosConfig, baseWebpackConfig),
71
- plugins: getPlugins(cosmosConfig, baseWebpackConfig, userWebpack)
72
- }));
73
-
74
- case 4:
75
- case "end":
76
- return _context.stop();
77
- }
78
- }
79
- }, _callee);
80
- }));
81
- return _getExportWebpackConfig.apply(this, arguments);
82
- }
83
-
84
- function getEntry() {
85
- // The React devtools hook needs to be imported before any other module that
86
- // might import React
87
- var devtoolsHook = (0, _resolveWebpackClientPath.resolveWebpackClientPath)('reactDevtoolsHook');
88
- var clientIndex = (0, _resolveWebpackClientPath.resolveWebpackClientPath)('index');
89
- return [devtoolsHook, clientIndex];
90
- }
91
-
92
- function getOutput(cosmosConfig) {
93
- var exportPath = cosmosConfig.exportPath,
94
- publicUrl = cosmosConfig.publicUrl;
95
-
96
- var _createWebpackCosmosC = (0, _webpack.createWebpackCosmosConfig)(cosmosConfig),
97
- includeHashInOutputFilename = _createWebpackCosmosC.includeHashInOutputFilename;
98
-
99
- return {
100
- path: _path.default.resolve(exportPath, (0, _utils.removeLeadingSlash)(publicUrl)),
101
- filename: includeHashInOutputFilename ? '[name].[contenthash].js' : '[name].js',
102
- publicPath: publicUrl
103
- };
104
- }
105
-
106
- function getPlugins(cosmosConfig, baseWebpackConfig, userWebpack) {
107
- var existingPlugins = baseWebpackConfig.plugins || [];
108
- var globalsPlugin = (0, _plugins.getGlobalsPlugin)(cosmosConfig, userWebpack, false);
109
- var noEmitErrorsPlugin = new userWebpack.NoEmitOnErrorsPlugin();
110
- return (0, _htmlPlugin.ensureHtmlWebackPlugin)(cosmosConfig, [].concat(_toConsumableArray(existingPlugins), [globalsPlugin, noEmitErrorsPlugin]));
111
- }
@@ -1,3 +0,0 @@
1
- import webpack from 'webpack';
2
- import { CosmosConfig } from '../../../config/shared';
3
- export declare function getUserWebpackConfig(cosmosConfig: CosmosConfig, userWebpack: typeof webpack): Promise<webpack.Configuration>;
@@ -1,136 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getUserWebpackConfig = getUserWebpackConfig;
7
-
8
- var _path = _interopRequireDefault(require("path"));
9
-
10
- var _cli = require("../../../shared/cli");
11
-
12
- var _fs = require("../../../shared/fs");
13
-
14
- var _webpack = require("../cosmosConfig/webpack");
15
-
16
- var _getDefaultWebpackConfig = require("./getDefaultWebpackConfig");
17
-
18
- var _getWebpackNodeEnv = require("./getWebpackNodeEnv");
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
- 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); }
23
-
24
- 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); } }
25
-
26
- 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); }); }; }
27
-
28
- function getUserWebpackConfig(_x, _x2) {
29
- return _getUserWebpackConfig.apply(this, arguments);
30
- }
31
-
32
- function _getUserWebpackConfig() {
33
- _getUserWebpackConfig = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(cosmosConfig, userWebpack) {
34
- var baseWebpackConfig, _createWebpackCosmosC, overridePath, relPath, webpackOverride;
35
-
36
- return regeneratorRuntime.wrap(function _callee$(_context) {
37
- while (1) {
38
- switch (_context.prev = _context.next) {
39
- case 0:
40
- _context.next = 2;
41
- return getBaseWebpackConfig(cosmosConfig, userWebpack);
42
-
43
- case 2:
44
- baseWebpackConfig = _context.sent;
45
- _createWebpackCosmosC = (0, _webpack.createWebpackCosmosConfig)(cosmosConfig), overridePath = _createWebpackCosmosC.overridePath;
46
-
47
- if (!(!overridePath || !(0, _fs.moduleExists)(overridePath))) {
48
- _context.next = 6;
49
- break;
50
- }
51
-
52
- return _context.abrupt("return", baseWebpackConfig);
53
-
54
- case 6:
55
- relPath = _path.default.relative(process.cwd(), overridePath);
56
- console.log("[Cosmos] Overriding webpack config at ".concat(relPath));
57
- webpackOverride = getDefaultExport((0, _fs.requireModule)(overridePath));
58
- return _context.abrupt("return", webpackOverride(baseWebpackConfig, (0, _getWebpackNodeEnv.getWebpackNodeEnv)()));
59
-
60
- case 10:
61
- case "end":
62
- return _context.stop();
63
- }
64
- }
65
- }, _callee);
66
- }));
67
- return _getUserWebpackConfig.apply(this, arguments);
68
- }
69
-
70
- function getBaseWebpackConfig(_x3, _x4) {
71
- return _getBaseWebpackConfig.apply(this, arguments);
72
- } // Get "default" export from either an ES or CJS module
73
- // More context: https://github.com/react-cosmos/react-cosmos/issues/895
74
-
75
-
76
- function _getBaseWebpackConfig() {
77
- _getBaseWebpackConfig = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(cosmosConfig, userWebpack) {
78
- var rootDir, _createWebpackCosmosC2, configPath, relPath, userConfigExport, cliArgs;
79
-
80
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
81
- while (1) {
82
- switch (_context2.prev = _context2.next) {
83
- case 0:
84
- rootDir = cosmosConfig.rootDir;
85
- _createWebpackCosmosC2 = (0, _webpack.createWebpackCosmosConfig)(cosmosConfig), configPath = _createWebpackCosmosC2.configPath;
86
-
87
- if (!(!configPath || !(0, _fs.moduleExists)(configPath))) {
88
- _context2.next = 5;
89
- break;
90
- }
91
-
92
- console.log('[Cosmos] Using default webpack config');
93
- return _context2.abrupt("return", (0, _getDefaultWebpackConfig.getDefaultWebpackConfig)(userWebpack, rootDir));
94
-
95
- case 5:
96
- relPath = _path.default.relative(process.cwd(), configPath);
97
- console.log("[Cosmos] Using webpack config found at ".concat(relPath));
98
- userConfigExport = getDefaultExport((0, _fs.requireModule)(configPath));
99
- cliArgs = (0, _cli.getCliArgs)();
100
-
101
- if (!(typeof userConfigExport === 'function')) {
102
- _context2.next = 15;
103
- break;
104
- }
105
-
106
- _context2.next = 12;
107
- return userConfigExport(cliArgs.env || (0, _getWebpackNodeEnv.getWebpackNodeEnv)(), cliArgs);
108
-
109
- case 12:
110
- _context2.t0 = _context2.sent;
111
- _context2.next = 16;
112
- break;
113
-
114
- case 15:
115
- _context2.t0 = userConfigExport;
116
-
117
- case 16:
118
- return _context2.abrupt("return", _context2.t0);
119
-
120
- case 17:
121
- case "end":
122
- return _context2.stop();
123
- }
124
- }
125
- }, _callee2);
126
- }));
127
- return _getBaseWebpackConfig.apply(this, arguments);
128
- }
129
-
130
- function getDefaultExport(module) {
131
- if (_typeof(module) === 'object' && 'default' in module) {
132
- return module.default;
133
- }
134
-
135
- return module;
136
- }
@@ -1,2 +0,0 @@
1
- import webpack from 'webpack';
2
- export declare function getWebpackConfigModule(webpackConfig: webpack.Configuration): webpack.ModuleOptions;
@@ -1,45 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getWebpackConfigModule = getWebpackConfigModule;
7
-
8
- var _resolveWebpackClientPath = require("./resolveWebpackClientPath");
9
-
10
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
11
-
12
- 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."); }
13
-
14
- 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); }
15
-
16
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
17
-
18
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
19
-
20
- 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; }
21
-
22
- 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; }
23
-
24
- 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; }
25
-
26
- 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; }
27
-
28
- function getWebpackConfigModule(webpackConfig) {
29
- return _objectSpread(_objectSpread({}, webpackConfig.module), {}, {
30
- rules: getRules(webpackConfig)
31
- });
32
- }
33
-
34
- function getRules(_ref) {
35
- var module = _ref.module;
36
- var existingRules = module && module.rules || [];
37
- return [].concat(_toConsumableArray(existingRules), [getUserDepsLoaderRule()]);
38
- }
39
-
40
- function getUserDepsLoaderRule() {
41
- return {
42
- loader: require.resolve('./userDepsLoader'),
43
- include: (0, _resolveWebpackClientPath.resolveWebpackClientPath)('userDeps')
44
- };
45
- }
@@ -1,4 +0,0 @@
1
- import webpack from 'webpack';
2
- import { CosmosConfig } from '../../../config/shared';
3
- export declare function getWebpackConfigResolve(cosmosConfig: CosmosConfig, webpackConfig: webpack.Configuration): webpack.ResolveOptions;
4
- export declare function isInstanceOfResolvePlugin(plugin: webpack.ResolvePluginInstance | '...', constructorName: string): boolean;
@@ -1,107 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getWebpackConfigResolve = getWebpackConfigResolve;
7
- exports.isInstanceOfResolvePlugin = isInstanceOfResolvePlugin;
8
-
9
- var _path = _interopRequireDefault(require("path"));
10
-
11
- var _resolveFrom = _interopRequireDefault(require("resolve-from"));
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
16
-
17
- 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."); }
18
-
19
- 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); }
20
-
21
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
22
-
23
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
24
-
25
- 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; }
26
-
27
- 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; }
28
-
29
- 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; }
30
-
31
- 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; }
32
-
33
- function getWebpackConfigResolve(cosmosConfig, webpackConfig) {
34
- return removeModuleScopePlugin(resolveLocalReactDeps(cosmosConfig, webpackConfig.resolve));
35
- }
36
-
37
- function removeModuleScopePlugin() {
38
- var resolve = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
39
- var plugins = resolve.plugins;
40
- if (!plugins) return resolve;
41
- return _objectSpread(_objectSpread({}, resolve), {}, {
42
- plugins: plugins.filter(function (p) {
43
- return !isInstanceOfResolvePlugin(p, 'ModuleScopePlugin');
44
- })
45
- });
46
- }
47
-
48
- function resolveLocalReactDeps(cosmosConfig) {
49
- var resolve = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
50
- var rootDir = cosmosConfig.rootDir;
51
- var alias = resolve.alias || {}; // Preserve existing React aliases (eg. when using Preact)
52
-
53
- var reactAlias = hasAlias(alias, 'react');
54
- var reactDomAlias = hasAlias(alias, 'react-dom');
55
-
56
- if (reactAlias && reactDomAlias) {
57
- console.log('[Cosmos] React and React DOM aliases found in webpack config');
58
- return resolve;
59
- }
60
-
61
- if (reactAlias) {
62
- console.log('[Cosmos] React alias found in webpack config');
63
- } else {
64
- var reactPath = _resolveFrom.default.silent(rootDir, 'react');
65
-
66
- if (!reactPath) throw new Error("[Cosmos] Local dependency not found: react");
67
- alias = addAlias(alias, 'react', _path.default.dirname(reactPath));
68
- }
69
-
70
- if (reactDomAlias) {
71
- console.log('[Cosmos] React DOM alias found in webpack config');
72
- } else {
73
- var reactDomPath = _resolveFrom.default.silent(rootDir, 'react-dom');
74
-
75
- if (!reactDomPath) throw new Error("[Cosmos] Local dependency not found: react-dom");
76
- alias = addAlias(alias, 'react-dom', _path.default.dirname(reactDomPath));
77
- }
78
-
79
- return _objectSpread(_objectSpread({}, resolve), {}, {
80
- alias: alias
81
- });
82
- }
83
-
84
- function hasAlias(alias, name) {
85
- if (!alias) return false;
86
- var exactName = "".concat(name, "$");
87
-
88
- if (Array.isArray(alias)) {
89
- return alias.some(function (a) {
90
- return a.name === name || a.name === exactName;
91
- });
92
- } else {
93
- var keys = Object.keys(alias);
94
- return keys.includes(name) || keys.includes(exactName);
95
- }
96
- }
97
-
98
- function addAlias(alias, name, value) {
99
- return Array.isArray(alias) ? [].concat(_toConsumableArray(alias), [{
100
- name: name,
101
- alias: value
102
- }]) : _objectSpread(_objectSpread({}, alias), {}, _defineProperty({}, name, value));
103
- }
104
-
105
- function isInstanceOfResolvePlugin(plugin, constructorName) {
106
- return plugin.constructor && plugin.constructor.name === constructorName;
107
- }
@@ -1 +0,0 @@
1
- export declare function getWebpackNodeEnv(): "production" | "development";
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getWebpackNodeEnv = getWebpackNodeEnv;
7
-
8
- function getWebpackNodeEnv() {
9
- // Disallow non dev/prod environments, like "test" inside Jest, because
10
- // they are not supported by webpack
11
- return process.env.NODE_ENV === 'production' ? 'production' : 'development';
12
- }
@@ -1,16 +0,0 @@
1
- import { Options as HtmlWebpackPluginOptions } from 'html-webpack-plugin';
2
- import webpack from 'webpack';
3
- import { CosmosConfig } from '../../../config/shared';
4
- export declare type HtmlWebpackPlugin = webpack.WebpackPluginInstance & {
5
- constructor: HtmlWebpackPluginConstructor;
6
- } & ({
7
- options: HtmlWebpackPluginOptions;
8
- userOptions: undefined;
9
- } | {
10
- userOptions: HtmlWebpackPluginOptions;
11
- options: undefined;
12
- });
13
- declare type HtmlWebpackPluginConstructor = new (options?: HtmlWebpackPluginOptions) => HtmlWebpackPlugin;
14
- export declare function ensureHtmlWebackPlugin({ rootDir }: CosmosConfig, plugins: webpack.WebpackPluginInstance[]): webpack.WebpackPluginInstance[];
15
- export declare function getHtmlWebpackPlugin(rootDir: string): HtmlWebpackPluginConstructor | null;
16
- export {};
@@ -1,80 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ensureHtmlWebackPlugin = ensureHtmlWebackPlugin;
7
- exports.getHtmlWebpackPlugin = getHtmlWebpackPlugin;
8
-
9
- var _importFrom = _interopRequireDefault(require("import-from"));
10
-
11
- var _lodash = require("lodash");
12
-
13
- var _playgroundHtml = require("../../../shared/playgroundHtml");
14
-
15
- var _plugins = require("./plugins");
16
-
17
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
-
19
- 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; }
20
-
21
- 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; }
22
-
23
- 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; }
24
-
25
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
26
-
27
- 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."); }
28
-
29
- 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); }
30
-
31
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
32
-
33
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
34
-
35
- 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; }
36
-
37
- function ensureHtmlWebackPlugin(_ref, plugins) {
38
- var rootDir = _ref.rootDir;
39
-
40
- if ((0, _plugins.hasPlugin)(plugins, 'HtmlWebpackPlugin')) {
41
- return plugins.map(function (plugin) {
42
- return isHtmlWebpackPlugin(plugin) ? changeHtmlPluginFilename(plugin) : plugin;
43
- });
44
- }
45
-
46
- var htmlWebpackPlugin = getHtmlWebpackPlugin(rootDir);
47
-
48
- if (!htmlWebpackPlugin) {
49
- return plugins;
50
- }
51
-
52
- return [].concat(_toConsumableArray(plugins), [new htmlWebpackPlugin({
53
- title: 'React Cosmos',
54
- filename: _playgroundHtml.RENDERER_FILENAME
55
- })]);
56
- }
57
-
58
- function getHtmlWebpackPlugin(rootDir) {
59
- return _importFrom.default.silent(rootDir, 'html-webpack-plugin');
60
- }
61
-
62
- function isHtmlWebpackPlugin(plugin) {
63
- return (0, _plugins.isInstanceOfWebpackPlugin)(plugin, 'HtmlWebpackPlugin');
64
- }
65
-
66
- function changeHtmlPluginFilename(htmlPlugin) {
67
- if (!isIndexHtmlWebpackPlugin(htmlPlugin)) return htmlPlugin;
68
- var options = htmlPlugin.userOptions || htmlPlugin.options;
69
- var safeOptions = (0, _lodash.omit)(options, 'chunks');
70
- return new htmlPlugin.constructor(_objectSpread(_objectSpread({}, safeOptions), {}, {
71
- filename: _playgroundHtml.RENDERER_FILENAME
72
- }));
73
- }
74
-
75
- function isIndexHtmlWebpackPlugin(htmlPlugin) {
76
- var _ref2 = htmlPlugin.userOptions || htmlPlugin.options,
77
- filename = _ref2.filename;
78
-
79
- return filename === 'index.html' || typeof filename !== 'string' || filename.endsWith('/index.html');
80
- }
@@ -1,5 +0,0 @@
1
- import webpack from 'webpack';
2
- import { CosmosConfig } from '../../../config/shared';
3
- export declare function getGlobalsPlugin({ publicUrl }: CosmosConfig, userWebpack: typeof webpack, devServerOn: boolean): webpack.DefinePlugin;
4
- export declare function hasPlugin(plugins: void | webpack.WebpackPluginInstance[], pluginName: string): boolean | void;
5
- export declare function isInstanceOfWebpackPlugin(plugin: webpack.WebpackPluginInstance, constructorName: string): boolean;
@@ -1,37 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getGlobalsPlugin = getGlobalsPlugin;
7
- exports.hasPlugin = hasPlugin;
8
- exports.isInstanceOfWebpackPlugin = isInstanceOfWebpackPlugin;
9
-
10
- var _getWebpackNodeEnv = require("./getWebpackNodeEnv");
11
-
12
- function getGlobalsPlugin(_ref, userWebpack, devServerOn) {
13
- var publicUrl = _ref.publicUrl;
14
- var cleanPublicUrl = removeTrailingSlash(publicUrl);
15
- return new userWebpack.DefinePlugin({
16
- // "if (__DEV__)" blocks get stripped when compiling a static export build
17
- __DEV__: JSON.stringify(devServerOn),
18
- 'process.env': {
19
- NODE_ENV: JSON.stringify((0, _getWebpackNodeEnv.getWebpackNodeEnv)()),
20
- PUBLIC_URL: JSON.stringify(cleanPublicUrl)
21
- }
22
- });
23
- }
24
-
25
- function hasPlugin(plugins, pluginName) {
26
- return plugins && plugins.filter(function (p) {
27
- return isInstanceOfWebpackPlugin(p, pluginName);
28
- }).length > 0;
29
- }
30
-
31
- function isInstanceOfWebpackPlugin(plugin, constructorName) {
32
- return plugin.constructor && plugin.constructor.name === constructorName;
33
- }
34
-
35
- function removeTrailingSlash(url) {
36
- return url.replace(/\/$/, '');
37
- }
@@ -1 +0,0 @@
1
- export declare function resolveWebpackClientPath(relPath: string): string;
@@ -1,10 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.resolveWebpackClientPath = resolveWebpackClientPath;
7
-
8
- function resolveWebpackClientPath(relPath) {
9
- return require.resolve("../client/".concat(relPath));
10
- }
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- var _detectCosmosConfig = require("../../../config/detectCosmosConfig");
4
-
5
- var _generateUserDepsModule = require("../../../userDeps/generateUserDepsModule");
6
-
7
- var _dom = require("../cosmosConfig/dom");
8
-
9
- module.exports = function injectUserDeps() {
10
- var _this = this;
11
-
12
- var cosmosConfig = (0, _detectCosmosConfig.detectCosmosConfig)(); // This ensures this loader is invalidated whenever a new file is added to or
13
- // removed from user's project, which in turn triggers react-cosmos-voyager2
14
- // to detect fixture files and finally update fixture list inside Playground.
15
- // Note that while this may not be very performant, it's not the equivalent
16
- // of require.context, which not only watches for file changes but also
17
- // automatically bundles new files that match the watcher's query.
18
- // https://github.com/webpack/webpack/issues/222#issuecomment-40691546
19
-
20
- var watchDirs = cosmosConfig.watchDirs;
21
- watchDirs.forEach(function (watchDir) {
22
- return _this.addContextDependency(watchDir);
23
- });
24
-
25
- var _createDomCosmosConfi = (0, _dom.createDomCosmosConfig)(cosmosConfig),
26
- containerQuerySelector = _createDomCosmosConfi.containerQuerySelector;
27
-
28
- var rendererConfig = {
29
- containerQuerySelector: containerQuerySelector
30
- };
31
- return (0, _generateUserDepsModule.generateUserDepsModule)({
32
- cosmosConfig: cosmosConfig,
33
- rendererConfig: rendererConfig,
34
- relativeToDir: null
35
- });
36
- };
@@ -1,14 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getCliArgs = getCliArgs;
7
-
8
- var _yargs = _interopRequireDefault(require("yargs"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- function getCliArgs() {
13
- return _yargs.default.argv;
14
- }
@@ -1,4 +0,0 @@
1
- export declare function requireModule(modulePath: string): any;
2
- export declare function moduleExists(modulePath: string): boolean | "";
3
- export declare function fileExists(filePath: string): boolean;
4
- export declare function dirExists(dirPath: string): boolean;