@caweb/webpack 1.5.7 → 1.5.9

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.
Files changed (2) hide show
  1. package/package.json +4 -1
  2. package/webpack.config.js +31 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caweb/webpack",
3
- "version": "1.5.7",
3
+ "version": "1.5.9",
4
4
  "description": "CAWebPublishing Webpack Configuration",
5
5
  "main": "webpack.config.js",
6
6
  "files": [
@@ -37,6 +37,7 @@
37
37
  },
38
38
  "homepage": "https://github.com/CAWebPublishing/webpack#readme",
39
39
  "dependencies": {
40
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
40
41
  "@wordpress/scripts": "^30.20.0",
41
42
  "css-minimizer-webpack-plugin": "^7.0.2",
42
43
  "handlebars-loader": "^1.7.3",
@@ -45,6 +46,8 @@
45
46
  "html-webpack-skip-assets-plugin": "^1.0.4",
46
47
  "mini-css-extract-plugin": "^2.9.2",
47
48
  "rtlcss-webpack-plugin": "^4.0.7",
49
+ "thread-loader": "^4.0.2",
50
+ "ts-loader": "^9.5.4",
48
51
  "webpack": "^5.102.1",
49
52
  "webpack-dev-server": "^5.2.2",
50
53
  "webpack-remove-empty-scripts": "^1.1.1"
package/webpack.config.js CHANGED
@@ -107,18 +107,33 @@ baseConfig.module.rules.forEach((rule, i) => {
107
107
  delete rule.issuer;
108
108
  }
109
109
  break;
110
+ // silence deprecation warnings from sass
110
111
  case new RegExp(/\.(sc|sa)ss$/).toString():
111
112
  rule.use[rule.use.length-1].options.sassOptions = {
112
113
  silenceDeprecations: ['global-builtin', 'import', 'color-functions']
113
114
  };
114
115
  break;
116
+ case new RegExp(/\.m?(j|t)sx?$/).toString():
117
+ // @since @wordpress/scripts@30.20.0 babel-loader is used for js and ts files
118
+
119
+ // Added the Transform class properties syntax plugin to the babel-loader.
120
+ // @see https://babeljs.io/docs/en/babel-plugin-proposal-class-properties
121
+ rule.use[0].options.plugins.push('@babel/plugin-proposal-class-properties');
122
+
123
+ // we add thread-loader before the babel-loader
124
+ // Spawns multiple processes and split work between them. This makes faster build.
125
+ // @see https://webpack.js.org/loaders/thread-loader/
126
+ rule.use = [{
127
+ loader: 'thread-loader',
128
+ options: {
129
+ workers: -1,
130
+ },
131
+ }].concat(rule.use);
132
+
133
+ break;
115
134
  }
116
135
  });
117
136
 
118
- // we remove the WordPress CleanWebpackPlugin definition
119
- // instead we use the Webpack output.clean definition
120
- baseConfig.plugins.splice(1,1, false);
121
-
122
137
  /**
123
138
  * we remove the WordPress devServer declaration since we can only have 1 when exporting multiple configurations
124
139
  *
@@ -280,8 +295,16 @@ let webpackConfig = {
280
295
  // Handle `.tsx` and `.ts` files.
281
296
  {
282
297
  test: /\.tsx?$/,
283
- use: 'ts-loader',
284
298
  exclude: /node_modules/,
299
+ use: [
300
+ {
301
+ loader: 'ts-loader',
302
+ options: {
303
+ happyPackMode: true,
304
+ transpileOnly: true,
305
+ }
306
+ }
307
+ ],
285
308
  }
286
309
  ]
287
310
  },
@@ -293,11 +316,11 @@ let webpackConfig = {
293
316
  // @see https://webpack.js.org/configuration/externals/#externals
294
317
  externals: {
295
318
  // Third party dependencies.
296
- jquery: 'jQuery',
297
319
  underscore: '_',
320
+ jquery: 'jQuery',
298
321
  lodash: 'lodash',
299
- react: ['vendor', 'React'],
300
- 'react-dom': ['vendor', 'ReactDOM'],
322
+ react: 'React',
323
+ 'react-dom': 'ReactDOM',
301
324
 
302
325
  // WordPress dependencies.
303
326
  '@wordpress/hooks': ['vendor', 'wp', 'hooks'],