playroom 0.27.3 → 0.27.7
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/lib/getStaticTypes.js +16 -1
- package/lib/makeWebpackConfig.js +5 -19
- package/lib/start.js +19 -23
- package/package.json +4 -6
package/lib/getStaticTypes.js
CHANGED
|
@@ -4,6 +4,7 @@ const keyBy = require('lodash/keyBy');
|
|
|
4
4
|
const mapValues = require('lodash/mapValues');
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const ts = require('typescript');
|
|
7
|
+
const path = require('path');
|
|
7
8
|
|
|
8
9
|
const stringRegex = /^"(.*)"$/;
|
|
9
10
|
const parsePropType = (propType) => {
|
|
@@ -23,6 +24,7 @@ module.exports = async (playroomConfig) => {
|
|
|
23
24
|
} = playroomConfig;
|
|
24
25
|
|
|
25
26
|
const tsConfigPath = await findUp('tsconfig.json', { cwd });
|
|
27
|
+
const basePath = path.dirname(tsConfigPath);
|
|
26
28
|
|
|
27
29
|
if (!tsConfigPath) {
|
|
28
30
|
return {};
|
|
@@ -38,12 +40,25 @@ module.exports = async (playroomConfig) => {
|
|
|
38
40
|
throw error;
|
|
39
41
|
}
|
|
40
42
|
|
|
43
|
+
const { options, errors } = ts.parseJsonConfigFileContent(
|
|
44
|
+
config,
|
|
45
|
+
ts.sys,
|
|
46
|
+
basePath,
|
|
47
|
+
{},
|
|
48
|
+
tsConfigPath
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
if (errors && errors.length) {
|
|
52
|
+
console.error('Error parsing tsConfig file.');
|
|
53
|
+
throw errors[0];
|
|
54
|
+
}
|
|
55
|
+
|
|
41
56
|
try {
|
|
42
57
|
const files = await fastGlob(typeScriptFiles, { cwd, absolute: true });
|
|
43
58
|
const types = require('react-docgen-typescript')
|
|
44
59
|
.withCompilerOptions(
|
|
45
60
|
{
|
|
46
|
-
...
|
|
61
|
+
...options,
|
|
47
62
|
noErrorTruncation: true,
|
|
48
63
|
},
|
|
49
64
|
{
|
package/lib/makeWebpackConfig.js
CHANGED
|
@@ -2,7 +2,7 @@ const path = require('path');
|
|
|
2
2
|
const webpack = require('webpack');
|
|
3
3
|
const { merge } = require('webpack-merge');
|
|
4
4
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
5
|
-
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
|
|
5
|
+
const FriendlyErrorsWebpackPlugin = require('@soda/friendly-errors-webpack-plugin');
|
|
6
6
|
const getStaticTypes = require('./getStaticTypes');
|
|
7
7
|
const makeDefaultWebpackConfig = require('./makeDefaultWebpackConfig');
|
|
8
8
|
|
|
@@ -18,21 +18,12 @@ module.exports = async (playroomConfig, options) => {
|
|
|
18
18
|
|
|
19
19
|
const staticTypes = await getStaticTypes(playroomConfig);
|
|
20
20
|
|
|
21
|
-
const devServerEntries = options.production
|
|
22
|
-
? []
|
|
23
|
-
: [
|
|
24
|
-
`${require.resolve('webpack-dev-server/client')}?http://localhost:${
|
|
25
|
-
playroomConfig.port
|
|
26
|
-
}`,
|
|
27
|
-
`${require.resolve('webpack/hot/dev-server')}`,
|
|
28
|
-
];
|
|
29
|
-
|
|
30
21
|
const ourConfig = {
|
|
31
22
|
mode: options.production ? 'production' : 'development',
|
|
32
23
|
entry: {
|
|
33
|
-
index: [
|
|
34
|
-
frame: [
|
|
35
|
-
preview: [
|
|
24
|
+
index: [require.resolve('../src/index.js')],
|
|
25
|
+
frame: [require.resolve('../src/frame.js')],
|
|
26
|
+
preview: [require.resolve('../src/preview.js')],
|
|
36
27
|
},
|
|
37
28
|
output: {
|
|
38
29
|
filename: '[name].[contenthash].js',
|
|
@@ -172,12 +163,7 @@ module.exports = async (playroomConfig, options) => {
|
|
|
172
163
|
filename: 'preview/index.html',
|
|
173
164
|
publicPath: '../',
|
|
174
165
|
}),
|
|
175
|
-
...(options.production
|
|
176
|
-
? []
|
|
177
|
-
: [
|
|
178
|
-
new webpack.HotModuleReplacementPlugin(),
|
|
179
|
-
new FriendlyErrorsWebpackPlugin(),
|
|
180
|
-
]),
|
|
166
|
+
...(options.production ? [] : [new FriendlyErrorsWebpackPlugin()]),
|
|
181
167
|
],
|
|
182
168
|
devtool: !options.production && 'eval-source-map',
|
|
183
169
|
};
|
package/lib/start.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const webpack = require('webpack');
|
|
2
2
|
const WebpackDevServer = require('webpack-dev-server');
|
|
3
|
-
const open = require('open');
|
|
4
3
|
const makeWebpackConfig = require('./makeWebpackConfig');
|
|
5
4
|
const portfinder = require('portfinder');
|
|
6
5
|
|
|
@@ -17,22 +16,6 @@ module.exports = async (config, callback) => {
|
|
|
17
16
|
},
|
|
18
17
|
}
|
|
19
18
|
);
|
|
20
|
-
const webpackDevServerConfig = {
|
|
21
|
-
hot: true,
|
|
22
|
-
stats: {},
|
|
23
|
-
noInfo: true,
|
|
24
|
-
quiet: true,
|
|
25
|
-
clientLogLevel: 'none',
|
|
26
|
-
compress: true,
|
|
27
|
-
inline: true,
|
|
28
|
-
watchOptions: { ignored: /node_modules/ },
|
|
29
|
-
// Added to prevent Webpack HMR from breaking when iframeSandbox option is used
|
|
30
|
-
// See: https://github.com/webpack/webpack-dev-server/issues/1604
|
|
31
|
-
disableHostCheck: true,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const compiler = webpack(webpackConfig);
|
|
35
|
-
const devServer = new WebpackDevServer(compiler, webpackDevServerConfig);
|
|
36
19
|
const { port, openBrowser } = config;
|
|
37
20
|
|
|
38
21
|
portfinder.getPort({ port }, function (portErr, availablePort) {
|
|
@@ -40,15 +23,28 @@ module.exports = async (config, callback) => {
|
|
|
40
23
|
console.error('portErr: ', portErr);
|
|
41
24
|
return;
|
|
42
25
|
}
|
|
43
|
-
|
|
44
|
-
|
|
26
|
+
const webpackDevServerConfig = {
|
|
27
|
+
hot: true,
|
|
28
|
+
port: availablePort,
|
|
29
|
+
open: openBrowser,
|
|
30
|
+
devMiddleware: {
|
|
31
|
+
stats: false,
|
|
32
|
+
},
|
|
33
|
+
compress: true,
|
|
34
|
+
static: {
|
|
35
|
+
watch: { ignored: /node_modules/ },
|
|
36
|
+
},
|
|
37
|
+
// Added to prevent Webpack HMR from breaking when iframeSandbox option is used
|
|
38
|
+
// See: https://github.com/webpack/webpack-dev-server/issues/1604
|
|
39
|
+
allowedHosts: 'all',
|
|
40
|
+
};
|
|
45
41
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
42
|
+
const compiler = webpack(webpackConfig);
|
|
43
|
+
const devServer = new WebpackDevServer(webpackDevServerConfig, compiler);
|
|
49
44
|
|
|
45
|
+
devServer.startCallback(() => {
|
|
50
46
|
if (typeof callback === 'function') {
|
|
51
|
-
callback(
|
|
47
|
+
callback();
|
|
52
48
|
}
|
|
53
49
|
});
|
|
54
50
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playroom",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.7",
|
|
4
4
|
"description": "Design with code, powered by your own component library",
|
|
5
5
|
"main": "utils/index.js",
|
|
6
6
|
"types": "utils/index.d.ts",
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
"@babel/preset-react": "^7.12.13",
|
|
68
68
|
"@babel/preset-typescript": "^7.13.0",
|
|
69
69
|
"@babel/standalone": "^7.13.11",
|
|
70
|
+
"@soda/friendly-errors-webpack-plugin": "^1.8.0",
|
|
70
71
|
"@types/base64-url": "^2.2.0",
|
|
71
|
-
"@types/classnames": "^2.2.11",
|
|
72
72
|
"@types/codemirror": "^0.0.108",
|
|
73
73
|
"@types/dedent": "^0.7.0",
|
|
74
74
|
"@types/history": "^4.7.8",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"@types/react-dom": "^17.0.2",
|
|
80
80
|
"autoprefixer": "^10.2.5",
|
|
81
81
|
"babel-loader": "^8.2.2",
|
|
82
|
-
"classnames": "^2.
|
|
82
|
+
"classnames": "^2.3.1",
|
|
83
83
|
"codemirror": "^5.59.4",
|
|
84
84
|
"command-line-args": "^5.1.1",
|
|
85
85
|
"command-line-usage": "^6.1.1",
|
|
@@ -89,7 +89,6 @@
|
|
|
89
89
|
"dedent": "^0.7.0",
|
|
90
90
|
"fast-glob": "^3.2.5",
|
|
91
91
|
"find-up": "^5.0.0",
|
|
92
|
-
"friendly-errors-webpack-plugin": "^1.7.0",
|
|
93
92
|
"fuzzy": "^0.1.3",
|
|
94
93
|
"history": "^5.0.0",
|
|
95
94
|
"html-webpack-plugin": "^5.3.1",
|
|
@@ -101,7 +100,6 @@
|
|
|
101
100
|
"locate-path": "^6.0.0",
|
|
102
101
|
"lodash": "^4.17.21",
|
|
103
102
|
"lz-string": "^1.4.4",
|
|
104
|
-
"open": "^8.0.2",
|
|
105
103
|
"parse-prop-types": "^0.3.0",
|
|
106
104
|
"portfinder": "^1.0.28",
|
|
107
105
|
"postcss-loader": "^5.2.0",
|
|
@@ -119,7 +117,7 @@
|
|
|
119
117
|
"url-join": "^4.0.1",
|
|
120
118
|
"use-debounce": "^3.3.0",
|
|
121
119
|
"webpack": "^5.26.0",
|
|
122
|
-
"webpack-dev-server": "^
|
|
120
|
+
"webpack-dev-server": "^4.2.0",
|
|
123
121
|
"webpack-merge": "^5.7.3"
|
|
124
122
|
},
|
|
125
123
|
"devDependencies": {
|