@s-ui/bundler 7.33.0 → 7.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,8 +8,9 @@ process.on('unhandledRejection', err => {
8
8
  const program = require('commander')
9
9
  const path = require('path')
10
10
  const WebpackDevServer = require('webpack-dev-server')
11
- const clearConsole = require('react-dev-utils/clearConsole')
12
- const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles')
11
+
12
+ const clearConsole = require('../utils/clearConsole')
13
+ const checkRequiredFiles = require('../utils/checkRequiredFiles')
13
14
  const {
14
15
  choosePort,
15
16
  prepareUrls
@@ -55,9 +56,6 @@ if (!module.parent) {
55
56
  webpackConfig.context = context || webpackConfig.context
56
57
  }
57
58
 
58
- // Don't show ugly deprecation warnings that mess with the logging
59
- process.noDeprecation = true
60
-
61
59
  const start = async ({
62
60
  config = webpackConfig,
63
61
  packagesToLink = program.linkPackage || []
@@ -85,13 +83,20 @@ const start = async ({
85
83
  })
86
84
  const compiler = createCompiler(nextConfig, urls)
87
85
  const serverConfig = createDevServerConfig(nextConfig, urls.lanUrlForConfig)
88
- const devServer = new WebpackDevServer(compiler, serverConfig)
86
+ const devServer = new WebpackDevServer(
87
+ {
88
+ ...serverConfig,
89
+ port,
90
+ host: HOST
91
+ },
92
+ compiler
93
+ )
89
94
  log.processing('❯ Starting the development server...\n')
90
- devServer.listen(port, HOST, err => {
95
+ devServer.startCallback(err => {
91
96
  if (err) return log.error(err)
92
97
  ;['SIGINT', 'SIGTERM'].forEach(sig => {
93
98
  process.on(sig, () => {
94
- devServer.close()
99
+ devServer.stop()
95
100
  process.exit()
96
101
  })
97
102
  })
@@ -1,6 +1,6 @@
1
1
  const webpack = require('webpack')
2
- const clearConsole = require('react-dev-utils/clearConsole')
3
- const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages')
2
+ const formatWebpackMessages = require('../utils/formatWebpackMessages')
3
+ const clearConsole = require('../utils/clearConsole')
4
4
  const log = require('../shared/log')
5
5
 
6
6
  const isInteractive = process.stdout.isTTY
@@ -1,51 +1,38 @@
1
- const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware')
1
+ // @ts-check
2
+
2
3
  const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware')
3
4
  const ignoredFiles = require('react-dev-utils/ignoredFiles')
4
5
 
5
- const protocol = process.env.HTTPS === 'true' ? 'https' : 'http'
6
- const host = process.env.HOST || '0.0.0.0'
6
+ const {HOST, HTTPS} = process.env
7
+ const protocol = HTTPS === 'true' ? 'https' : 'http'
8
+ const host = HOST || '0.0.0.0'
7
9
 
8
- module.exports = (config, allowedHost) => ({
9
- // Enable gzip compression of generated files.
10
- compress: true,
11
- // Silence WebpackDevServer's own logs since they're generally not useful.
12
- // It will still show compile warnings and errors with this setting.
13
- clientLogLevel: 'none',
14
- // Tell the server where to serve content from. This is only necessary if you want to serve static files from this folder as normally they come from memory
15
- contentBase: 'public',
16
- // By default files from `contentBase` will not trigger a page reload.
17
- watchContentBase: true,
18
- // Enable hot reloading server.
19
- hot: true,
20
- // Use 'ws' instead of 'sockjs-node' on server since we're using native
21
- // websockets in `webpackHotDevClient`.
22
- transportMode: 'ws',
23
- // Prevent a WS client from getting injected as we're already including
24
- // `webpackHotDevClient`.
25
- injectClient: false,
26
- // Tell the server at what URL to serve devServer.contentBase static content.
27
- publicPath: config.output.publicPath,
28
- // WebpackDevServer is noisy by default so we emit custom message instead
29
- // by listening to the compiler events with `compiler.hooks[...].tap` calls above.
30
- quiet: true,
31
- // Reportedly, this avoids CPU overload on some systems.
32
- watchOptions: {
33
- ignored: ignoredFiles(config.context)
10
+ module.exports = config => ({
11
+ allowedHosts: 'all',
12
+ client: {
13
+ logging: 'none',
14
+ overlay: {
15
+ errors: true,
16
+ warnings: false
17
+ },
18
+ progress: true
19
+ },
20
+ static: {
21
+ directory: 'public',
22
+ watch: {
23
+ ignored: ignoredFiles(config.context)
24
+ }
34
25
  },
26
+ hot: true,
35
27
  https: protocol === 'https',
36
28
  host,
37
- overlay: false,
38
29
  historyApiFallback: {
39
30
  disableDotRule: true
40
31
  },
41
- public: allowedHost,
42
- before(app) {
43
- // This lets us open files from the runtime error overlay.
44
- app.use(errorOverlayMiddleware())
45
- },
46
- after(app) {
32
+ open: true,
33
+ onAfterSetupMiddleware(devServer) {
47
34
  // This service worker file is effectively a 'no-op' that will reset any
48
35
  // previous service worker registered for the same host:port combination.
49
- app.use(noopServiceWorkerMiddleware(config.output.publicPath))
36
+ devServer.app.use(noopServiceWorkerMiddleware(config.output.publicPath))
50
37
  }
51
38
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s-ui/bundler",
3
- "version": "7.33.0",
3
+ "version": "7.34.0",
4
4
  "description": "Config-free bundler for ES6 React apps.",
5
5
  "bin": {
6
6
  "sui-bundler": "./bin/sui-bundler.js"
@@ -29,7 +29,7 @@
29
29
  "commander": "6.2.1",
30
30
  "css-loader": "4.3.0",
31
31
  "css-minimizer-webpack-plugin": "1.1.5",
32
- "esbuild-loader": "2.15.1",
32
+ "esbuild-loader": "2.16.0",
33
33
  "fast-glob": "3.2.7",
34
34
  "html-webpack-plugin": "4.5.0",
35
35
  "mini-css-extract-plugin": "1.6.0",
@@ -38,14 +38,14 @@
38
38
  "postcss-loader": "4.1.0",
39
39
  "react-dev-utils": "11.0.4",
40
40
  "rimraf": "3.0.2",
41
- "sass": "1.39.0",
41
+ "sass": "1.43.3",
42
42
  "sass-loader": "10.1.0",
43
43
  "super-sass-loader": "0.1",
44
44
  "speed-measure-webpack-plugin": "1.5.0",
45
45
  "style-loader": "2.0.0",
46
46
  "terser-webpack-plugin": "4.2.2",
47
47
  "webpack": "4.46.0",
48
- "webpack-dev-server": "3.11.2",
48
+ "webpack-dev-server": "4.3.1",
49
49
  "webpack-manifest-plugin": "4.0.2",
50
50
  "webpack-node-externals": "3.0.0"
51
51
  }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in https://github.com/facebook/create-react-app/blob/main/packages/react-dev-utils/LICENSE
6
+ */
7
+
8
+ const fs = require('fs')
9
+ const path = require('path')
10
+
11
+ function checkRequiredFiles(files) {
12
+ let currentFilePath
13
+ try {
14
+ files.forEach(filePath => {
15
+ currentFilePath = filePath
16
+ fs.accessSync(filePath, fs.F_OK)
17
+ })
18
+ return true
19
+ } catch (err) {
20
+ const dirName = path.dirname(currentFilePath)
21
+ const fileName = path.basename(currentFilePath)
22
+
23
+ console.log('Could not find a required file:')
24
+ console.log(` Name: ${fileName}`)
25
+ console.log(` Searched in: ${dirName}`)
26
+
27
+ return false
28
+ }
29
+ }
30
+
31
+ module.exports = checkRequiredFiles
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in https://github.com/facebook/create-react-app/blob/main/packages/react-dev-utils/LICENSE
6
+ */
7
+
8
+ function clearConsole() {
9
+ process.stdout.write(
10
+ process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H'
11
+ )
12
+ }
13
+
14
+ module.exports = clearConsole
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in https://github.com/facebook/create-react-app/blob/main/packages/react-dev-utils/LICENSE
6
+ */
7
+
8
+ const friendlySyntaxErrorLabel = 'Syntax error:'
9
+
10
+ function isLikelyASyntaxError(message) {
11
+ return message.includes(friendlySyntaxErrorLabel)
12
+ }
13
+
14
+ // Cleans up webpack error messages.
15
+ function formatMessage(message) {
16
+ let lines = []
17
+
18
+ if (typeof message === 'string') {
19
+ lines = message.split('\n')
20
+ } else if ('message' in message) {
21
+ lines = message.message.split('\n')
22
+ } else if (Array.isArray(message)) {
23
+ message.forEach(message => {
24
+ if ('message' in message) {
25
+ lines = message.message.split('\n')
26
+ }
27
+ })
28
+ }
29
+
30
+ // Strip webpack-added headers off errors/warnings
31
+ // https://github.com/webpack/webpack/blob/master/lib/ModuleError.js
32
+ lines = lines.filter(line => !/Module [A-z ]+\(from/.test(line))
33
+
34
+ // Transform parsing error into syntax error
35
+ // TODO: move this to our ESLint formatter?
36
+ lines = lines.map(line => {
37
+ const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(
38
+ line
39
+ )
40
+ if (!parsingError) {
41
+ return line
42
+ }
43
+ const [, errorLine, errorColumn, errorMessage] = parsingError
44
+ return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`
45
+ })
46
+
47
+ message = lines.join('\n')
48
+ // Smoosh syntax errors (commonly found in CSS)
49
+ message = message.replace(
50
+ /SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g,
51
+ `${friendlySyntaxErrorLabel} $3 ($1:$2)\n`
52
+ )
53
+ // Clean up export errors
54
+ message = message.replace(
55
+ /^.*export '(.+?)' was not found in '(.+?)'.*$/gm,
56
+ `Attempted import error: '$1' is not exported from '$2'.`
57
+ )
58
+ message = message.replace(
59
+ /^.*export 'default' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm,
60
+ `Attempted import error: '$2' does not contain a default export (imported as '$1').`
61
+ )
62
+ message = message.replace(
63
+ /^.*export '(.+?)' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm,
64
+ `Attempted import error: '$1' is not exported from '$3' (imported as '$2').`
65
+ )
66
+ lines = message.split('\n')
67
+
68
+ // Remove leading newline
69
+ if (lines.length > 2 && lines[1].trim() === '') {
70
+ lines.splice(1, 1)
71
+ }
72
+ // Clean up file name
73
+ lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, '$1')
74
+
75
+ // Cleans up verbose "module not found" messages for files and packages.
76
+ if (lines[1] && lines[1].indexOf('Module not found: ') === 0) {
77
+ lines = [
78
+ lines[0],
79
+ lines[1]
80
+ .replace('Error: ', '')
81
+ .replace('Module not found: Cannot find file:', 'Cannot find file:')
82
+ ]
83
+ }
84
+
85
+ // Add helpful message for users trying to use Sass for the first time
86
+ if (lines[1] && lines[1].match(/Cannot find module.+sass/)) {
87
+ lines[1] = 'To import Sass files, you first need to install sass.\n'
88
+ lines[1] +=
89
+ 'Run `npm install sass` or `yarn add sass` inside your workspace.'
90
+ }
91
+
92
+ message = lines.join('\n')
93
+ // Internal stacks are generally useless so we strip them... with the
94
+ // exception of stacks containing `webpack:` because they're normally
95
+ // from user code generated by webpack. For more information see
96
+ // https://github.com/facebook/create-react-app/pull/1050
97
+ message = message.replace(
98
+ /^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm,
99
+ ''
100
+ ) // at ... ...:x:y
101
+ message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, '') // at <anonymous>
102
+ lines = message.split('\n')
103
+
104
+ // Remove duplicated newlines
105
+ lines = lines.filter(
106
+ (line, index, arr) =>
107
+ index === 0 || line.trim() !== '' || line.trim() !== arr[index - 1].trim()
108
+ )
109
+
110
+ // Reassemble the message
111
+ message = lines.join('\n')
112
+ return message.trim()
113
+ }
114
+
115
+ function formatWebpackMessages(json) {
116
+ const formattedErrors = json.errors.map(formatMessage)
117
+ const formattedWarnings = json.warnings.map(formatMessage)
118
+ const result = {errors: formattedErrors, warnings: formattedWarnings}
119
+ if (result.errors.some(isLikelyASyntaxError)) {
120
+ // If there are any syntax errors, show just them.
121
+ result.errors = result.errors.filter(isLikelyASyntaxError)
122
+ }
123
+ return result
124
+ }
125
+
126
+ module.exports = formatWebpackMessages
@@ -27,6 +27,7 @@ const webpackConfig = {
27
27
  extensions: ['.js', '.json'],
28
28
  modules: ['node_modules', path.resolve(process.cwd())]
29
29
  },
30
+ stats: 'errors-only',
30
31
  entry: cleanList([
31
32
  require.resolve('react-dev-utils/webpackHotDevClient'),
32
33
  MAIN_ENTRY_POINT