@s-ui/bundler 9.7.0 → 9.8.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.8.0",
4
4
  "description": "Config-free bundler for ES6 React apps.",
5
5
  "bin": {
6
6
  "sui-bundler": "./bin/sui-bundler.js"
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.esbuildMinify,
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})
@@ -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},