openmrs 3.2.1-pre.933 → 3.2.1-pre.940
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/default-webpack-config.js +2 -209
- package/dist/utils/dependencies.js +1 -13
- package/dist/utils/importmap.js +3 -5
- package/package.json +5 -17
- package/src/utils/dependencies.ts +0 -20
- package/src/utils/importmap.ts +2 -18
|
@@ -1,210 +1,3 @@
|
|
|
1
|
-
const
|
|
2
|
-
const { resolve, dirname, basename } = require("path");
|
|
3
|
-
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
|
4
|
-
const { DefinePlugin, container } = require("webpack");
|
|
5
|
-
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
|
|
6
|
-
const { StatsWriterPlugin } = require("webpack-stats-plugin");
|
|
7
|
-
const { merge, mergeWith, isArray } = require("lodash");
|
|
1
|
+
const { default: extendConfig, ...rest } = require("@openmrs/webpack-config");
|
|
8
2
|
|
|
9
|
-
|
|
10
|
-
const { ModuleFederationPlugin } = container;
|
|
11
|
-
|
|
12
|
-
function getFrameworkVersion() {
|
|
13
|
-
try {
|
|
14
|
-
const { version } = require("@openmrs/esm-framework/package.json");
|
|
15
|
-
return `^${version}`;
|
|
16
|
-
} catch {
|
|
17
|
-
return "3.x";
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function makeIdent(name) {
|
|
22
|
-
if (name.indexOf("/") !== -1) {
|
|
23
|
-
name = name.substr(name.indexOf("/"));
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (name.endsWith("-app")) {
|
|
27
|
-
name = name.substr(0, name.length - 4);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return name;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const overrides = {};
|
|
34
|
-
const additionalConfig = {};
|
|
35
|
-
const scriptRuleConfig = {};
|
|
36
|
-
const cssRuleConfig = {};
|
|
37
|
-
const scssRuleConfig = {};
|
|
38
|
-
const assetRuleConfig = {};
|
|
39
|
-
|
|
40
|
-
module.exports = (env, argv = {}) => {
|
|
41
|
-
const root = process.cwd();
|
|
42
|
-
const { name, peerDependencies, browser, main, types } = require(resolve(
|
|
43
|
-
root,
|
|
44
|
-
"package.json"
|
|
45
|
-
));
|
|
46
|
-
const mode = argv.mode || process.env.NODE_ENV || "development";
|
|
47
|
-
const filename = basename(browser || main);
|
|
48
|
-
const outDir = dirname(browser || main);
|
|
49
|
-
const srcFile = resolve(root, browser ? main : types);
|
|
50
|
-
const ident = makeIdent(name);
|
|
51
|
-
const frameworkVersion = getFrameworkVersion();
|
|
52
|
-
|
|
53
|
-
const cssLoader = {
|
|
54
|
-
loader: "css-loader",
|
|
55
|
-
options: {
|
|
56
|
-
modules: {
|
|
57
|
-
localIdentName: `${ident}__[name]__[local]___[hash:base64:5]`,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const baseConfig = {
|
|
63
|
-
entry: {
|
|
64
|
-
[name]: "systemjs-webpack-interop/auto-public-path",
|
|
65
|
-
},
|
|
66
|
-
output: {
|
|
67
|
-
libraryTarget: "system",
|
|
68
|
-
publicPath: "",
|
|
69
|
-
path: resolve(root, outDir),
|
|
70
|
-
},
|
|
71
|
-
target: "web",
|
|
72
|
-
module: {
|
|
73
|
-
rules: [
|
|
74
|
-
merge(
|
|
75
|
-
{
|
|
76
|
-
test: /\.m?(js|ts|tsx)$/,
|
|
77
|
-
exclude: /(node_modules|bower_components)/,
|
|
78
|
-
use: {
|
|
79
|
-
loader: require.resolve("babel-loader"),
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
scriptRuleConfig
|
|
83
|
-
),
|
|
84
|
-
merge(
|
|
85
|
-
{
|
|
86
|
-
test: /\.css$/,
|
|
87
|
-
use: [require.resolve("style-loader"), cssLoader],
|
|
88
|
-
},
|
|
89
|
-
cssRuleConfig
|
|
90
|
-
),
|
|
91
|
-
merge(
|
|
92
|
-
{
|
|
93
|
-
test: /\.s[ac]ss$/i,
|
|
94
|
-
use: [
|
|
95
|
-
require.resolve("style-loader"),
|
|
96
|
-
cssLoader,
|
|
97
|
-
{ loader: require.resolve("sass-loader") },
|
|
98
|
-
],
|
|
99
|
-
},
|
|
100
|
-
scssRuleConfig
|
|
101
|
-
),
|
|
102
|
-
merge(
|
|
103
|
-
{
|
|
104
|
-
test: /\.(png|jpe?g|gif|svg)$/i,
|
|
105
|
-
type: "asset/resource",
|
|
106
|
-
},
|
|
107
|
-
assetRuleConfig
|
|
108
|
-
),
|
|
109
|
-
],
|
|
110
|
-
},
|
|
111
|
-
mode,
|
|
112
|
-
devtool: mode === production ? "source-map" : "inline-source-map",
|
|
113
|
-
devServer: {
|
|
114
|
-
headers: {
|
|
115
|
-
"Access-Control-Allow-Origin": "*",
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
performance: {
|
|
119
|
-
hints: mode === production && "warning",
|
|
120
|
-
},
|
|
121
|
-
plugins: [
|
|
122
|
-
new ForkTsCheckerWebpackPlugin(),
|
|
123
|
-
new CleanWebpackPlugin(),
|
|
124
|
-
new BundleAnalyzerPlugin({
|
|
125
|
-
analyzerMode: env && env.analyze ? "server" : "disabled",
|
|
126
|
-
}),
|
|
127
|
-
new DefinePlugin({
|
|
128
|
-
"process.env.FRAMEWORK_VERSION": JSON.stringify(frameworkVersion),
|
|
129
|
-
}),
|
|
130
|
-
new ModuleFederationPlugin({
|
|
131
|
-
name,
|
|
132
|
-
library: { type: "system", name },
|
|
133
|
-
filename,
|
|
134
|
-
exposes: {
|
|
135
|
-
app: srcFile,
|
|
136
|
-
},
|
|
137
|
-
shared: Object.keys(peerDependencies).reduce((obj, depName) => {
|
|
138
|
-
obj[depName] = {
|
|
139
|
-
requiredVersion: peerDependencies[depName],
|
|
140
|
-
singleton: true,
|
|
141
|
-
import: depName,
|
|
142
|
-
shareKey: depName,
|
|
143
|
-
shareScope: "default",
|
|
144
|
-
};
|
|
145
|
-
return obj;
|
|
146
|
-
}, {}),
|
|
147
|
-
}),
|
|
148
|
-
new StatsWriterPlugin({
|
|
149
|
-
filename: `${filename}.buildmanifest.json`,
|
|
150
|
-
stats: {
|
|
151
|
-
all: false,
|
|
152
|
-
chunks: true,
|
|
153
|
-
},
|
|
154
|
-
}),
|
|
155
|
-
],
|
|
156
|
-
resolve: {
|
|
157
|
-
extensions: [".tsx", ".ts", ".jsx", ".js", ".scss"],
|
|
158
|
-
},
|
|
159
|
-
...overrides,
|
|
160
|
-
};
|
|
161
|
-
return mergeWith(baseConfig, additionalConfig, mergeFunction);
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
function mergeFunction(objValue, srcValue) {
|
|
165
|
-
if (isArray(objValue)) {
|
|
166
|
-
return objValue.concat(srcValue);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* This object will be merged into the webpack config.
|
|
172
|
-
* Array values will be concatenated with the existing array.
|
|
173
|
-
* Make sure to modify this object and not reassign it.
|
|
174
|
-
*/
|
|
175
|
-
module.exports.additionalConfig = additionalConfig;
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* The keys of this object will override the top-level keys
|
|
179
|
-
* of the webpack config.
|
|
180
|
-
* Make sure to modify this object and not reassign it.
|
|
181
|
-
*/
|
|
182
|
-
module.exports.overrides = overrides;
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* This object will be merged into the webpack rule governing
|
|
186
|
-
* the loading of JS, JSX, TS, etc. files.
|
|
187
|
-
* Make sure to modify this object and not reassign it.
|
|
188
|
-
*/
|
|
189
|
-
module.exports.scriptRuleConfig = scriptRuleConfig;
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* This object will be merged into the webpack rule governing
|
|
193
|
-
* the loading of CSS files.
|
|
194
|
-
* Make sure to modify this object and not reassign it.
|
|
195
|
-
*/
|
|
196
|
-
module.exports.cssRuleConfig = cssRuleConfig;
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* This object will be merged into the webpack rule governing
|
|
200
|
-
* the loading of SCSS files.
|
|
201
|
-
* Make sure to modify this object and not reassign it.
|
|
202
|
-
*/
|
|
203
|
-
module.exports.scssRuleConfig = scssRuleConfig;
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* This object will be merged into the webpack rule governing
|
|
207
|
-
* the loading of static asset files.
|
|
208
|
-
* Make sure to modify this object and not reassign it.
|
|
209
|
-
*/
|
|
210
|
-
module.exports.assetRuleConfig = assetRuleConfig;
|
|
3
|
+
module.exports = Object.assign(extendConfig, rest);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getMainBundle = exports.getSharedDependencies = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
function getSharedDependencies() {
|
|
6
6
|
return require("@openmrs/esm-app-shell/dependencies.json");
|
|
@@ -15,15 +15,3 @@ function getMainBundle(project) {
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
exports.getMainBundle = getMainBundle;
|
|
18
|
-
function getDependentModules(root, host, peerDependencies = {}, sharedDependencies = []) {
|
|
19
|
-
const appShellShared = [...getSharedDependencies(), ...sharedDependencies];
|
|
20
|
-
const mifeExpected = Object.keys(peerDependencies);
|
|
21
|
-
const mifeRequired = mifeExpected.filter((name) => !appShellShared.includes(name));
|
|
22
|
-
return mifeRequired.reduce((deps, moduleName) => {
|
|
23
|
-
const project = require(`${root}/node_modules/${moduleName}/package.json`);
|
|
24
|
-
const bundle = getMainBundle(project);
|
|
25
|
-
deps[moduleName] = `${host}/node_modules/${moduleName}/${bundle.path}`;
|
|
26
|
-
return deps;
|
|
27
|
-
}, {});
|
|
28
|
-
}
|
|
29
|
-
exports.getDependentModules = getDependentModules;
|
package/dist/utils/importmap.js
CHANGED
|
@@ -79,12 +79,10 @@ function matchAny(baseDir, patterns) {
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
const defaultConfigPath = (0, path_1.resolve)(__dirname, "..", "..", "default-webpack-config.js");
|
|
82
|
-
function runProjectWebpack(configPath, port, project,
|
|
82
|
+
function runProjectWebpack(configPath, port, project, sourceDirectory, importMap) {
|
|
83
83
|
const bundle = (0, dependencies_1.getMainBundle)(project);
|
|
84
84
|
const host = `http://localhost:${port}`;
|
|
85
|
-
const dependencies = (0, dependencies_1.getDependentModules)(process.cwd(), host, project.peerDependencies, sharedDependencies);
|
|
86
85
|
(0, webpack_1.startWebpack)(configPath, port, sourceDirectory);
|
|
87
|
-
Object.assign(importMap, dependencies);
|
|
88
86
|
importMap[project.name] = `${host}/${bundle.name}`;
|
|
89
87
|
}
|
|
90
88
|
function runProject(basePort, sharedDependencies, sourceDirectoryPatterns) {
|
|
@@ -120,11 +118,11 @@ function runProject(basePort, sharedDependencies, sourceDirectoryPatterns) {
|
|
|
120
118
|
else if (!(0, fs_1.existsSync)(configPath)) {
|
|
121
119
|
// try to locate and run via default webpack
|
|
122
120
|
(0, logger_1.logWarn)(`No "webpack.config.json" found in directory "${sourceDirectory}". Trying to use default config ...`);
|
|
123
|
-
runProjectWebpack(defaultConfigPath, port, project,
|
|
121
|
+
runProjectWebpack(defaultConfigPath, port, project, sourceDirectory, importMap);
|
|
124
122
|
}
|
|
125
123
|
else {
|
|
126
124
|
// run via specialized webpack.config.js
|
|
127
|
-
runProjectWebpack(configPath, port, project,
|
|
125
|
+
runProjectWebpack(configPath, port, project, sourceDirectory, importMap);
|
|
128
126
|
}
|
|
129
127
|
}
|
|
130
128
|
(0, logger_1.logInfo)(`Assembled dynamic import map (${Object.keys(importMap).join(", ")}).`);
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openmrs",
|
|
3
|
-
"version": "3.2.1-pre.
|
|
3
|
+
"version": "3.2.1-pre.940",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"openmrs": "./dist/cli.js"
|
|
8
8
|
},
|
|
9
|
+
"types": "src/index.ts",
|
|
9
10
|
"engines": {
|
|
10
11
|
"node": ">= 12.0.0"
|
|
11
12
|
},
|
|
@@ -31,23 +32,16 @@
|
|
|
31
32
|
],
|
|
32
33
|
"homepage": "https://github.com/openmrs/openmrs-esm-core#readme",
|
|
33
34
|
"dependencies": {
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@babel/preset-react": "^7.10.4",
|
|
37
|
-
"@babel/preset-typescript": "^7.10.4",
|
|
38
|
-
"@openmrs/esm-app-shell": "3.2.1-pre.933",
|
|
35
|
+
"@openmrs/esm-app-shell": "3.2.1-pre.940",
|
|
36
|
+
"@openmrs/webpack-config": "^3.2.1-pre.940",
|
|
39
37
|
"@types/react": "^16.9.46",
|
|
40
38
|
"@types/systemjs": "^6.1.0",
|
|
41
39
|
"autoprefixer": "^10.4.2",
|
|
42
40
|
"axios": "^0.21.1",
|
|
43
|
-
"babel-loader": "^8.2.2",
|
|
44
41
|
"browserslist-config-openmrs": "^1.0.1",
|
|
45
|
-
"clean-webpack-plugin": "^4.0.0",
|
|
46
42
|
"copy-webpack-plugin": "^10.0.0",
|
|
47
|
-
"css-loader": "^5.2.4",
|
|
48
43
|
"cssnano": "^5.0.16",
|
|
49
44
|
"ejs": "^2.6.2",
|
|
50
|
-
"fork-ts-checker-webpack-plugin": "^6.5.0",
|
|
51
45
|
"glob": "^7.1.3",
|
|
52
46
|
"html-webpack-plugin": "^5.5.0",
|
|
53
47
|
"inquirer": "^7.3.3",
|
|
@@ -55,19 +49,13 @@
|
|
|
55
49
|
"postcss": "^8.4.6",
|
|
56
50
|
"postcss-loader": "^6.2.1",
|
|
57
51
|
"rimraf": "^3.0.2",
|
|
58
|
-
"sass": "^1.44.0",
|
|
59
|
-
"sass-loader": "^12.3.0",
|
|
60
|
-
"style-loader": "^3.3.1",
|
|
61
|
-
"systemjs-webpack-interop": "^2.3.7",
|
|
62
52
|
"tar": "^6.0.5",
|
|
63
53
|
"ts-loader": "^9.2.6",
|
|
64
54
|
"typescript": "~4.5.2",
|
|
65
55
|
"webpack": "^5.64.0",
|
|
66
|
-
"webpack-bundle-analyzer": "^4.5.0",
|
|
67
56
|
"webpack-cli": "^4.9.1",
|
|
68
57
|
"webpack-dev-server": "^4.6.0",
|
|
69
58
|
"webpack-pwa-manifest": "^4.3.0",
|
|
70
|
-
"webpack-stats-plugin": "^1.0.3",
|
|
71
59
|
"workbox-webpack-plugin": "^6.4.1",
|
|
72
60
|
"yargs": "16.0.3"
|
|
73
61
|
},
|
|
@@ -79,5 +67,5 @@
|
|
|
79
67
|
"@types/rimraf": "^2.0.2",
|
|
80
68
|
"@types/tar": "^4.0.3"
|
|
81
69
|
},
|
|
82
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "91a29fc9adab5602ee21e570d9df4f98955c7811"
|
|
83
71
|
}
|
|
@@ -12,23 +12,3 @@ export function getMainBundle(project: any) {
|
|
|
12
12
|
dir: dirname(file),
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
export function getDependentModules(
|
|
17
|
-
root: string,
|
|
18
|
-
host: string,
|
|
19
|
-
peerDependencies: Record<string, string> = {},
|
|
20
|
-
sharedDependencies: Array<string> = []
|
|
21
|
-
) {
|
|
22
|
-
const appShellShared = [...getSharedDependencies(), ...sharedDependencies];
|
|
23
|
-
const mifeExpected = Object.keys(peerDependencies);
|
|
24
|
-
const mifeRequired = mifeExpected.filter(
|
|
25
|
-
(name) => !appShellShared.includes(name)
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
return mifeRequired.reduce((deps, moduleName) => {
|
|
29
|
-
const project = require(`${root}/node_modules/${moduleName}/package.json`);
|
|
30
|
-
const bundle = getMainBundle(project);
|
|
31
|
-
deps[moduleName] = `${host}/node_modules/${moduleName}/${bundle.path}`;
|
|
32
|
-
return deps;
|
|
33
|
-
}, {});
|
|
34
|
-
}
|
package/src/utils/importmap.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { existsSync, readFileSync } from "fs";
|
|
|
4
4
|
import { exec } from "child_process";
|
|
5
5
|
import { logFail, logInfo, logWarn } from "./logger";
|
|
6
6
|
import { startWebpack } from "./webpack";
|
|
7
|
-
import {
|
|
7
|
+
import { getMainBundle } from "./dependencies";
|
|
8
8
|
import axios from "axios";
|
|
9
9
|
|
|
10
10
|
import glob = require("glob");
|
|
@@ -89,21 +89,13 @@ function runProjectWebpack(
|
|
|
89
89
|
configPath: string,
|
|
90
90
|
port: number,
|
|
91
91
|
project: any,
|
|
92
|
-
sharedDependencies: Array<string>,
|
|
93
92
|
sourceDirectory: string,
|
|
94
93
|
importMap: Record<string, string>
|
|
95
94
|
) {
|
|
96
95
|
const bundle = getMainBundle(project);
|
|
97
96
|
const host = `http://localhost:${port}`;
|
|
98
|
-
const dependencies = getDependentModules(
|
|
99
|
-
process.cwd(),
|
|
100
|
-
host,
|
|
101
|
-
project.peerDependencies,
|
|
102
|
-
sharedDependencies
|
|
103
|
-
);
|
|
104
97
|
|
|
105
98
|
startWebpack(configPath, port, sourceDirectory);
|
|
106
|
-
Object.assign(importMap, dependencies);
|
|
107
99
|
importMap[project.name] = `${host}/${bundle.name}`;
|
|
108
100
|
}
|
|
109
101
|
|
|
@@ -156,20 +148,12 @@ export async function runProject(
|
|
|
156
148
|
defaultConfigPath,
|
|
157
149
|
port,
|
|
158
150
|
project,
|
|
159
|
-
sharedDependencies,
|
|
160
151
|
sourceDirectory,
|
|
161
152
|
importMap
|
|
162
153
|
);
|
|
163
154
|
} else {
|
|
164
155
|
// run via specialized webpack.config.js
|
|
165
|
-
runProjectWebpack(
|
|
166
|
-
configPath,
|
|
167
|
-
port,
|
|
168
|
-
project,
|
|
169
|
-
sharedDependencies,
|
|
170
|
-
sourceDirectory,
|
|
171
|
-
importMap
|
|
172
|
-
);
|
|
156
|
+
runProjectWebpack(configPath, port, project, sourceDirectory, importMap);
|
|
173
157
|
}
|
|
174
158
|
}
|
|
175
159
|
|