@workleap/webpack-configs 0.0.1 → 0.0.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ # @workleap/webpack-configs
2
+
3
+ ## 0.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#92](https://github.com/gsoft-inc/wl-web-configs/pull/92) [`66e8f10`](https://github.com/gsoft-inc/wl-web-configs/commit/66e8f1033a987523c65fe9e61f53dac6d2e38777) Thanks [@ofrogon](https://github.com/ofrogon)! - Migrate project from GitHub organization
package/README.md CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  ## Gotchas to remember
4
4
 
5
- ### Add the @swc/helpers packages to all importer projects having JSX code
5
+ ### Add the @swc/helpers packages to all monorepo imported projects having JSX code
6
6
 
7
7
  To work properly, all projects having React/JSX code that are referenced by the host project must also install `@swc/helpers` as a `devDependency`.
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 { Configuration } from 'webpack';
4
+ import webpack, { Configuration } from 'webpack';
5
5
  import { WebpackConfigTransformer } from './transformers/applyTransformers.js';
6
6
 
7
7
  type MiniCssExtractPluginOptions = NonNullable<ConstructorParameters<typeof MiniCssExtractPlugin>[number]>;
@@ -19,8 +19,9 @@ interface DefineBuildConfigOptions {
19
19
  cssModules?: boolean;
20
20
  postcssConfigFilePath?: string;
21
21
  swcConfig: Config;
22
+ environmentVariables?: Record<string, string | undefined>;
22
23
  transformers?: WebpackConfigTransformer[];
23
24
  }
24
- declare function defineBuildConfig(options: DefineBuildConfigOptions): Configuration;
25
+ declare function defineBuildConfig(options: DefineBuildConfigOptions): webpack.Configuration;
25
26
 
26
27
  export { DefineBuildConfigOptions, defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig };
package/dist/build.js CHANGED
@@ -1,2 +1,2 @@
1
- export { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig } from './chunk-6VLNR4XR.js';
1
+ export { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig } from './chunk-XOV4FKHU.js';
2
2
  import './chunk-URL2KA63.js';
@@ -22,7 +22,7 @@ function findPlugin(config, matcher) {
22
22
  if (matches.length > 1) {
23
23
  const matcherInfo = matcher.info;
24
24
  throw new Error(`[webpack-configs] Found more than 1 matching plugin.
25
- [webpack-configs] Matcher: "${JSON.stringify(matcherInfo)}"
25
+ [webp-configs] Matcher: "${JSON.stringify(matcherInfo)}"
26
26
  [webpack-configs] Matches: "${JSON.stringify(matches.map((x) => x.plugin))}"`);
27
27
  }
28
28
  return matches[0];
@@ -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(`[web-configs] Couldn't replace the plugin because no match has been found.
36
+ console.log(`[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(`[web-configs] Couldn't add the new plugins because no match has been found.
46
+ console.log(`[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(`[web-configs] Couldn't add the new plugins because no match has been found.
56
+ console.log(`[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(`[web-configs] Didn't remove any plugin because no match has been found.
66
+ console.log(`[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
  }
@@ -4,7 +4,9 @@ import MiniCssExtractPlugin from 'mini-css-extract-plugin';
4
4
  import { createRequire } from 'node:module';
5
5
  import path from 'path';
6
6
  import TerserPlugin from 'terser-webpack-plugin';
7
+ import webpack from 'webpack';
7
8
 
9
+ var DefinePlugin = webpack.DefinePlugin;
8
10
  var require2 = createRequire(import.meta.url);
9
11
  function defineBuildHtmlWebpackPluginConfig(options = {}) {
10
12
  const {
@@ -40,6 +42,7 @@ function defineBuildConfig(options) {
40
42
  cssModules = false,
41
43
  postcssConfigFilePath,
42
44
  swcConfig,
45
+ environmentVariables,
43
46
  transformers = []
44
47
  } = options;
45
48
  const config = {
@@ -119,11 +122,16 @@ function defineBuildConfig(options) {
119
122
  plugins: [
120
123
  new HtmlWebpackPlugin(htmlWebpackPlugin),
121
124
  new MiniCssExtractPlugin(miniCssExtractPlugin),
125
+ new DefinePlugin({
126
+ // Parenthesis around the stringified object are mandatory otherwise it breaks
127
+ // at build time.
128
+ "process.env": `(${JSON.stringify(environmentVariables)})`
129
+ }),
122
130
  ...plugins
123
- ]
131
+ ].filter(Boolean)
124
132
  };
125
133
  const transformedConfig = applyTransformers(config, transformers, {
126
- env: "build"
134
+ environment: "build"
127
135
  });
128
136
  return transformedConfig;
129
137
  }
@@ -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(`[web-configs] Couldn't add the new module rules because no match has been found.
110
+ console.log(`[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(`[web-configs] Couldn't add the new module rules because no match has been found.
120
+ console.log(`[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(`[web-configs] Couldn't replace the module rule because no match has been found.
130
+ console.log(`[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(`[web-configs] Didn't remove any module rules because no match has been found.
149
+ console.log(`[webpack-configs] Didn't remove any module rules because no match has been found.
150
150
  [webpack-configs] Matcher: "${matcherInfo}"`);
151
151
  }
152
152
  }
@@ -5,8 +5,10 @@ import HtmlWebpackPlugin from 'html-webpack-plugin';
5
5
  import { createRequire } from 'node:module';
6
6
  import path from 'path';
7
7
  import { fileURLToPath } from 'url';
8
+ import webpack from 'webpack';
8
9
  import 'webpack-dev-server';
9
10
 
11
+ var DefinePlugin = webpack.DefinePlugin;
10
12
  var require2 = createRequire(import.meta.url);
11
13
  function defineDevHtmlWebpackPluginConfig(options = {}) {
12
14
  const {
@@ -23,11 +25,11 @@ function defineFastRefreshPluginConfig(options = {}) {
23
25
  }
24
26
  function preflight(options) {
25
27
  if (!require2.resolve("webpack-dev-server")) {
26
- throw new Error('To use the "dev" config, install https://www.npmjs.com/package/webpack-dev-server as a "devDependency".');
28
+ throw new Error('[webpack-configs] To use the "dev" config, install https://www.npmjs.com/package/webpack-dev-server as a "devDependency".');
27
29
  }
28
30
  if (options.fastRefresh) {
29
31
  if (!require2.resolve("@pmmmwh/react-refresh-webpack-plugin")) {
30
- throw new Error('To use Webpack Fast Refresh, install https://www.npmjs.com/package/@pmmmwh/react-refresh-webpack-plugin as a "devDependency".');
32
+ throw new Error('[webpack-configs] To use Webpack Fast Refresh, install https://www.npmjs.com/package/@pmmmwh/react-refresh-webpack-plugin as a "devDependency".');
31
33
  }
32
34
  }
33
35
  }
@@ -53,6 +55,7 @@ function defineDevConfig(options) {
53
55
  cssModules = false,
54
56
  postcssConfigFilePath,
55
57
  swcConfig,
58
+ environmentVariables,
56
59
  transformers = []
57
60
  } = options;
58
61
  const config = {
@@ -140,12 +143,15 @@ function defineDevConfig(options) {
140
143
  },
141
144
  plugins: [
142
145
  new HtmlWebpackPlugin(htmlWebpackPluginOptions),
146
+ new DefinePlugin({
147
+ "process.env": JSON.stringify(environmentVariables)
148
+ }),
143
149
  fastRefresh && new ReactRefreshWebpackPlugin(isObject(fastRefresh) ? fastRefresh : defineFastRefreshPluginConfig()),
144
150
  ...plugins
145
151
  ].filter(Boolean)
146
152
  };
147
153
  const transformedConfig = applyTransformers(config, transformers, {
148
- env: "dev"
154
+ environment: "dev"
149
155
  });
150
156
  return transformedConfig;
151
157
  }
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 { Configuration } from 'webpack';
4
+ import webpack, { Configuration } from 'webpack';
5
5
  import { WebpackConfigTransformer } from './transformers/applyTransformers.js';
6
6
 
7
7
  declare function defineDevHtmlWebpackPluginConfig(options?: HtmlWebpackPlugin.Options): HtmlWebpackPlugin.Options;
@@ -20,8 +20,9 @@ interface DefineDevConfigOptions {
20
20
  cssModules?: boolean;
21
21
  postcssConfigFilePath?: string;
22
22
  swcConfig: Config;
23
+ environmentVariables?: Record<string, string | undefined>;
23
24
  transformers?: WebpackConfigTransformer[];
24
25
  }
25
- declare function defineDevConfig(options: DefineDevConfigOptions): Configuration;
26
+ declare function defineDevConfig(options: DefineDevConfigOptions): webpack.Configuration;
26
27
 
27
28
  export { DefineDevConfigOptions, defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig };
package/dist/dev.js CHANGED
@@ -1,3 +1,3 @@
1
- export { defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './chunk-LUBW6XFE.js';
1
+ export { defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './chunk-ZKKR575Q.js';
2
2
  import './chunk-P2Z3EEVF.js';
3
3
  import './chunk-URL2KA63.js';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig } from './chunk-6VLNR4XR.js';
2
- export { defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './chunk-LUBW6XFE.js';
1
+ export { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig } from './chunk-XOV4FKHU.js';
2
+ export { defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './chunk-ZKKR575Q.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-RZJNTAWK.js';
6
- export { addAfterPlugin, addBeforePlugin, findPlugin, matchConstructorName, removePlugin, replacePlugin } from './chunk-ZOH3SP3K.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';
@@ -1,7 +1,7 @@
1
1
  import { Configuration } from 'webpack';
2
2
 
3
3
  interface WebpackConfigTransformerContext {
4
- env: "dev" | "build";
4
+ environment: "dev" | "build";
5
5
  }
6
6
  type WebpackConfigTransformer = (config: Configuration, context: WebpackConfigTransformerContext) => Configuration;
7
7
  declare function applyTransformers(config: Configuration, transformers: WebpackConfigTransformer[], context: WebpackConfigTransformerContext): Configuration;
@@ -1 +1 @@
1
- export { addAfterModuleRule, addBeforeModuleRule, findModuleRule, findModuleRules, matchAssetModuleType, matchLoaderName, matchTest, removeModuleRules, replaceModuleRule } from '../chunk-RZJNTAWK.js';
1
+ export { addAfterModuleRule, addBeforeModuleRule, findModuleRule, findModuleRules, matchAssetModuleType, matchLoaderName, matchTest, removeModuleRules, replaceModuleRule } from '../chunk-YF3OAEUP.js';
@@ -1 +1 @@
1
- export { addAfterPlugin, addBeforePlugin, findPlugin, matchConstructorName, removePlugin, replacePlugin } from '../chunk-ZOH3SP3K.js';
1
+ export { addAfterPlugin, addBeforePlugin, findPlugin, matchConstructorName, removePlugin, replacePlugin } from '../chunk-GSID5BLX.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.1",
5
+ "version": "0.0.2",
6
6
  "license": "Apache-2.0",
7
7
  "keywords": [
8
8
  "workleap",
@@ -24,7 +24,7 @@
24
24
  ],
25
25
  "repository": {
26
26
  "type": "git",
27
- "url": "git+https://github.com/workleap/wl-web-configs.git",
27
+ "url": "git+https://github.com/gsoft-inc/wl-web-configs.git",
28
28
  "directory": "packages/webpack-configs"
29
29
  },
30
30
  "dependencies": {
@@ -71,10 +71,10 @@
71
71
  "typescript": "5.0.4",
72
72
  "webpack": "5.86.0",
73
73
  "webpack-dev-server": "4.15.0",
74
- "@workleap/eslint-plugin": "1.8.2",
75
- "@workleap/swc-configs": "1.0.0",
76
- "@workleap/tsup-configs": "2.0.0",
77
- "@workleap/typescript-configs": "2.3.2"
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"
78
78
  },
79
79
  "publishConfig": {
80
80
  "access": "public",