@corespeed/webpack 0.1.0-beta.2 → 0.1.0-beta.3

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/dist/index.cjs CHANGED
@@ -21,7 +21,7 @@ var installPkg = require('@antfu/install-pkg');
21
21
  var castArray = require('foxts/cast-array');
22
22
  var LightningCSS = require('lightningcss');
23
23
  var reactCompilerWebpack = require('react-compiler-webpack');
24
- var TerserPlugin = require('terser-webpack-plugin');
24
+ var TerserWebpackPlugin = require('terser-webpack-plugin');
25
25
  var lightningcssLoader = require('lightningcss-loader');
26
26
  var path = require('node:path');
27
27
 
@@ -38,7 +38,7 @@ var MiniCssExtractPlugin__default = /*#__PURE__*/_interopDefault(MiniCssExtractP
38
38
  var TsconfigPathsPlugin__default = /*#__PURE__*/_interopDefault(TsconfigPathsPlugin);
39
39
  var isCI__default = /*#__PURE__*/_interopDefault(isCI);
40
40
  var LightningCSS__default = /*#__PURE__*/_interopDefault(LightningCSS);
41
- var TerserPlugin__default = /*#__PURE__*/_interopDefault(TerserPlugin);
41
+ var TerserWebpackPlugin__default = /*#__PURE__*/_interopDefault(TerserWebpackPlugin);
42
42
  var path__default = /*#__PURE__*/_interopDefault(path);
43
43
 
44
44
  function getSupportedBrowsers(browserlists, dir, isDevelopment) {
@@ -409,10 +409,7 @@ const loaders = ({ cwd, postcss, svgr, reactCompiler, webpackExperimentalBuiltin
409
409
  },
410
410
  {
411
411
  test: /assets\//,
412
- type: 'asset/resource',
413
- generator: {
414
- filename: '_assets/[hash][ext][query]'
415
- }
412
+ type: 'asset/resource'
416
413
  }
417
414
  ]
418
415
  });
@@ -485,19 +482,21 @@ const loaders = ({ cwd, postcss, svgr, reactCompiler, webpackExperimentalBuiltin
485
482
  // };
486
483
  };
487
484
 
488
- const optimization = ({ development: isDevelopment, browserlists }, { supportedBrowsers })=>(config)=>{
485
+ const optimization = ({ development: isDevelopment, browserlists, dropConsoleInProduction }, { supportedBrowsers })=>(config)=>{
489
486
  config.optimization ??= {};
490
487
  config.optimization.emitOnErrors = !isDevelopment;
491
488
  config.optimization.checkWasmTypes = false;
492
489
  config.optimization.nodeEnv = false; // we manually bring our own DefinePlugin
493
490
  config.optimization.minimizer ??= [];
494
- config.optimization.minimizer.push(new TerserPlugin__default.default({
495
- minify: TerserPlugin__default.default.swcMinify,
491
+ config.optimization.minimizer.push(new TerserWebpackPlugin__default.default({
492
+ minify: TerserWebpackPlugin__default.default.swcMinify,
496
493
  terserOptions: {
497
494
  compress: {
498
495
  ecma: 2018,
499
496
  comparisons: false,
500
- inline: 2 // https://github.com/vercel/next.js/issues/7178#issuecomment-493048965
497
+ inline: 2,
498
+ // inline: 1,
499
+ drop_console: isDevelopment ? false : dropConsoleInProduction
501
500
  },
502
501
  mangle: {
503
502
  safari10: true
@@ -630,6 +629,7 @@ const splitChunks = ({ cwd, topLevelFrameworkPackages })=>(config)=>{
630
629
  plugins: [],
631
630
  dotenv: {},
632
631
  lodashTreeShaking: false,
632
+ dropConsoleInProduction: true,
633
633
  ...options
634
634
  };
635
635
  // dotenv
package/dist/index.d.ts CHANGED
@@ -46,10 +46,12 @@ interface CreateWebpackOptions {
46
46
  * Path to HTML template file.
47
47
  *
48
48
  * This will be used by `html-webpack-plugin` to generate the final `index.html`.
49
+ * Default to `./src/index.html`, but you can set it to `null`, `undefined` or `false` to disable `html-webpack-plugin`.
49
50
  *
50
- * If not specificied, the `html-webpack-plugin` will not be enabled
51
+ * @default './src/index.html'
52
+
51
53
  */
52
- htmlTemplatePath?: string;
54
+ htmlTemplatePath?: string | null | undefined | false;
53
55
  output?: {
54
56
  /**
55
57
  * `output.path`, where the built files will be emitted to.
@@ -199,6 +201,15 @@ interface CreateWebpackOptions {
199
201
  */
200
202
  plugins?: Configuration['plugins'];
201
203
  dotenv?: boolean | DotenvConfigOptions;
204
+ /**
205
+ * Remove all `console.*` calls in production build.
206
+ * Uses `swc` compiler's built-in capability to do so.
207
+ *
208
+ * If you need console statements in production, set this option to `false`.
209
+ *
210
+ * @default true
211
+ */
212
+ dropConsoleInProduction?: boolean;
202
213
  /**
203
214
  * By default we will use "browserlists" package to looking for config, like `.browserslistrc` file or `browserslist` field in `package.json`, etc.
204
215
  *
package/dist/index.mjs CHANGED
@@ -19,7 +19,7 @@ import { installPackage } from '@antfu/install-pkg';
19
19
  import { castArray } from 'foxts/cast-array';
20
20
  import LightningCSS, { browserslistToTargets } from 'lightningcss';
21
21
  import { defineReactCompilerLoaderOption, reactCompilerLoader } from 'react-compiler-webpack';
22
- import TerserPlugin from 'terser-webpack-plugin';
22
+ import TerserWebpackPlugin from 'terser-webpack-plugin';
23
23
  import { LightningCssMinifyPlugin } from 'lightningcss-loader';
24
24
  import path from 'node:path';
25
25
 
@@ -393,10 +393,7 @@ const loaders = ({ cwd, postcss, svgr, reactCompiler, webpackExperimentalBuiltin
393
393
  },
394
394
  {
395
395
  test: /assets\//,
396
- type: 'asset/resource',
397
- generator: {
398
- filename: '_assets/[hash][ext][query]'
399
- }
396
+ type: 'asset/resource'
400
397
  }
401
398
  ]
402
399
  });
@@ -469,19 +466,21 @@ const loaders = ({ cwd, postcss, svgr, reactCompiler, webpackExperimentalBuiltin
469
466
  // };
470
467
  };
471
468
 
472
- const optimization = ({ development: isDevelopment, browserlists }, { supportedBrowsers })=>(config)=>{
469
+ const optimization = ({ development: isDevelopment, browserlists, dropConsoleInProduction }, { supportedBrowsers })=>(config)=>{
473
470
  config.optimization ??= {};
474
471
  config.optimization.emitOnErrors = !isDevelopment;
475
472
  config.optimization.checkWasmTypes = false;
476
473
  config.optimization.nodeEnv = false; // we manually bring our own DefinePlugin
477
474
  config.optimization.minimizer ??= [];
478
- config.optimization.minimizer.push(new TerserPlugin({
479
- minify: TerserPlugin.swcMinify,
475
+ config.optimization.minimizer.push(new TerserWebpackPlugin({
476
+ minify: TerserWebpackPlugin.swcMinify,
480
477
  terserOptions: {
481
478
  compress: {
482
479
  ecma: 2018,
483
480
  comparisons: false,
484
- inline: 2 // https://github.com/vercel/next.js/issues/7178#issuecomment-493048965
481
+ inline: 2,
482
+ // inline: 1,
483
+ drop_console: isDevelopment ? false : dropConsoleInProduction
485
484
  },
486
485
  mangle: {
487
486
  safari10: true
@@ -616,6 +615,7 @@ __node_cjsModule.createRequire(import.meta.url);
616
615
  plugins: [],
617
616
  dotenv: {},
618
617
  lodashTreeShaking: false,
618
+ dropConsoleInProduction: true,
619
619
  ...options
620
620
  };
621
621
  // dotenv
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corespeed/webpack",
3
- "version": "0.1.0-beta.2",
3
+ "version": "0.1.0-beta.3",
4
4
  "description": "The opinionated webpack configuration for CoreSpeed projects.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,7 +32,7 @@
32
32
  "@clack/prompts": "^0.11.0",
33
33
  "@pmmmwh/react-refresh-webpack-plugin": "^0.6.2",
34
34
  "@sentry/webpack-plugin": "^4.6.1",
35
- "@swc/core": "^1.15.7",
35
+ "@swc/core": "^1.15.8",
36
36
  "@types/webpack-bundle-analyzer": "^4.7.0",
37
37
  "browserslist": "^4.28.1",
38
38
  "clean-webpack-plugin": "^4.0.0",
@@ -51,20 +51,20 @@
51
51
  "swc-loader": "^0.2.6",
52
52
  "terser-webpack-plugin": "^5.3.16",
53
53
  "tsconfig-paths-webpack-plugin": "^4.2.0",
54
- "webpack-bundle-analyzer": "^5.1.0",
54
+ "webpack-bundle-analyzer": "^5.1.1",
55
55
  "webpackbar": "^7.0.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@svgr/webpack": "^8.1.0",
59
59
  "@swc/types": "^0.1.25",
60
- "@types/node": "^25.0.3",
60
+ "@types/node": "^25.0.6",
61
61
  "@types/webpack": "^5.28.5",
62
62
  "bumpp": "^10.3.2",
63
- "bunchee": "^6.7.0",
63
+ "bunchee": "^6.9.3",
64
64
  "core-js": "^3.47.0",
65
65
  "eslint": "^9.39.2",
66
- "eslint-config-sukka": "^8.0.6",
67
- "eslint-formatter-sukka": "^8.0.6",
66
+ "eslint-config-sukka": "^8.1.0",
67
+ "eslint-formatter-sukka": "^8.1.0",
68
68
  "typescript": "^5.9.3",
69
69
  "webpack": "^5.104.1",
70
70
  "webpack-dev-server": "^5.2.2"