@workleap/webpack-configs 1.0.0 → 1.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 +12 -0
- package/dist/build.d.ts +5 -3
- package/dist/build.js +1 -1
- package/dist/{chunk-QSPIAXE3.js → chunk-IGATFK3O.js} +50 -10
- package/dist/{chunk-OVSH7SYO.js → chunk-SBBLJ5AL.js} +46 -14
- package/dist/dev.d.ts +3 -3
- package/dist/dev.js +1 -1
- package/dist/index.js +2 -2
- package/package.json +18 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @workleap/webpack-configs
|
|
2
2
|
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#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
|
|
8
|
+
|
|
9
|
+
## 1.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#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
|
|
14
|
+
|
|
3
15
|
## 1.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
package/dist/build.d.ts
CHANGED
|
@@ -11,16 +11,18 @@ 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
|
-
swcConfig: Config;
|
|
21
22
|
environmentVariables?: Record<string, string | undefined>;
|
|
22
23
|
transformers?: WebpackConfigTransformer[];
|
|
24
|
+
profile?: boolean;
|
|
23
25
|
}
|
|
24
|
-
declare function defineBuildConfig(
|
|
26
|
+
declare function defineBuildConfig(swcConfig: Config, options?: DefineBuildConfigOptions): Configuration;
|
|
25
27
|
|
|
26
28
|
export { DefineBuildConfigOptions, defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig };
|
package/dist/build.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig } from './chunk-
|
|
1
|
+
export { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig } from './chunk-IGATFK3O.js';
|
|
2
2
|
import './chunk-URL2KA63.js';
|
|
@@ -2,7 +2,8 @@ import { applyTransformers } from './chunk-URL2KA63.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
|
|
|
@@ -28,21 +29,23 @@ function defineMiniCssExtractPluginConfig(options = {}) {
|
|
|
28
29
|
filename
|
|
29
30
|
};
|
|
30
31
|
}
|
|
31
|
-
function defineBuildConfig(options) {
|
|
32
|
+
function defineBuildConfig(swcConfig, options = {}) {
|
|
32
33
|
const {
|
|
33
34
|
entry = path.resolve("./src/index.tsx"),
|
|
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
|
-
swcConfig,
|
|
44
46
|
environmentVariables,
|
|
45
|
-
transformers = []
|
|
47
|
+
transformers = [],
|
|
48
|
+
profile = false
|
|
46
49
|
} = options;
|
|
47
50
|
const config = {
|
|
48
51
|
mode: "production",
|
|
@@ -54,6 +57,34 @@ function defineBuildConfig(options) {
|
|
|
54
57
|
publicPath,
|
|
55
58
|
clean: true
|
|
56
59
|
},
|
|
60
|
+
cache: cache && {
|
|
61
|
+
type: "filesystem",
|
|
62
|
+
allowCollectingMemory: false,
|
|
63
|
+
buildDependencies: {
|
|
64
|
+
config: [fileURLToPath(import.meta.url)]
|
|
65
|
+
},
|
|
66
|
+
cacheDirectory
|
|
67
|
+
},
|
|
68
|
+
// Fixes caching for environmental variables using the DefinePlugin by forcing
|
|
69
|
+
// webpack caching to prioritize hashes over timestamps.
|
|
70
|
+
snapshot: {
|
|
71
|
+
buildDependencies: {
|
|
72
|
+
hash: true,
|
|
73
|
+
timestamp: true
|
|
74
|
+
},
|
|
75
|
+
module: {
|
|
76
|
+
hash: true,
|
|
77
|
+
timestamp: true
|
|
78
|
+
},
|
|
79
|
+
resolve: {
|
|
80
|
+
hash: true,
|
|
81
|
+
timestamp: true
|
|
82
|
+
},
|
|
83
|
+
resolveBuildDependencies: {
|
|
84
|
+
hash: true,
|
|
85
|
+
timestamp: true
|
|
86
|
+
}
|
|
87
|
+
},
|
|
57
88
|
optimization: minify ? {
|
|
58
89
|
minimize: true,
|
|
59
90
|
minimizer: [
|
|
@@ -66,6 +97,11 @@ function defineBuildConfig(options) {
|
|
|
66
97
|
})
|
|
67
98
|
]
|
|
68
99
|
} : void 0,
|
|
100
|
+
infrastructureLogging: profile ? {
|
|
101
|
+
appendOnly: true,
|
|
102
|
+
level: "verbose",
|
|
103
|
+
debug: /PackFileCache/
|
|
104
|
+
} : void 0,
|
|
69
105
|
module: {
|
|
70
106
|
rules: [
|
|
71
107
|
{
|
|
@@ -109,15 +145,19 @@ function defineBuildConfig(options) {
|
|
|
109
145
|
]
|
|
110
146
|
},
|
|
111
147
|
resolve: {
|
|
112
|
-
extensions: [".js", ".jsx", ".ts", ".tsx", ".css"]
|
|
148
|
+
extensions: [".js", ".jsx", ".ts", ".tsx", ".css"],
|
|
149
|
+
alias: {
|
|
150
|
+
// Fixes Module not found: Error: Can't resolve '@swc/helpers/_/_class_private_field_init'.
|
|
151
|
+
// View https://github.com/vercel/next.js/pull/38174 for more information and https://github.com/vercel/next.js/issues/48593.
|
|
152
|
+
"@swc/helpers": path.dirname(require2.resolve("@swc/helpers/package.json"))
|
|
153
|
+
}
|
|
113
154
|
},
|
|
114
155
|
plugins: [
|
|
115
|
-
new HtmlWebpackPlugin(
|
|
156
|
+
htmlWebpackPlugin && new HtmlWebpackPlugin(htmlWebpackPlugin),
|
|
116
157
|
new MiniCssExtractPlugin(miniCssExtractPluginOptions),
|
|
117
158
|
new DefinePlugin({
|
|
118
|
-
//
|
|
119
|
-
|
|
120
|
-
"process.env": `(${JSON.stringify(environmentVariables)})`
|
|
159
|
+
// Webpack automatically stringify object literals.
|
|
160
|
+
"process.env": environmentVariables
|
|
121
161
|
}),
|
|
122
162
|
...plugins
|
|
123
163
|
].filter(Boolean)
|
|
@@ -3,8 +3,8 @@ import { applyTransformers } from './chunk-URL2KA63.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,13 +33,13 @@ 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
|
}
|
|
42
|
-
function defineDevConfig(options) {
|
|
42
|
+
function defineDevConfig(swcConfig, options = {}) {
|
|
43
43
|
preflight(options);
|
|
44
44
|
const {
|
|
45
45
|
entry = path.resolve("./src/index.tsx"),
|
|
@@ -50,12 +50,12 @@ function defineDevConfig(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
|
-
swcConfig,
|
|
57
56
|
environmentVariables,
|
|
58
|
-
transformers = []
|
|
57
|
+
transformers = [],
|
|
58
|
+
profile = false
|
|
59
59
|
} = options;
|
|
60
60
|
const config = {
|
|
61
61
|
mode: "development",
|
|
@@ -75,14 +75,35 @@ function defineDevConfig(options) {
|
|
|
75
75
|
// The trailing / is very important, otherwise paths will not be resolved correctly.
|
|
76
76
|
publicPath: `${https ? "https" : "http"}://${host}:${port}/`
|
|
77
77
|
},
|
|
78
|
-
cache: cache
|
|
78
|
+
cache: cache && {
|
|
79
79
|
type: "filesystem",
|
|
80
80
|
allowCollectingMemory: true,
|
|
81
|
+
maxMemoryGenerations: 1,
|
|
81
82
|
buildDependencies: {
|
|
82
83
|
config: [fileURLToPath(import.meta.url)]
|
|
83
84
|
},
|
|
84
85
|
cacheDirectory
|
|
85
86
|
},
|
|
87
|
+
// Fixes caching for environmental variables using the DefinePlugin by forcing
|
|
88
|
+
// webpack caching to prioritize hashes over timestamps.
|
|
89
|
+
snapshot: {
|
|
90
|
+
buildDependencies: {
|
|
91
|
+
hash: true,
|
|
92
|
+
timestamp: true
|
|
93
|
+
},
|
|
94
|
+
module: {
|
|
95
|
+
hash: true,
|
|
96
|
+
timestamp: true
|
|
97
|
+
},
|
|
98
|
+
resolve: {
|
|
99
|
+
hash: true,
|
|
100
|
+
timestamp: true
|
|
101
|
+
},
|
|
102
|
+
resolveBuildDependencies: {
|
|
103
|
+
hash: true,
|
|
104
|
+
timestamp: true
|
|
105
|
+
}
|
|
106
|
+
},
|
|
86
107
|
optimization: {
|
|
87
108
|
// See: https://webpack.js.org/guides/build-performance/#avoid-extra-optimization-steps
|
|
88
109
|
runtimeChunk: true,
|
|
@@ -90,13 +111,18 @@ function defineDevConfig(options) {
|
|
|
90
111
|
removeEmptyChunks: false,
|
|
91
112
|
splitChunks: false
|
|
92
113
|
},
|
|
114
|
+
infrastructureLogging: profile ? {
|
|
115
|
+
appendOnly: true,
|
|
116
|
+
level: "verbose",
|
|
117
|
+
debug: /PackFileCache/
|
|
118
|
+
} : void 0,
|
|
93
119
|
module: {
|
|
94
120
|
rules: [
|
|
95
121
|
{
|
|
96
122
|
test: /\.(js|jsx|ts|tsx)/i,
|
|
97
123
|
exclude: /node_modules/,
|
|
98
124
|
loader: require2.resolve("swc-loader"),
|
|
99
|
-
options: fastRefresh
|
|
125
|
+
options: trySetSwcFastRefresh(swcConfig, fastRefresh !== false)
|
|
100
126
|
},
|
|
101
127
|
{
|
|
102
128
|
// https://stackoverflow.com/questions/69427025/programmatic-webpack-jest-esm-cant-resolve-module-without-js-file-exten
|
|
@@ -133,12 +159,18 @@ function defineDevConfig(options) {
|
|
|
133
159
|
]
|
|
134
160
|
},
|
|
135
161
|
resolve: {
|
|
136
|
-
extensions: [".js", ".jsx", ".ts", ".tsx", ".css"]
|
|
162
|
+
extensions: [".js", ".jsx", ".ts", ".tsx", ".css"],
|
|
163
|
+
alias: {
|
|
164
|
+
// Fixes Module not found: Error: Can't resolve '@swc/helpers/_/_class_private_field_init'.
|
|
165
|
+
// View https://github.com/vercel/next.js/pull/38174 for more information and https://github.com/vercel/next.js/issues/48593.
|
|
166
|
+
"@swc/helpers": path.dirname(require2.resolve("@swc/helpers/package.json"))
|
|
167
|
+
}
|
|
137
168
|
},
|
|
138
169
|
plugins: [
|
|
139
|
-
new HtmlWebpackPlugin(
|
|
170
|
+
htmlWebpackPlugin && new HtmlWebpackPlugin(htmlWebpackPlugin),
|
|
140
171
|
new DefinePlugin({
|
|
141
|
-
|
|
172
|
+
// Webpack automatically stringify object literals.
|
|
173
|
+
"process.env": environmentVariables
|
|
142
174
|
}),
|
|
143
175
|
fastRefresh && new ReactRefreshWebpackPlugin(isObject(fastRefresh) ? fastRefresh : defineFastRefreshPluginConfig()),
|
|
144
176
|
...plugins
|
package/dist/dev.d.ts
CHANGED
|
@@ -15,13 +15,13 @@ 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
|
-
swcConfig: Config;
|
|
22
21
|
environmentVariables?: Record<string, string | undefined>;
|
|
23
22
|
transformers?: WebpackConfigTransformer[];
|
|
23
|
+
profile?: boolean;
|
|
24
24
|
}
|
|
25
|
-
declare function defineDevConfig(
|
|
25
|
+
declare function defineDevConfig(swcConfig: Config, options?: DefineDevConfigOptions): Configuration;
|
|
26
26
|
|
|
27
27
|
export { DefineDevConfigOptions, defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig };
|
package/dist/dev.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './chunk-
|
|
1
|
+
export { defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './chunk-SBBLJ5AL.js';
|
|
2
2
|
import './chunk-P2Z3EEVF.js';
|
|
3
3
|
import './chunk-URL2KA63.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig } from './chunk-
|
|
2
|
-
export { defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './chunk-
|
|
1
|
+
export { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig } from './chunk-IGATFK3O.js';
|
|
2
|
+
export { defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './chunk-SBBLJ5AL.js';
|
|
3
3
|
import './chunk-P2Z3EEVF.js';
|
|
4
4
|
import './chunk-URL2KA63.js';
|
|
5
5
|
export { addAfterModuleRule, addBeforeModuleRule, findModuleRule, findModuleRules, matchAssetModuleType, matchLoaderName, matchTest, removeModuleRules, replaceModuleRule } from './chunk-34O5ZLZ6.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.2",
|
|
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.
|
|
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
|
-
"@
|
|
59
|
-
"@
|
|
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.
|
|
63
|
-
"@types/jest": "29.5.
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
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": "
|
|
71
|
-
"typescript": "5.
|
|
72
|
-
"webpack": "5.
|
|
73
|
-
"webpack-dev-server": "4.15.
|
|
74
|
-
"@workleap/eslint-plugin": "2.
|
|
75
|
-
"@workleap/swc-configs": "2.
|
|
64
|
+
"tsup": "7.2.0",
|
|
65
|
+
"typescript": "5.2.2",
|
|
66
|
+
"webpack": "5.88.2",
|
|
67
|
+
"webpack-dev-server": "4.15.1",
|
|
68
|
+
"@workleap/eslint-plugin": "2.1.0",
|
|
69
|
+
"@workleap/swc-configs": "2.1.1",
|
|
76
70
|
"@workleap/tsup-configs": "3.0.0",
|
|
77
|
-
"@workleap/typescript-configs": "3.0.
|
|
71
|
+
"@workleap/typescript-configs": "3.0.2"
|
|
78
72
|
},
|
|
79
73
|
"publishConfig": {
|
|
80
74
|
"access": "public",
|