@openmrs/webpack-config 5.3.3-pre.1240 → 5.3.3-pre.1247
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 +39 -46
- package/package.json +1 -1
- package/src/index.ts +60 -79
package/.turbo/turbo-build.log
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[
|
|
1
|
+
[32m@openmrs/webpack-config:build[0m: cache hit, replaying output [2mb0d0a41957bed3cd[0m
|
package/dist/index.js
CHANGED
|
@@ -53,22 +53,22 @@ const webpack_stats_plugin_1 = require("webpack-stats-plugin");
|
|
|
53
53
|
const lodash_1 = require("lodash");
|
|
54
54
|
const fs_1 = require("fs");
|
|
55
55
|
const semver_1 = require("semver");
|
|
56
|
-
const production =
|
|
56
|
+
const production = 'production';
|
|
57
57
|
const { ModuleFederationPlugin } = webpack_1.container;
|
|
58
58
|
function getFrameworkVersion() {
|
|
59
59
|
try {
|
|
60
|
-
const { version } = require(
|
|
60
|
+
const { version } = require('@openmrs/esm-framework/package.json');
|
|
61
61
|
return `^${version}`;
|
|
62
62
|
}
|
|
63
63
|
catch (_a) {
|
|
64
|
-
return
|
|
64
|
+
return '5.x';
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
function makeIdent(name) {
|
|
68
|
-
if (name.indexOf(
|
|
69
|
-
name = name.substr(name.indexOf(
|
|
68
|
+
if (name.indexOf('/') !== -1) {
|
|
69
|
+
name = name.substr(name.indexOf('/'));
|
|
70
70
|
}
|
|
71
|
-
if (name.endsWith(
|
|
71
|
+
if (name.endsWith('-app')) {
|
|
72
72
|
name = name.substr(0, name.length - 4);
|
|
73
73
|
}
|
|
74
74
|
return name;
|
|
@@ -79,7 +79,7 @@ function mergeFunction(objValue, srcValue) {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
function slugify(name) {
|
|
82
|
-
return name.replace(/[\/\-@]/g,
|
|
82
|
+
return name.replace(/[\/\-@]/g, '_');
|
|
83
83
|
}
|
|
84
84
|
function fileExistsSync(name) {
|
|
85
85
|
return (0, fs_1.existsSync)(name) && (0, fs_1.statSync)(name).isFile();
|
|
@@ -134,26 +134,24 @@ exports.watchConfig = {};
|
|
|
134
134
|
exports.optimizationConfig = {};
|
|
135
135
|
exports.default = (env, argv = {}) => {
|
|
136
136
|
const root = process.cwd();
|
|
137
|
-
const { name, version, peerDependencies, browser, main, types
|
|
137
|
+
const { name, version, peerDependencies, browser, main, types } = require((0, path_1.resolve)(root, 'package.json'));
|
|
138
138
|
// this typing is provably incorrect, but actually works
|
|
139
|
-
const mode = (argv.mode ||
|
|
140
|
-
process.env.NODE_ENV ||
|
|
141
|
-
"development");
|
|
139
|
+
const mode = (argv.mode || process.env.NODE_ENV || 'development');
|
|
142
140
|
const filename = (0, path_1.basename)(browser || main);
|
|
143
141
|
const outDir = (0, path_1.dirname)(browser || main);
|
|
144
142
|
const srcFile = (0, path_1.resolve)(root, browser ? main : types);
|
|
145
143
|
const ident = makeIdent(name);
|
|
146
144
|
const frameworkVersion = getFrameworkVersion();
|
|
147
|
-
const routes = (0, path_1.resolve)(root,
|
|
145
|
+
const routes = (0, path_1.resolve)(root, 'src', 'routes.json');
|
|
148
146
|
const hasRoutesDefined = fileExistsSync(routes);
|
|
149
147
|
if (!hasRoutesDefined) {
|
|
150
|
-
console.error(
|
|
148
|
+
console.error('This app does not define a routes.json. This file is required for this app to be used by the OpenMRS 3 App Shell.');
|
|
151
149
|
// key-smash error code
|
|
152
150
|
// so this (hopefully) doesn't interfere with Webpack-specific exit codes
|
|
153
151
|
process.exit(9819023573289);
|
|
154
152
|
}
|
|
155
153
|
const cssLoader = {
|
|
156
|
-
loader:
|
|
154
|
+
loader: 'css-loader',
|
|
157
155
|
options: {
|
|
158
156
|
modules: {
|
|
159
157
|
localIdentName: `${ident}__[name]__[local]___[hash:base64:5]`,
|
|
@@ -166,48 +164,48 @@ exports.default = (env, argv = {}) => {
|
|
|
166
164
|
// only one container context--i.e., if we had an entry point per module,
|
|
167
165
|
// WMF could get confused and not resolve shared dependencies correctly.
|
|
168
166
|
output: {
|
|
169
|
-
publicPath:
|
|
167
|
+
publicPath: 'auto',
|
|
170
168
|
path: (0, path_1.resolve)(root, outDir),
|
|
171
|
-
hashFunction:
|
|
169
|
+
hashFunction: 'xxhash64',
|
|
172
170
|
}, module: {
|
|
173
171
|
rules: [
|
|
174
172
|
(0, lodash_1.merge)({
|
|
175
173
|
test: /\.m?(js|ts|tsx)$/,
|
|
176
174
|
exclude: /node_modules(?![\/\\]@openmrs)/,
|
|
177
|
-
use:
|
|
175
|
+
use: 'swc-loader',
|
|
178
176
|
}, exports.scriptRuleConfig),
|
|
179
177
|
(0, lodash_1.merge)({
|
|
180
178
|
test: /\.css$/,
|
|
181
|
-
use: [require.resolve(
|
|
179
|
+
use: [require.resolve('style-loader'), cssLoader],
|
|
182
180
|
}, exports.cssRuleConfig),
|
|
183
181
|
(0, lodash_1.merge)({
|
|
184
182
|
test: /\.s[ac]ss$/i,
|
|
185
183
|
use: [
|
|
186
|
-
require.resolve(
|
|
184
|
+
require.resolve('style-loader'),
|
|
187
185
|
cssLoader,
|
|
188
186
|
{
|
|
189
|
-
loader: require.resolve(
|
|
187
|
+
loader: require.resolve('sass-loader'),
|
|
190
188
|
options: { sassOptions: { quietDeps: true } },
|
|
191
189
|
},
|
|
192
190
|
],
|
|
193
191
|
}, exports.scssRuleConfig),
|
|
194
192
|
(0, lodash_1.merge)({
|
|
195
193
|
test: /\.(png|jpe?g|gif|svg)$/i,
|
|
196
|
-
type:
|
|
194
|
+
type: 'asset/resource',
|
|
197
195
|
}, exports.assetRuleConfig),
|
|
198
196
|
],
|
|
199
|
-
}, mode, devtool: mode === production ?
|
|
197
|
+
}, mode, devtool: mode === production ? 'hidden-nosources-source-map' : 'source-map', devServer: {
|
|
200
198
|
headers: {
|
|
201
|
-
|
|
199
|
+
'Access-Control-Allow-Origin': '*',
|
|
202
200
|
},
|
|
203
201
|
devMiddleware: {
|
|
204
202
|
writeToDisk: true,
|
|
205
203
|
},
|
|
206
204
|
static: [(0, path_1.resolve)(root, outDir)],
|
|
207
205
|
}, watchOptions: (0, lodash_1.merge)({
|
|
208
|
-
ignored: [
|
|
206
|
+
ignored: ['.git', 'test-results'],
|
|
209
207
|
}, exports.watchConfig), performance: {
|
|
210
|
-
hints: mode === production &&
|
|
208
|
+
hints: mode === production && 'warning',
|
|
211
209
|
}, optimization: (0, lodash_1.merge)({
|
|
212
210
|
// The defaults for both of these are 30; however, due to the modular nature of
|
|
213
211
|
// the frontend, we want each app to produce substantially
|
|
@@ -219,35 +217,32 @@ exports.default = (env, argv = {}) => {
|
|
|
219
217
|
new fork_ts_checker_webpack_plugin_1.default(),
|
|
220
218
|
new clean_webpack_plugin_1.CleanWebpackPlugin(),
|
|
221
219
|
new webpack_bundle_analyzer_1.BundleAnalyzerPlugin({
|
|
222
|
-
analyzerMode: env && env.analyze ?
|
|
220
|
+
analyzerMode: env && env.analyze ? 'server' : 'disabled',
|
|
223
221
|
}),
|
|
224
222
|
new webpack_1.DefinePlugin({
|
|
225
|
-
|
|
223
|
+
'process.env.FRAMEWORK_VERSION': JSON.stringify(frameworkVersion),
|
|
226
224
|
}),
|
|
227
225
|
new ModuleFederationPlugin({
|
|
228
226
|
// Look in the `esm-dynamic-loading` framework package for an explanation of how modules
|
|
229
227
|
// get loaded into the application.
|
|
230
228
|
name,
|
|
231
|
-
library: { type:
|
|
229
|
+
library: { type: 'var', name: slugify(name) },
|
|
232
230
|
filename,
|
|
233
231
|
exposes: {
|
|
234
|
-
|
|
232
|
+
'./start': srcFile,
|
|
235
233
|
},
|
|
236
|
-
shared: [
|
|
237
|
-
...Object.keys(peerDependencies),
|
|
238
|
-
"@openmrs/esm-framework/src/internal",
|
|
239
|
-
].reduce((obj, depName) => {
|
|
234
|
+
shared: [...Object.keys(peerDependencies), '@openmrs/esm-framework/src/internal'].reduce((obj, depName) => {
|
|
240
235
|
var _a, _b;
|
|
241
|
-
if (depName ===
|
|
236
|
+
if (depName === 'swr') {
|
|
242
237
|
// SWR is annoying with Module Federation
|
|
243
238
|
// See: https://github.com/webpack/webpack/issues/16125 and https://github.com/vercel/swr/issues/2356
|
|
244
|
-
obj[
|
|
245
|
-
requiredVersion: (_a = peerDependencies[
|
|
239
|
+
obj['swr/'] = {
|
|
240
|
+
requiredVersion: (_a = peerDependencies['swr']) !== null && _a !== void 0 ? _a : false,
|
|
246
241
|
singleton: true,
|
|
247
|
-
import:
|
|
248
|
-
shareKey:
|
|
249
|
-
shareScope:
|
|
250
|
-
version: require(
|
|
242
|
+
import: 'swr/',
|
|
243
|
+
shareKey: 'swr/',
|
|
244
|
+
shareScope: 'default',
|
|
245
|
+
version: require('swr/package.json').version,
|
|
251
246
|
};
|
|
252
247
|
}
|
|
253
248
|
else {
|
|
@@ -256,7 +251,7 @@ exports.default = (env, argv = {}) => {
|
|
|
256
251
|
singleton: true,
|
|
257
252
|
import: depName,
|
|
258
253
|
shareKey: depName,
|
|
259
|
-
shareScope:
|
|
254
|
+
shareScope: 'default',
|
|
260
255
|
};
|
|
261
256
|
}
|
|
262
257
|
return obj;
|
|
@@ -269,9 +264,7 @@ exports.default = (env, argv = {}) => {
|
|
|
269
264
|
from: routes,
|
|
270
265
|
transform: {
|
|
271
266
|
transformer: (content) => JSON.stringify(Object.assign({}, JSON.parse(content.toString()), {
|
|
272
|
-
version: mode === production
|
|
273
|
-
? version
|
|
274
|
-
: (0, semver_1.inc)(version, "prerelease", "local"),
|
|
267
|
+
version: mode === production ? version : (0, semver_1.inc)(version, 'prerelease', 'local'),
|
|
275
268
|
})),
|
|
276
269
|
},
|
|
277
270
|
},
|
|
@@ -285,9 +278,9 @@ exports.default = (env, argv = {}) => {
|
|
|
285
278
|
},
|
|
286
279
|
}),
|
|
287
280
|
].filter(Boolean), resolve: {
|
|
288
|
-
extensions: [
|
|
281
|
+
extensions: ['.tsx', '.ts', '.jsx', '.js', '.scss', '.json'],
|
|
289
282
|
alias: {
|
|
290
|
-
|
|
283
|
+
'@openmrs/esm-framework': '@openmrs/esm-framework/src/internal',
|
|
291
284
|
},
|
|
292
285
|
} }, exports.overrides);
|
|
293
286
|
return (0, lodash_1.mergeWith)(baseConfig, exports.additionalConfig, mergeFunction);
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -36,46 +36,46 @@
|
|
|
36
36
|
* Telling Webpack to use `/a/b/c`? If the Webpack config is symlinked
|
|
37
37
|
* from `/d/e/`, then it *might* in *some cases* try to import `/d/e/c`.
|
|
38
38
|
*/
|
|
39
|
-
import ForkTsCheckerWebpackPlugin from
|
|
40
|
-
import { resolve, dirname, basename } from
|
|
41
|
-
import { CleanWebpackPlugin } from
|
|
42
|
-
import CopyWebpackPlugin from
|
|
39
|
+
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
|
|
40
|
+
import { resolve, dirname, basename } from 'path';
|
|
41
|
+
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
|
|
42
|
+
import CopyWebpackPlugin from 'copy-webpack-plugin';
|
|
43
43
|
import {
|
|
44
44
|
DefinePlugin,
|
|
45
45
|
container,
|
|
46
46
|
type ModuleOptions,
|
|
47
47
|
type WebpackOptionsNormalized as WebpackConfiguration,
|
|
48
48
|
type RuleSetRule,
|
|
49
|
-
} from
|
|
50
|
-
import { BundleAnalyzerPlugin } from
|
|
51
|
-
import { StatsWriterPlugin } from
|
|
49
|
+
} from 'webpack';
|
|
50
|
+
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
|
|
51
|
+
import { StatsWriterPlugin } from 'webpack-stats-plugin';
|
|
52
52
|
// eslint-disable-next-line no-restricted-imports
|
|
53
|
-
import { merge, mergeWith, isArray } from
|
|
54
|
-
import { existsSync, statSync } from
|
|
55
|
-
import { inc } from
|
|
53
|
+
import { merge, mergeWith, isArray } from 'lodash';
|
|
54
|
+
import { existsSync, statSync } from 'fs';
|
|
55
|
+
import { inc } from 'semver';
|
|
56
56
|
|
|
57
|
-
type OpenmrsWebpackConfig = Omit<Partial<WebpackConfiguration>,
|
|
57
|
+
type OpenmrsWebpackConfig = Omit<Partial<WebpackConfiguration>, 'module'> & {
|
|
58
58
|
module: ModuleOptions;
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
const production =
|
|
61
|
+
const production = 'production';
|
|
62
62
|
const { ModuleFederationPlugin } = container;
|
|
63
63
|
|
|
64
64
|
function getFrameworkVersion() {
|
|
65
65
|
try {
|
|
66
|
-
const { version } = require(
|
|
66
|
+
const { version } = require('@openmrs/esm-framework/package.json');
|
|
67
67
|
return `^${version}`;
|
|
68
68
|
} catch {
|
|
69
|
-
return
|
|
69
|
+
return '5.x';
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
function makeIdent(name: string) {
|
|
74
|
-
if (name.indexOf(
|
|
75
|
-
name = name.substr(name.indexOf(
|
|
74
|
+
if (name.indexOf('/') !== -1) {
|
|
75
|
+
name = name.substr(name.indexOf('/'));
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
if (name.endsWith(
|
|
78
|
+
if (name.endsWith('-app')) {
|
|
79
79
|
name = name.substr(0, name.length - 4);
|
|
80
80
|
}
|
|
81
81
|
|
|
@@ -89,7 +89,7 @@ function mergeFunction(objValue: any, srcValue: any) {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
function slugify(name: string) {
|
|
92
|
-
return name.replace(/[\/\-@]/g,
|
|
92
|
+
return name.replace(/[\/\-@]/g, '_');
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
function fileExistsSync(name: string) {
|
|
@@ -143,44 +143,31 @@ export const assetRuleConfig: Partial<RuleSetRule> = {};
|
|
|
143
143
|
* the watch options.
|
|
144
144
|
* Make sure to modify this object and not reassign it.
|
|
145
145
|
*/
|
|
146
|
-
export const watchConfig: Partial<WebpackConfiguration[
|
|
146
|
+
export const watchConfig: Partial<WebpackConfiguration['watchOptions']> = {};
|
|
147
147
|
|
|
148
148
|
/**
|
|
149
149
|
* This object will be merged with the webpack optimization
|
|
150
150
|
* object.
|
|
151
151
|
* Make sure to modify this object and not reassign it.
|
|
152
152
|
*/
|
|
153
|
-
export const optimizationConfig: Partial<WebpackConfiguration[
|
|
154
|
-
{};
|
|
153
|
+
export const optimizationConfig: Partial<WebpackConfiguration['optimization']> = {};
|
|
155
154
|
|
|
156
|
-
export default (
|
|
157
|
-
env: Record<string, string>,
|
|
158
|
-
argv: Record<string, string> = {}
|
|
159
|
-
) => {
|
|
155
|
+
export default (env: Record<string, string>, argv: Record<string, string> = {}) => {
|
|
160
156
|
const root = process.cwd();
|
|
161
|
-
const {
|
|
162
|
-
name,
|
|
163
|
-
version,
|
|
164
|
-
peerDependencies,
|
|
165
|
-
browser,
|
|
166
|
-
main,
|
|
167
|
-
types,
|
|
168
|
-
} = require(resolve(root, "package.json"));
|
|
157
|
+
const { name, version, peerDependencies, browser, main, types } = require(resolve(root, 'package.json'));
|
|
169
158
|
// this typing is provably incorrect, but actually works
|
|
170
|
-
const mode = (argv.mode ||
|
|
171
|
-
process.env.NODE_ENV ||
|
|
172
|
-
"development") as WebpackConfiguration["mode"];
|
|
159
|
+
const mode = (argv.mode || process.env.NODE_ENV || 'development') as WebpackConfiguration['mode'];
|
|
173
160
|
const filename = basename(browser || main);
|
|
174
161
|
const outDir = dirname(browser || main);
|
|
175
162
|
const srcFile = resolve(root, browser ? main : types);
|
|
176
163
|
const ident = makeIdent(name);
|
|
177
164
|
const frameworkVersion = getFrameworkVersion();
|
|
178
|
-
const routes = resolve(root,
|
|
165
|
+
const routes = resolve(root, 'src', 'routes.json');
|
|
179
166
|
const hasRoutesDefined = fileExistsSync(routes);
|
|
180
167
|
|
|
181
168
|
if (!hasRoutesDefined) {
|
|
182
169
|
console.error(
|
|
183
|
-
|
|
170
|
+
'This app does not define a routes.json. This file is required for this app to be used by the OpenMRS 3 App Shell.',
|
|
184
171
|
);
|
|
185
172
|
// key-smash error code
|
|
186
173
|
// so this (hopefully) doesn't interfere with Webpack-specific exit codes
|
|
@@ -188,7 +175,7 @@ export default (
|
|
|
188
175
|
}
|
|
189
176
|
|
|
190
177
|
const cssLoader = {
|
|
191
|
-
loader:
|
|
178
|
+
loader: 'css-loader',
|
|
192
179
|
options: {
|
|
193
180
|
modules: {
|
|
194
181
|
localIdentName: `${ident}__[name]__[local]___[hash:base64:5]`,
|
|
@@ -202,9 +189,9 @@ export default (
|
|
|
202
189
|
// only one container context--i.e., if we had an entry point per module,
|
|
203
190
|
// WMF could get confused and not resolve shared dependencies correctly.
|
|
204
191
|
output: {
|
|
205
|
-
publicPath:
|
|
192
|
+
publicPath: 'auto',
|
|
206
193
|
path: resolve(root, outDir),
|
|
207
|
-
hashFunction:
|
|
194
|
+
hashFunction: 'xxhash64',
|
|
208
195
|
},
|
|
209
196
|
module: {
|
|
210
197
|
rules: [
|
|
@@ -212,45 +199,45 @@ export default (
|
|
|
212
199
|
{
|
|
213
200
|
test: /\.m?(js|ts|tsx)$/,
|
|
214
201
|
exclude: /node_modules(?![\/\\]@openmrs)/,
|
|
215
|
-
use:
|
|
202
|
+
use: 'swc-loader',
|
|
216
203
|
},
|
|
217
|
-
scriptRuleConfig
|
|
204
|
+
scriptRuleConfig,
|
|
218
205
|
),
|
|
219
206
|
merge(
|
|
220
207
|
{
|
|
221
208
|
test: /\.css$/,
|
|
222
|
-
use: [require.resolve(
|
|
209
|
+
use: [require.resolve('style-loader'), cssLoader],
|
|
223
210
|
},
|
|
224
|
-
cssRuleConfig
|
|
211
|
+
cssRuleConfig,
|
|
225
212
|
),
|
|
226
213
|
merge(
|
|
227
214
|
{
|
|
228
215
|
test: /\.s[ac]ss$/i,
|
|
229
216
|
use: [
|
|
230
|
-
require.resolve(
|
|
217
|
+
require.resolve('style-loader'),
|
|
231
218
|
cssLoader,
|
|
232
219
|
{
|
|
233
|
-
loader: require.resolve(
|
|
220
|
+
loader: require.resolve('sass-loader'),
|
|
234
221
|
options: { sassOptions: { quietDeps: true } },
|
|
235
222
|
},
|
|
236
223
|
],
|
|
237
224
|
},
|
|
238
|
-
scssRuleConfig
|
|
225
|
+
scssRuleConfig,
|
|
239
226
|
),
|
|
240
227
|
merge(
|
|
241
228
|
{
|
|
242
229
|
test: /\.(png|jpe?g|gif|svg)$/i,
|
|
243
|
-
type:
|
|
230
|
+
type: 'asset/resource',
|
|
244
231
|
},
|
|
245
|
-
assetRuleConfig
|
|
232
|
+
assetRuleConfig,
|
|
246
233
|
),
|
|
247
234
|
],
|
|
248
235
|
},
|
|
249
236
|
mode,
|
|
250
|
-
devtool: mode === production ?
|
|
237
|
+
devtool: mode === production ? 'hidden-nosources-source-map' : 'source-map',
|
|
251
238
|
devServer: {
|
|
252
239
|
headers: {
|
|
253
|
-
|
|
240
|
+
'Access-Control-Allow-Origin': '*',
|
|
254
241
|
},
|
|
255
242
|
devMiddleware: {
|
|
256
243
|
writeToDisk: true,
|
|
@@ -259,12 +246,12 @@ export default (
|
|
|
259
246
|
},
|
|
260
247
|
watchOptions: merge(
|
|
261
248
|
{
|
|
262
|
-
ignored: [
|
|
249
|
+
ignored: ['.git', 'test-results'],
|
|
263
250
|
},
|
|
264
|
-
watchConfig
|
|
251
|
+
watchConfig,
|
|
265
252
|
),
|
|
266
253
|
performance: {
|
|
267
|
-
hints: mode === production &&
|
|
254
|
+
hints: mode === production && 'warning',
|
|
268
255
|
},
|
|
269
256
|
optimization: merge(
|
|
270
257
|
{
|
|
@@ -275,40 +262,37 @@ export default (
|
|
|
275
262
|
maxInitialRequests: 1,
|
|
276
263
|
},
|
|
277
264
|
},
|
|
278
|
-
optimizationConfig
|
|
265
|
+
optimizationConfig,
|
|
279
266
|
),
|
|
280
267
|
plugins: [
|
|
281
268
|
new ForkTsCheckerWebpackPlugin(),
|
|
282
269
|
new CleanWebpackPlugin(),
|
|
283
270
|
new BundleAnalyzerPlugin({
|
|
284
|
-
analyzerMode: env && env.analyze ?
|
|
271
|
+
analyzerMode: env && env.analyze ? 'server' : 'disabled',
|
|
285
272
|
}),
|
|
286
273
|
new DefinePlugin({
|
|
287
|
-
|
|
274
|
+
'process.env.FRAMEWORK_VERSION': JSON.stringify(frameworkVersion),
|
|
288
275
|
}),
|
|
289
276
|
new ModuleFederationPlugin({
|
|
290
277
|
// Look in the `esm-dynamic-loading` framework package for an explanation of how modules
|
|
291
278
|
// get loaded into the application.
|
|
292
279
|
name,
|
|
293
|
-
library: { type:
|
|
280
|
+
library: { type: 'var', name: slugify(name) },
|
|
294
281
|
filename,
|
|
295
282
|
exposes: {
|
|
296
|
-
|
|
283
|
+
'./start': srcFile,
|
|
297
284
|
},
|
|
298
|
-
shared: [
|
|
299
|
-
|
|
300
|
-
"@openmrs/esm-framework/src/internal",
|
|
301
|
-
].reduce((obj, depName) => {
|
|
302
|
-
if (depName === "swr") {
|
|
285
|
+
shared: [...Object.keys(peerDependencies), '@openmrs/esm-framework/src/internal'].reduce((obj, depName) => {
|
|
286
|
+
if (depName === 'swr') {
|
|
303
287
|
// SWR is annoying with Module Federation
|
|
304
288
|
// See: https://github.com/webpack/webpack/issues/16125 and https://github.com/vercel/swr/issues/2356
|
|
305
|
-
obj[
|
|
306
|
-
requiredVersion: peerDependencies[
|
|
289
|
+
obj['swr/'] = {
|
|
290
|
+
requiredVersion: peerDependencies['swr'] ?? false,
|
|
307
291
|
singleton: true,
|
|
308
|
-
import:
|
|
309
|
-
shareKey:
|
|
310
|
-
shareScope:
|
|
311
|
-
version: require(
|
|
292
|
+
import: 'swr/',
|
|
293
|
+
shareKey: 'swr/',
|
|
294
|
+
shareScope: 'default',
|
|
295
|
+
version: require('swr/package.json').version,
|
|
312
296
|
};
|
|
313
297
|
} else {
|
|
314
298
|
obj[depName] = {
|
|
@@ -316,7 +300,7 @@ export default (
|
|
|
316
300
|
singleton: true,
|
|
317
301
|
import: depName,
|
|
318
302
|
shareKey: depName,
|
|
319
|
-
shareScope:
|
|
303
|
+
shareScope: 'default',
|
|
320
304
|
};
|
|
321
305
|
}
|
|
322
306
|
|
|
@@ -332,11 +316,8 @@ export default (
|
|
|
332
316
|
transformer: (content) =>
|
|
333
317
|
JSON.stringify(
|
|
334
318
|
Object.assign({}, JSON.parse(content.toString()), {
|
|
335
|
-
version:
|
|
336
|
-
|
|
337
|
-
? version
|
|
338
|
-
: inc(version, "prerelease", "local"),
|
|
339
|
-
})
|
|
319
|
+
version: mode === production ? version : inc(version, 'prerelease', 'local'),
|
|
320
|
+
}),
|
|
340
321
|
),
|
|
341
322
|
},
|
|
342
323
|
},
|
|
@@ -351,9 +332,9 @@ export default (
|
|
|
351
332
|
}),
|
|
352
333
|
].filter(Boolean),
|
|
353
334
|
resolve: {
|
|
354
|
-
extensions: [
|
|
335
|
+
extensions: ['.tsx', '.ts', '.jsx', '.js', '.scss', '.json'],
|
|
355
336
|
alias: {
|
|
356
|
-
|
|
337
|
+
'@openmrs/esm-framework': '@openmrs/esm-framework/src/internal',
|
|
357
338
|
},
|
|
358
339
|
},
|
|
359
340
|
...overrides,
|