@openmrs/webpack-config 5.2.1-pre.1129 → 5.2.1-pre.1133
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/.turbo/turbo-build.log +1 -1
- package/dist/index.js +19 -3
- package/package.json +1 -1
- package/src/index.ts +42 -10
package/.turbo/turbo-build.log
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[
|
|
1
|
+
[32m@openmrs/webpack-config:build[0m: cache hit, replaying output [2m982807e193dc48c0[0m
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.watchConfig = exports.assetRuleConfig = exports.scssRuleConfig = exports.cssRuleConfig = exports.scriptRuleConfig = exports.additionalConfig = exports.overrides = void 0;
|
|
6
|
+
exports.optimizationConfig = exports.watchConfig = exports.assetRuleConfig = exports.scssRuleConfig = exports.cssRuleConfig = exports.scriptRuleConfig = exports.additionalConfig = exports.overrides = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* This is the base webpack config for all OpenMRS 3.x modules.
|
|
9
9
|
*
|
|
@@ -126,10 +126,19 @@ exports.assetRuleConfig = {};
|
|
|
126
126
|
* Make sure to modify this object and not reassign it.
|
|
127
127
|
*/
|
|
128
128
|
exports.watchConfig = {};
|
|
129
|
+
/**
|
|
130
|
+
* This object will be merged with the webpack optimization
|
|
131
|
+
* object.
|
|
132
|
+
* Make sure to modify this object and not reassign it.
|
|
133
|
+
*/
|
|
134
|
+
exports.optimizationConfig = {};
|
|
129
135
|
exports.default = (env, argv = {}) => {
|
|
130
136
|
const root = process.cwd();
|
|
131
137
|
const { name, version, peerDependencies, browser, main, types, } = require((0, path_1.resolve)(root, "package.json"));
|
|
132
|
-
|
|
138
|
+
// this typing is provably incorrect, but actually works
|
|
139
|
+
const mode = (argv.mode ||
|
|
140
|
+
process.env.NODE_ENV ||
|
|
141
|
+
"development");
|
|
133
142
|
const filename = (0, path_1.basename)(browser || main);
|
|
134
143
|
const outDir = (0, path_1.dirname)(browser || main);
|
|
135
144
|
const srcFile = (0, path_1.resolve)(root, browser ? main : types);
|
|
@@ -199,7 +208,14 @@ exports.default = (env, argv = {}) => {
|
|
|
199
208
|
ignored: [".git", "test-results"],
|
|
200
209
|
}, exports.watchConfig), performance: {
|
|
201
210
|
hints: mode === production && "warning",
|
|
202
|
-
},
|
|
211
|
+
}, optimization: (0, lodash_1.merge)({
|
|
212
|
+
// The defaults for both of these are 30; however, due to the modular nature of
|
|
213
|
+
// the frontend, we want each app to produce substantially
|
|
214
|
+
splitChunks: {
|
|
215
|
+
maxAsyncRequests: 3,
|
|
216
|
+
maxInitialRequests: 1,
|
|
217
|
+
},
|
|
218
|
+
}, exports.optimizationConfig), plugins: [
|
|
203
219
|
new fork_ts_checker_webpack_plugin_1.default(),
|
|
204
220
|
new clean_webpack_plugin_1.CleanWebpackPlugin(),
|
|
205
221
|
new webpack_bundle_analyzer_1.BundleAnalyzerPlugin({
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -40,7 +40,13 @@ import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
|
|
|
40
40
|
import { resolve, dirname, basename } from "path";
|
|
41
41
|
import { CleanWebpackPlugin } from "clean-webpack-plugin";
|
|
42
42
|
import CopyWebpackPlugin from "copy-webpack-plugin";
|
|
43
|
-
import {
|
|
43
|
+
import {
|
|
44
|
+
DefinePlugin,
|
|
45
|
+
container,
|
|
46
|
+
type ModuleOptions,
|
|
47
|
+
type WebpackOptionsNormalized as WebpackConfiguration,
|
|
48
|
+
type RuleSetRule,
|
|
49
|
+
} from "webpack";
|
|
44
50
|
import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer";
|
|
45
51
|
import { StatsWriterPlugin } from "webpack-stats-plugin";
|
|
46
52
|
// eslint-disable-next-line no-restricted-imports
|
|
@@ -48,6 +54,10 @@ import { merge, mergeWith, isArray } from "lodash";
|
|
|
48
54
|
import { existsSync, statSync } from "fs";
|
|
49
55
|
import { inc } from "semver";
|
|
50
56
|
|
|
57
|
+
type OpenmrsWebpackConfig = Omit<Partial<WebpackConfiguration>, "module"> & {
|
|
58
|
+
module: ModuleOptions;
|
|
59
|
+
};
|
|
60
|
+
|
|
51
61
|
const production = "production";
|
|
52
62
|
const { ModuleFederationPlugin } = container;
|
|
53
63
|
|
|
@@ -91,49 +101,57 @@ function fileExistsSync(name: string) {
|
|
|
91
101
|
* Array values will be concatenated with the existing array.
|
|
92
102
|
* Make sure to modify this object and not reassign it.
|
|
93
103
|
*/
|
|
94
|
-
export const overrides = {};
|
|
104
|
+
export const overrides: Partial<OpenmrsWebpackConfig> = {};
|
|
95
105
|
|
|
96
106
|
/**
|
|
97
107
|
* The keys of this object will override the top-level keys
|
|
98
108
|
* of the webpack config.
|
|
99
109
|
* Make sure to modify this object and not reassign it.
|
|
100
110
|
*/
|
|
101
|
-
export const additionalConfig = {};
|
|
111
|
+
export const additionalConfig: Partial<OpenmrsWebpackConfig> = {};
|
|
102
112
|
|
|
103
113
|
/**
|
|
104
114
|
* This object will be merged into the webpack rule governing
|
|
105
115
|
* the loading of JS, JSX, TS, etc. files.
|
|
106
116
|
* Make sure to modify this object and not reassign it.
|
|
107
117
|
*/
|
|
108
|
-
export const scriptRuleConfig = {};
|
|
118
|
+
export const scriptRuleConfig: Partial<RuleSetRule> = {};
|
|
109
119
|
|
|
110
120
|
/**
|
|
111
121
|
* This object will be merged into the webpack rule governing
|
|
112
122
|
* the loading of CSS files.
|
|
113
123
|
* Make sure to modify this object and not reassign it.
|
|
114
124
|
*/
|
|
115
|
-
export const cssRuleConfig = {};
|
|
125
|
+
export const cssRuleConfig: Partial<RuleSetRule> = {};
|
|
116
126
|
|
|
117
127
|
/**
|
|
118
128
|
* This object will be merged into the webpack rule governing
|
|
119
129
|
* the loading of SCSS files.
|
|
120
130
|
* Make sure to modify this object and not reassign it.
|
|
121
131
|
*/
|
|
122
|
-
export const scssRuleConfig = {};
|
|
132
|
+
export const scssRuleConfig: Partial<RuleSetRule> = {};
|
|
123
133
|
|
|
124
134
|
/**
|
|
125
135
|
* This object will be merged into the webpack rule governing
|
|
126
136
|
* the loading of static asset files.
|
|
127
137
|
* Make sure to modify this object and not reassign it.
|
|
128
138
|
*/
|
|
129
|
-
export const assetRuleConfig = {};
|
|
139
|
+
export const assetRuleConfig: Partial<RuleSetRule> = {};
|
|
130
140
|
|
|
131
141
|
/**
|
|
132
142
|
* This object will be merged into the webpack rule governing
|
|
133
143
|
* the watch options.
|
|
134
144
|
* Make sure to modify this object and not reassign it.
|
|
135
145
|
*/
|
|
136
|
-
export const watchConfig = {};
|
|
146
|
+
export const watchConfig: Partial<WebpackConfiguration["watchOptions"]> = {};
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* This object will be merged with the webpack optimization
|
|
150
|
+
* object.
|
|
151
|
+
* Make sure to modify this object and not reassign it.
|
|
152
|
+
*/
|
|
153
|
+
export const optimizationConfig: Partial<WebpackConfiguration["optimization"]> =
|
|
154
|
+
{};
|
|
137
155
|
|
|
138
156
|
export default (
|
|
139
157
|
env: Record<string, string>,
|
|
@@ -148,7 +166,10 @@ export default (
|
|
|
148
166
|
main,
|
|
149
167
|
types,
|
|
150
168
|
} = require(resolve(root, "package.json"));
|
|
151
|
-
|
|
169
|
+
// this typing is provably incorrect, but actually works
|
|
170
|
+
const mode = (argv.mode ||
|
|
171
|
+
process.env.NODE_ENV ||
|
|
172
|
+
"development") as WebpackConfiguration["mode"];
|
|
152
173
|
const filename = basename(browser || main);
|
|
153
174
|
const outDir = dirname(browser || main);
|
|
154
175
|
const srcFile = resolve(root, browser ? main : types);
|
|
@@ -175,7 +196,7 @@ export default (
|
|
|
175
196
|
},
|
|
176
197
|
};
|
|
177
198
|
|
|
178
|
-
const baseConfig = {
|
|
199
|
+
const baseConfig: OpenmrsWebpackConfig = {
|
|
179
200
|
// The only `entry` in the application is the app shell. Everything else is
|
|
180
201
|
// a Webpack Module Federation "remote." This ensures that there is always
|
|
181
202
|
// only one container context--i.e., if we had an entry point per module,
|
|
@@ -245,6 +266,17 @@ export default (
|
|
|
245
266
|
performance: {
|
|
246
267
|
hints: mode === production && "warning",
|
|
247
268
|
},
|
|
269
|
+
optimization: merge(
|
|
270
|
+
{
|
|
271
|
+
// The defaults for both of these are 30; however, due to the modular nature of
|
|
272
|
+
// the frontend, we want each app to produce substantially
|
|
273
|
+
splitChunks: {
|
|
274
|
+
maxAsyncRequests: 3,
|
|
275
|
+
maxInitialRequests: 1,
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
optimizationConfig
|
|
279
|
+
),
|
|
248
280
|
plugins: [
|
|
249
281
|
new ForkTsCheckerWebpackPlugin(),
|
|
250
282
|
new CleanWebpackPlugin(),
|