react-cosmos 5.6.7 → 5.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dom/DomFixtureLoader.d.ts +3 -3
- package/dist/dom/index.d.ts +3 -3
- package/dist/getFixtureUrls.js +8 -9
- package/dist/getFixtures.js +11 -12
- package/dist/getFixtures2.js +7 -7
- package/dist/native.d.ts +3 -3
- package/dist/plugins/webpack/client/userDeps.d.ts +3 -3
- package/dist/plugins/webpack/webpackConfig/devServer.js +16 -15
- package/dist/plugins/webpack/webpackConfig/export.js +16 -15
- package/dist/plugins/webpack/webpackConfig/{default.d.ts → getDefaultWebpackConfig.d.ts} +0 -0
- package/dist/plugins/webpack/webpackConfig/{default.js → getDefaultWebpackConfig.js} +2 -2
- 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.js +3 -3
- 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/shared/userDeps/getUserModules.d.ts +3 -3
- package/dist/shared/userDeps/getUserModules.js +5 -5
- package/dist/shared/userDeps/userDepsTemplate.js +1 -1
- package/package.json +4 -4
- 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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { ReactDecorators, ReactFixtureWrappers } from 'react-cosmos-shared2/react';
|
|
3
3
|
declare type Props = {
|
|
4
|
-
fixtures:
|
|
5
|
-
decorators:
|
|
4
|
+
fixtures: ReactFixtureWrappers;
|
|
5
|
+
decorators: ReactDecorators;
|
|
6
6
|
onErrorReset?: () => unknown;
|
|
7
7
|
};
|
|
8
8
|
export declare function DomFixtureLoader({ fixtures, decorators, onErrorReset, }: Props): JSX.Element;
|
package/dist/dom/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactDecorators, ReactFixtureWrappers } from 'react-cosmos-shared2/react';
|
|
2
2
|
import { DomRendererConfig } from '../shared/rendererConfig';
|
|
3
3
|
import './globalErrorHandler';
|
|
4
4
|
import { rendererConnect } from './rendererConnect';
|
|
@@ -6,8 +6,8 @@ import { rendererId } from './rendererId';
|
|
|
6
6
|
export { rendererId, rendererConnect };
|
|
7
7
|
declare type Args = {
|
|
8
8
|
rendererConfig: DomRendererConfig;
|
|
9
|
-
fixtures:
|
|
10
|
-
decorators:
|
|
9
|
+
fixtures: ReactFixtureWrappers;
|
|
10
|
+
decorators: ReactDecorators;
|
|
11
11
|
onErrorReset?: () => unknown;
|
|
12
12
|
};
|
|
13
13
|
export declare function mountDomRenderer({ rendererConfig, fixtures, decorators, onErrorReset, }: Args): void;
|
package/dist/getFixtureUrls.js
CHANGED
|
@@ -53,19 +53,18 @@ function getFixtureUrlsSync(_ref2) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
var _getUserModules = (0, _userDeps.getUserModules)(cosmosConfig),
|
|
56
|
-
|
|
56
|
+
fixtures = _getUserModules.fixtures;
|
|
57
57
|
|
|
58
|
-
var
|
|
59
|
-
Object.keys(
|
|
60
|
-
var
|
|
58
|
+
var fixtureList = (0, _react.getFixtureListFromExports)(fixtures);
|
|
59
|
+
Object.keys(fixtureList).forEach(function (fixturePath) {
|
|
60
|
+
var fixtureItem = fixtureList[fixturePath];
|
|
61
61
|
|
|
62
|
-
if (
|
|
62
|
+
if (fixtureItem.type === 'single') {
|
|
63
63
|
pushFixtureUrl({
|
|
64
|
-
path: fixturePath
|
|
65
|
-
name: null
|
|
64
|
+
path: fixturePath
|
|
66
65
|
});
|
|
67
|
-
} else {
|
|
68
|
-
fixtureNames.forEach(function (fixtureName) {
|
|
66
|
+
} else if (fixtureItem.type === 'multi') {
|
|
67
|
+
fixtureItem.fixtureNames.forEach(function (fixtureName) {
|
|
69
68
|
pushFixtureUrl({
|
|
70
69
|
path: fixturePath,
|
|
71
70
|
name: fixtureName
|
package/dist/getFixtures.js
CHANGED
|
@@ -43,12 +43,12 @@ function getFixturesSync(_ref2) {
|
|
|
43
43
|
var cosmosConfig = _ref2.cosmosConfig;
|
|
44
44
|
|
|
45
45
|
var _getUserModules = (0, _userDeps.getUserModules)(cosmosConfig),
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
fixtures = _getUserModules.fixtures,
|
|
47
|
+
decorators = _getUserModules.decorators;
|
|
48
48
|
|
|
49
|
-
var
|
|
50
|
-
Object.keys(
|
|
51
|
-
var fixtureExport =
|
|
49
|
+
var result = [];
|
|
50
|
+
Object.keys(fixtures).forEach(function (fixturePath) {
|
|
51
|
+
var fixtureExport = fixtures[fixturePath];
|
|
52
52
|
|
|
53
53
|
if ((0, _react.isMultiFixture)(fixtureExport)) {
|
|
54
54
|
// FIXME: Why does fixtureExport need to be cast as ReactFixtureMap when
|
|
@@ -59,23 +59,22 @@ function getFixturesSync(_ref2) {
|
|
|
59
59
|
path: fixturePath,
|
|
60
60
|
name: fixtureName
|
|
61
61
|
};
|
|
62
|
-
|
|
62
|
+
result.push({
|
|
63
63
|
fixtureId: fixtureId,
|
|
64
|
-
getElement: createFixtureElementGetter(multiFixtureExport[fixtureName], fixturePath,
|
|
64
|
+
getElement: createFixtureElementGetter(multiFixtureExport[fixtureName], fixturePath, decorators)
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
67
|
} else {
|
|
68
68
|
var fixtureId = {
|
|
69
|
-
path: fixturePath
|
|
70
|
-
name: null
|
|
69
|
+
path: fixturePath
|
|
71
70
|
};
|
|
72
|
-
|
|
71
|
+
result.push({
|
|
73
72
|
fixtureId: fixtureId,
|
|
74
|
-
getElement: createFixtureElementGetter(fixtureExport, fixturePath,
|
|
73
|
+
getElement: createFixtureElementGetter(fixtureExport, fixturePath, decorators)
|
|
75
74
|
});
|
|
76
75
|
}
|
|
77
76
|
});
|
|
78
|
-
return
|
|
77
|
+
return result;
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
function createFixtureElementGetter(fixture, fixturePath, decoratorsByPath) {
|
package/dist/getFixtures2.js
CHANGED
|
@@ -42,12 +42,12 @@ function getFixtures2(cosmosConfig) {
|
|
|
42
42
|
var fixtureInfo = [];
|
|
43
43
|
|
|
44
44
|
var _getUserModules = (0, _userDeps.getUserModules)(cosmosConfig),
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
fixtures = _getUserModules.fixtures,
|
|
46
|
+
decorators = _getUserModules.decorators;
|
|
47
47
|
|
|
48
|
-
var
|
|
48
|
+
var fixtureList = (0, _react.getFixtureListFromExports)(fixtures);
|
|
49
49
|
var fixtureTree = (0, _fixtureTree.createFixtureTree)({
|
|
50
|
-
fixtures:
|
|
50
|
+
fixtures: fixtureList,
|
|
51
51
|
fixturesDir: fixturesDir,
|
|
52
52
|
fixtureFileSuffix: fixtureFileSuffix
|
|
53
53
|
});
|
|
@@ -57,14 +57,14 @@ function getFixtures2(cosmosConfig) {
|
|
|
57
57
|
fixtureId = _ref.fixtureId,
|
|
58
58
|
name = _ref.name,
|
|
59
59
|
parents = _ref.parents;
|
|
60
|
-
var fixtureExport =
|
|
61
|
-
var fixture = fixtureId.name ===
|
|
60
|
+
var fixtureExport = fixtures[fixtureId.path];
|
|
61
|
+
var fixture = fixtureId.name === undefined ? fixtureExport : fixtureExport[fixtureId.name];
|
|
62
62
|
var treePath = [].concat(_toConsumableArray(parents), [fileName]);
|
|
63
63
|
if (name) treePath.push(name);
|
|
64
64
|
fixtureInfo.push({
|
|
65
65
|
absoluteFilePath: _path.default.join(rootDir, fixtureId.path),
|
|
66
66
|
fileName: fileName,
|
|
67
|
-
getElement: createFixtureElementGetter(fixture, fixtureId.path,
|
|
67
|
+
getElement: createFixtureElementGetter(fixture, fixtureId.path, decorators),
|
|
68
68
|
name: name,
|
|
69
69
|
parents: parents,
|
|
70
70
|
playgroundUrl: getPlaygroundUrl(cosmosConfig, fixtureId),
|
package/dist/native.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { ReactDecorators, ReactFixtureWrappers } from 'react-cosmos-shared2/react';
|
|
3
3
|
import { NativeRendererConfig } from './shared/rendererConfig';
|
|
4
4
|
declare type Props = {
|
|
5
5
|
rendererConfig: NativeRendererConfig;
|
|
6
|
-
fixtures:
|
|
7
|
-
decorators:
|
|
6
|
+
fixtures: ReactFixtureWrappers;
|
|
7
|
+
decorators: ReactDecorators;
|
|
8
8
|
};
|
|
9
9
|
export declare function NativeFixtureLoader({ rendererConfig: { port }, fixtures, decorators, }: Props): JSX.Element;
|
|
10
10
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactDecorators, ReactFixtureWrappers } from 'react-cosmos-shared2/react';
|
|
2
2
|
import { DomRendererConfig } from '../../../shared/rendererConfig';
|
|
3
3
|
export declare const rendererConfig: DomRendererConfig;
|
|
4
|
-
export declare const fixtures:
|
|
5
|
-
export declare const decorators:
|
|
4
|
+
export declare const fixtures: ReactFixtureWrappers;
|
|
5
|
+
export declare const decorators: ReactDecorators;
|
|
@@ -9,9 +9,17 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
9
9
|
|
|
10
10
|
var _webpack = require("../cosmosConfig/webpack");
|
|
11
11
|
|
|
12
|
+
var _getUserWebpackConfig = require("./getUserWebpackConfig");
|
|
13
|
+
|
|
14
|
+
var _getWebpackConfigResolve = require("./getWebpackConfigResolve");
|
|
15
|
+
|
|
16
|
+
var _getWebpackConfigModule = require("./getWebpackConfigModule");
|
|
17
|
+
|
|
12
18
|
var _htmlPlugin = require("./htmlPlugin");
|
|
13
19
|
|
|
14
|
-
var
|
|
20
|
+
var _plugins = require("./plugins");
|
|
21
|
+
|
|
22
|
+
var _resolveWebpackClientPath = require("./resolveWebpackClientPath");
|
|
15
23
|
|
|
16
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
25
|
|
|
@@ -51,17 +59,15 @@ function _getDevWebpackConfig() {
|
|
|
51
59
|
switch (_context.prev = _context.next) {
|
|
52
60
|
case 0:
|
|
53
61
|
_context.next = 2;
|
|
54
|
-
return (0,
|
|
62
|
+
return (0, _getUserWebpackConfig.getUserWebpackConfig)(cosmosConfig, userWebpack);
|
|
55
63
|
|
|
56
64
|
case 2:
|
|
57
65
|
baseWebpackConfig = _context.sent;
|
|
58
66
|
webpackConfig = _objectSpread(_objectSpread({}, baseWebpackConfig), {}, {
|
|
59
67
|
entry: getEntry(cosmosConfig),
|
|
60
68
|
output: getOutput(cosmosConfig),
|
|
61
|
-
module:
|
|
62
|
-
|
|
63
|
-
}),
|
|
64
|
-
resolve: (0, _shared.resolveLocalReactDeps)(cosmosConfig, baseWebpackConfig),
|
|
69
|
+
module: (0, _getWebpackConfigModule.getWebpackConfigModule)(baseWebpackConfig),
|
|
70
|
+
resolve: (0, _getWebpackConfigResolve.getWebpackConfigResolve)(cosmosConfig, baseWebpackConfig),
|
|
65
71
|
plugins: getPlugins(cosmosConfig, baseWebpackConfig, userWebpack)
|
|
66
72
|
}); // optimization.splitChunks.name = false breaks auto fixture file discovery.
|
|
67
73
|
// When the splitChunks.name is set to false, existing fixtures hot reload
|
|
@@ -98,8 +104,8 @@ function getEntry(cosmosConfig) {
|
|
|
98
104
|
// might import React
|
|
99
105
|
|
|
100
106
|
|
|
101
|
-
var devtoolsHook = (0,
|
|
102
|
-
var clientIndex = (0,
|
|
107
|
+
var devtoolsHook = (0, _resolveWebpackClientPath.resolveWebpackClientPath)('reactDevtoolsHook');
|
|
108
|
+
var clientIndex = (0, _resolveWebpackClientPath.resolveWebpackClientPath)('index');
|
|
103
109
|
return hotReload ? [devtoolsHook, getHotMiddlewareEntry(reloadOnFail), clientIndex] : [devtoolsHook, clientIndex];
|
|
104
110
|
}
|
|
105
111
|
|
|
@@ -116,21 +122,16 @@ function getOutput(_ref) {
|
|
|
116
122
|
};
|
|
117
123
|
}
|
|
118
124
|
|
|
119
|
-
function getRules(baseWebpackConfig) {
|
|
120
|
-
var existingRules = baseWebpackConfig.module && baseWebpackConfig.module.rules || [];
|
|
121
|
-
return [].concat(_toConsumableArray(existingRules), [(0, _shared.getUserDepsLoaderRule)()]);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
125
|
function getPlugins(cosmosConfig, baseWebpackConfig, userWebpack) {
|
|
125
126
|
var existingPlugins = baseWebpackConfig.plugins || [];
|
|
126
|
-
var globalsPlugin = (0,
|
|
127
|
+
var globalsPlugin = (0, _plugins.getGlobalsPlugin)(cosmosConfig, userWebpack, true);
|
|
127
128
|
var noEmitErrorsPlugin = new userWebpack.NoEmitOnErrorsPlugin();
|
|
128
129
|
var plugins = [].concat(_toConsumableArray(existingPlugins), [globalsPlugin, noEmitErrorsPlugin]);
|
|
129
130
|
|
|
130
131
|
var _createWebpackCosmosC2 = (0, _webpack.createWebpackCosmosConfig)(cosmosConfig),
|
|
131
132
|
hotReload = _createWebpackCosmosC2.hotReload;
|
|
132
133
|
|
|
133
|
-
if (hotReload && !(0,
|
|
134
|
+
if (hotReload && !(0, _plugins.hasPlugin)(plugins, 'HotModuleReplacementPlugin')) {
|
|
134
135
|
var hmrPlugin = new userWebpack.HotModuleReplacementPlugin();
|
|
135
136
|
plugins = [].concat(_toConsumableArray(plugins), [hmrPlugin]);
|
|
136
137
|
}
|
|
@@ -7,13 +7,21 @@ exports.getExportWebpackConfig = getExportWebpackConfig;
|
|
|
7
7
|
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
|
|
10
|
+
var _shared = require("../../../shared/shared");
|
|
11
|
+
|
|
10
12
|
var _webpack = require("../cosmosConfig/webpack");
|
|
11
13
|
|
|
12
|
-
var
|
|
14
|
+
var _getUserWebpackConfig = require("./getUserWebpackConfig");
|
|
15
|
+
|
|
16
|
+
var _getWebpackConfigResolve = require("./getWebpackConfigResolve");
|
|
17
|
+
|
|
18
|
+
var _getWebpackConfigModule = require("./getWebpackConfigModule");
|
|
13
19
|
|
|
14
20
|
var _htmlPlugin = require("./htmlPlugin");
|
|
15
21
|
|
|
16
|
-
var
|
|
22
|
+
var _plugins = require("./plugins");
|
|
23
|
+
|
|
24
|
+
var _resolveWebpackClientPath = require("./resolveWebpackClientPath");
|
|
17
25
|
|
|
18
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
27
|
|
|
@@ -51,17 +59,15 @@ function _getExportWebpackConfig() {
|
|
|
51
59
|
switch (_context.prev = _context.next) {
|
|
52
60
|
case 0:
|
|
53
61
|
_context.next = 2;
|
|
54
|
-
return (0,
|
|
62
|
+
return (0, _getUserWebpackConfig.getUserWebpackConfig)(cosmosConfig, userWebpack);
|
|
55
63
|
|
|
56
64
|
case 2:
|
|
57
65
|
baseWebpackConfig = _context.sent;
|
|
58
66
|
return _context.abrupt("return", _objectSpread(_objectSpread({}, baseWebpackConfig), {}, {
|
|
59
67
|
entry: getEntry(),
|
|
60
68
|
output: getOutput(cosmosConfig),
|
|
61
|
-
module:
|
|
62
|
-
|
|
63
|
-
}),
|
|
64
|
-
resolve: (0, _shared2.resolveLocalReactDeps)(cosmosConfig, baseWebpackConfig),
|
|
69
|
+
module: (0, _getWebpackConfigModule.getWebpackConfigModule)(baseWebpackConfig),
|
|
70
|
+
resolve: (0, _getWebpackConfigResolve.getWebpackConfigResolve)(cosmosConfig, baseWebpackConfig),
|
|
65
71
|
plugins: getPlugins(cosmosConfig, baseWebpackConfig, userWebpack)
|
|
66
72
|
}));
|
|
67
73
|
|
|
@@ -78,8 +84,8 @@ function _getExportWebpackConfig() {
|
|
|
78
84
|
function getEntry() {
|
|
79
85
|
// The React devtools hook needs to be imported before any other module that
|
|
80
86
|
// might import React
|
|
81
|
-
var devtoolsHook = (0,
|
|
82
|
-
var clientIndex = (0,
|
|
87
|
+
var devtoolsHook = (0, _resolveWebpackClientPath.resolveWebpackClientPath)('reactDevtoolsHook');
|
|
88
|
+
var clientIndex = (0, _resolveWebpackClientPath.resolveWebpackClientPath)('index');
|
|
83
89
|
return [devtoolsHook, clientIndex];
|
|
84
90
|
}
|
|
85
91
|
|
|
@@ -97,14 +103,9 @@ function getOutput(cosmosConfig) {
|
|
|
97
103
|
};
|
|
98
104
|
}
|
|
99
105
|
|
|
100
|
-
function getRules(baseWebpackConfig) {
|
|
101
|
-
var existingRules = baseWebpackConfig.module && baseWebpackConfig.module.rules || [];
|
|
102
|
-
return [].concat(_toConsumableArray(existingRules), [(0, _shared2.getUserDepsLoaderRule)()]);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
106
|
function getPlugins(cosmosConfig, baseWebpackConfig, userWebpack) {
|
|
106
107
|
var existingPlugins = baseWebpackConfig.plugins || [];
|
|
107
|
-
var globalsPlugin = (0,
|
|
108
|
+
var globalsPlugin = (0, _plugins.getGlobalsPlugin)(cosmosConfig, userWebpack, false);
|
|
108
109
|
var noEmitErrorsPlugin = new userWebpack.NoEmitOnErrorsPlugin();
|
|
109
110
|
return (0, _htmlPlugin.ensureHtmlWebackPlugin)(cosmosConfig, [].concat(_toConsumableArray(existingPlugins), [globalsPlugin, noEmitErrorsPlugin]));
|
|
110
111
|
}
|
|
File without changes
|
|
@@ -9,7 +9,7 @@ var _resolveFrom = _interopRequireDefault(require("resolve-from"));
|
|
|
9
9
|
|
|
10
10
|
var _playgroundHtml = require("../../../shared/playgroundHtml");
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _getWebpackNodeEnv = require("./getWebpackNodeEnv");
|
|
13
13
|
|
|
14
14
|
var _htmlPlugin = require("./htmlPlugin");
|
|
15
15
|
|
|
@@ -141,7 +141,7 @@ function getDefaultWebpackConfig(userWebpack, rootDir) {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
return _objectSpread(_objectSpread({}, config), {}, {
|
|
144
|
-
mode: (0,
|
|
144
|
+
mode: (0, _getWebpackNodeEnv.getWebpackNodeEnv)(),
|
|
145
145
|
optimization: {
|
|
146
146
|
// Cosmos reads component names at run-time, so it is crucial to not
|
|
147
147
|
// minify even when building with production env (ie. when exporting)
|
|
@@ -0,0 +1,136 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import webpack from 'webpack';
|
|
2
|
+
import { CosmosConfig } from '../../../config';
|
|
3
|
+
export declare function getWebpackConfigResolve(cosmosConfig: CosmosConfig, webpackConfig: webpack.Configuration): webpack.ResolveOptions;
|
|
4
|
+
export declare function isInstanceOfResolvePlugin(plugin: webpack.ResolvePluginInstance | '...', constructorName: string): boolean;
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getWebpackNodeEnv(): "production" | "development";
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
}
|
|
@@ -12,7 +12,7 @@ var _lodash = require("lodash");
|
|
|
12
12
|
|
|
13
13
|
var _playgroundHtml = require("../../../shared/playgroundHtml");
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _plugins = require("./plugins");
|
|
16
16
|
|
|
17
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
18
|
|
|
@@ -37,7 +37,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
37
37
|
function ensureHtmlWebackPlugin(_ref, plugins) {
|
|
38
38
|
var rootDir = _ref.rootDir;
|
|
39
39
|
|
|
40
|
-
if ((0,
|
|
40
|
+
if ((0, _plugins.hasPlugin)(plugins, 'HtmlWebpackPlugin')) {
|
|
41
41
|
return plugins.map(function (plugin) {
|
|
42
42
|
return isHtmlWebpackPlugin(plugin) ? changeHtmlPluginFilename(plugin) : plugin;
|
|
43
43
|
});
|
|
@@ -60,7 +60,7 @@ function getHtmlWebpackPlugin(rootDir) {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
function isHtmlWebpackPlugin(plugin) {
|
|
63
|
-
return (0,
|
|
63
|
+
return (0, _plugins.isInstanceOfWebpackPlugin)(plugin, 'HtmlWebpackPlugin');
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
function changeHtmlPluginFilename(htmlPlugin) {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import webpack from 'webpack';
|
|
2
|
+
import { CosmosConfig } from '../../../config';
|
|
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;
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveWebpackClientPath(relPath: string): string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactDecorators, ReactFixtureExports } from 'react-cosmos-shared2/react';
|
|
2
2
|
import { CosmosConfig } from '../../config';
|
|
3
3
|
declare type UserModules = {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
fixtures: ReactFixtureExports;
|
|
5
|
+
decorators: ReactDecorators;
|
|
6
6
|
};
|
|
7
7
|
export declare function getUserModules({ rootDir, fixturesDir, fixtureFileSuffix, }: CosmosConfig): UserModules;
|
|
8
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 _ = require(".");
|
|
13
|
+
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
16
|
function getUserModules(_ref) {
|
|
@@ -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
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-cosmos",
|
|
3
|
-
"version": "5.6.
|
|
3
|
+
"version": "5.6.8",
|
|
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",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"open": "^8.4.0",
|
|
21
21
|
"pem": "^1.14.4",
|
|
22
22
|
"pkg-up": "^3.1.0",
|
|
23
|
-
"react-cosmos-playground2": "^5.6.
|
|
23
|
+
"react-cosmos-playground2": "^5.6.8",
|
|
24
24
|
"react-cosmos-plugin": "^5.6.0",
|
|
25
|
-
"react-cosmos-shared2": "^5.6.
|
|
25
|
+
"react-cosmos-shared2": "^5.6.8",
|
|
26
26
|
"react-error-overlay": "6.0.9",
|
|
27
27
|
"regenerator-runtime": "^0.13.9",
|
|
28
28
|
"resolve-from": "^5.0.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": "cf9e3bd7e977f9faf4a45c9d6003b65ddd11a23a"
|
|
42
42
|
}
|
|
@@ -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"; 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); }
|
|
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(): "production" | "development";
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getBaseWebpackConfig = getBaseWebpackConfig;
|
|
7
|
-
exports.getGlobalsPlugin = getGlobalsPlugin;
|
|
8
|
-
exports.getNodeEnv = getNodeEnv;
|
|
9
|
-
exports.getUserDepsLoaderRule = getUserDepsLoaderRule;
|
|
10
|
-
exports.getUserWebpackConfig = getUserWebpackConfig;
|
|
11
|
-
exports.hasPlugin = hasPlugin;
|
|
12
|
-
exports.isInstanceOfPlugin = isInstanceOfPlugin;
|
|
13
|
-
exports.resolveClientPath = resolveClientPath;
|
|
14
|
-
exports.resolveLocalReactDeps = resolveLocalReactDeps;
|
|
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); 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 = 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; }
|
|
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
|
-
}
|