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.
- package/bin/cosmos-export.js +4 -3
- package/bin/cosmos-native.js +4 -3
- package/bin/cosmos.js +5 -4
- package/config.schema.json +14 -4
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -70
- package/dist/jest.d.ts +7 -0
- package/dist/jest.js +7 -0
- package/dist/{config → server/cosmosConfig}/createCosmosConfig.d.ts +1 -1
- package/dist/server/cosmosConfig/createCosmosConfig.js +84 -0
- package/dist/server/cosmosConfig/detectCosmosConfig.d.ts +2 -0
- package/dist/server/cosmosConfig/detectCosmosConfig.js +38 -0
- package/dist/{config → server/cosmosConfig}/getCosmosConfigAtPath.d.ts +1 -1
- package/dist/server/cosmosConfig/getCosmosConfigAtPath.js +12 -0
- package/dist/server/cosmosConfig/shared.d.ts +2 -0
- package/dist/server/cosmosConfig/shared.js +7 -0
- package/dist/{config/shared.d.ts → server/cosmosConfig/types.d.ts} +5 -5
- package/dist/server/cosmosPlugin/findCosmosPluginConfigs.d.ts +8 -0
- package/dist/server/cosmosPlugin/findCosmosPluginConfigs.js +14 -0
- package/dist/server/cosmosPlugin/pluginConfigs.d.ts +8 -0
- package/dist/server/cosmosPlugin/pluginConfigs.js +16 -0
- package/dist/server/cosmosPlugin/readCosmosPluginConfig.d.ts +8 -0
- package/dist/server/cosmosPlugin/readCosmosPluginConfig.js +31 -0
- package/dist/server/cosmosPlugin/types.d.ts +21 -0
- package/dist/server/devServer/corePlugins/httpProxy.d.ts +2 -0
- package/dist/server/devServer/corePlugins/httpProxy.js +18 -0
- package/dist/server/devServer/corePlugins/openFile.d.ts +2 -0
- package/dist/server/devServer/corePlugins/openFile.js +53 -0
- package/dist/server/devServer/corePlugins/pluginEndpoint.d.ts +2 -0
- package/dist/server/devServer/corePlugins/pluginEndpoint.js +17 -0
- package/dist/server/devServer/corePlugins/userDepsFile.d.ts +2 -0
- package/dist/server/devServer/corePlugins/userDepsFile.js +37 -0
- package/dist/server/devServer/expressApp.d.ts +5 -0
- package/dist/server/devServer/expressApp.js +21 -0
- package/dist/server/devServer/httpServer.d.ts +12 -0
- package/dist/server/devServer/httpServer.js +42 -0
- package/dist/{devServer → server/devServer}/messageHandler.d.ts +2 -2
- package/dist/server/devServer/messageHandler.js +29 -0
- package/dist/server/devServer/startDevServer.d.ts +2 -0
- package/dist/server/devServer/startDevServer.js +91 -0
- package/dist/server/export/generateExport.d.ts +1 -0
- package/dist/server/export/generateExport.js +97 -0
- package/dist/server/getFixtures/getFixtures.d.ts +14 -0
- package/dist/server/getFixtures/getFixtures.js +63 -0
- package/dist/server/shared/logPluginInfo.d.ts +2 -0
- package/dist/server/shared/logPluginInfo.js +8 -0
- package/dist/server/shared/playgroundHtml.d.ts +6 -0
- package/dist/server/shared/playgroundHtml.js +85 -0
- package/dist/server/shared/playgroundUrl.d.ts +2 -0
- package/dist/server/shared/playgroundUrl.js +6 -0
- package/dist/server/shared/requirePluginModule.d.ts +2 -0
- package/dist/server/shared/requirePluginModule.js +10 -0
- package/dist/server/shared/resolveUrlPath.d.ts +1 -0
- package/dist/server/shared/resolveUrlPath.js +12 -0
- package/dist/server/shared/staticPath.d.ts +1 -0
- package/dist/server/shared/staticPath.js +4 -0
- package/dist/{shared/static.d.ts → server/shared/staticServer.d.ts} +0 -1
- package/dist/server/shared/staticServer.js +12 -0
- package/dist/{shared → server}/static/index.html +1 -1
- package/dist/server/testHelpers/cwd.d.ts +1 -0
- package/dist/server/testHelpers/cwd.js +4 -0
- package/dist/server/testHelpers/mockConsole.d.ts +5 -0
- package/dist/server/testHelpers/mockConsole.js +11 -0
- package/dist/server/testHelpers/mockEsmRequire.js +13 -0
- package/dist/server/testHelpers/mockEsmResolve.d.ts +1 -0
- package/dist/server/testHelpers/mockEsmResolve.js +13 -0
- package/dist/server/testHelpers/mockEsmStaticPath.d.ts +1 -0
- package/dist/server/testHelpers/mockEsmStaticPath.js +7 -0
- package/dist/server/testHelpers/mockFetch.d.ts +2 -0
- package/dist/server/testHelpers/mockFetch.js +7 -0
- package/dist/server/testHelpers/mockFs.d.ts +5 -0
- package/dist/server/testHelpers/mockFs.js +64 -0
- package/dist/server/testHelpers/mockYargs.d.ts +2 -0
- package/dist/server/testHelpers/mockYargs.js +21 -0
- package/dist/{userDeps → server/userDeps}/findUserModulePaths.d.ts +2 -2
- package/dist/server/userDeps/findUserModulePaths.js +20 -0
- package/dist/server/userDeps/fixtureWatcher.d.ts +3 -0
- package/dist/server/userDeps/fixtureWatcher.js +20 -0
- package/dist/{userDeps → server/userDeps}/generateUserDepsModule.d.ts +3 -3
- package/dist/server/userDeps/generateUserDepsModule.js +18 -0
- package/dist/{userDeps → server/userDeps}/getUserModules.d.ts +3 -3
- package/dist/server/userDeps/getUserModules.js +25 -0
- package/dist/{userDeps → server/userDeps}/shared.d.ts +1 -1
- package/dist/server/userDeps/shared.js +20 -0
- package/dist/{userDeps → server/userDeps}/userDepsTemplate.d.ts +2 -2
- package/dist/server/userDeps/userDepsTemplate.js +49 -0
- package/dist/server/utils/cli.js +4 -0
- package/dist/server/utils/fs.d.ts +4 -0
- package/dist/server/utils/fs.js +24 -0
- package/dist/server/utils/isNodeError.d.ts +2 -0
- package/dist/server/utils/isNodeError.js +3 -0
- package/dist/server/utils/requireModule.d.ts +2 -0
- package/dist/server/utils/requireModule.js +13 -0
- package/dist/server/utils/requireSilent.d.ts +1 -0
- package/dist/server/utils/requireSilent.js +11 -0
- package/dist/server/utils/resolve.d.ts +2 -0
- package/dist/server/utils/resolve.js +14 -0
- package/dist/server/utils/resolveLoose.d.ts +1 -0
- package/dist/server/utils/resolveLoose.js +12 -0
- package/dist/server/utils/resolveSilent.d.ts +2 -0
- package/dist/server/utils/resolveSilent.js +22 -0
- package/dist/server/utils/slash.d.ts +1 -0
- package/dist/server/utils/slash.js +5 -0
- package/dist/server.d.ts +20 -0
- package/dist/server.js +20 -0
- package/index.d.ts +1 -1
- package/index.js +1 -2
- package/jest.d.ts +1 -0
- package/jest.js +1 -0
- package/package.json +17 -28
- package/server.d.ts +1 -0
- package/server.js +1 -0
- package/dist/config/createCosmosConfig.js +0 -133
- package/dist/config/detectCosmosConfig.d.ts +0 -2
- package/dist/config/detectCosmosConfig.js +0 -57
- package/dist/config/getCosmosConfigAtPath.js +0 -28
- package/dist/config/resolveModule.d.ts +0 -1
- package/dist/config/resolveModule.js +0 -20
- package/dist/config/shared.js +0 -17
- package/dist/devServer/app.d.ts +0 -5
- package/dist/devServer/app.js +0 -51
- package/dist/devServer/httpServer.d.ts +0 -11
- package/dist/devServer/httpServer.js +0 -183
- package/dist/devServer/messageHandler.js +0 -42
- package/dist/devServer/startDevServer.d.ts +0 -18
- package/dist/devServer/startDevServer.js +0 -209
- package/dist/dom/DomFixtureLoader.d.ts +0 -9
- package/dist/dom/DomFixtureLoader.js +0 -38
- package/dist/dom/ErrorCatch.d.ts +0 -15
- package/dist/dom/ErrorCatch.js +0 -117
- package/dist/dom/container.d.ts +0 -1
- package/dist/dom/container.js +0 -32
- package/dist/dom/globalErrorHandler.js +0 -14
- package/dist/dom/index.d.ts +0 -13
- package/dist/dom/index.js +0 -47
- package/dist/dom/renderMessage.d.ts +0 -4
- package/dist/dom/renderMessage.js +0 -30
- package/dist/dom/rendererConnect.d.ts +0 -1
- package/dist/dom/rendererConnect.js +0 -18
- package/dist/dom/rendererId.d.ts +0 -1
- package/dist/dom/rendererId.js +0 -26
- package/dist/dom/selectedFixtureId.d.ts +0 -2
- package/dist/dom/selectedFixtureId.js +0 -41
- package/dist/dom/shared.d.ts +0 -1
- package/dist/dom/shared.js +0 -14
- package/dist/export/generateExport.d.ts +0 -6
- package/dist/export/generateExport.js +0 -137
- package/dist/fixture.d.ts +0 -1
- package/dist/fixture.js +0 -31
- package/dist/generateWebExport.d.ts +0 -1
- package/dist/generateWebExport.js +0 -37
- package/dist/getFixtureUrls.d.ts +0 -8
- package/dist/getFixtureUrls.js +0 -97
- package/dist/getFixtures.d.ts +0 -13
- package/dist/getFixtures.js +0 -89
- package/dist/getFixtures2.d.ts +0 -14
- package/dist/getFixtures2.js +0 -117
- package/dist/native/NativeFixtureLoader.d.ts +0 -12
- package/dist/native/NativeFixtureLoader.js +0 -67
- package/dist/native/index.d.ts +0 -1
- package/dist/native/index.js +0 -25
- package/dist/plugins/httpProxy.d.ts +0 -2
- package/dist/plugins/httpProxy.js +0 -31
- package/dist/plugins/openFile.d.ts +0 -2
- package/dist/plugins/openFile.js +0 -87
- package/dist/plugins/userDepsFile.d.ts +0 -2
- package/dist/plugins/userDepsFile.js +0 -166
- package/dist/plugins/webpack/client/errorOverlay/index.d.ts +0 -1
- package/dist/plugins/webpack/client/errorOverlay/index.js +0 -16
- package/dist/plugins/webpack/client/errorOverlay/reactErrorOverlay.d.ts +0 -2
- package/dist/plugins/webpack/client/errorOverlay/reactErrorOverlay.js +0 -63
- package/dist/plugins/webpack/client/hmrErrorHandler.js +0 -16
- package/dist/plugins/webpack/client/index.d.ts +0 -6
- package/dist/plugins/webpack/client/index.js +0 -43
- package/dist/plugins/webpack/client/reactDevtoolsHook.d.ts +0 -0
- package/dist/plugins/webpack/client/reactDevtoolsHook.js +0 -19
- package/dist/plugins/webpack/client/userDeps.d.ts +0 -5
- package/dist/plugins/webpack/client/userDeps.js +0 -15
- package/dist/plugins/webpack/cosmosConfig/dom.d.ts +0 -6
- package/dist/plugins/webpack/cosmosConfig/dom.js +0 -19
- package/dist/plugins/webpack/cosmosConfig/webpack.d.ts +0 -10
- package/dist/plugins/webpack/cosmosConfig/webpack.js +0 -95
- package/dist/plugins/webpack/devServer.d.ts +0 -2
- package/dist/plugins/webpack/devServer.js +0 -168
- package/dist/plugins/webpack/export.d.ts +0 -2
- package/dist/plugins/webpack/export.js +0 -139
- package/dist/plugins/webpack/index.d.ts +0 -2
- package/dist/plugins/webpack/index.js +0 -21
- package/dist/plugins/webpack/shared.d.ts +0 -2
- package/dist/plugins/webpack/shared.js +0 -22
- package/dist/plugins/webpack/webpackConfig/getDefaultWebpackConfig.d.ts +0 -2
- package/dist/plugins/webpack/webpackConfig/getDefaultWebpackConfig.js +0 -152
- package/dist/plugins/webpack/webpackConfig/getDevWebpackConfig.d.ts +0 -3
- package/dist/plugins/webpack/webpackConfig/getDevWebpackConfig.js +0 -146
- package/dist/plugins/webpack/webpackConfig/getExportWebpackConfig.d.ts +0 -3
- package/dist/plugins/webpack/webpackConfig/getExportWebpackConfig.js +0 -111
- package/dist/plugins/webpack/webpackConfig/getUserWebpackConfig.d.ts +0 -3
- package/dist/plugins/webpack/webpackConfig/getUserWebpackConfig.js +0 -136
- package/dist/plugins/webpack/webpackConfig/getWebpackConfigModule.d.ts +0 -2
- package/dist/plugins/webpack/webpackConfig/getWebpackConfigModule.js +0 -45
- package/dist/plugins/webpack/webpackConfig/getWebpackConfigResolve.d.ts +0 -4
- package/dist/plugins/webpack/webpackConfig/getWebpackConfigResolve.js +0 -107
- package/dist/plugins/webpack/webpackConfig/getWebpackNodeEnv.d.ts +0 -1
- package/dist/plugins/webpack/webpackConfig/getWebpackNodeEnv.js +0 -12
- package/dist/plugins/webpack/webpackConfig/htmlPlugin.d.ts +0 -16
- package/dist/plugins/webpack/webpackConfig/htmlPlugin.js +0 -80
- package/dist/plugins/webpack/webpackConfig/plugins.d.ts +0 -5
- package/dist/plugins/webpack/webpackConfig/plugins.js +0 -37
- package/dist/plugins/webpack/webpackConfig/resolveWebpackClientPath.d.ts +0 -1
- package/dist/plugins/webpack/webpackConfig/resolveWebpackClientPath.js +0 -10
- package/dist/plugins/webpack/webpackConfig/userDepsLoader.js +0 -36
- package/dist/shared/cli.js +0 -14
- package/dist/shared/fs.d.ts +0 -4
- package/dist/shared/fs.js +0 -37
- package/dist/shared/playgroundHtml.d.ts +0 -6
- package/dist/shared/playgroundHtml.js +0 -116
- package/dist/shared/pluginConfigs.d.ts +0 -2
- package/dist/shared/pluginConfigs.js +0 -15
- package/dist/shared/rendererConfig.d.ts +0 -6
- package/dist/shared/rendererConfig.js +0 -5
- package/dist/shared/static.js +0 -30
- package/dist/shared/types.d.ts +0 -1
- package/dist/shared/types.js +0 -5
- package/dist/shared/utils.d.ts +0 -5
- package/dist/shared/utils.js +0 -22
- package/dist/startNativeServer.d.ts +0 -1
- package/dist/startNativeServer.js +0 -39
- package/dist/startWebServer.d.ts +0 -1
- package/dist/startWebServer.js +0 -43
- package/dist/userDeps/findUserModulePaths.js +0 -45
- package/dist/userDeps/generateUserDepsModule.js +0 -37
- package/dist/userDeps/getUserModules.js +0 -45
- package/dist/userDeps/shared.js +0 -32
- package/dist/userDeps/userDepsTemplate.js +0 -52
- package/dom.d.ts +0 -1
- package/dom.js +0 -2
- package/fixture.d.ts +0 -1
- package/fixture.js +0 -2
- package/native.d.ts +0 -1
- package/native.js +0 -2
- package/yarn-error.log +0 -13450
- /package/dist/{dom/globalErrorHandler.d.ts → server/cosmosConfig/types.js} +0 -0
- /package/dist/{plugins/webpack/client/hmrErrorHandler.d.ts → server/cosmosPlugin/types.js} +0 -0
- /package/dist/{shared → server}/static/favicon.ico +0 -0
- /package/dist/{plugins/webpack/webpackConfig/userDepsLoader.d.ts → server/testHelpers/mockEsmRequire.d.ts} +0 -0
- /package/dist/{shared → server/utils}/cli.d.ts +0 -0
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.webpackDevServer = webpackDevServer;
|
|
7
|
-
|
|
8
|
-
var _webpackHotMiddleware = _interopRequireDefault(require("@skidding/webpack-hot-middleware"));
|
|
9
|
-
|
|
10
|
-
var _path = _interopRequireDefault(require("path"));
|
|
11
|
-
|
|
12
|
-
var _static = require("../../shared/static");
|
|
13
|
-
|
|
14
|
-
var _utils = require("../../shared/utils");
|
|
15
|
-
|
|
16
|
-
var _webpack = require("./cosmosConfig/webpack");
|
|
17
|
-
|
|
18
|
-
var _shared = require("./shared");
|
|
19
|
-
|
|
20
|
-
var _getDevWebpackConfig = require("./webpackConfig/getDevWebpackConfig");
|
|
21
|
-
|
|
22
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: 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 webpackDevServer(_x) {
|
|
29
|
-
return _webpackDevServer.apply(this, arguments);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function _webpackDevServer() {
|
|
33
|
-
_webpackDevServer = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_ref) {
|
|
34
|
-
var cosmosConfig, expressApp, sendMessage, userWebpack, webpackConfig, webpackDerivedStaticPath, sendBuildMessage, webpackCompiler, onCompilationDone, wdm, wdmInst, _createWebpackCosmosC, hotReload;
|
|
35
|
-
|
|
36
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
37
|
-
while (1) {
|
|
38
|
-
switch (_context2.prev = _context2.next) {
|
|
39
|
-
case 0:
|
|
40
|
-
sendBuildMessage = function _sendBuildMessage(msg) {
|
|
41
|
-
sendMessage(msg);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
cosmosConfig = _ref.cosmosConfig, expressApp = _ref.expressApp, sendMessage = _ref.sendMessage;
|
|
45
|
-
|
|
46
|
-
if (!cosmosConfig.experimentalRendererUrl) {
|
|
47
|
-
_context2.next = 4;
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return _context2.abrupt("return");
|
|
52
|
-
|
|
53
|
-
case 4:
|
|
54
|
-
userWebpack = (0, _shared.getWebpack)(cosmosConfig.rootDir);
|
|
55
|
-
|
|
56
|
-
if (userWebpack) {
|
|
57
|
-
_context2.next = 7;
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return _context2.abrupt("return");
|
|
62
|
-
|
|
63
|
-
case 7:
|
|
64
|
-
_context2.next = 9;
|
|
65
|
-
return (0, _getDevWebpackConfig.getDevWebpackConfig)(cosmosConfig, userWebpack);
|
|
66
|
-
|
|
67
|
-
case 9:
|
|
68
|
-
webpackConfig = _context2.sent;
|
|
69
|
-
|
|
70
|
-
// Serve static path derived from devServer.contentBase webpack config
|
|
71
|
-
if (cosmosConfig.staticPath === null) {
|
|
72
|
-
webpackDerivedStaticPath = getWebpackStaticPath(webpackConfig);
|
|
73
|
-
|
|
74
|
-
if (webpackDerivedStaticPath !== null) {
|
|
75
|
-
(0, _static.serveStaticDir)(expressApp, _path.default.resolve(cosmosConfig.rootDir, webpackDerivedStaticPath), cosmosConfig.publicUrl);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
webpackCompiler = userWebpack(webpackConfig);
|
|
80
|
-
webpackCompiler.hooks.invalid.tap('Cosmos', function (filePath) {
|
|
81
|
-
if (typeof filePath === 'string') {
|
|
82
|
-
var relFilePath = _path.default.relative(process.cwd(), filePath);
|
|
83
|
-
|
|
84
|
-
console.log('[Cosmos] webpack build invalidated by', relFilePath);
|
|
85
|
-
} else {
|
|
86
|
-
console.log('[Cosmos] webpack build invalidated by unknown file');
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
sendBuildMessage({
|
|
90
|
-
type: 'buildStart'
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
webpackCompiler.hooks.failed.tap('Cosmos', function () {
|
|
94
|
-
sendBuildMessage({
|
|
95
|
-
type: 'buildError'
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
onCompilationDone = new Promise(function (resolve) {
|
|
99
|
-
webpackCompiler.hooks.done.tap('Cosmos', function (stats) {
|
|
100
|
-
resolve();
|
|
101
|
-
|
|
102
|
-
if (stats.hasErrors()) {
|
|
103
|
-
sendBuildMessage({
|
|
104
|
-
type: 'buildError'
|
|
105
|
-
});
|
|
106
|
-
} else {
|
|
107
|
-
sendBuildMessage({
|
|
108
|
-
type: 'buildDone'
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
console.log('[Cosmos] Building webpack...'); // Why import WDM here instead of at module level? Because it imports webpack,
|
|
114
|
-
// which might not be installed in the user's codebase. If this were to happen
|
|
115
|
-
// the Cosmos server would crash with a cryptic import error. See import here:
|
|
116
|
-
// https://github.com/webpack/webpack-dev-middleware/blob/eb2e32bab57df11bdfbbac19474eb16817d504fe/lib/fs.js#L8
|
|
117
|
-
// Instead, prior to importing WDM we check if webpack is installed and fail
|
|
118
|
-
// gracefully if not.
|
|
119
|
-
|
|
120
|
-
wdm = require('webpack-dev-middleware');
|
|
121
|
-
wdmInst = wdm(webpackCompiler, {
|
|
122
|
-
// publicPath is the base path for the webpack assets and has to match
|
|
123
|
-
// webpack.output.path
|
|
124
|
-
publicPath: (0, _utils.removeLeadingDot)(cosmosConfig.publicUrl)
|
|
125
|
-
});
|
|
126
|
-
expressApp.use(wdmInst);
|
|
127
|
-
_createWebpackCosmosC = (0, _webpack.createWebpackCosmosConfig)(cosmosConfig), hotReload = _createWebpackCosmosC.hotReload;
|
|
128
|
-
|
|
129
|
-
if (hotReload) {
|
|
130
|
-
expressApp.use((0, _webpackHotMiddleware.default)(webpackCompiler));
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
_context2.next = 23;
|
|
134
|
-
return onCompilationDone;
|
|
135
|
-
|
|
136
|
-
case 23:
|
|
137
|
-
return _context2.abrupt("return", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
138
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
139
|
-
while (1) {
|
|
140
|
-
switch (_context.prev = _context.next) {
|
|
141
|
-
case 0:
|
|
142
|
-
_context.next = 2;
|
|
143
|
-
return new Promise(function (res) {
|
|
144
|
-
return wdmInst.close(res);
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
case 2:
|
|
148
|
-
case "end":
|
|
149
|
-
return _context.stop();
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}, _callee);
|
|
153
|
-
})));
|
|
154
|
-
|
|
155
|
-
case 24:
|
|
156
|
-
case "end":
|
|
157
|
-
return _context2.stop();
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}, _callee2);
|
|
161
|
-
}));
|
|
162
|
-
return _webpackDevServer.apply(this, arguments);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function getWebpackStaticPath(_ref2) {
|
|
166
|
-
var devServer = _ref2.devServer;
|
|
167
|
-
return devServer && typeof devServer.contentBase === 'string' ? devServer.contentBase : null;
|
|
168
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.webpackExport = webpackExport;
|
|
9
|
-
|
|
10
|
-
var _shared = require("./shared");
|
|
11
|
-
|
|
12
|
-
var _getExportWebpackConfig = require("./webpackConfig/getExportWebpackConfig");
|
|
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
|
-
|
|
18
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
19
|
-
|
|
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); }
|
|
21
|
-
|
|
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); }; }
|
|
23
|
-
|
|
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); }
|
|
25
|
-
|
|
26
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
27
|
-
|
|
28
|
-
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
29
|
-
|
|
30
|
-
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
31
|
-
|
|
32
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
33
|
-
|
|
34
|
-
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
35
|
-
|
|
36
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
37
|
-
|
|
38
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
39
|
-
|
|
40
|
-
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; }
|
|
41
|
-
|
|
42
|
-
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); } }
|
|
43
|
-
|
|
44
|
-
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); }); }; }
|
|
45
|
-
|
|
46
|
-
function webpackExport(_x) {
|
|
47
|
-
return _webpackExport.apply(this, arguments);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function _webpackExport() {
|
|
51
|
-
_webpackExport = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref) {
|
|
52
|
-
var cosmosConfig, userWebpack, webpackConfig, webpackError;
|
|
53
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
54
|
-
while (1) {
|
|
55
|
-
switch (_context.prev = _context.next) {
|
|
56
|
-
case 0:
|
|
57
|
-
cosmosConfig = _ref.cosmosConfig;
|
|
58
|
-
userWebpack = (0, _shared.getWebpack)(cosmosConfig.rootDir);
|
|
59
|
-
|
|
60
|
-
if (userWebpack) {
|
|
61
|
-
_context.next = 4;
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return _context.abrupt("return");
|
|
66
|
-
|
|
67
|
-
case 4:
|
|
68
|
-
_context.next = 6;
|
|
69
|
-
return (0, _getExportWebpackConfig.getExportWebpackConfig)(cosmosConfig, userWebpack);
|
|
70
|
-
|
|
71
|
-
case 6:
|
|
72
|
-
webpackConfig = _context.sent;
|
|
73
|
-
_context.prev = 7;
|
|
74
|
-
_context.next = 10;
|
|
75
|
-
return runWebpackCompiler(userWebpack, webpackConfig);
|
|
76
|
-
|
|
77
|
-
case 10:
|
|
78
|
-
_context.next = 17;
|
|
79
|
-
break;
|
|
80
|
-
|
|
81
|
-
case 12:
|
|
82
|
-
_context.prev = 12;
|
|
83
|
-
_context.t0 = _context["catch"](7);
|
|
84
|
-
webpackError = _context.t0;
|
|
85
|
-
|
|
86
|
-
if (webpackError.webpackErrors) {
|
|
87
|
-
webpackError.webpackErrors.forEach(function (error) {
|
|
88
|
-
console.error("".concat(error, "\n"));
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
throw webpackError;
|
|
93
|
-
|
|
94
|
-
case 17:
|
|
95
|
-
case "end":
|
|
96
|
-
return _context.stop();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}, _callee, null, [[7, 12]]);
|
|
100
|
-
}));
|
|
101
|
-
return _webpackExport.apply(this, arguments);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function runWebpackCompiler(userWebpack, webpackConfig) {
|
|
105
|
-
return new Promise(function (resolve, reject) {
|
|
106
|
-
var compiler = userWebpack(webpackConfig);
|
|
107
|
-
compiler.run(function (err, stats) {
|
|
108
|
-
if (err) {
|
|
109
|
-
reject(err);
|
|
110
|
-
} else if (stats !== null && stats !== void 0 && stats.hasErrors()) {
|
|
111
|
-
var error = new WebpackCompilationError();
|
|
112
|
-
error.webpackErrors = stats.toJson().errors;
|
|
113
|
-
reject(error);
|
|
114
|
-
} else {
|
|
115
|
-
resolve(stats);
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
var WebpackCompilationError = /*#__PURE__*/function (_Error) {
|
|
122
|
-
_inherits(WebpackCompilationError, _Error);
|
|
123
|
-
|
|
124
|
-
var _super = _createSuper(WebpackCompilationError);
|
|
125
|
-
|
|
126
|
-
function WebpackCompilationError() {
|
|
127
|
-
var _this;
|
|
128
|
-
|
|
129
|
-
_classCallCheck(this, WebpackCompilationError);
|
|
130
|
-
|
|
131
|
-
_this = _super.call(this, 'Webpack errors occurred');
|
|
132
|
-
|
|
133
|
-
_defineProperty(_assertThisInitialized(_this), "webpackErrors", void 0);
|
|
134
|
-
|
|
135
|
-
return _this;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return _createClass(WebpackCompilationError);
|
|
139
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "webpackDevServer", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _devServer.webpackDevServer;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "webpackExport", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _export.webpackExport;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
var _devServer = require("./devServer");
|
|
20
|
-
|
|
21
|
-
var _export = require("./export");
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getWebpack = getWebpack;
|
|
7
|
-
|
|
8
|
-
var _importFrom = _interopRequireDefault(require("import-from"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
function getWebpack(rootDir) {
|
|
13
|
-
var userWebpack = _importFrom.default.silent(rootDir, 'webpack');
|
|
14
|
-
|
|
15
|
-
if (!userWebpack) {
|
|
16
|
-
console.warn('[Cosmos] webpack dependency missing!');
|
|
17
|
-
console.log('Install using "yarn add --dev webpack" or "npm install --save-dev webpack"');
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return userWebpack;
|
|
22
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getDefaultWebpackConfig = getDefaultWebpackConfig;
|
|
7
|
-
|
|
8
|
-
var _resolveFrom = _interopRequireDefault(require("resolve-from"));
|
|
9
|
-
|
|
10
|
-
var _playgroundHtml = require("../../../shared/playgroundHtml");
|
|
11
|
-
|
|
12
|
-
var _getWebpackNodeEnv = require("./getWebpackNodeEnv");
|
|
13
|
-
|
|
14
|
-
var _htmlPlugin = require("./htmlPlugin");
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
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
|
-
|
|
20
|
-
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
|
-
|
|
22
|
-
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
|
-
|
|
24
|
-
// This config doesn't have entry and output set up because it's not meant to
|
|
25
|
-
// work standalone. An entry & output will be added to this base config.
|
|
26
|
-
function getDefaultWebpackConfig(userWebpack, rootDir) {
|
|
27
|
-
// react-cosmos doesn't directly depend on any webpack loader.
|
|
28
|
-
// Instead, it includes the ones already installed by the user.
|
|
29
|
-
var tsLoaderPath = _resolveFrom.default.silent(rootDir, 'ts-loader');
|
|
30
|
-
|
|
31
|
-
var babelLoaderPath = _resolveFrom.default.silent(rootDir, 'next/dist/compiled/babel-loader') || _resolveFrom.default.silent(rootDir, 'babel-loader');
|
|
32
|
-
|
|
33
|
-
var styleLoaderPath = _resolveFrom.default.silent(rootDir, 'style-loader');
|
|
34
|
-
|
|
35
|
-
var cssLoaderPath = _resolveFrom.default.silent(rootDir, 'css-loader');
|
|
36
|
-
|
|
37
|
-
var postcssLoaderPath = _resolveFrom.default.silent(rootDir, 'postcss-loader'); // Note: Since webpack >= v2.0.0, importing of JSON files will work by default
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var jsonLoaderPath = _resolveFrom.default.silent(rootDir, 'json-loader');
|
|
41
|
-
|
|
42
|
-
var rules = [];
|
|
43
|
-
var plugins = []; // Prefer babel-loader over ts-loader if user has both installed. If user
|
|
44
|
-
// has babel-loader installed then most likely they won't want ts-loader
|
|
45
|
-
// to handle module transformation.
|
|
46
|
-
|
|
47
|
-
if (babelLoaderPath) {
|
|
48
|
-
rules.push({
|
|
49
|
-
test: /\.(js|ts)x?$/,
|
|
50
|
-
exclude: /node_modules/,
|
|
51
|
-
use: {
|
|
52
|
-
loader: babelLoaderPath,
|
|
53
|
-
options: {
|
|
54
|
-
root: rootDir
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
} else if (tsLoaderPath) {
|
|
59
|
-
rules.push({
|
|
60
|
-
test: /\.tsx?$/,
|
|
61
|
-
loader: tsLoaderPath
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (styleLoaderPath && cssLoaderPath) {
|
|
66
|
-
if (postcssLoaderPath) {
|
|
67
|
-
rules.push({
|
|
68
|
-
test: /\.css$/,
|
|
69
|
-
use: [styleLoaderPath, {
|
|
70
|
-
loader: cssLoaderPath,
|
|
71
|
-
options: {
|
|
72
|
-
importLoaders: 1
|
|
73
|
-
}
|
|
74
|
-
}, postcssLoaderPath],
|
|
75
|
-
exclude: /node_modules/
|
|
76
|
-
});
|
|
77
|
-
} else {
|
|
78
|
-
rules.push({
|
|
79
|
-
test: /\.css$/,
|
|
80
|
-
use: [{
|
|
81
|
-
loader: styleLoaderPath
|
|
82
|
-
}, {
|
|
83
|
-
loader: cssLoaderPath
|
|
84
|
-
}],
|
|
85
|
-
exclude: /node_modules/
|
|
86
|
-
});
|
|
87
|
-
} // Preprocess 3rd party .css files located in node_modules
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
rules.push({
|
|
91
|
-
test: /\.css$/,
|
|
92
|
-
use: [{
|
|
93
|
-
loader: styleLoaderPath
|
|
94
|
-
}, {
|
|
95
|
-
loader: cssLoaderPath
|
|
96
|
-
}],
|
|
97
|
-
include: /node_modules/
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (jsonLoaderPath) {
|
|
102
|
-
rules.push({
|
|
103
|
-
test: /\.json$/,
|
|
104
|
-
loader: jsonLoaderPath,
|
|
105
|
-
exclude: /node_modules/
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
var htmlWebpackPlugin = (0, _htmlPlugin.getHtmlWebpackPlugin)(rootDir);
|
|
110
|
-
|
|
111
|
-
if (htmlWebpackPlugin) {
|
|
112
|
-
plugins.push(new htmlWebpackPlugin({
|
|
113
|
-
title: 'React Cosmos',
|
|
114
|
-
filename: _playgroundHtml.RENDERER_FILENAME
|
|
115
|
-
}));
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
var config = {
|
|
119
|
-
// Besides other advantages, cheap-module-source-map is compatible with
|
|
120
|
-
// React.componentDidCatch https://github.com/facebook/react/issues/10441
|
|
121
|
-
devtool: 'cheap-module-source-map',
|
|
122
|
-
resolve: {
|
|
123
|
-
// Warning: webpack 1.x expects ['', '.js', '.jsx']
|
|
124
|
-
extensions: ['.js', '.jsx', '.ts', '.tsx']
|
|
125
|
-
},
|
|
126
|
-
module: {
|
|
127
|
-
// Note: `module.rules` only works with webpack >=2.x. For 1.x
|
|
128
|
-
// compatibility a custom webpack config (with module.loaders) is required
|
|
129
|
-
rules: rules
|
|
130
|
-
},
|
|
131
|
-
plugins: plugins,
|
|
132
|
-
stats: 'minimal',
|
|
133
|
-
infrastructureLogging: {
|
|
134
|
-
level: 'warn'
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
var webpack4 = userWebpack.version && parseInt(userWebpack.version, 10) >= 4;
|
|
138
|
-
|
|
139
|
-
if (!webpack4) {
|
|
140
|
-
return config;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return _objectSpread(_objectSpread({}, config), {}, {
|
|
144
|
-
mode: (0, _getWebpackNodeEnv.getWebpackNodeEnv)(),
|
|
145
|
-
optimization: {
|
|
146
|
-
// Cosmos reads component names at run-time, so it is crucial to not
|
|
147
|
-
// minify even when building with production env (ie. when exporting)
|
|
148
|
-
// https://github.com/react-cosmos/react-cosmos/issues/701
|
|
149
|
-
minimize: false
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getDevWebpackConfig = getDevWebpackConfig;
|
|
7
|
-
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
|
-
var _webpack = require("../cosmosConfig/webpack");
|
|
11
|
-
|
|
12
|
-
var _getUserWebpackConfig = require("./getUserWebpackConfig");
|
|
13
|
-
|
|
14
|
-
var _getWebpackConfigModule = require("./getWebpackConfigModule");
|
|
15
|
-
|
|
16
|
-
var _getWebpackConfigResolve = require("./getWebpackConfigResolve");
|
|
17
|
-
|
|
18
|
-
var _htmlPlugin = require("./htmlPlugin");
|
|
19
|
-
|
|
20
|
-
var _plugins = require("./plugins");
|
|
21
|
-
|
|
22
|
-
var _resolveWebpackClientPath = require("./resolveWebpackClientPath");
|
|
23
|
-
|
|
24
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
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; }
|
|
27
|
-
|
|
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; }
|
|
29
|
-
|
|
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; }
|
|
31
|
-
|
|
32
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
33
|
-
|
|
34
|
-
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."); }
|
|
35
|
-
|
|
36
|
-
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); }
|
|
37
|
-
|
|
38
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
39
|
-
|
|
40
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
41
|
-
|
|
42
|
-
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; }
|
|
43
|
-
|
|
44
|
-
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); } }
|
|
45
|
-
|
|
46
|
-
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); }); }; }
|
|
47
|
-
|
|
48
|
-
function getDevWebpackConfig(_x, _x2) {
|
|
49
|
-
return _getDevWebpackConfig.apply(this, arguments);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function _getDevWebpackConfig() {
|
|
53
|
-
_getDevWebpackConfig = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(cosmosConfig, userWebpack) {
|
|
54
|
-
var _webpackConfig$optimi;
|
|
55
|
-
|
|
56
|
-
var baseWebpackConfig, webpackConfig, name;
|
|
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
|
-
webpackConfig = _objectSpread(_objectSpread({}, baseWebpackConfig), {}, {
|
|
67
|
-
entry: getEntry(cosmosConfig),
|
|
68
|
-
output: getOutput(cosmosConfig),
|
|
69
|
-
module: (0, _getWebpackConfigModule.getWebpackConfigModule)(baseWebpackConfig),
|
|
70
|
-
resolve: (0, _getWebpackConfigResolve.getWebpackConfigResolve)(cosmosConfig, baseWebpackConfig),
|
|
71
|
-
plugins: getPlugins(cosmosConfig, baseWebpackConfig, userWebpack)
|
|
72
|
-
}); // optimization.splitChunks.name = false breaks auto fixture file discovery.
|
|
73
|
-
// When the splitChunks.name is set to false, existing fixtures hot reload
|
|
74
|
-
// fine, but added or removed fixture files don't appear or disappear in the
|
|
75
|
-
// React Cosmos UI automatically — a page refresh is required. The webpack
|
|
76
|
-
// build updates correctly, but module.hot.accept isn't called on the client:
|
|
77
|
-
// https://github.com/react-cosmos/react-cosmos/blob/548e9b7e9ca9fbc66f3915861cf1ae9d60222b28/packages/react-cosmos/src/plugins/webpack/client/index.ts#L24-L29
|
|
78
|
-
// Create React App uses this setting:
|
|
79
|
-
// https://github.com/facebook/create-react-app/blob/37712374bcaa6ccb168eeaf4fe8bd52d120dbc58/packages/react-scripts/config/webpack.config.js#L286
|
|
80
|
-
// Apparently it's a webpack 4 bug:
|
|
81
|
-
// https://twitter.com/wSokra/status/1255925851557974016
|
|
82
|
-
|
|
83
|
-
if ((_webpackConfig$optimi = webpackConfig.optimization) !== null && _webpackConfig$optimi !== void 0 && _webpackConfig$optimi.splitChunks) {
|
|
84
|
-
name = webpackConfig.optimization.splitChunks.name;
|
|
85
|
-
if (name === false) delete webpackConfig.optimization.splitChunks.name;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return _context.abrupt("return", webpackConfig);
|
|
89
|
-
|
|
90
|
-
case 6:
|
|
91
|
-
case "end":
|
|
92
|
-
return _context.stop();
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}, _callee);
|
|
96
|
-
}));
|
|
97
|
-
return _getDevWebpackConfig.apply(this, arguments);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function getEntry(cosmosConfig) {
|
|
101
|
-
var _createWebpackCosmosC = (0, _webpack.createWebpackCosmosConfig)(cosmosConfig),
|
|
102
|
-
hotReload = _createWebpackCosmosC.hotReload,
|
|
103
|
-
reloadOnFail = _createWebpackCosmosC.reloadOnFail; // The React devtools hook needs to be imported before any other module that
|
|
104
|
-
// might import React
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
var devtoolsHook = (0, _resolveWebpackClientPath.resolveWebpackClientPath)('reactDevtoolsHook');
|
|
108
|
-
var clientIndex = (0, _resolveWebpackClientPath.resolveWebpackClientPath)('index');
|
|
109
|
-
return hotReload ? [devtoolsHook, getHotMiddlewareEntry(reloadOnFail), clientIndex] : [devtoolsHook, clientIndex];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function getOutput(_ref) {
|
|
113
|
-
var publicUrl = _ref.publicUrl;
|
|
114
|
-
var filename = '[name].js';
|
|
115
|
-
return {
|
|
116
|
-
filename: filename,
|
|
117
|
-
publicPath: publicUrl,
|
|
118
|
-
// Enable click-to-open source in react-error-overlay
|
|
119
|
-
devtoolModuleFilenameTemplate: function devtoolModuleFilenameTemplate(info) {
|
|
120
|
-
return _path.default.resolve(info.absoluteResourcePath).replace(/\\/g, '/');
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function getPlugins(cosmosConfig, baseWebpackConfig, userWebpack) {
|
|
126
|
-
var existingPlugins = baseWebpackConfig.plugins || [];
|
|
127
|
-
var globalsPlugin = (0, _plugins.getGlobalsPlugin)(cosmosConfig, userWebpack, true);
|
|
128
|
-
var noEmitErrorsPlugin = new userWebpack.NoEmitOnErrorsPlugin();
|
|
129
|
-
var plugins = [].concat(_toConsumableArray(existingPlugins), [globalsPlugin, noEmitErrorsPlugin]);
|
|
130
|
-
|
|
131
|
-
var _createWebpackCosmosC2 = (0, _webpack.createWebpackCosmosConfig)(cosmosConfig),
|
|
132
|
-
hotReload = _createWebpackCosmosC2.hotReload;
|
|
133
|
-
|
|
134
|
-
if (hotReload && !(0, _plugins.hasPlugin)(plugins, 'HotModuleReplacementPlugin')) {
|
|
135
|
-
var hmrPlugin = new userWebpack.HotModuleReplacementPlugin();
|
|
136
|
-
plugins = [].concat(_toConsumableArray(plugins), [hmrPlugin]);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return (0, _htmlPlugin.ensureHtmlWebackPlugin)(cosmosConfig, plugins);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function getHotMiddlewareEntry(reloadOnFail) {
|
|
143
|
-
var clientPath = require.resolve('@skidding/webpack-hot-middleware/client');
|
|
144
|
-
|
|
145
|
-
return "".concat(clientPath, "?reload=").concat(reloadOnFail, "&overlay=false");
|
|
146
|
-
}
|