@s-ui/bundler 9.7.0 → 9.10.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.
package/README.md CHANGED
@@ -163,6 +163,7 @@ This tool works with zero configuration out the box but you could use some confi
163
163
  {
164
164
  "config": {
165
165
  "sui-bundler": {
166
+ "supportLegacyBrowsers": false, // default
166
167
  "onlyHash": "true",
167
168
  "env": ["APP_NAME", ["USER", "DEFAULT_VALUE"]],
168
169
  "vendor": ["react", "react-dom"],
@@ -172,13 +173,6 @@ This tool works with zero configuration out the box but you could use some confi
172
173
  "react": "preact"
173
174
  },
174
175
  "offline": true,
175
- "targets": {
176
- "chrome": "41",
177
- "ie": "11",
178
- "safari": "8",
179
- "firefox": "60",
180
- "ios": "8"
181
- },
182
176
  "sourcemaps": {
183
177
  "dev": "cheap-module-eval-source-map",
184
178
  "prod": "hidden-source-map"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s-ui/bundler",
3
- "version": "9.7.0",
3
+ "version": "9.10.0",
4
4
  "description": "Config-free bundler for ES6 React apps.",
5
5
  "bin": {
6
6
  "sui-bundler": "./bin/sui-bundler.js"
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "homepage": "https://github.com/SUI-Components/sui/tree/master/packages/sui-bundler#readme",
23
23
  "dependencies": {
24
- "@babel/core": "7.17.2",
24
+ "@babel/core": "7.17.5",
25
25
  "@s-ui/helpers": "1",
26
26
  "@s-ui/sass-loader": "1",
27
27
  "address": "1.1.2",
@@ -32,23 +32,23 @@
32
32
  "commander": "8.3.0",
33
33
  "css-loader": "6.6.0",
34
34
  "css-minimizer-webpack-plugin": "3.4.1",
35
- "esbuild": "0.14.21",
35
+ "esbuild": "0.14.23",
36
36
  "escape-string-regexp": "4.0.0",
37
37
  "fast-glob": "3.2.11",
38
38
  "find-free-ports": "3.0.0",
39
39
  "html-webpack-plugin": "5.5.0",
40
40
  "https-browserify": "1.0.0",
41
41
  "mini-css-extract-plugin": "2.5.3",
42
- "postcss": "8.4.5",
42
+ "postcss": "8.4.6",
43
43
  "postcss-loader": "6.2.1",
44
44
  "process": "0.11.10",
45
45
  "rimraf": "3.0.2",
46
- "sass": "1.49.7",
46
+ "sass": "1.49.8",
47
47
  "stream-http": "3.2.0",
48
48
  "strip-ansi": "6.0.1",
49
49
  "style-loader": "3.3.1",
50
50
  "url": "0.11.0",
51
- "webpack": "5.69.0",
51
+ "webpack": "5.69.1",
52
52
  "webpack-dev-server": "4.7.4",
53
53
  "webpack-manifest-plugin": "4.1.1",
54
54
  "webpack-node-externals": "3.0.0"
@@ -2,23 +2,23 @@
2
2
 
3
3
  'use strict'
4
4
 
5
- var noop = function() {}
5
+ var noop = function () {}
6
6
  var SW_URL = '/service-worker.js'
7
7
 
8
8
  /* eslint-disable no-console */
9
- exports.register = function(options) {
9
+ exports.register = function (options) {
10
10
  options = options || {}
11
11
  var first = options.first || noop
12
12
  var renovate = options.renovate || noop
13
13
 
14
14
  if ('serviceWorker' in navigator) {
15
- window.addEventListener('load', function() {
15
+ window.addEventListener('load', function () {
16
16
  navigator.serviceWorker
17
17
  .register(SW_URL)
18
- .then(function(registration) {
19
- registration.onupdatefound = function() {
18
+ .then(function (registration) {
19
+ registration.onupdatefound = function () {
20
20
  var installingWorker = registration.installing
21
- installingWorker.onstatechange = function() {
21
+ installingWorker.onstatechange = function () {
22
22
  if (installingWorker.state === 'installed') {
23
23
  if (navigator.serviceWorker.controller) {
24
24
  // At this point, the old content will have been purged and
@@ -36,16 +36,16 @@ exports.register = function(options) {
36
36
  }
37
37
  }
38
38
  })
39
- .catch(function(error) {
39
+ .catch(function (error) {
40
40
  console.error('Error during service worker registration:', error)
41
41
  })
42
42
  })
43
43
  }
44
44
  }
45
45
 
46
- exports.unregister = function() {
46
+ exports.unregister = function () {
47
47
  if ('serviceWorker' in navigator) {
48
- navigator.serviceWorker.ready.then(function(registration) {
48
+ navigator.serviceWorker.ready.then(function (registration) {
49
49
  registration.unregister()
50
50
  })
51
51
  }
package/service-worker.js CHANGED
@@ -41,7 +41,7 @@ function canConstructResponseFromBodyStream() {
41
41
  * @param {Object} response
42
42
  * @returns {Promise<Response>}
43
43
  */
44
- const copyResponse = async function(response) {
44
+ const copyResponse = async function (response) {
45
45
  const clonedResponse = response.clone()
46
46
 
47
47
  const responseInit = {
package/shared/config.js CHANGED
@@ -4,8 +4,13 @@ const {
4
4
  } = require(`${process.cwd()}/package.json`)
5
5
 
6
6
  const {'sui-bundler': config = {}} = packageJsonConfig
7
- const {extractComments, sourcemaps} = config
7
+ const {
8
+ extractComments = false,
9
+ sourcemaps,
10
+ supportLegacyBrowsers = false
11
+ } = config
8
12
 
9
13
  exports.config = config
10
- exports.extractComments = extractComments || false
14
+ exports.supportLegacyBrowsers = supportLegacyBrowsers
15
+ exports.extractComments = extractComments
11
16
  exports.sourceMap = (sourcemaps && sourcemaps.prod) || false
@@ -1,6 +1,8 @@
1
1
  const TerserPlugin = require('terser-webpack-plugin')
2
2
 
3
- module.exports = ({extractComments, sourceMap}) =>
3
+ const {supportLegacyBrowsers} = require('./config.js')
4
+
5
+ const esbuildMinifier = ({sourceMap}) =>
4
6
  new TerserPlugin({
5
7
  minify: TerserPlugin.esbuildMinify,
6
8
  terserOptions: {
@@ -8,3 +10,18 @@ module.exports = ({extractComments, sourceMap}) =>
8
10
  sourcemap: sourceMap !== 'none' && sourceMap !== false
9
11
  }
10
12
  })
13
+
14
+ const terserMinifier = ({extractComments, sourceMap}) =>
15
+ new TerserPlugin({
16
+ minify: TerserPlugin.terserMinify,
17
+ extractComments,
18
+ terserOptions: {
19
+ ecma: 5,
20
+ sourceMap: sourceMap !== 'none' && sourceMap !== false
21
+ }
22
+ })
23
+
24
+ module.exports = ({extractComments, sourceMap}) =>
25
+ supportLegacyBrowsers
26
+ ? terserMinifier({extractComments, sourceMap})
27
+ : esbuildMinifier({sourceMap})
@@ -273,7 +273,7 @@ function prepareProxy(proxy, appPublicFolder, servedPathname) {
273
273
  // Modern browsers include text/html into `accept` header when navigating.
274
274
  // However API calls like `fetch()` won’t generally accept text/html.
275
275
  // If this heuristic doesn’t work well for you, use `src/setupProxy.js`.
276
- context: function(pathname, req) {
276
+ context: function (pathname, req) {
277
277
  return (
278
278
  req.method !== 'GET' ||
279
279
  (mayProxy(pathname) &&
@@ -47,7 +47,7 @@ const connection = new WebSocket(
47
47
  // Unlike WebpackDevServer client, we won't try to reconnect
48
48
  // to avoid spamming the console. Disconnect usually happens
49
49
  // when developer stops the server.
50
- connection.onclose = function() {
50
+ connection.onclose = function () {
51
51
  if (typeof console !== 'undefined' && typeof console.info === 'function') {
52
52
  console.info(
53
53
  'The development server has disconnected.\nRefresh the page if necessary.'
@@ -151,7 +151,7 @@ function handleAvailableHash(hash) {
151
151
  }
152
152
 
153
153
  // Handle messages from the server.
154
- connection.onmessage = function(e) {
154
+ connection.onmessage = function (e) {
155
155
  const message = JSON.parse(e.data)
156
156
  switch (message.type) {
157
157
  case 'hash':
@@ -242,10 +242,10 @@ function tryApplyUpdates(onHotUpdateSuccess) {
242
242
  // // webpack 2 returns a Promise instead of invoking a callback
243
243
  if (result && result.then) {
244
244
  result.then(
245
- function(updatedModules) {
245
+ function (updatedModules) {
246
246
  handleApplyUpdates(null, updatedModules)
247
247
  },
248
- function(err) {
248
+ function (err) {
249
249
  handleApplyUpdates(err, null)
250
250
  }
251
251
  )
@@ -17,7 +17,11 @@ const {
17
17
  config
18
18
  } = require('./shared/index.js')
19
19
  const {aliasFromConfig} = require('./shared/resolve-alias.js')
20
- const {extractComments, sourceMap} = require('./shared/config.js')
20
+ const {
21
+ extractComments,
22
+ sourceMap,
23
+ supportLegacyBrowsers
24
+ } = require('./shared/config.js')
21
25
  const {resolveLoader} = require('./shared/resolve-loader.js')
22
26
  const babelRules = require('./shared/module-rules-babel.js')
23
27
  const definePlugin = require('./shared/define.js')
@@ -35,13 +39,15 @@ const cssFileName = config.onlyHash
35
39
  ? '[contenthash:8].css'
36
40
  : '[name].[contenthash:8].css'
37
41
 
42
+ const target = supportLegacyBrowsers ? ['web', 'es5'] : 'web'
43
+
38
44
  /** @typedef {import('webpack').Configuration} WebpackConfig */
39
45
 
40
46
  /** @type {WebpackConfig} */
41
47
  const webpackConfig = {
42
48
  devtool: sourceMap,
43
49
  mode: 'production',
44
- target: ['web', 'es5'],
50
+ target,
45
51
  context: path.resolve(process.cwd(), 'src'),
46
52
  resolve: {
47
53
  alias: {...aliasFromConfig},