react-cosmos 5.6.6 → 5.7.1
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 +1 -1
- package/bin/cosmos-native.js +1 -1
- package/bin/cosmos.js +1 -1
- package/dist/config/createCosmosConfig.js +4 -4
- package/dist/config/{resolve.d.ts → resolveModule.d.ts} +0 -0
- package/dist/config/{resolve.js → resolveModule.js} +0 -0
- package/dist/{shared/devServer → devServer}/app.d.ts +2 -2
- package/dist/{shared/devServer → devServer}/app.js +2 -2
- package/dist/{shared/devServer → devServer}/httpServer.d.ts +2 -2
- package/dist/{shared/devServer → devServer}/httpServer.js +0 -0
- package/dist/{shared/devServer → devServer}/messageHandler.d.ts +0 -0
- package/dist/{shared/devServer → devServer}/messageHandler.js +0 -0
- package/dist/{shared/devServer/index.d.ts → devServer/startDevServer.d.ts} +2 -2
- package/dist/{shared/devServer/index.js → devServer/startDevServer.js} +5 -5
- package/dist/dom/DomFixtureLoader.d.ts +4 -3
- package/dist/dom/ErrorCatch.js +4 -4
- package/dist/dom/index.d.ts +3 -3
- package/dist/dom/renderMessage.d.ts +1 -0
- package/dist/{shared/export.d.ts → export/generateExport.d.ts} +1 -1
- package/dist/{shared/export.js → export/generateExport.js} +7 -7
- package/dist/fixture.js +6 -6
- package/dist/{webExport.d.ts → generateWebExport.d.ts} +0 -0
- package/dist/{webExport.js → generateWebExport.js} +2 -2
- package/dist/getFixtureUrls.d.ts +1 -1
- package/dist/getFixtureUrls.js +11 -12
- package/dist/getFixtures.d.ts +1 -1
- package/dist/getFixtures.js +14 -15
- package/dist/getFixtures2.d.ts +1 -1
- package/dist/getFixtures2.js +9 -9
- package/dist/index.d.ts +3 -1
- package/dist/index.js +22 -18
- package/dist/native/NativeFixtureLoader.d.ts +12 -0
- package/dist/{native.js → native/NativeFixtureLoader.js} +5 -7
- package/dist/native/index.d.ts +1 -0
- package/dist/native/index.js +25 -0
- package/dist/plugins/httpProxy.d.ts +1 -1
- package/dist/plugins/httpProxy.js +1 -1
- package/dist/plugins/openFile.d.ts +1 -1
- package/dist/plugins/openFile.js +3 -3
- package/dist/plugins/userDepsFile.d.ts +1 -1
- package/dist/plugins/userDepsFile.js +6 -4
- package/dist/plugins/webpack/client/errorOverlay/reactErrorOverlay.js +2 -2
- package/dist/plugins/webpack/client/userDeps.d.ts +3 -3
- package/dist/plugins/webpack/client/userDeps.js +1 -1
- package/dist/plugins/webpack/cosmosConfig/dom.d.ts +1 -1
- package/dist/plugins/webpack/cosmosConfig/webpack.d.ts +1 -1
- package/dist/plugins/webpack/cosmosConfig/webpack.js +5 -5
- package/dist/plugins/webpack/devServer.d.ts +1 -1
- package/dist/plugins/webpack/devServer.js +7 -7
- package/dist/plugins/webpack/export.d.ts +1 -1
- package/dist/plugins/webpack/export.js +10 -6
- package/dist/plugins/webpack/webpackConfig/{default.d.ts → getDefaultWebpackConfig.d.ts} +0 -0
- package/dist/plugins/webpack/webpackConfig/{default.js → getDefaultWebpackConfig.js} +4 -4
- package/dist/plugins/webpack/webpackConfig/{devServer.d.ts → getDevWebpackConfig.d.ts} +1 -1
- package/dist/plugins/webpack/webpackConfig/{devServer.js → getDevWebpackConfig.js} +18 -17
- package/dist/plugins/webpack/webpackConfig/{export.d.ts → getExportWebpackConfig.d.ts} +1 -1
- package/dist/plugins/webpack/webpackConfig/{export.js → getExportWebpackConfig.js} +19 -18
- package/dist/plugins/webpack/webpackConfig/getUserWebpackConfig.d.ts +3 -0
- package/dist/plugins/webpack/webpackConfig/getUserWebpackConfig.js +136 -0
- package/dist/plugins/webpack/webpackConfig/getWebpackConfigModule.d.ts +2 -0
- package/dist/plugins/webpack/webpackConfig/getWebpackConfigModule.js +45 -0
- package/dist/plugins/webpack/webpackConfig/getWebpackConfigResolve.d.ts +4 -0
- package/dist/plugins/webpack/webpackConfig/getWebpackConfigResolve.js +107 -0
- package/dist/plugins/webpack/webpackConfig/getWebpackNodeEnv.d.ts +1 -0
- package/dist/plugins/webpack/webpackConfig/getWebpackNodeEnv.js +12 -0
- package/dist/plugins/webpack/webpackConfig/htmlPlugin.d.ts +1 -1
- package/dist/plugins/webpack/webpackConfig/htmlPlugin.js +5 -5
- package/dist/plugins/webpack/webpackConfig/plugins.d.ts +5 -0
- package/dist/plugins/webpack/webpackConfig/plugins.js +37 -0
- package/dist/plugins/webpack/webpackConfig/resolveWebpackClientPath.d.ts +1 -0
- package/dist/plugins/webpack/webpackConfig/resolveWebpackClientPath.js +10 -0
- package/dist/plugins/webpack/webpackConfig/userDepsLoader.js +4 -4
- package/dist/shared/fs.js +3 -3
- package/dist/shared/playgroundHtml.d.ts +2 -2
- package/dist/shared/playgroundHtml.js +6 -6
- package/dist/shared/pluginConfigs.d.ts +1 -1
- package/dist/shared/static.js +2 -2
- package/dist/shared/types.d.ts +1 -0
- package/dist/shared/types.js +5 -0
- package/dist/shared/{shared.d.ts → utils.d.ts} +0 -1
- package/dist/shared/{shared.js → utils.js} +2 -2
- package/dist/{nativeServer.d.ts → startNativeServer.d.ts} +0 -0
- package/dist/{nativeServer.js → startNativeServer.js} +3 -3
- package/dist/{webServer.d.ts → startWebServer.d.ts} +0 -0
- package/dist/{webServer.js → startWebServer.js} +3 -3
- package/dist/{shared/userDeps → userDeps}/findUserModulePaths.d.ts +0 -0
- package/dist/{shared/userDeps → userDeps}/findUserModulePaths.js +0 -0
- package/dist/{shared/userDeps → userDeps}/generateUserDepsModule.d.ts +1 -1
- package/dist/{shared/userDeps → userDeps}/generateUserDepsModule.js +0 -0
- package/dist/userDeps/getUserModules.d.ts +8 -0
- package/dist/{shared/userDeps → userDeps}/getUserModules.js +6 -6
- package/dist/{shared/userDeps → userDeps}/shared.d.ts +0 -0
- package/dist/{shared/userDeps → userDeps}/shared.js +3 -3
- package/dist/{shared/userDeps → userDeps}/userDepsTemplate.d.ts +0 -0
- package/dist/{shared/userDeps → userDeps}/userDepsTemplate.js +3 -3
- package/package.json +12 -12
- package/dist/config/index.d.ts +0 -5
- package/dist/config/index.js +0 -51
- package/dist/native.d.ts +0 -9
- package/dist/plugins/webpack/webpackConfig/index.d.ts +0 -2
- package/dist/plugins/webpack/webpackConfig/index.js +0 -21
- package/dist/plugins/webpack/webpackConfig/module.d.ts +0 -3
- package/dist/plugins/webpack/webpackConfig/module.js +0 -18
- package/dist/plugins/webpack/webpackConfig/shared.d.ts +0 -11
- package/dist/plugins/webpack/webpackConfig/shared.js +0 -254
- package/dist/shared/userDeps/getUserModules.d.ts +0 -8
- package/dist/shared/userDeps/index.d.ts +0 -4
- package/dist/shared/userDeps/index.js +0 -49
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactDecorators, ReactFixtureExports } from 'react-cosmos-shared2/react';
|
|
2
|
+
import { CosmosConfig } from '../config/shared';
|
|
3
|
+
declare type UserModules = {
|
|
4
|
+
fixtures: ReactFixtureExports;
|
|
5
|
+
decorators: ReactDecorators;
|
|
6
|
+
};
|
|
7
|
+
export declare function getUserModules({ rootDir, fixturesDir, fixtureFileSuffix, }: CosmosConfig): UserModules;
|
|
8
|
+
export {};
|
|
@@ -7,10 +7,10 @@ exports.getUserModules = getUserModules;
|
|
|
7
7
|
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
|
|
10
|
-
var _ = require(".");
|
|
11
|
-
|
|
12
10
|
var _slash = _interopRequireDefault(require("slash"));
|
|
13
11
|
|
|
12
|
+
var _findUserModulePaths2 = require("./findUserModulePaths");
|
|
13
|
+
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
16
|
function getUserModules(_ref) {
|
|
@@ -18,7 +18,7 @@ function getUserModules(_ref) {
|
|
|
18
18
|
fixturesDir = _ref.fixturesDir,
|
|
19
19
|
fixtureFileSuffix = _ref.fixtureFileSuffix;
|
|
20
20
|
|
|
21
|
-
var _findUserModulePaths = (0,
|
|
21
|
+
var _findUserModulePaths = (0, _findUserModulePaths2.findUserModulePaths)({
|
|
22
22
|
rootDir: rootDir,
|
|
23
23
|
fixturesDir: fixturesDir,
|
|
24
24
|
fixtureFileSuffix: fixtureFileSuffix
|
|
@@ -27,12 +27,12 @@ function getUserModules(_ref) {
|
|
|
27
27
|
decoratorPaths = _findUserModulePaths.decoratorPaths;
|
|
28
28
|
|
|
29
29
|
return {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
fixtures: getDefaultExports(fixturePaths, rootDir),
|
|
31
|
+
decorators: getDefaultExports(decoratorPaths, rootDir)
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
function
|
|
35
|
+
function getDefaultExports(paths, rootDir) {
|
|
36
36
|
var exportsByPath = {};
|
|
37
37
|
paths.forEach(function (p) {
|
|
38
38
|
// Converting to forward slashes on Windows is important because the
|
|
File without changes
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getFixturePatterns = getFixturePatterns;
|
|
7
6
|
exports.getDecoratorPatterns = getDecoratorPatterns;
|
|
7
|
+
exports.getFixturePatterns = getFixturePatterns;
|
|
8
8
|
exports.getIgnorePatterns = getIgnorePatterns;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _utils = require("../shared/utils");
|
|
11
11
|
|
|
12
12
|
// NODE: These can be made configurable if a proper need arises
|
|
13
13
|
var FIXTURE_PATTERNS = ['**/<fixturesDir>/**/*.{js,jsx,ts,tsx}', '**/*.<fixtureFileSuffix>.{js,jsx,ts,tsx}'];
|
|
@@ -16,7 +16,7 @@ var IGNORE_PATTERNS = ['**/node_modules/**'];
|
|
|
16
16
|
|
|
17
17
|
function getFixturePatterns(fixturesDir, fixtureFileSuffix) {
|
|
18
18
|
return FIXTURE_PATTERNS.map(function (pattern) {
|
|
19
|
-
return (0,
|
|
19
|
+
return (0, _utils.replaceKeys)(pattern, {
|
|
20
20
|
'<fixturesDir>': fixturesDir,
|
|
21
21
|
'<fixtureFileSuffix>': fixtureFileSuffix
|
|
22
22
|
});
|
|
File without changes
|
|
@@ -11,9 +11,9 @@ var _slash = _interopRequireDefault(require("slash"));
|
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
|
|
14
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
14
|
+
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; }
|
|
15
15
|
|
|
16
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
16
|
+
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; }
|
|
17
17
|
|
|
18
18
|
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; }
|
|
19
19
|
|
|
@@ -35,7 +35,7 @@ function userDepsTemplate(_ref) {
|
|
|
35
35
|
}).join("\n"), "\n\n").concat(decoratorKeys.map(function (k, i) {
|
|
36
36
|
return "import decorator".concat(i, " from '").concat(decorators[k], "';");
|
|
37
37
|
}).join("\n"), "\n\nexport const rendererConfig = ").concat(JSON.stringify(rendererConfig, null, 2), ";\n\nexport const fixtures = {\n").concat(fixtureKeys.map(function (k, i) {
|
|
38
|
-
return " '".concat(k, "': fixture").concat(i);
|
|
38
|
+
return " '".concat(k, "': { module: { default: fixture").concat(i, " } }");
|
|
39
39
|
}).join(",\n"), "\n};\n\nexport const decorators = {\n").concat(decoratorKeys.map(function (k, i) {
|
|
40
40
|
return " '".concat(k, "': decorator").concat(i);
|
|
41
41
|
}).join(",\n"), "\n};\n").trimLeft();
|
package/package.json
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-cosmos",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.7.1",
|
|
4
4
|
"description": "CLI for running React Cosmos inside webpack-powered apps",
|
|
5
5
|
"repository": "https://github.com/react-cosmos/react-cosmos/tree/main/packages/react-cosmos",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@skidding/launch-editor": "^2.2.3",
|
|
10
|
-
"@skidding/webpack-hot-middleware": "^2.25.
|
|
10
|
+
"@skidding/webpack-hot-middleware": "^2.25.1",
|
|
11
11
|
"chokidar": "^3.5.2",
|
|
12
|
-
"core-js": "^3.
|
|
13
|
-
"express": "^4.17.
|
|
12
|
+
"core-js": "^3.20.3",
|
|
13
|
+
"express": "^4.17.2",
|
|
14
14
|
"fs-extra": "10.0.0",
|
|
15
|
-
"glob": "^7.
|
|
16
|
-
"http-proxy-middleware": "^2.0.
|
|
15
|
+
"glob": "^7.2.0",
|
|
16
|
+
"http-proxy-middleware": "^2.0.1",
|
|
17
17
|
"import-from": "^3.0.0",
|
|
18
18
|
"lodash": "^4.17.21",
|
|
19
19
|
"micromatch": "^4.0.4",
|
|
20
|
-
"open": "^8.
|
|
20
|
+
"open": "^8.4.0",
|
|
21
21
|
"pem": "^1.14.4",
|
|
22
22
|
"pkg-up": "^3.1.0",
|
|
23
|
-
"react-cosmos-playground2": "^5.
|
|
23
|
+
"react-cosmos-playground2": "^5.7.1",
|
|
24
24
|
"react-cosmos-plugin": "^5.6.0",
|
|
25
|
-
"react-cosmos-shared2": "^5.
|
|
25
|
+
"react-cosmos-shared2": "^5.7.1",
|
|
26
26
|
"react-error-overlay": "6.0.9",
|
|
27
|
-
"regenerator-runtime": "^0.13.
|
|
27
|
+
"regenerator-runtime": "^0.13.9",
|
|
28
28
|
"resolve-from": "^5.0.0",
|
|
29
29
|
"slash": "^3.0.0",
|
|
30
30
|
"socket.io": "2.2.0",
|
|
31
|
-
"url-parse": "^1.5.
|
|
31
|
+
"url-parse": "^1.5.4",
|
|
32
32
|
"util.promisify": "^1.1.1",
|
|
33
33
|
"webpack-dev-middleware": "^4.3.0",
|
|
34
34
|
"yargs": "^16.2.0"
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"cosmos-export": "./bin/cosmos-export.js",
|
|
39
39
|
"cosmos-native": "./bin/cosmos-native.js"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "6219d1d9370a7bd086510e2a073999309d28a926"
|
|
42
42
|
}
|
package/dist/config/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { createCosmosConfig } from './createCosmosConfig';
|
|
2
|
-
export { detectCosmosConfig, detectCosmosConfigPath, } from './detectCosmosConfig';
|
|
3
|
-
export { getCosmosConfigAtPath } from './getCosmosConfigAtPath';
|
|
4
|
-
export { resolveModule } from './resolve';
|
|
5
|
-
export { CosmosConfig } from './shared';
|
package/dist/config/index.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "createCosmosConfig", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _createCosmosConfig.createCosmosConfig;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "detectCosmosConfig", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _detectCosmosConfig.detectCosmosConfig;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "detectCosmosConfigPath", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function get() {
|
|
21
|
-
return _detectCosmosConfig.detectCosmosConfigPath;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "getCosmosConfigAtPath", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function get() {
|
|
27
|
-
return _getCosmosConfigAtPath.getCosmosConfigAtPath;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "resolveModule", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function get() {
|
|
33
|
-
return _resolve.resolveModule;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "CosmosConfig", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function get() {
|
|
39
|
-
return _shared.CosmosConfig;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
var _createCosmosConfig = require("./createCosmosConfig");
|
|
44
|
-
|
|
45
|
-
var _detectCosmosConfig = require("./detectCosmosConfig");
|
|
46
|
-
|
|
47
|
-
var _getCosmosConfigAtPath = require("./getCosmosConfigAtPath");
|
|
48
|
-
|
|
49
|
-
var _resolve = require("./resolve");
|
|
50
|
-
|
|
51
|
-
var _shared = require("./shared");
|
package/dist/native.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ReactDecoratorsByPath, ReactFixtureExportsByPath } from 'react-cosmos-shared2/react';
|
|
2
|
-
import { NativeRendererConfig } from './shared/rendererConfig';
|
|
3
|
-
declare type Props = {
|
|
4
|
-
rendererConfig: NativeRendererConfig;
|
|
5
|
-
fixtures: ReactFixtureExportsByPath;
|
|
6
|
-
decorators: ReactDecoratorsByPath;
|
|
7
|
-
};
|
|
8
|
-
export declare function NativeFixtureLoader({ rendererConfig: { port }, fixtures, decorators, }: Props): JSX.Element;
|
|
9
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "getDevWebpackConfig", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _devServer.getDevWebpackConfig;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "getExportWebpackConfig", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _export.getExportWebpackConfig;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
var _devServer = require("./devServer");
|
|
20
|
-
|
|
21
|
-
var _export = require("./export");
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getDefaultExport = getDefaultExport;
|
|
7
|
-
|
|
8
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
9
|
-
|
|
10
|
-
// Get "default" export from either an ES or CJS module
|
|
11
|
-
// More context: https://github.com/react-cosmos/react-cosmos/issues/895
|
|
12
|
-
function getDefaultExport(module) {
|
|
13
|
-
if (_typeof(module) === 'object' && 'default' in module) {
|
|
14
|
-
return module.default;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return module;
|
|
18
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import webpack from 'webpack';
|
|
2
|
-
import { CosmosConfig } from '../../../config';
|
|
3
|
-
export declare function getUserWebpackConfig(cosmosConfig: CosmosConfig, userWebpack: typeof webpack): Promise<webpack.Configuration>;
|
|
4
|
-
export declare function getBaseWebpackConfig(cosmosConfig: CosmosConfig, userWebpack: typeof webpack): Promise<webpack.Configuration>;
|
|
5
|
-
export declare function resolveClientPath(relPath: string): string;
|
|
6
|
-
export declare function getUserDepsLoaderRule(): webpack.RuleSetRule;
|
|
7
|
-
export declare function resolveLocalReactDeps(cosmosConfig: CosmosConfig, baseWebpackConfig: webpack.Configuration): webpack.ResolveOptions;
|
|
8
|
-
export declare function getGlobalsPlugin({ publicUrl }: CosmosConfig, userWebpack: typeof webpack, devServerOn: boolean): webpack.DefinePlugin;
|
|
9
|
-
export declare function hasPlugin(plugins: void | webpack.WebpackPluginInstance[], pluginName: string): boolean | void;
|
|
10
|
-
export declare function isInstanceOfPlugin(plugin: webpack.WebpackPluginInstance, constructorName: string): boolean;
|
|
11
|
-
export declare function getNodeEnv(): "development" | "production";
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getUserWebpackConfig = getUserWebpackConfig;
|
|
7
|
-
exports.getBaseWebpackConfig = getBaseWebpackConfig;
|
|
8
|
-
exports.resolveClientPath = resolveClientPath;
|
|
9
|
-
exports.getUserDepsLoaderRule = getUserDepsLoaderRule;
|
|
10
|
-
exports.resolveLocalReactDeps = resolveLocalReactDeps;
|
|
11
|
-
exports.getGlobalsPlugin = getGlobalsPlugin;
|
|
12
|
-
exports.hasPlugin = hasPlugin;
|
|
13
|
-
exports.isInstanceOfPlugin = isInstanceOfPlugin;
|
|
14
|
-
exports.getNodeEnv = getNodeEnv;
|
|
15
|
-
|
|
16
|
-
var _path = _interopRequireDefault(require("path"));
|
|
17
|
-
|
|
18
|
-
var _resolveFrom = _interopRequireDefault(require("resolve-from"));
|
|
19
|
-
|
|
20
|
-
var _cli = require("../../../shared/cli");
|
|
21
|
-
|
|
22
|
-
var _fs = require("../../../shared/fs");
|
|
23
|
-
|
|
24
|
-
var _webpack = require("../cosmosConfig/webpack");
|
|
25
|
-
|
|
26
|
-
var _default = require("./default");
|
|
27
|
-
|
|
28
|
-
var _module = require("./module");
|
|
29
|
-
|
|
30
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: 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 ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
45
|
-
|
|
46
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
47
|
-
|
|
48
|
-
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; }
|
|
49
|
-
|
|
50
|
-
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); } }
|
|
51
|
-
|
|
52
|
-
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); }); }; }
|
|
53
|
-
|
|
54
|
-
function getUserWebpackConfig(_x, _x2) {
|
|
55
|
-
return _getUserWebpackConfig.apply(this, arguments);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function _getUserWebpackConfig() {
|
|
59
|
-
_getUserWebpackConfig = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(cosmosConfig, userWebpack) {
|
|
60
|
-
var baseWebpackConfig, _createWebpackCosmosC, overridePath, relPath, webpackOverride;
|
|
61
|
-
|
|
62
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
63
|
-
while (1) {
|
|
64
|
-
switch (_context.prev = _context.next) {
|
|
65
|
-
case 0:
|
|
66
|
-
_context.next = 2;
|
|
67
|
-
return getBaseWebpackConfig(cosmosConfig, userWebpack);
|
|
68
|
-
|
|
69
|
-
case 2:
|
|
70
|
-
baseWebpackConfig = _context.sent;
|
|
71
|
-
_createWebpackCosmosC = (0, _webpack.createWebpackCosmosConfig)(cosmosConfig), overridePath = _createWebpackCosmosC.overridePath;
|
|
72
|
-
|
|
73
|
-
if (!(!overridePath || !(0, _fs.moduleExists)(overridePath))) {
|
|
74
|
-
_context.next = 6;
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return _context.abrupt("return", baseWebpackConfig);
|
|
79
|
-
|
|
80
|
-
case 6:
|
|
81
|
-
relPath = _path.default.relative(process.cwd(), overridePath);
|
|
82
|
-
console.log("[Cosmos] Overriding webpack config at ".concat(relPath));
|
|
83
|
-
webpackOverride = (0, _module.getDefaultExport)((0, _fs.requireModule)(overridePath));
|
|
84
|
-
return _context.abrupt("return", webpackOverride(baseWebpackConfig, getNodeEnv()));
|
|
85
|
-
|
|
86
|
-
case 10:
|
|
87
|
-
case "end":
|
|
88
|
-
return _context.stop();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}, _callee);
|
|
92
|
-
}));
|
|
93
|
-
return _getUserWebpackConfig.apply(this, arguments);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function getBaseWebpackConfig(_x3, _x4) {
|
|
97
|
-
return _getBaseWebpackConfig.apply(this, arguments);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function _getBaseWebpackConfig() {
|
|
101
|
-
_getBaseWebpackConfig = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(cosmosConfig, userWebpack) {
|
|
102
|
-
var rootDir, _createWebpackCosmosC2, configPath, relPath, userConfigExport, cliArgs;
|
|
103
|
-
|
|
104
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
105
|
-
while (1) {
|
|
106
|
-
switch (_context2.prev = _context2.next) {
|
|
107
|
-
case 0:
|
|
108
|
-
rootDir = cosmosConfig.rootDir;
|
|
109
|
-
_createWebpackCosmosC2 = (0, _webpack.createWebpackCosmosConfig)(cosmosConfig), configPath = _createWebpackCosmosC2.configPath;
|
|
110
|
-
|
|
111
|
-
if (!(!configPath || !(0, _fs.moduleExists)(configPath))) {
|
|
112
|
-
_context2.next = 5;
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
console.log('[Cosmos] Using default webpack config');
|
|
117
|
-
return _context2.abrupt("return", (0, _default.getDefaultWebpackConfig)(userWebpack, rootDir));
|
|
118
|
-
|
|
119
|
-
case 5:
|
|
120
|
-
relPath = _path.default.relative(process.cwd(), configPath);
|
|
121
|
-
console.log("[Cosmos] Using webpack config found at ".concat(relPath));
|
|
122
|
-
userConfigExport = (0, _module.getDefaultExport)((0, _fs.requireModule)(configPath));
|
|
123
|
-
cliArgs = (0, _cli.getCliArgs)();
|
|
124
|
-
|
|
125
|
-
if (!(typeof userConfigExport === 'function')) {
|
|
126
|
-
_context2.next = 15;
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
_context2.next = 12;
|
|
131
|
-
return userConfigExport(cliArgs.env || getNodeEnv(), cliArgs);
|
|
132
|
-
|
|
133
|
-
case 12:
|
|
134
|
-
_context2.t0 = _context2.sent;
|
|
135
|
-
_context2.next = 16;
|
|
136
|
-
break;
|
|
137
|
-
|
|
138
|
-
case 15:
|
|
139
|
-
_context2.t0 = userConfigExport;
|
|
140
|
-
|
|
141
|
-
case 16:
|
|
142
|
-
return _context2.abrupt("return", _context2.t0);
|
|
143
|
-
|
|
144
|
-
case 17:
|
|
145
|
-
case "end":
|
|
146
|
-
return _context2.stop();
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}, _callee2);
|
|
150
|
-
}));
|
|
151
|
-
return _getBaseWebpackConfig.apply(this, arguments);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function resolveClientPath(relPath) {
|
|
155
|
-
return require.resolve("../client/".concat(relPath));
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function getUserDepsLoaderRule() {
|
|
159
|
-
return {
|
|
160
|
-
loader: require.resolve('./userDepsLoader'),
|
|
161
|
-
include: resolveClientPath('userDeps')
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function resolveLocalReactDeps(cosmosConfig, baseWebpackConfig) {
|
|
166
|
-
var rootDir = cosmosConfig.rootDir;
|
|
167
|
-
var _baseWebpackConfig$re = baseWebpackConfig.resolve,
|
|
168
|
-
resolve = _baseWebpackConfig$re === void 0 ? {} : _baseWebpackConfig$re;
|
|
169
|
-
var alias = resolve.alias || {}; // Preserve existing React aliases (eg. when using Preact)
|
|
170
|
-
|
|
171
|
-
var reactAlias = hasAlias(alias, 'react');
|
|
172
|
-
var reactDomAlias = hasAlias(alias, 'react-dom');
|
|
173
|
-
|
|
174
|
-
if (reactAlias && reactDomAlias) {
|
|
175
|
-
console.log('[Cosmos] React and React DOM aliases found in webpack config');
|
|
176
|
-
return resolve;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (reactAlias) {
|
|
180
|
-
console.log('[Cosmos] React alias found in webpack config');
|
|
181
|
-
} else {
|
|
182
|
-
var reactPath = _resolveFrom.default.silent(rootDir, 'react');
|
|
183
|
-
|
|
184
|
-
if (!reactPath) throw new Error("[Cosmos] Local dependency not found: react");
|
|
185
|
-
alias = addAlias(alias, 'react', _path.default.dirname(reactPath));
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (reactDomAlias) {
|
|
189
|
-
console.log('[Cosmos] React DOM alias found in webpack config');
|
|
190
|
-
} else {
|
|
191
|
-
var reactDomPath = _resolveFrom.default.silent(rootDir, 'react-dom');
|
|
192
|
-
|
|
193
|
-
if (!reactDomPath) throw new Error("[Cosmos] Local dependency not found: react-dom");
|
|
194
|
-
alias = addAlias(alias, 'react-dom', _path.default.dirname(reactDomPath));
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return _objectSpread(_objectSpread({}, resolve), {}, {
|
|
198
|
-
alias: alias
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
function getGlobalsPlugin(_ref, userWebpack, devServerOn) {
|
|
203
|
-
var publicUrl = _ref.publicUrl;
|
|
204
|
-
var cleanPublicUrl = removeTrailingSlash(publicUrl);
|
|
205
|
-
return new userWebpack.DefinePlugin({
|
|
206
|
-
// "if (__DEV__)" blocks get stripped when compiling a static export build
|
|
207
|
-
__DEV__: JSON.stringify(devServerOn),
|
|
208
|
-
'process.env': {
|
|
209
|
-
NODE_ENV: JSON.stringify(getNodeEnv()),
|
|
210
|
-
PUBLIC_URL: JSON.stringify(cleanPublicUrl)
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function hasPlugin(plugins, pluginName) {
|
|
216
|
-
return plugins && plugins.filter(function (p) {
|
|
217
|
-
return isInstanceOfPlugin(p, pluginName);
|
|
218
|
-
}).length > 0;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
function isInstanceOfPlugin(plugin, constructorName) {
|
|
222
|
-
return plugin.constructor && plugin.constructor.name === constructorName;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function removeTrailingSlash(url) {
|
|
226
|
-
return url.replace(/\/$/, '');
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
function getNodeEnv() {
|
|
230
|
-
// Disallow non dev/prod environments, like "test" inside Jest, because
|
|
231
|
-
// they are not supported by webpack
|
|
232
|
-
return process.env.NODE_ENV === 'production' ? 'production' : 'development';
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
function hasAlias(alias, name) {
|
|
236
|
-
if (!alias) return false;
|
|
237
|
-
var exactName = "".concat(name, "$");
|
|
238
|
-
|
|
239
|
-
if (Array.isArray(alias)) {
|
|
240
|
-
return alias.some(function (a) {
|
|
241
|
-
return a.name === name || a.name === exactName;
|
|
242
|
-
});
|
|
243
|
-
} else {
|
|
244
|
-
var keys = Object.keys(alias);
|
|
245
|
-
return keys.includes(name) || keys.includes(exactName);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function addAlias(alias, name, value) {
|
|
250
|
-
return Array.isArray(alias) ? [].concat(_toConsumableArray(alias), [{
|
|
251
|
-
name: name,
|
|
252
|
-
alias: value
|
|
253
|
-
}]) : _objectSpread(_objectSpread({}, alias), {}, _defineProperty({}, name, value));
|
|
254
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ReactFixtureExportsByPath, ReactDecoratorsByPath } from 'react-cosmos-shared2/react';
|
|
2
|
-
import { CosmosConfig } from '../../config';
|
|
3
|
-
declare type UserModules = {
|
|
4
|
-
fixtureExportsByPath: ReactFixtureExportsByPath;
|
|
5
|
-
decoratorsByPath: ReactDecoratorsByPath;
|
|
6
|
-
};
|
|
7
|
-
export declare function getUserModules({ rootDir, fixturesDir, fixtureFileSuffix, }: CosmosConfig): UserModules;
|
|
8
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "getDecoratorPatterns", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _shared.getDecoratorPatterns;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "getFixturePatterns", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _shared.getFixturePatterns;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "getIgnorePatterns", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function get() {
|
|
21
|
-
return _shared.getIgnorePatterns;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "findUserModulePaths", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function get() {
|
|
27
|
-
return _findUserModulePaths.findUserModulePaths;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "getUserModules", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function get() {
|
|
33
|
-
return _getUserModules.getUserModules;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "generateUserDepsModule", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function get() {
|
|
39
|
-
return _generateUserDepsModule.generateUserDepsModule;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
var _shared = require("./shared");
|
|
44
|
-
|
|
45
|
-
var _findUserModulePaths = require("./findUserModulePaths");
|
|
46
|
-
|
|
47
|
-
var _getUserModules = require("./getUserModules");
|
|
48
|
-
|
|
49
|
-
var _generateUserDepsModule = require("./generateUserDepsModule");
|