@s-ui/bundler 7.33.0-beta.0 → 7.35.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 || []
@@ -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,14 +1,21 @@
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
10
  module.exports = config => ({
9
11
  allowedHosts: 'all',
10
12
  client: {
11
- logging: 'none'
13
+ logging: 'none',
14
+ overlay: {
15
+ errors: true,
16
+ warnings: false
17
+ },
18
+ progress: true
12
19
  },
13
20
  static: {
14
21
  directory: 'public',
@@ -22,10 +29,6 @@ module.exports = config => ({
22
29
  historyApiFallback: {
23
30
  disableDotRule: true
24
31
  },
25
- onBeforeSetupMiddleware(devServer) {
26
- // This lets us open files from the runtime error overlay.
27
- devServer.app.use(errorOverlayMiddleware())
28
- },
29
32
  onAfterSetupMiddleware(devServer) {
30
33
  // This service worker file is effectively a 'no-op' that will reset any
31
34
  // previous service worker registered for the same host:port combination.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s-ui/bundler",
3
- "version": "7.33.0-beta.0",
3
+ "version": "7.35.0",
4
4
  "description": "Config-free bundler for ES6 React apps.",
5
5
  "bin": {
6
6
  "sui-bundler": "./bin/sui-bundler.js"
@@ -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