@storybook/react 5.1.7 → 5.1.11
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/package.json +5 -4
- package/dist/client/preview/element_check.test.js +0 -88
- package/dist/client/preview/index.test.js +0 -38
- package/dist/server/__mocks__/mockConfig.js +0 -25
- package/dist/server/__mocks__/mockRules.js +0 -151
- package/dist/server/__mocks__/react-scripts-2-0-0/config/webpack.config.dev.js +0 -63
- package/dist/server/__mocks__/react-scripts-2-0-0/package.json +0 -4
- package/dist/server/__mocks__/react-scripts-2-1-0/config/webpack.config.dev.js +0 -63
- package/dist/server/__mocks__/react-scripts-2-1-0/package.json +0 -4
- package/dist/server/__snapshots__/cra-config.test.js.snap +0 -128
- package/dist/server/cra-config.test.js +0 -140
- package/dist/server/framework-preset-react-docgen.test.js +0 -54
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.11",
|
|
4
4
|
"description": "Storybook for React: Develop React Component in isolation with Hot Reloading.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -29,9 +29,10 @@
|
|
|
29
29
|
"@babel/plugin-transform-react-constant-elements": "^7.2.0",
|
|
30
30
|
"@babel/preset-flow": "^7.0.0",
|
|
31
31
|
"@babel/preset-react": "^7.0.0",
|
|
32
|
-
"@storybook/core": "5.1.
|
|
33
|
-
"@storybook/node-logger": "5.1.
|
|
32
|
+
"@storybook/core": "5.1.11",
|
|
33
|
+
"@storybook/node-logger": "5.1.11",
|
|
34
34
|
"@svgr/webpack": "^4.0.3",
|
|
35
|
+
"babel-plugin-add-react-displayname": "^0.0.5",
|
|
35
36
|
"babel-plugin-named-asset-import": "^0.3.1",
|
|
36
37
|
"babel-plugin-react-docgen": "^3.0.0",
|
|
37
38
|
"babel-preset-react-app": "^9.0.0",
|
|
@@ -57,5 +58,5 @@
|
|
|
57
58
|
"publishConfig": {
|
|
58
59
|
"access": "public"
|
|
59
60
|
},
|
|
60
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "aeeafda2de3e97cd91e36c3dc7bdb0543d073429"
|
|
61
62
|
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("core-js/modules/es.object.define-property");
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.object.get-own-property-descriptor");
|
|
6
|
-
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
|
|
9
|
-
var _element_check = _interopRequireWildcard(require("./element_check"));
|
|
10
|
-
|
|
11
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
|
|
12
|
-
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
|
-
|
|
15
|
-
describe('element_check.utils.isValidFiberElement', function () {
|
|
16
|
-
it('should accept to render a string', function () {
|
|
17
|
-
var string = 'react is awesome';
|
|
18
|
-
expect((0, _element_check.isValidFiberElement)(string)).toBe(true);
|
|
19
|
-
});
|
|
20
|
-
it('should accept to render a number', function () {
|
|
21
|
-
var number = 42;
|
|
22
|
-
expect((0, _element_check.isValidFiberElement)(number)).toBe(true);
|
|
23
|
-
});
|
|
24
|
-
it('should accept to render a valid React element', function () {
|
|
25
|
-
var element = _react["default"].createElement("button", {
|
|
26
|
-
type: "button"
|
|
27
|
-
}, "Click me");
|
|
28
|
-
|
|
29
|
-
expect((0, _element_check.isValidFiberElement)(element)).toBe(true);
|
|
30
|
-
});
|
|
31
|
-
it("shouldn't accept to render an arbitrary object", function () {
|
|
32
|
-
var object = {
|
|
33
|
-
key: 'bee bop'
|
|
34
|
-
};
|
|
35
|
-
expect((0, _element_check.isValidFiberElement)(object)).toBe(false);
|
|
36
|
-
});
|
|
37
|
-
it("shouldn't accept to render a function", function () {
|
|
38
|
-
var noop = function noop() {};
|
|
39
|
-
|
|
40
|
-
expect((0, _element_check.isValidFiberElement)(noop)).toBe(false);
|
|
41
|
-
});
|
|
42
|
-
it("shouldn't accept to render undefined", function () {
|
|
43
|
-
expect((0, _element_check.isValidFiberElement)(undefined)).toBe(false);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
describe('element_check.utils.isPriorToFiber', function () {
|
|
47
|
-
it('should return true if React version is prior to Fiber (< 16)', function () {
|
|
48
|
-
var oldVersion = '0.14.5';
|
|
49
|
-
var version = '15.5.4';
|
|
50
|
-
expect((0, _element_check.isPriorToFiber)(oldVersion)).toBe(true);
|
|
51
|
-
expect((0, _element_check.isPriorToFiber)(version)).toBe(true);
|
|
52
|
-
});
|
|
53
|
-
it('should return false if React version is using Fiber features (>= 16)', function () {
|
|
54
|
-
var alphaVersion = '16.0.0-alpha.13';
|
|
55
|
-
var version = '18.3.1';
|
|
56
|
-
expect((0, _element_check.isPriorToFiber)(alphaVersion)).toBe(false);
|
|
57
|
-
expect((0, _element_check.isPriorToFiber)(version)).toBe(false);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
describe('element_check.isReactRenderable', function () {
|
|
61
|
-
var string = 'yo';
|
|
62
|
-
var number = 1337;
|
|
63
|
-
|
|
64
|
-
var element = _react["default"].createElement("span", null, "what's up");
|
|
65
|
-
|
|
66
|
-
var array = [string, number, element];
|
|
67
|
-
var object = {
|
|
68
|
-
key: null
|
|
69
|
-
};
|
|
70
|
-
it('allows rendering React elements only prior to React Fiber', function () {
|
|
71
|
-
// mutate version for the purpose of the test
|
|
72
|
-
_react["default"].version = '15.5.4';
|
|
73
|
-
expect((0, _element_check["default"])(string)).toBe(false);
|
|
74
|
-
expect((0, _element_check["default"])(number)).toBe(false);
|
|
75
|
-
expect((0, _element_check["default"])(element)).toBe(true);
|
|
76
|
-
expect((0, _element_check["default"])(array)).toBe(false);
|
|
77
|
-
expect((0, _element_check["default"])(object)).toBe(false);
|
|
78
|
-
});
|
|
79
|
-
it('allows rendering string, numbers, arrays and React elements with React Fiber', function () {
|
|
80
|
-
// mutate version for the purpose of the test
|
|
81
|
-
_react["default"].version = '16.0.0-alpha.13';
|
|
82
|
-
expect((0, _element_check["default"])(string)).toBe(true);
|
|
83
|
-
expect((0, _element_check["default"])(number)).toBe(true);
|
|
84
|
-
expect((0, _element_check["default"])(element)).toBe(true);
|
|
85
|
-
expect((0, _element_check["default"])(array)).toBe(true);
|
|
86
|
-
expect((0, _element_check["default"])(object)).toBe(false);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("core-js/modules/es.array.every");
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.object.keys");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.object.values");
|
|
8
|
-
|
|
9
|
-
/* eslint-disable global-require */
|
|
10
|
-
describe('preview', function () {
|
|
11
|
-
afterEach(function () {
|
|
12
|
-
jest.resetModules();
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
var isFunction = function isFunction(value) {
|
|
16
|
-
return typeof value === 'function';
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
it('should return the client api in a browser environment', function () {
|
|
20
|
-
var api = require('.');
|
|
21
|
-
|
|
22
|
-
expect(Object.keys(api).length).toBeGreaterThan(0);
|
|
23
|
-
expect(Object.values(api).every(isFunction)).toEqual(true);
|
|
24
|
-
});
|
|
25
|
-
it('should return the client api in a node.js environment', function () {
|
|
26
|
-
jest.mock('global', function () {
|
|
27
|
-
return {
|
|
28
|
-
document: undefined,
|
|
29
|
-
window: undefined
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
var api = require('.');
|
|
34
|
-
|
|
35
|
-
expect(Object.keys(api).length).toBeGreaterThan(0);
|
|
36
|
-
expect(Object.values(api).every(isFunction)).toEqual(true);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
class BaseTestPlugin1 {}
|
|
2
|
-
class BaseTestPlugin2 {}
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
devtool: 'cheap-eval-source-map',
|
|
6
|
-
resolve: {
|
|
7
|
-
extensions: ['.js', '.jsx'],
|
|
8
|
-
alias: {
|
|
9
|
-
baseAlias: 'base-alias',
|
|
10
|
-
},
|
|
11
|
-
modules: [],
|
|
12
|
-
},
|
|
13
|
-
module: {
|
|
14
|
-
noParse: /jquery/,
|
|
15
|
-
rules: [
|
|
16
|
-
{
|
|
17
|
-
test: /\.js$/,
|
|
18
|
-
include: 'app/baseSrc',
|
|
19
|
-
loader: 'babel-loader',
|
|
20
|
-
options: {},
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
},
|
|
24
|
-
plugins: [new BaseTestPlugin1(), new BaseTestPlugin2()],
|
|
25
|
-
};
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
export default [
|
|
2
|
-
{ parser: { requireEnsure: false } },
|
|
3
|
-
{
|
|
4
|
-
test: /\.(js|mjs|jsx)$/,
|
|
5
|
-
enforce: 'pre',
|
|
6
|
-
use: [
|
|
7
|
-
{
|
|
8
|
-
options: {
|
|
9
|
-
formatter: '/mock_folder/node_modules/react-dev-utils/eslintFormatter.js',
|
|
10
|
-
eslintPath: '/mock_folder/node_modules/eslint/lib/api.js',
|
|
11
|
-
baseConfig: {
|
|
12
|
-
extends: ['/mock_folder/node_modules/eslint-config-react-app/index.js'],
|
|
13
|
-
settings: { react: { version: '999.999.999' } },
|
|
14
|
-
},
|
|
15
|
-
ignore: false,
|
|
16
|
-
useEslintrc: false,
|
|
17
|
-
},
|
|
18
|
-
loader: '/mock_folder/node_modules/eslint-loader/index.js',
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
include: '/mock_folder/src',
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
oneOf: [
|
|
25
|
-
{
|
|
26
|
-
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
|
|
27
|
-
loader: '/mock_folder/node_modules/url-loader/dist/cjs.js',
|
|
28
|
-
options: { limit: 10000, name: 'static/media/[name].[hash:8].[ext]' },
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
test: /\.(js|mjs|jsx|ts|tsx)$/,
|
|
32
|
-
include: '/mock_folder/src',
|
|
33
|
-
loader: '/mock_folder/node_modules/babel-loader/lib/index.js',
|
|
34
|
-
options: {
|
|
35
|
-
customize: '/mock_folder/node_modules/babel-preset-react-app/webpack-overrides.js',
|
|
36
|
-
babelrc: false,
|
|
37
|
-
configFile: false,
|
|
38
|
-
presets: ['/mock_folder/node_modules/babel-preset-react-app/index.js'],
|
|
39
|
-
cacheIdentifier:
|
|
40
|
-
'development:babel-plugin-named-asset-import@0.2.3:babel-preset-react-app@6.1.0:react-dev-utils@6.1.1:react-scripts@',
|
|
41
|
-
plugins: [
|
|
42
|
-
[
|
|
43
|
-
'/mock_folder/node_modules/babel-plugin-named-asset-import/index.js',
|
|
44
|
-
{
|
|
45
|
-
loaderMap: {
|
|
46
|
-
svg: {
|
|
47
|
-
ReactComponent: '@svgr/webpack?-prettier,-svgo![path]',
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
],
|
|
53
|
-
cacheDirectory: true,
|
|
54
|
-
cacheCompression: false,
|
|
55
|
-
compact: false,
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
test: /\.(js|mjs)$/,
|
|
60
|
-
exclude: {},
|
|
61
|
-
loader: '/mock_folder/node_modules/babel-loader/lib/index.js',
|
|
62
|
-
options: {
|
|
63
|
-
babelrc: false,
|
|
64
|
-
configFile: false,
|
|
65
|
-
compact: false,
|
|
66
|
-
presets: [
|
|
67
|
-
['/mock_folder/node_modules/babel-preset-react-app/dependencies.js', { helpers: true }],
|
|
68
|
-
],
|
|
69
|
-
cacheDirectory: true,
|
|
70
|
-
cacheCompression: false,
|
|
71
|
-
cacheIdentifier:
|
|
72
|
-
'development:babel-plugin-named-asset-import@0.2.3:babel-preset-react-app@6.1.0:react-dev-utils@6.1.1:react-scripts@',
|
|
73
|
-
sourceMaps: false,
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
test: /\.css$/,
|
|
78
|
-
exclude: {},
|
|
79
|
-
use: [
|
|
80
|
-
'/mock_folder/node_modules/bmr-react-scripts/node_modules/style-loader/index.js',
|
|
81
|
-
{
|
|
82
|
-
loader: '/mock_folder/node_modules/bmr-react-scripts/node_modules/css-loader/index.js',
|
|
83
|
-
options: { importLoaders: 1, sourceMap: false },
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
loader: '/mock_folder/node_modules/postcss-loader/src/index.js',
|
|
87
|
-
options: { ident: 'postcss', sourceMap: false },
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
sideEffects: true,
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
test: /\.module\.css$/,
|
|
94
|
-
use: [
|
|
95
|
-
'/mock_folder/node_modules/bmr-react-scripts/node_modules/style-loader/index.js',
|
|
96
|
-
{
|
|
97
|
-
loader: '/mock_folder/node_modules/bmr-react-scripts/node_modules/css-loader/index.js',
|
|
98
|
-
options: { importLoaders: 1, sourceMap: false, modules: true },
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
loader: '/mock_folder/node_modules/postcss-loader/src/index.js',
|
|
102
|
-
options: { ident: 'postcss', sourceMap: false },
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
test: /\.(scss|sass)$/,
|
|
108
|
-
exclude: {},
|
|
109
|
-
use: [
|
|
110
|
-
'/mock_folder/node_modules/bmr-react-scripts/node_modules/style-loader/index.js',
|
|
111
|
-
{
|
|
112
|
-
loader: '/mock_folder/node_modules/bmr-react-scripts/node_modules/css-loader/index.js',
|
|
113
|
-
options: { importLoaders: 2, sourceMap: false },
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
loader: '/mock_folder/node_modules/postcss-loader/src/index.js',
|
|
117
|
-
options: { ident: 'postcss', sourceMap: false },
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
loader: '/mock_folder/node_modules/sass-loader/lib/loader.js',
|
|
121
|
-
options: { sourceMap: false },
|
|
122
|
-
},
|
|
123
|
-
],
|
|
124
|
-
sideEffects: true,
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
test: /\.module\.(scss|sass)$/,
|
|
128
|
-
use: [
|
|
129
|
-
'/mock_folder/node_modules/bmr-react-scripts/node_modules/style-loader/index.js',
|
|
130
|
-
{
|
|
131
|
-
loader: '/mock_folder/node_modules/bmr-react-scripts/node_modules/css-loader/index.js',
|
|
132
|
-
options: { importLoaders: 2, sourceMap: false, modules: true },
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
loader: '/mock_folder/node_modules/postcss-loader/src/index.js',
|
|
136
|
-
options: { ident: 'postcss', sourceMap: false },
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
loader: '/mock_folder/node_modules/sass-loader/lib/loader.js',
|
|
140
|
-
options: { sourceMap: false },
|
|
141
|
-
},
|
|
142
|
-
],
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
loader: '/mock_folder/node_modules/file-loader/dist/cjs.js',
|
|
146
|
-
exclude: [{}, {}, {}],
|
|
147
|
-
options: { name: 'static/media/[name].[hash:8].[ext]' },
|
|
148
|
-
},
|
|
149
|
-
],
|
|
150
|
-
},
|
|
151
|
-
];
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
const cssRegex = /\.css$/;
|
|
2
|
-
const cssModuleRegex = /\.module\.css$/;
|
|
3
|
-
const sassRegex = /\.(scss|sass)$/;
|
|
4
|
-
const sassModuleRegex = /\.module\.(scss|sass)$/;
|
|
5
|
-
|
|
6
|
-
class CRATestPlugin1 {}
|
|
7
|
-
class CRATestPlugin2 {}
|
|
8
|
-
|
|
9
|
-
module.exports = {
|
|
10
|
-
devtool: 'source-map',
|
|
11
|
-
resolve: {
|
|
12
|
-
extensions: [],
|
|
13
|
-
alias: {
|
|
14
|
-
'react-native': 'react-native-web',
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
module: {
|
|
18
|
-
strictExportPresence: true,
|
|
19
|
-
rules: [
|
|
20
|
-
{
|
|
21
|
-
test: /\.(js|mjs|jsx)$/,
|
|
22
|
-
enforce: 'pre',
|
|
23
|
-
use: [
|
|
24
|
-
{
|
|
25
|
-
options: {},
|
|
26
|
-
loader: 'eslint-loader',
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
include: 'app/src',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
test: /\.(js|mjs|jsx|ts|tsx)$/,
|
|
33
|
-
include: 'app/src',
|
|
34
|
-
loader: 'babel-loader',
|
|
35
|
-
options: {},
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
test: cssRegex,
|
|
39
|
-
exclude: cssModuleRegex,
|
|
40
|
-
use: 'style-loader',
|
|
41
|
-
sideEffects: true,
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
test: cssModuleRegex,
|
|
45
|
-
use: 'style-loader',
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
test: sassRegex,
|
|
49
|
-
exclude: sassModuleRegex,
|
|
50
|
-
use: 'sass-loader',
|
|
51
|
-
sideEffects: true,
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
test: sassModuleRegex,
|
|
55
|
-
use: 'sass-loader',
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
},
|
|
59
|
-
plugins: [new CRATestPlugin1(), new CRATestPlugin2()],
|
|
60
|
-
optimization: {
|
|
61
|
-
minimize: true,
|
|
62
|
-
},
|
|
63
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
const cssRegex = /\.css$/;
|
|
2
|
-
const cssModuleRegex = /\.module\.css$/;
|
|
3
|
-
const sassRegex = /\.(scss|sass)$/;
|
|
4
|
-
const sassModuleRegex = /\.module\.(scss|sass)$/;
|
|
5
|
-
|
|
6
|
-
class CRATestPlugin1 {}
|
|
7
|
-
class CRATestPlugin2 {}
|
|
8
|
-
|
|
9
|
-
module.exports = {
|
|
10
|
-
devtool: 'source-map',
|
|
11
|
-
resolve: {
|
|
12
|
-
extensions: [],
|
|
13
|
-
alias: {
|
|
14
|
-
'react-native': 'react-native-web',
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
module: {
|
|
18
|
-
strictExportPresence: true,
|
|
19
|
-
rules: [
|
|
20
|
-
{
|
|
21
|
-
test: /\.(js|mjs|jsx)$/,
|
|
22
|
-
enforce: 'pre',
|
|
23
|
-
use: [
|
|
24
|
-
{
|
|
25
|
-
options: {},
|
|
26
|
-
loader: 'eslint-loader',
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
include: 'app/src',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
test: /\.(js|mjs|jsx|ts|tsx)$/,
|
|
33
|
-
include: 'app/src',
|
|
34
|
-
loader: 'babel-loader',
|
|
35
|
-
options: {},
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
test: cssRegex,
|
|
39
|
-
exclude: cssModuleRegex,
|
|
40
|
-
use: 'style-loader',
|
|
41
|
-
sideEffects: true,
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
test: cssModuleRegex,
|
|
45
|
-
use: 'style-loader',
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
test: sassRegex,
|
|
49
|
-
exclude: sassModuleRegex,
|
|
50
|
-
use: 'sass-loader',
|
|
51
|
-
sideEffects: true,
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
test: sassModuleRegex,
|
|
55
|
-
use: 'sass-loader',
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
},
|
|
59
|
-
plugins: [new CRATestPlugin1(), new CRATestPlugin2()],
|
|
60
|
-
optimization: {
|
|
61
|
-
minimize: true,
|
|
62
|
-
},
|
|
63
|
-
};
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`cra-config when used with react-scripts < 2.1.0 should apply styling webpack rules 1`] = `
|
|
4
|
-
Object {
|
|
5
|
-
"devtool": "cheap-eval-source-map",
|
|
6
|
-
"module": Object {
|
|
7
|
-
"noParse": /jquery/,
|
|
8
|
-
"rules": Array [
|
|
9
|
-
Object {
|
|
10
|
-
"include": "app/baseSrc",
|
|
11
|
-
"loader": "babel-loader",
|
|
12
|
-
"options": Object {},
|
|
13
|
-
"test": /\\\\\\.js\\$/,
|
|
14
|
-
},
|
|
15
|
-
Object {
|
|
16
|
-
"exclude": /\\\\\\.module\\\\\\.css\\$/,
|
|
17
|
-
"sideEffects": true,
|
|
18
|
-
"test": /\\\\\\.css\\$/,
|
|
19
|
-
"use": "style-loader",
|
|
20
|
-
},
|
|
21
|
-
Object {
|
|
22
|
-
"test": /\\\\\\.module\\\\\\.css\\$/,
|
|
23
|
-
"use": "style-loader",
|
|
24
|
-
},
|
|
25
|
-
Object {
|
|
26
|
-
"exclude": /\\\\\\.module\\\\\\.\\(scss\\|sass\\)\\$/,
|
|
27
|
-
"sideEffects": true,
|
|
28
|
-
"test": /\\\\\\.\\(scss\\|sass\\)\\$/,
|
|
29
|
-
"use": "sass-loader",
|
|
30
|
-
},
|
|
31
|
-
Object {
|
|
32
|
-
"test": /\\\\\\.module\\\\\\.\\(scss\\|sass\\)\\$/,
|
|
33
|
-
"use": "sass-loader",
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
},
|
|
37
|
-
"plugins": Array [
|
|
38
|
-
BaseTestPlugin1 {},
|
|
39
|
-
BaseTestPlugin2 {},
|
|
40
|
-
],
|
|
41
|
-
"resolve": Object {
|
|
42
|
-
"alias": Object {
|
|
43
|
-
"baseAlias": "base-alias",
|
|
44
|
-
},
|
|
45
|
-
"extensions": Array [
|
|
46
|
-
".js",
|
|
47
|
-
".jsx",
|
|
48
|
-
],
|
|
49
|
-
"modules": Array [],
|
|
50
|
-
},
|
|
51
|
-
"resolveLoader": Object {
|
|
52
|
-
"modules": Array [
|
|
53
|
-
"node_modules",
|
|
54
|
-
"/app/react/src/server/__mocks__/react-scripts-2-0-0/node_modules",
|
|
55
|
-
],
|
|
56
|
-
},
|
|
57
|
-
}
|
|
58
|
-
`;
|
|
59
|
-
|
|
60
|
-
exports[`cra-config when used with react-scripts >= 2.1.0 should apply Babel, styling rules and merge plugins 1`] = `
|
|
61
|
-
Object {
|
|
62
|
-
"devtool": "cheap-eval-source-map",
|
|
63
|
-
"module": Object {
|
|
64
|
-
"noParse": /jquery/,
|
|
65
|
-
"rules": Array [
|
|
66
|
-
Object {
|
|
67
|
-
"include": "app/baseSrc",
|
|
68
|
-
"loader": "babel-loader",
|
|
69
|
-
"options": Object {},
|
|
70
|
-
"test": /\\\\\\.js\\$/,
|
|
71
|
-
},
|
|
72
|
-
Object {
|
|
73
|
-
"exclude": /\\\\\\.module\\\\\\.css\\$/,
|
|
74
|
-
"sideEffects": true,
|
|
75
|
-
"test": /\\\\\\.css\\$/,
|
|
76
|
-
"use": "style-loader",
|
|
77
|
-
},
|
|
78
|
-
Object {
|
|
79
|
-
"test": /\\\\\\.module\\\\\\.css\\$/,
|
|
80
|
-
"use": "style-loader",
|
|
81
|
-
},
|
|
82
|
-
Object {
|
|
83
|
-
"exclude": /\\\\\\.module\\\\\\.\\(scss\\|sass\\)\\$/,
|
|
84
|
-
"sideEffects": true,
|
|
85
|
-
"test": /\\\\\\.\\(scss\\|sass\\)\\$/,
|
|
86
|
-
"use": "sass-loader",
|
|
87
|
-
},
|
|
88
|
-
Object {
|
|
89
|
-
"test": /\\\\\\.module\\\\\\.\\(scss\\|sass\\)\\$/,
|
|
90
|
-
"use": "sass-loader",
|
|
91
|
-
},
|
|
92
|
-
Object {
|
|
93
|
-
"include": Array [
|
|
94
|
-
"app/src",
|
|
95
|
-
"/test-project",
|
|
96
|
-
],
|
|
97
|
-
"loader": "babel-loader",
|
|
98
|
-
"options": Object {},
|
|
99
|
-
"test": /\\\\\\.\\(js\\|mjs\\|jsx\\|ts\\|tsx\\)\\$/,
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
},
|
|
103
|
-
"plugins": Array [
|
|
104
|
-
BaseTestPlugin1 {},
|
|
105
|
-
BaseTestPlugin2 {},
|
|
106
|
-
CRATestPlugin1 {},
|
|
107
|
-
CRATestPlugin2 {},
|
|
108
|
-
],
|
|
109
|
-
"resolve": Object {
|
|
110
|
-
"alias": Object {
|
|
111
|
-
"baseAlias": "base-alias",
|
|
112
|
-
},
|
|
113
|
-
"extensions": Array [
|
|
114
|
-
".js",
|
|
115
|
-
".jsx",
|
|
116
|
-
".ts",
|
|
117
|
-
".tsx",
|
|
118
|
-
],
|
|
119
|
-
"modules": Array [],
|
|
120
|
-
},
|
|
121
|
-
"resolveLoader": Object {
|
|
122
|
-
"modules": Array [
|
|
123
|
-
"node_modules",
|
|
124
|
-
"/app/react/src/server/__mocks__/react-scripts-2-1-0/node_modules",
|
|
125
|
-
],
|
|
126
|
-
},
|
|
127
|
-
}
|
|
128
|
-
`;
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("core-js/modules/es.string.replace");
|
|
4
|
-
|
|
5
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
6
|
-
|
|
7
|
-
var _path = _interopRequireDefault(require("path"));
|
|
8
|
-
|
|
9
|
-
var _craConfig = require("./cra-config");
|
|
10
|
-
|
|
11
|
-
var _mockRules = _interopRequireDefault(require("./__mocks__/mockRules"));
|
|
12
|
-
|
|
13
|
-
var _mockConfig = _interopRequireDefault(require("./__mocks__/mockConfig"));
|
|
14
|
-
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
|
|
17
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
|
18
|
-
|
|
19
|
-
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; }
|
|
20
|
-
|
|
21
|
-
jest.mock('fs', () => ({
|
|
22
|
-
realpathSync: jest.fn(() => '/test-project'),
|
|
23
|
-
readFileSync: jest.fn(),
|
|
24
|
-
existsSync: jest.fn(() => true)
|
|
25
|
-
}));
|
|
26
|
-
jest.mock('mini-css-extract-plugin', () => {});
|
|
27
|
-
const SCRIPT_PATH = '.bin/react-scripts';
|
|
28
|
-
|
|
29
|
-
const stripCwd = loaderPath => loaderPath.replace(process.cwd(), '');
|
|
30
|
-
|
|
31
|
-
describe('cra-config', () => {
|
|
32
|
-
describe('when used with the default react-scripts package', () => {
|
|
33
|
-
beforeEach(() => {
|
|
34
|
-
_fs.default.realpathSync.mockImplementationOnce(filePath => filePath.replace(SCRIPT_PATH, `react-scripts/${SCRIPT_PATH}`));
|
|
35
|
-
});
|
|
36
|
-
it('should locate the react-scripts package', () => {
|
|
37
|
-
expect((0, _craConfig.getReactScriptsPath)({
|
|
38
|
-
noCache: true
|
|
39
|
-
})).toEqual('/test-project/node_modules/react-scripts');
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
describe('when used with a custom react-scripts package', () => {
|
|
43
|
-
beforeEach(() => {
|
|
44
|
-
_fs.default.realpathSync.mockImplementationOnce(filePath => filePath.replace(SCRIPT_PATH, `custom-react-scripts/${SCRIPT_PATH}`));
|
|
45
|
-
});
|
|
46
|
-
it('should locate the react-scripts package', () => {
|
|
47
|
-
expect((0, _craConfig.getReactScriptsPath)({
|
|
48
|
-
noCache: true
|
|
49
|
-
})).toEqual('/test-project/node_modules/custom-react-scripts');
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
describe('when used with a custom react-scripts package without symlinks in .bin folder', () => {
|
|
53
|
-
beforeEach(() => {
|
|
54
|
-
// In case of .bin/react-scripts is not symlink (like it happens on Windows),
|
|
55
|
-
// realpathSync() method does not translate the path.
|
|
56
|
-
_fs.default.realpathSync.mockImplementationOnce(filePath => filePath);
|
|
57
|
-
|
|
58
|
-
_fs.default.readFileSync.mockImplementationOnce(() => `#!/bin/sh
|
|
59
|
-
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
60
|
-
|
|
61
|
-
case \`uname\` in
|
|
62
|
-
*CYGWIN*) basedir=\`cygpath -w "$basedir"\`;;
|
|
63
|
-
esac
|
|
64
|
-
|
|
65
|
-
if [ -x "$basedir/node" ]; then
|
|
66
|
-
"$basedir/node" "$basedir/../custom-react-scripts/bin/react-scripts.js" "$@"
|
|
67
|
-
ret=$?
|
|
68
|
-
else
|
|
69
|
-
node "$basedir/../custom-react-scripts/bin/react-scripts.js" "$@"
|
|
70
|
-
ret=$?
|
|
71
|
-
fi
|
|
72
|
-
exit $ret`);
|
|
73
|
-
});
|
|
74
|
-
it('should locate the react-scripts package', () => {
|
|
75
|
-
expect((0, _craConfig.getReactScriptsPath)({
|
|
76
|
-
noCache: true
|
|
77
|
-
})).toEqual('/test-project/node_modules/custom-react-scripts');
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
describe('when used with TypeScript', () => {
|
|
81
|
-
it('should return the correct config', () => {
|
|
82
|
-
// Normalise the return, as we know our new rules object will be an array, whereas a string is expected.
|
|
83
|
-
const rules = (0, _craConfig.getTypeScriptRules)(_mockRules.default, './.storybook');
|
|
84
|
-
|
|
85
|
-
const rulesObject = _objectSpread({}, rules[0], {
|
|
86
|
-
include: rules[0].include[0]
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
expect(rulesObject).toMatchObject(_mockRules.default[2].oneOf[1]);
|
|
90
|
-
}); // Allows using TypeScript in the `.storybook` (or config) folder.
|
|
91
|
-
|
|
92
|
-
it('should add the Storybook config directory to `include`', () => {
|
|
93
|
-
const rules = (0, _craConfig.getTypeScriptRules)(_mockRules.default, './.storybook');
|
|
94
|
-
expect(rules[0].include.findIndex(string => string.includes('.storybook'))).toEqual(1);
|
|
95
|
-
});
|
|
96
|
-
it('should get the baseUrl from a tsconfig.json', () => {
|
|
97
|
-
jest.spyOn(_path.default, 'join').mockImplementation(() => 'project/tsconfig.json');
|
|
98
|
-
jest.mock('project/tsconfig.json', () => ({
|
|
99
|
-
compilerOptions: {
|
|
100
|
-
baseUrl: 'src'
|
|
101
|
-
}
|
|
102
|
-
}), {
|
|
103
|
-
virtual: true
|
|
104
|
-
});
|
|
105
|
-
expect((0, _craConfig.getModulePath)()).toEqual('src');
|
|
106
|
-
|
|
107
|
-
_path.default.join.mockRestore();
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
describe('when used with react-scripts < 2.1.0', () => {
|
|
111
|
-
beforeEach(() => {
|
|
112
|
-
_fs.default.realpathSync.mockImplementationOnce(() => _path.default.join(__dirname, '__mocks__/react-scripts-2-0-0/sub1/sub2'));
|
|
113
|
-
|
|
114
|
-
(0, _craConfig.getReactScriptsPath)({
|
|
115
|
-
noCache: true
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
it('should apply styling webpack rules', () => {
|
|
119
|
-
const webpackConfig = (0, _craConfig.applyCRAWebpackConfig)(_mockConfig.default, '/test-project'); // We don't want full paths in snapshots.
|
|
120
|
-
|
|
121
|
-
webpackConfig.resolveLoader.modules = webpackConfig.resolveLoader.modules.map(stripCwd);
|
|
122
|
-
expect(webpackConfig).toMatchSnapshot();
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
describe('when used with react-scripts >= 2.1.0', () => {
|
|
126
|
-
beforeEach(() => {
|
|
127
|
-
_fs.default.realpathSync.mockImplementationOnce(() => _path.default.join(__dirname, '__mocks__/react-scripts-2-1-0/sub1/sub2'));
|
|
128
|
-
|
|
129
|
-
(0, _craConfig.getReactScriptsPath)({
|
|
130
|
-
noCache: true
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
it('should apply Babel, styling rules and merge plugins', () => {
|
|
134
|
-
const webpackConfig = (0, _craConfig.applyCRAWebpackConfig)(_mockConfig.default, '/test-project'); // We don't want full paths in snapshots.
|
|
135
|
-
|
|
136
|
-
webpackConfig.resolveLoader.modules = webpackConfig.resolveLoader.modules.map(stripCwd);
|
|
137
|
-
expect(webpackConfig).toMatchSnapshot();
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var preset = _interopRequireWildcard(require("./framework-preset-react-docgen"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
6
|
-
|
|
7
|
-
describe('framework-preset-react-docgen', () => {
|
|
8
|
-
const babelPluginReactDocgenPath = require.resolve('babel-plugin-react-docgen');
|
|
9
|
-
|
|
10
|
-
it('should return the config with the extra plugins when `plugins` is an array.', () => {
|
|
11
|
-
const babelConfig = {
|
|
12
|
-
babelrc: false,
|
|
13
|
-
presets: ['env', 'foo-preset'],
|
|
14
|
-
plugins: ['foo-plugin']
|
|
15
|
-
};
|
|
16
|
-
const config = preset.babel(babelConfig);
|
|
17
|
-
expect(config).toEqual({
|
|
18
|
-
babelrc: false,
|
|
19
|
-
plugins: ['foo-plugin', [babelPluginReactDocgenPath, {
|
|
20
|
-
DOC_GEN_COLLECTION_NAME: 'STORYBOOK_REACT_CLASSES'
|
|
21
|
-
}]],
|
|
22
|
-
presets: ['env', 'foo-preset']
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
it('should return the config with the extra plugins when `plugins` is not an array.', () => {
|
|
26
|
-
const babelConfig = {
|
|
27
|
-
babelrc: false,
|
|
28
|
-
presets: ['env', 'foo-preset'],
|
|
29
|
-
plugins: 'bar-plugin'
|
|
30
|
-
};
|
|
31
|
-
const config = preset.babel(babelConfig);
|
|
32
|
-
expect(config).toEqual({
|
|
33
|
-
babelrc: false,
|
|
34
|
-
plugins: ['bar-plugin', [babelPluginReactDocgenPath, {
|
|
35
|
-
DOC_GEN_COLLECTION_NAME: 'STORYBOOK_REACT_CLASSES'
|
|
36
|
-
}]],
|
|
37
|
-
presets: ['env', 'foo-preset']
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
it('should return the config only with the extra plugins when `plugins` is not present.', () => {
|
|
41
|
-
const babelConfig = {
|
|
42
|
-
babelrc: false,
|
|
43
|
-
presets: ['env', 'foo-preset']
|
|
44
|
-
};
|
|
45
|
-
const config = preset.babel(babelConfig);
|
|
46
|
-
expect(config).toEqual({
|
|
47
|
-
babelrc: false,
|
|
48
|
-
plugins: [[babelPluginReactDocgenPath, {
|
|
49
|
-
DOC_GEN_COLLECTION_NAME: 'STORYBOOK_REACT_CLASSES'
|
|
50
|
-
}]],
|
|
51
|
-
presets: ['env', 'foo-preset']
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
});
|