@workleap/webpack-configs 0.0.2 → 1.0.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @workleap/webpack-configs
2
2
 
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#116](https://github.com/gsoft-inc/wl-web-configs/pull/116) [`5d7f448`](https://github.com/gsoft-inc/wl-web-configs/commit/5d7f4486b80f397efb59361935c8e944fcd00d97) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Move fast-refresh package to a dependency rather than an optional peerDependency and move webpack config swcConfig as the first param
8
+
9
+ ## 1.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - [#98](https://github.com/gsoft-inc/wl-web-configs/pull/98) [`56ca32e`](https://github.com/gsoft-inc/wl-web-configs/commit/56ca32ee3194c51210aacc5189f3ebbec5a4a7b6) Thanks [@patricklafrance](https://github.com/patricklafrance)! - New start, every package has a major version bump
14
+
3
15
  ## 0.0.2
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -1,7 +1,22 @@
1
1
  # webpack-configs
2
2
 
3
- ## Gotchas to remember
3
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](../../LICENSE)
4
+ [![npm version](https://img.shields.io/npm/v/@workleap/webpack-configs)](https://www.npmjs.com/package/@workleap/webpack-configs)
4
5
 
5
- ### Add the @swc/helpers packages to all monorepo imported projects having JSX code
6
+ ## Usage
7
+
8
+ View the [user's documentation](https://gsoft-inc.github.io/wl-web-configs/).
9
+
10
+ ## 🤝 Contributing
11
+
12
+ View the [contributor's documentation](../../CONTRIBUTING.md).
13
+
14
+ ### Notes
15
+
16
+ #### Add the @swc/helpers packages to all monorepo imported projects having JSX code
6
17
 
7
18
  To work properly, all projects having React/JSX code that are referenced by the host project must also install `@swc/helpers` as a `devDependency`.
19
+
20
+ ## License
21
+
22
+ Copyright © 2023, Workleap. This code is licensed under the Apache License, Version 2.0. You may obtain a copy of this license at https://github.com/gsoft-inc/workleap-license/blob/master/LICENSE.
package/dist/build.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Config } from '@swc/core';
2
2
  import HtmlWebpackPlugin from 'html-webpack-plugin';
3
3
  import MiniCssExtractPlugin from 'mini-css-extract-plugin';
4
- import webpack, { Configuration } from 'webpack';
4
+ import { Configuration } from 'webpack';
5
5
  import { WebpackConfigTransformer } from './transformers/applyTransformers.js';
6
6
 
7
7
  type MiniCssExtractPluginOptions = NonNullable<ConstructorParameters<typeof MiniCssExtractPlugin>[number]>;
@@ -13,15 +13,13 @@ interface DefineBuildConfigOptions {
13
13
  publicPath?: string;
14
14
  moduleRules?: NonNullable<Configuration["module"]>["rules"];
15
15
  plugins?: Configuration["plugins"];
16
- htmlWebpackPlugin?: HtmlWebpackPlugin.Options;
17
- miniCssExtractPlugin?: MiniCssExtractPluginOptions;
16
+ htmlWebpackPluginOptions?: HtmlWebpackPlugin.Options;
17
+ miniCssExtractPluginOptions?: MiniCssExtractPluginOptions;
18
18
  minify?: boolean;
19
19
  cssModules?: boolean;
20
- postcssConfigFilePath?: string;
21
- swcConfig: Config;
22
20
  environmentVariables?: Record<string, string | undefined>;
23
21
  transformers?: WebpackConfigTransformer[];
24
22
  }
25
- declare function defineBuildConfig(options: DefineBuildConfigOptions): webpack.Configuration;
23
+ declare function defineBuildConfig(swcConfig: Config, options?: DefineBuildConfigOptions): Configuration;
26
24
 
27
25
  export { DefineBuildConfigOptions, defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig };
package/dist/build.js CHANGED
@@ -1,2 +1,2 @@
1
- export { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig } from './chunk-XOV4FKHU.js';
1
+ export { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig } from './chunk-Z4O6KPRR.js';
2
2
  import './chunk-URL2KA63.js';
@@ -107,7 +107,7 @@ function addBeforeModuleRule(config, matcher, newModuleRules) {
107
107
  match.parent.splice(match.index, 0, ...newModuleRules);
108
108
  } else {
109
109
  const matcherInfo = matcher.info;
110
- console.log(`[webpack-configs] Couldn't add the new module rules because no match has been found.
110
+ throw new Error(`[webpack-configs] Couldn't add the new module rules because no match has been found.
111
111
  [webpack-configs] Matcher: "${JSON.stringify(matcherInfo)}"`);
112
112
  }
113
113
  }
@@ -117,7 +117,7 @@ function addAfterModuleRule(config, matcher, newModuleRules) {
117
117
  match.parent.splice(match.index + 1, 0, ...newModuleRules);
118
118
  } else {
119
119
  const matcherInfo = matcher.info;
120
- console.log(`[webpack-configs] Couldn't add the new module rules because no match has been found.
120
+ throw new Error(`[webpack-configs] Couldn't add the new module rules because no match has been found.
121
121
  [webpack-configs] Matcher: "${JSON.stringify(matcherInfo)}"`);
122
122
  }
123
123
  }
@@ -127,7 +127,7 @@ function replaceModuleRule(config, matcher, newModuleRule) {
127
127
  match.parent[match.index] = newModuleRule;
128
128
  } else {
129
129
  const matcherInfo = matcher.info;
130
- console.log(`[webpack-configs] Couldn't replace the module rule because no match has been found.
130
+ throw new Error(`[webpack-configs] Couldn't replace the module rule because no match has been found.
131
131
  [webpack-configs] Matcher: "${JSON.stringify(matcherInfo)}"`);
132
132
  }
133
133
  }
@@ -146,7 +146,7 @@ function removeModuleRules(config, matcher) {
146
146
  });
147
147
  } else {
148
148
  const matcherInfo = matcher.info;
149
- console.log(`[webpack-configs] Didn't remove any module rules because no match has been found.
149
+ throw new Error(`[webpack-configs] Didn't remove any module rules because no match has been found.
150
150
  [webpack-configs] Matcher: "${matcherInfo}"`);
151
151
  }
152
152
  }
@@ -39,7 +39,7 @@ function tryEnableSwcReactRefresh(config) {
39
39
  }
40
40
  return config;
41
41
  }
42
- function defineDevConfig(options) {
42
+ function defineDevConfig(swcConfig, options = {}) {
43
43
  preflight(options);
44
44
  const {
45
45
  entry = path.resolve("./src/index.tsx"),
@@ -53,8 +53,6 @@ function defineDevConfig(options) {
53
53
  htmlWebpackPluginOptions = defineDevHtmlWebpackPluginConfig(),
54
54
  fastRefresh = false,
55
55
  cssModules = false,
56
- postcssConfigFilePath,
57
- swcConfig,
58
56
  environmentVariables,
59
57
  transformers = []
60
58
  } = options;
@@ -63,7 +61,9 @@ function defineDevConfig(options) {
63
61
  target: "web",
64
62
  devtool: "eval-cheap-module-source-map",
65
63
  devServer: {
66
- hot: !fastRefresh,
64
+ // According to the Fast Refresh plugin documentation, hot should be "true" to enable Fast Refresh:
65
+ // https://github.com/pmmmwh/react-refresh-webpack-plugin#usage.
66
+ hot: true,
67
67
  https,
68
68
  host,
69
69
  port,
@@ -117,14 +117,7 @@ function defineDevConfig(options) {
117
117
  modules: true
118
118
  } : void 0
119
119
  },
120
- {
121
- loader: require2.resolve("postcss-loader"),
122
- options: postcssConfigFilePath ? {
123
- postcssOptions: {
124
- config: postcssConfigFilePath
125
- }
126
- } : void 0
127
- }
120
+ { loader: require2.resolve("postcss-loader") }
128
121
  ]
129
122
  },
130
123
  {
@@ -33,7 +33,7 @@ function replacePlugin(config, matcher, newPlugin) {
33
33
  config.plugins[match.index] = newPlugin;
34
34
  } else {
35
35
  const matcherInfo = matcher.info;
36
- console.log(`[webpack-configs] Couldn't replace the plugin because no match has been found.
36
+ throw new Error(`[webpack-configs] Couldn't replace the plugin because no match has been found.
37
37
  [webpack-configs] Matcher: "${JSON.stringify(matcherInfo)}"`);
38
38
  }
39
39
  }
@@ -43,7 +43,7 @@ function addBeforePlugin(config, matcher, newPlugins) {
43
43
  config.plugins?.splice(match.index, 0, ...newPlugins);
44
44
  } else {
45
45
  const matcherInfo = matcher.info;
46
- console.log(`[webpack-configs] Couldn't add the new plugins because no match has been found.
46
+ throw new Error(`[webpack-configs] Couldn't add the new plugins because no match has been found.
47
47
  [webpack-configs] Matcher: "${JSON.stringify(matcherInfo)}"`);
48
48
  }
49
49
  }
@@ -53,7 +53,7 @@ function addAfterPlugin(config, matcher, newPlugins) {
53
53
  config.plugins?.splice(match.index + 1, 0, ...newPlugins);
54
54
  } else {
55
55
  const matcherInfo = matcher.info;
56
- console.log(`[webpack-configs] Couldn't add the new plugins because no match has been found.
56
+ throw new Error(`[webpack-configs] Couldn't add the new plugins because no match has been found.
57
57
  [webpack-configs] Matcher: "${JSON.stringify(matcherInfo)}"`);
58
58
  }
59
59
  }
@@ -63,7 +63,7 @@ function removePlugin(config, matcher) {
63
63
  const countAfter = config.plugins?.length ?? 0;
64
64
  if (countBefore === countAfter) {
65
65
  const matcherInfo = matcher.info;
66
- console.log(`[webpack-configs] Didn't remove any plugin because no match has been found.
66
+ throw new Error(`[webpack-configs] Didn't remove any plugin because no match has been found.
67
67
  [webpack-configs] Matcher: "${JSON.stringify(matcherInfo)}"`);
68
68
  }
69
69
  }
@@ -28,7 +28,7 @@ function defineMiniCssExtractPluginConfig(options = {}) {
28
28
  filename
29
29
  };
30
30
  }
31
- function defineBuildConfig(options) {
31
+ function defineBuildConfig(swcConfig, options = {}) {
32
32
  const {
33
33
  entry = path.resolve("./src/index.tsx"),
34
34
  outputPath = path.resolve("dist"),
@@ -36,12 +36,10 @@ function defineBuildConfig(options) {
36
36
  publicPath = "http://localhost:8080/",
37
37
  moduleRules = [],
38
38
  plugins = [],
39
- htmlWebpackPlugin = defineBuildHtmlWebpackPluginConfig(),
40
- miniCssExtractPlugin = defineMiniCssExtractPluginConfig(),
39
+ htmlWebpackPluginOptions = defineBuildHtmlWebpackPluginConfig(),
40
+ miniCssExtractPluginOptions = defineMiniCssExtractPluginConfig(),
41
41
  minify = true,
42
42
  cssModules = false,
43
- postcssConfigFilePath,
44
- swcConfig,
45
43
  environmentVariables,
46
44
  transformers = []
47
45
  } = options;
@@ -95,14 +93,7 @@ function defineBuildConfig(options) {
95
93
  modules: true
96
94
  } : void 0
97
95
  },
98
- {
99
- loader: require2.resolve("postcss-loader"),
100
- options: postcssConfigFilePath ? {
101
- postcssOptions: {
102
- config: postcssConfigFilePath
103
- }
104
- } : void 0
105
- }
96
+ { loader: require2.resolve("postcss-loader") }
106
97
  ]
107
98
  },
108
99
  {
@@ -120,8 +111,8 @@ function defineBuildConfig(options) {
120
111
  extensions: [".js", ".jsx", ".ts", ".tsx", ".css"]
121
112
  },
122
113
  plugins: [
123
- new HtmlWebpackPlugin(htmlWebpackPlugin),
124
- new MiniCssExtractPlugin(miniCssExtractPlugin),
114
+ new HtmlWebpackPlugin(htmlWebpackPluginOptions),
115
+ new MiniCssExtractPlugin(miniCssExtractPluginOptions),
125
116
  new DefinePlugin({
126
117
  // Parenthesis around the stringified object are mandatory otherwise it breaks
127
118
  // at build time.
package/dist/dev.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ReactRefreshPluginOptions } from '@pmmmwh/react-refresh-webpack-plugin/types/lib/types.d.ts';
2
2
  import { Config } from '@swc/core';
3
3
  import HtmlWebpackPlugin from 'html-webpack-plugin';
4
- import webpack, { Configuration } from 'webpack';
4
+ import { Configuration } from 'webpack';
5
5
  import { WebpackConfigTransformer } from './transformers/applyTransformers.js';
6
6
 
7
7
  declare function defineDevHtmlWebpackPluginConfig(options?: HtmlWebpackPlugin.Options): HtmlWebpackPlugin.Options;
@@ -18,11 +18,9 @@ interface DefineDevConfigOptions {
18
18
  htmlWebpackPluginOptions?: HtmlWebpackPlugin.Options;
19
19
  fastRefresh?: boolean | ReactRefreshPluginOptions;
20
20
  cssModules?: boolean;
21
- postcssConfigFilePath?: string;
22
- swcConfig: Config;
23
21
  environmentVariables?: Record<string, string | undefined>;
24
22
  transformers?: WebpackConfigTransformer[];
25
23
  }
26
- declare function defineDevConfig(options: DefineDevConfigOptions): webpack.Configuration;
24
+ declare function defineDevConfig(swcConfig: Config, options?: DefineDevConfigOptions): Configuration;
27
25
 
28
26
  export { DefineDevConfigOptions, defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig };
package/dist/dev.js CHANGED
@@ -1,3 +1,3 @@
1
- export { defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './chunk-ZKKR575Q.js';
1
+ export { defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './chunk-DSXM2GXS.js';
2
2
  import './chunk-P2Z3EEVF.js';
3
3
  import './chunk-URL2KA63.js';
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { Configuration as WebpackConfig } from 'webpack';
1
2
  export { DefineBuildConfigOptions, defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig } from './build.js';
2
3
  export { DefineDevConfigOptions, defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './dev.js';
3
4
  export { WebpackConfigTransformer, WebpackConfigTransformerContext } from './transformers/applyTransformers.js';
@@ -6,5 +7,4 @@ export { PluginMatch, PluginMatcher, WebpackPlugin, WithPluginMatcherInfo, addAf
6
7
  import '@swc/core';
7
8
  import 'html-webpack-plugin';
8
9
  import 'mini-css-extract-plugin';
9
- import 'webpack';
10
10
  import '@pmmmwh/react-refresh-webpack-plugin/types/lib/types.d.ts';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig } from './chunk-XOV4FKHU.js';
2
- export { defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './chunk-ZKKR575Q.js';
1
+ export { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig } from './chunk-Z4O6KPRR.js';
2
+ export { defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './chunk-DSXM2GXS.js';
3
3
  import './chunk-P2Z3EEVF.js';
4
4
  import './chunk-URL2KA63.js';
5
- export { addAfterModuleRule, addBeforeModuleRule, findModuleRule, findModuleRules, matchAssetModuleType, matchLoaderName, matchTest, removeModuleRules, replaceModuleRule } from './chunk-YF3OAEUP.js';
6
- export { addAfterPlugin, addBeforePlugin, findPlugin, matchConstructorName, removePlugin, replacePlugin } from './chunk-GSID5BLX.js';
5
+ export { addAfterModuleRule, addBeforeModuleRule, findModuleRule, findModuleRules, matchAssetModuleType, matchLoaderName, matchTest, removeModuleRules, replaceModuleRule } from './chunk-34O5ZLZ6.js';
6
+ export { addAfterPlugin, addBeforePlugin, findPlugin, matchConstructorName, removePlugin, replacePlugin } from './chunk-JPURRV2F.js';
@@ -1 +1 @@
1
- export { addAfterModuleRule, addBeforeModuleRule, findModuleRule, findModuleRules, matchAssetModuleType, matchLoaderName, matchTest, removeModuleRules, replaceModuleRule } from '../chunk-YF3OAEUP.js';
1
+ export { addAfterModuleRule, addBeforeModuleRule, findModuleRule, findModuleRules, matchAssetModuleType, matchLoaderName, matchTest, removeModuleRules, replaceModuleRule } from '../chunk-34O5ZLZ6.js';
@@ -1 +1 @@
1
- export { addAfterPlugin, addBeforePlugin, findPlugin, matchConstructorName, removePlugin, replacePlugin } from '../chunk-GSID5BLX.js';
1
+ export { addAfterPlugin, addBeforePlugin, findPlugin, matchConstructorName, removePlugin, replacePlugin } from '../chunk-JPURRV2F.js';
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@workleap/webpack-configs",
3
3
  "author": "Workleap",
4
4
  "description": "Workleap recommended webpack config.",
5
- "version": "0.0.2",
5
+ "version": "1.0.1",
6
6
  "license": "Apache-2.0",
7
7
  "keywords": [
8
8
  "workleap",
@@ -13,8 +13,7 @@
13
13
  "exports": {
14
14
  ".": {
15
15
  "import": "./dist/index.js",
16
- "types": "./dist/index.d.ts",
17
- "default": "./dist/index.js"
16
+ "types": "./dist/index.d.ts"
18
17
  }
19
18
  },
20
19
  "files": [
@@ -28,8 +27,9 @@
28
27
  "directory": "packages/webpack-configs"
29
28
  },
30
29
  "dependencies": {
30
+ "@pmmmwh/react-refresh-webpack-plugin": "0.5.11",
31
31
  "css-loader": "6.8.1",
32
- "html-webpack-plugin": "5.5.1",
32
+ "html-webpack-plugin": "5.5.3",
33
33
  "mini-css-extract-plugin": "2.7.6",
34
34
  "postcss-loader": "7.3.3",
35
35
  "style-loader": "3.3.3",
@@ -37,7 +37,6 @@
37
37
  "terser-webpack-plugin": "5.3.9"
38
38
  },
39
39
  "peerDependencies": {
40
- "@pmmmwh/react-refresh-webpack-plugin": "*",
41
40
  "@svgr/webpack": "*",
42
41
  "@swc/core": "*",
43
42
  "@swc/helpers": "*",
@@ -47,34 +46,29 @@
47
46
  "webpack-dev-server": "*"
48
47
  },
49
48
  "peerDependenciesMeta": {
50
- "@pmmmwh/react-refresh-webpack-plugin": {
51
- "optional": true
52
- },
53
49
  "webpack-dev-server": {
54
50
  "optional": true
55
51
  }
56
52
  },
57
53
  "devDependencies": {
58
- "@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
59
- "@svgr/webpack": "8.0.1",
60
- "@swc/core": "1.3.66",
54
+ "@svgr/webpack": "8.1.0",
55
+ "@swc/core": "1.3.82",
61
56
  "@swc/helpers": "0.5.1",
62
- "@swc/jest": "0.2.26",
63
- "@types/jest": "29.5.2",
64
- "@types/webpack": "5.28.1",
65
- "browserslist": "4.21.7",
66
- "jest": "29.5.0",
67
- "postcss": "8.4.24",
57
+ "@swc/jest": "0.2.29",
58
+ "@types/jest": "29.5.4",
59
+ "browserslist": "4.21.10",
60
+ "jest": "29.6.4",
61
+ "postcss": "8.4.29",
68
62
  "postcss-load-config": "4.0.1",
69
63
  "ts-node": "10.9.1",
70
- "tsup": "6.7.0",
71
- "typescript": "5.0.4",
72
- "webpack": "5.86.0",
73
- "webpack-dev-server": "4.15.0",
74
- "@workleap/eslint-plugin": "1.8.3",
75
- "@workleap/swc-configs": "1.0.1",
76
- "@workleap/tsup-configs": "2.0.1",
77
- "@workleap/typescript-configs": "2.3.3"
64
+ "tsup": "7.2.0",
65
+ "typescript": "5.2.2",
66
+ "webpack": "5.88.2",
67
+ "webpack-dev-server": "4.15.1",
68
+ "@workleap/swc-configs": "2.1.0",
69
+ "@workleap/eslint-plugin": "2.1.0",
70
+ "@workleap/tsup-configs": "3.0.0",
71
+ "@workleap/typescript-configs": "3.0.2"
78
72
  },
79
73
  "publishConfig": {
80
74
  "access": "public",