@workleap/webpack-configs 1.0.1 → 1.0.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/CHANGELOG.md +12 -0
- package/dist/build.d.ts +4 -1
- package/dist/build.js +2 -2
- package/dist/{chunk-Z4O6KPRR.js → chunk-2Q5IGCCY.js} +55 -11
- package/dist/chunk-EF2WO5MC.js +17 -0
- package/dist/{chunk-DSXM2GXS.js → chunk-EYIS42GE.js} +55 -17
- package/dist/dev.d.ts +2 -1
- package/dist/dev.js +2 -2
- package/dist/index.js +3 -3
- package/dist/transformers/applyTransformers.d.ts +1 -0
- package/dist/transformers/applyTransformers.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-URL2KA63.js +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @workleap/webpack-configs
|
|
2
2
|
|
|
3
|
+
## 1.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#123](https://github.com/gsoft-inc/wl-web-configs/pull/123) [`1c5458f`](https://github.com/gsoft-inc/wl-web-configs/commit/1c5458fba56494648b896e5263addaeb6380848e) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Updated web-configs
|
|
8
|
+
|
|
9
|
+
## 1.0.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#120](https://github.com/gsoft-inc/wl-web-configs/pull/120) [`0e66000`](https://github.com/gsoft-inc/wl-web-configs/commit/0e66000b2028cad9c606d3523e3bcf540e6350e2) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Updated configs
|
|
14
|
+
|
|
3
15
|
## 1.0.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/build.d.ts
CHANGED
|
@@ -11,14 +11,17 @@ interface DefineBuildConfigOptions {
|
|
|
11
11
|
entry?: string;
|
|
12
12
|
outputPath?: string;
|
|
13
13
|
publicPath?: string;
|
|
14
|
+
cache?: boolean;
|
|
15
|
+
cacheDirectory?: string;
|
|
14
16
|
moduleRules?: NonNullable<Configuration["module"]>["rules"];
|
|
15
17
|
plugins?: Configuration["plugins"];
|
|
16
|
-
|
|
18
|
+
htmlWebpackPlugin?: false | HtmlWebpackPlugin.Options;
|
|
17
19
|
miniCssExtractPluginOptions?: MiniCssExtractPluginOptions;
|
|
18
20
|
minify?: boolean;
|
|
19
21
|
cssModules?: boolean;
|
|
20
22
|
environmentVariables?: Record<string, string | undefined>;
|
|
21
23
|
transformers?: WebpackConfigTransformer[];
|
|
24
|
+
profile?: boolean;
|
|
22
25
|
}
|
|
23
26
|
declare function defineBuildConfig(swcConfig: Config, options?: DefineBuildConfigOptions): Configuration;
|
|
24
27
|
|
package/dist/build.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig } from './chunk-2Q5IGCCY.js';
|
|
2
|
+
import './chunk-EF2WO5MC.js';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { applyTransformers } from './chunk-
|
|
1
|
+
import { applyTransformers } from './chunk-EF2WO5MC.js';
|
|
2
2
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
3
3
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
4
4
|
import { createRequire } from 'node:module';
|
|
5
|
-
import path from 'path';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
6
7
|
import TerserPlugin from 'terser-webpack-plugin';
|
|
7
8
|
import webpack from 'webpack';
|
|
8
9
|
|
|
@@ -34,14 +35,19 @@ function defineBuildConfig(swcConfig, options = {}) {
|
|
|
34
35
|
outputPath = path.resolve("dist"),
|
|
35
36
|
// The trailing / is very important, otherwise paths will not be resolved correctly.
|
|
36
37
|
publicPath = "http://localhost:8080/",
|
|
38
|
+
cache = true,
|
|
39
|
+
cacheDirectory = path.resolve("node_modules/.cache/webpack"),
|
|
37
40
|
moduleRules = [],
|
|
38
41
|
plugins = [],
|
|
39
|
-
|
|
42
|
+
htmlWebpackPlugin = defineBuildHtmlWebpackPluginConfig(),
|
|
40
43
|
miniCssExtractPluginOptions = defineMiniCssExtractPluginConfig(),
|
|
41
44
|
minify = true,
|
|
42
45
|
cssModules = false,
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
// Using an empty object literal as the default value to ensure
|
|
47
|
+
// "process.env" is always available.
|
|
48
|
+
environmentVariables = {},
|
|
49
|
+
transformers = [],
|
|
50
|
+
profile = false
|
|
45
51
|
} = options;
|
|
46
52
|
const config = {
|
|
47
53
|
mode: "production",
|
|
@@ -53,6 +59,34 @@ function defineBuildConfig(swcConfig, options = {}) {
|
|
|
53
59
|
publicPath,
|
|
54
60
|
clean: true
|
|
55
61
|
},
|
|
62
|
+
cache: cache && {
|
|
63
|
+
type: "filesystem",
|
|
64
|
+
allowCollectingMemory: false,
|
|
65
|
+
buildDependencies: {
|
|
66
|
+
config: [fileURLToPath(import.meta.url)]
|
|
67
|
+
},
|
|
68
|
+
cacheDirectory
|
|
69
|
+
},
|
|
70
|
+
// Fixes caching for environmental variables using the DefinePlugin by forcing
|
|
71
|
+
// webpack caching to prioritize hashes over timestamps.
|
|
72
|
+
snapshot: cache ? {
|
|
73
|
+
buildDependencies: {
|
|
74
|
+
hash: true,
|
|
75
|
+
timestamp: true
|
|
76
|
+
},
|
|
77
|
+
module: {
|
|
78
|
+
hash: true,
|
|
79
|
+
timestamp: true
|
|
80
|
+
},
|
|
81
|
+
resolve: {
|
|
82
|
+
hash: true,
|
|
83
|
+
timestamp: true
|
|
84
|
+
},
|
|
85
|
+
resolveBuildDependencies: {
|
|
86
|
+
hash: true,
|
|
87
|
+
timestamp: true
|
|
88
|
+
}
|
|
89
|
+
} : void 0,
|
|
56
90
|
optimization: minify ? {
|
|
57
91
|
minimize: true,
|
|
58
92
|
minimizer: [
|
|
@@ -65,6 +99,11 @@ function defineBuildConfig(swcConfig, options = {}) {
|
|
|
65
99
|
})
|
|
66
100
|
]
|
|
67
101
|
} : void 0,
|
|
102
|
+
infrastructureLogging: profile ? {
|
|
103
|
+
appendOnly: true,
|
|
104
|
+
level: "verbose",
|
|
105
|
+
debug: /PackFileCache/
|
|
106
|
+
} : void 0,
|
|
68
107
|
module: {
|
|
69
108
|
rules: [
|
|
70
109
|
{
|
|
@@ -108,21 +147,26 @@ function defineBuildConfig(swcConfig, options = {}) {
|
|
|
108
147
|
]
|
|
109
148
|
},
|
|
110
149
|
resolve: {
|
|
111
|
-
extensions: [".js", ".jsx", ".ts", ".tsx", ".css"]
|
|
150
|
+
extensions: [".js", ".jsx", ".ts", ".tsx", ".css"],
|
|
151
|
+
alias: {
|
|
152
|
+
// Fixes Module not found: Error: Can't resolve '@swc/helpers/_/_class_private_field_init'.
|
|
153
|
+
// View https://github.com/vercel/next.js/pull/38174 for more information and https://github.com/vercel/next.js/issues/48593.
|
|
154
|
+
"@swc/helpers": path.dirname(require2.resolve("@swc/helpers/package.json"))
|
|
155
|
+
}
|
|
112
156
|
},
|
|
113
157
|
plugins: [
|
|
114
|
-
new HtmlWebpackPlugin(
|
|
158
|
+
htmlWebpackPlugin && new HtmlWebpackPlugin(htmlWebpackPlugin),
|
|
115
159
|
new MiniCssExtractPlugin(miniCssExtractPluginOptions),
|
|
116
160
|
new DefinePlugin({
|
|
117
|
-
//
|
|
118
|
-
|
|
119
|
-
"process.env": `(${JSON.stringify(environmentVariables)})`
|
|
161
|
+
// Webpack automatically stringify object literals.
|
|
162
|
+
"process.env": environmentVariables
|
|
120
163
|
}),
|
|
121
164
|
...plugins
|
|
122
165
|
].filter(Boolean)
|
|
123
166
|
};
|
|
124
167
|
const transformedConfig = applyTransformers(config, transformers, {
|
|
125
|
-
environment: "build"
|
|
168
|
+
environment: "build",
|
|
169
|
+
profile
|
|
126
170
|
});
|
|
127
171
|
return transformedConfig;
|
|
128
172
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/transformers/applyTransformers.ts
|
|
2
|
+
function applyTransformers(config, transformers, context) {
|
|
3
|
+
let count = 0;
|
|
4
|
+
const transformedConfig = transformers.reduce((acc, transformer) => {
|
|
5
|
+
transformer(acc, context);
|
|
6
|
+
count += 1;
|
|
7
|
+
return acc;
|
|
8
|
+
}, config);
|
|
9
|
+
if (context.profile) {
|
|
10
|
+
if (count > 0) {
|
|
11
|
+
console.log(`[webpack-configs] Applied ${count} configuration transformers.`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return transformedConfig;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { applyTransformers };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { isObject } from './chunk-P2Z3EEVF.js';
|
|
2
|
-
import { applyTransformers } from './chunk-
|
|
2
|
+
import { applyTransformers } from './chunk-EF2WO5MC.js';
|
|
3
3
|
import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';
|
|
4
4
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
5
5
|
import { createRequire } from 'node:module';
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import { fileURLToPath } from 'url';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
8
|
import webpack from 'webpack';
|
|
9
9
|
import 'webpack-dev-server';
|
|
10
10
|
|
|
@@ -33,9 +33,9 @@ function preflight(options) {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function trySetSwcFastRefresh(config, enabled) {
|
|
37
37
|
if (config?.jsc?.transform?.react) {
|
|
38
|
-
config.jsc.transform.react.refresh =
|
|
38
|
+
config.jsc.transform.react.refresh = enabled;
|
|
39
39
|
}
|
|
40
40
|
return config;
|
|
41
41
|
}
|
|
@@ -50,11 +50,14 @@ function defineDevConfig(swcConfig, options = {}) {
|
|
|
50
50
|
cacheDirectory = path.resolve("node_modules/.cache/webpack"),
|
|
51
51
|
moduleRules = [],
|
|
52
52
|
plugins = [],
|
|
53
|
-
|
|
54
|
-
fastRefresh =
|
|
53
|
+
htmlWebpackPlugin = defineDevHtmlWebpackPluginConfig(),
|
|
54
|
+
fastRefresh = true,
|
|
55
55
|
cssModules = false,
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
// Using an empty object literal as the default value to ensure
|
|
57
|
+
// "process.env" is always available.
|
|
58
|
+
environmentVariables = {},
|
|
59
|
+
transformers = [],
|
|
60
|
+
profile = false
|
|
58
61
|
} = options;
|
|
59
62
|
const config = {
|
|
60
63
|
mode: "development",
|
|
@@ -74,28 +77,56 @@ function defineDevConfig(swcConfig, options = {}) {
|
|
|
74
77
|
// The trailing / is very important, otherwise paths will not be resolved correctly.
|
|
75
78
|
publicPath: `${https ? "https" : "http"}://${host}:${port}/`
|
|
76
79
|
},
|
|
77
|
-
cache: cache
|
|
80
|
+
cache: cache && {
|
|
78
81
|
type: "filesystem",
|
|
79
82
|
allowCollectingMemory: true,
|
|
83
|
+
maxMemoryGenerations: 1,
|
|
80
84
|
buildDependencies: {
|
|
81
85
|
config: [fileURLToPath(import.meta.url)]
|
|
82
86
|
},
|
|
83
87
|
cacheDirectory
|
|
84
88
|
},
|
|
89
|
+
// Fixes caching for environmental variables using the DefinePlugin by forcing
|
|
90
|
+
// webpack caching to prioritize hashes over timestamps.
|
|
91
|
+
snapshot: cache ? {
|
|
92
|
+
buildDependencies: {
|
|
93
|
+
hash: true,
|
|
94
|
+
timestamp: true
|
|
95
|
+
},
|
|
96
|
+
module: {
|
|
97
|
+
hash: true,
|
|
98
|
+
timestamp: true
|
|
99
|
+
},
|
|
100
|
+
resolve: {
|
|
101
|
+
hash: true,
|
|
102
|
+
timestamp: true
|
|
103
|
+
},
|
|
104
|
+
resolveBuildDependencies: {
|
|
105
|
+
hash: true,
|
|
106
|
+
timestamp: true
|
|
107
|
+
}
|
|
108
|
+
} : void 0,
|
|
109
|
+
// See: https://webpack.js.org/guides/build-performance/#avoid-extra-optimization-steps
|
|
85
110
|
optimization: {
|
|
86
|
-
//
|
|
87
|
-
|
|
111
|
+
// Keep "runtimeChunk" to false, otherwise it breaks module federation
|
|
112
|
+
// (at least for the remote application).
|
|
113
|
+
runtimeChunk: false,
|
|
88
114
|
removeAvailableModules: false,
|
|
89
115
|
removeEmptyChunks: false,
|
|
90
116
|
splitChunks: false
|
|
91
117
|
},
|
|
118
|
+
infrastructureLogging: profile ? {
|
|
119
|
+
appendOnly: true,
|
|
120
|
+
level: "verbose",
|
|
121
|
+
debug: /PackFileCache/
|
|
122
|
+
} : void 0,
|
|
92
123
|
module: {
|
|
93
124
|
rules: [
|
|
94
125
|
{
|
|
95
126
|
test: /\.(js|jsx|ts|tsx)/i,
|
|
96
127
|
exclude: /node_modules/,
|
|
97
128
|
loader: require2.resolve("swc-loader"),
|
|
98
|
-
options: fastRefresh
|
|
129
|
+
options: trySetSwcFastRefresh(swcConfig, fastRefresh !== false)
|
|
99
130
|
},
|
|
100
131
|
{
|
|
101
132
|
// https://stackoverflow.com/questions/69427025/programmatic-webpack-jest-esm-cant-resolve-module-without-js-file-exten
|
|
@@ -132,19 +163,26 @@ function defineDevConfig(swcConfig, options = {}) {
|
|
|
132
163
|
]
|
|
133
164
|
},
|
|
134
165
|
resolve: {
|
|
135
|
-
extensions: [".js", ".jsx", ".ts", ".tsx", ".css"]
|
|
166
|
+
extensions: [".js", ".jsx", ".ts", ".tsx", ".css"],
|
|
167
|
+
alias: {
|
|
168
|
+
// Fixes Module not found: Error: Can't resolve '@swc/helpers/_/_class_private_field_init'.
|
|
169
|
+
// View https://github.com/vercel/next.js/pull/38174 for more information and https://github.com/vercel/next.js/issues/48593.
|
|
170
|
+
"@swc/helpers": path.dirname(require2.resolve("@swc/helpers/package.json"))
|
|
171
|
+
}
|
|
136
172
|
},
|
|
137
173
|
plugins: [
|
|
138
|
-
new HtmlWebpackPlugin(
|
|
174
|
+
htmlWebpackPlugin && new HtmlWebpackPlugin(htmlWebpackPlugin),
|
|
139
175
|
new DefinePlugin({
|
|
140
|
-
|
|
176
|
+
// Webpack automatically stringify object literals.
|
|
177
|
+
"process.env": environmentVariables
|
|
141
178
|
}),
|
|
142
179
|
fastRefresh && new ReactRefreshWebpackPlugin(isObject(fastRefresh) ? fastRefresh : defineFastRefreshPluginConfig()),
|
|
143
180
|
...plugins
|
|
144
181
|
].filter(Boolean)
|
|
145
182
|
};
|
|
146
183
|
const transformedConfig = applyTransformers(config, transformers, {
|
|
147
|
-
environment: "dev"
|
|
184
|
+
environment: "dev",
|
|
185
|
+
profile
|
|
148
186
|
});
|
|
149
187
|
return transformedConfig;
|
|
150
188
|
}
|
package/dist/dev.d.ts
CHANGED
|
@@ -15,11 +15,12 @@ interface DefineDevConfigOptions {
|
|
|
15
15
|
cacheDirectory?: string;
|
|
16
16
|
moduleRules?: NonNullable<Configuration["module"]>["rules"];
|
|
17
17
|
plugins?: Configuration["plugins"];
|
|
18
|
-
|
|
18
|
+
htmlWebpackPlugin?: false | HtmlWebpackPlugin.Options;
|
|
19
19
|
fastRefresh?: boolean | ReactRefreshPluginOptions;
|
|
20
20
|
cssModules?: boolean;
|
|
21
21
|
environmentVariables?: Record<string, string | undefined>;
|
|
22
22
|
transformers?: WebpackConfigTransformer[];
|
|
23
|
+
profile?: boolean;
|
|
23
24
|
}
|
|
24
25
|
declare function defineDevConfig(swcConfig: Config, options?: DefineDevConfigOptions): Configuration;
|
|
25
26
|
|
package/dist/dev.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './chunk-
|
|
1
|
+
export { defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './chunk-EYIS42GE.js';
|
|
2
2
|
import './chunk-P2Z3EEVF.js';
|
|
3
|
-
import './chunk-
|
|
3
|
+
import './chunk-EF2WO5MC.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig } from './chunk-
|
|
2
|
-
export { defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './chunk-
|
|
1
|
+
export { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig } from './chunk-2Q5IGCCY.js';
|
|
2
|
+
export { defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './chunk-EYIS42GE.js';
|
|
3
3
|
import './chunk-P2Z3EEVF.js';
|
|
4
|
-
import './chunk-
|
|
4
|
+
import './chunk-EF2WO5MC.js';
|
|
5
5
|
export { addAfterModuleRule, addBeforeModuleRule, findModuleRule, findModuleRules, matchAssetModuleType, matchLoaderName, matchTest, removeModuleRules, replaceModuleRule } from './chunk-34O5ZLZ6.js';
|
|
6
6
|
export { addAfterPlugin, addBeforePlugin, findPlugin, matchConstructorName, removePlugin, replacePlugin } from './chunk-JPURRV2F.js';
|
|
@@ -2,6 +2,7 @@ import { Configuration } from 'webpack';
|
|
|
2
2
|
|
|
3
3
|
interface WebpackConfigTransformerContext {
|
|
4
4
|
environment: "dev" | "build";
|
|
5
|
+
profile: boolean;
|
|
5
6
|
}
|
|
6
7
|
type WebpackConfigTransformer = (config: Configuration, context: WebpackConfigTransformerContext) => Configuration;
|
|
7
8
|
declare function applyTransformers(config: Configuration, transformers: WebpackConfigTransformer[], context: WebpackConfigTransformerContext): Configuration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { applyTransformers } from '../chunk-
|
|
1
|
+
export { applyTransformers } from '../chunk-EF2WO5MC.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": "1.0.
|
|
5
|
+
"version": "1.0.3",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"workleap",
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
"typescript": "5.2.2",
|
|
66
66
|
"webpack": "5.88.2",
|
|
67
67
|
"webpack-dev-server": "4.15.1",
|
|
68
|
-
"@workleap/swc-configs": "2.1.0",
|
|
69
68
|
"@workleap/eslint-plugin": "2.1.0",
|
|
70
69
|
"@workleap/tsup-configs": "3.0.0",
|
|
71
|
-
"@workleap/typescript-configs": "3.0.2"
|
|
70
|
+
"@workleap/typescript-configs": "3.0.2",
|
|
71
|
+
"@workleap/swc-configs": "2.1.1"
|
|
72
72
|
},
|
|
73
73
|
"publishConfig": {
|
|
74
74
|
"access": "public",
|