@openmrs/webpack-config 4.0.0-pre.0 → 4.0.1-pre.206
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 +2 -2
- package/dist/index.js +7 -3
- package/dist/optimize.js +0 -0
- package/package.json +2 -2
- package/src/index.ts +15 -6
- package/.turbo/turbo-lint.log +0 -2
- package/.turbo/turbo-test.log +0 -3
- package/dist/dynamic-register.js +0 -81
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
[
|
|
2
|
-
[
|
|
1
|
+
[32m@openmrs/webpack-config:build[0m: cache hit, replaying output [2m443ed1fd961bbc03[0m
|
|
2
|
+
[32m@openmrs/webpack-config:build: [0m$ tsc
|
package/dist/index.js
CHANGED
|
@@ -51,6 +51,7 @@ const webpack_stats_plugin_1 = require("webpack-stats-plugin");
|
|
|
51
51
|
// eslint-disable-next-line no-restricted-imports
|
|
52
52
|
const lodash_1 = require("lodash");
|
|
53
53
|
const optimize_1 = require("./optimize");
|
|
54
|
+
const semver_1 = require("semver");
|
|
54
55
|
const production = "production";
|
|
55
56
|
const { ModuleFederationPlugin } = webpack_1.container;
|
|
56
57
|
function getFrameworkVersion() {
|
|
@@ -117,7 +118,7 @@ exports.scssRuleConfig = {};
|
|
|
117
118
|
exports.assetRuleConfig = {};
|
|
118
119
|
exports.default = (env, argv = {}) => {
|
|
119
120
|
const root = process.cwd();
|
|
120
|
-
const { name, peerDependencies, browser, main, types } = require((0, path_1.resolve)(root, "package.json"));
|
|
121
|
+
const { name, version, peerDependencies, browser, main, types, } = require((0, path_1.resolve)(root, "package.json"));
|
|
121
122
|
const mode = argv.mode || process.env.NODE_ENV || "development";
|
|
122
123
|
const filename = (0, path_1.basename)(browser || main);
|
|
123
124
|
const outDir = (0, path_1.dirname)(browser || main);
|
|
@@ -138,7 +139,7 @@ exports.default = (env, argv = {}) => {
|
|
|
138
139
|
// only one container context--i.e., if we had an entry point per module,
|
|
139
140
|
// WMF could get confused and not resolve shared dependencies correctly.
|
|
140
141
|
output: {
|
|
141
|
-
// Use
|
|
142
|
+
// Use default `libraryTarget`, which is jsonp
|
|
142
143
|
publicPath: "auto",
|
|
143
144
|
path: (0, path_1.resolve)(root, outDir),
|
|
144
145
|
}, target: "web", module: {
|
|
@@ -170,7 +171,7 @@ exports.default = (env, argv = {}) => {
|
|
|
170
171
|
type: "asset/resource",
|
|
171
172
|
}, exports.assetRuleConfig),
|
|
172
173
|
],
|
|
173
|
-
}, mode, devtool: mode === production ?
|
|
174
|
+
}, mode, devtool: mode === production ? false : "inline-source-map", devServer: {
|
|
174
175
|
headers: {
|
|
175
176
|
"Access-Control-Allow-Origin": "*",
|
|
176
177
|
},
|
|
@@ -187,6 +188,9 @@ exports.default = (env, argv = {}) => {
|
|
|
187
188
|
analyzerMode: env && env.analyze ? "server" : "disabled",
|
|
188
189
|
}),
|
|
189
190
|
new webpack_1.DefinePlugin({
|
|
191
|
+
__VERSION__: mode === production
|
|
192
|
+
? JSON.stringify(version)
|
|
193
|
+
: JSON.stringify((0, semver_1.inc)(version, "prerelease", "local")),
|
|
190
194
|
"process.env.FRAMEWORK_VERSION": JSON.stringify(frameworkVersion),
|
|
191
195
|
}),
|
|
192
196
|
new ModuleFederationPlugin({
|
package/dist/optimize.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/webpack-config",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1-pre.206",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"typescript": "~4.5.2",
|
|
54
54
|
"webpack": "^5.64.0"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "7ac6e01b41238739cdf5d20efdff50062f46f500"
|
|
57
57
|
}
|
package/src/index.ts
CHANGED
|
@@ -45,6 +45,7 @@ import { StatsWriterPlugin } from "webpack-stats-plugin";
|
|
|
45
45
|
// eslint-disable-next-line no-restricted-imports
|
|
46
46
|
import { merge, mergeWith, isArray } from "lodash";
|
|
47
47
|
import { postProcessFile } from "./optimize";
|
|
48
|
+
import { inc } from "semver";
|
|
48
49
|
|
|
49
50
|
const production = "production";
|
|
50
51
|
const { ModuleFederationPlugin } = container;
|
|
@@ -127,10 +128,14 @@ export default (
|
|
|
127
128
|
argv: Record<string, string> = {}
|
|
128
129
|
) => {
|
|
129
130
|
const root = process.cwd();
|
|
130
|
-
const {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
const {
|
|
132
|
+
name,
|
|
133
|
+
version,
|
|
134
|
+
peerDependencies,
|
|
135
|
+
browser,
|
|
136
|
+
main,
|
|
137
|
+
types,
|
|
138
|
+
} = require(resolve(root, "package.json"));
|
|
134
139
|
const mode = argv.mode || process.env.NODE_ENV || "development";
|
|
135
140
|
const filename = basename(browser || main);
|
|
136
141
|
const outDir = dirname(browser || main);
|
|
@@ -153,7 +158,7 @@ export default (
|
|
|
153
158
|
// only one container context--i.e., if we had an entry point per module,
|
|
154
159
|
// WMF could get confused and not resolve shared dependencies correctly.
|
|
155
160
|
output: {
|
|
156
|
-
// Use
|
|
161
|
+
// Use default `libraryTarget`, which is jsonp
|
|
157
162
|
publicPath: "auto",
|
|
158
163
|
path: resolve(root, outDir),
|
|
159
164
|
},
|
|
@@ -201,7 +206,7 @@ export default (
|
|
|
201
206
|
],
|
|
202
207
|
},
|
|
203
208
|
mode,
|
|
204
|
-
devtool: mode === production ?
|
|
209
|
+
devtool: mode === production ? false : "inline-source-map",
|
|
205
210
|
devServer: {
|
|
206
211
|
headers: {
|
|
207
212
|
"Access-Control-Allow-Origin": "*",
|
|
@@ -221,6 +226,10 @@ export default (
|
|
|
221
226
|
analyzerMode: env && env.analyze ? "server" : "disabled",
|
|
222
227
|
}),
|
|
223
228
|
new DefinePlugin({
|
|
229
|
+
__VERSION__:
|
|
230
|
+
mode === production
|
|
231
|
+
? JSON.stringify(version)
|
|
232
|
+
: JSON.stringify(inc(version, "prerelease", "local")),
|
|
224
233
|
"process.env.FRAMEWORK_VERSION": JSON.stringify(frameworkVersion),
|
|
225
234
|
}),
|
|
226
235
|
new ModuleFederationPlugin({
|
package/.turbo/turbo-lint.log
DELETED
package/.turbo/turbo-test.log
DELETED
package/dist/dynamic-register.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.postProcessFile = exports.transformFile = void 0;
|
|
23
|
-
const types = __importStar(require("@babel/types"));
|
|
24
|
-
const core_1 = require("@babel/core");
|
|
25
|
-
const fs_1 = require("fs");
|
|
26
|
-
const path_1 = require("path");
|
|
27
|
-
function isUnique(current, index, arr) {
|
|
28
|
-
return arr.indexOf(current) === index;
|
|
29
|
-
}
|
|
30
|
-
function getFiles(manifest) {
|
|
31
|
-
const files = [];
|
|
32
|
-
manifest.chunks.forEach((chunk) => {
|
|
33
|
-
files.push(...chunk.files);
|
|
34
|
-
});
|
|
35
|
-
return files.filter(isUnique);
|
|
36
|
-
}
|
|
37
|
-
function transformFile(filename) {
|
|
38
|
-
var _a;
|
|
39
|
-
const root = (0, path_1.dirname)(filename);
|
|
40
|
-
const manifest = require(`${filename}.buildmanifest.json`);
|
|
41
|
-
const files = getFiles(manifest);
|
|
42
|
-
const code = (0, fs_1.readFileSync)(filename, "utf8");
|
|
43
|
-
const result = (0, core_1.transformSync)(code, {
|
|
44
|
-
filename,
|
|
45
|
-
sourceType: "script",
|
|
46
|
-
presets: ["minify"],
|
|
47
|
-
plugins: [
|
|
48
|
-
() => ({
|
|
49
|
-
visitor: {
|
|
50
|
-
Property(path) { },
|
|
51
|
-
CallExpression(path) {
|
|
52
|
-
const node = path.node;
|
|
53
|
-
if (types.isMemberExpression(node.callee) &&
|
|
54
|
-
types.isIdentifier(node.callee.object, { name: "System" }) &&
|
|
55
|
-
types.isIdentifier(node.callee.property, {
|
|
56
|
-
name: "register",
|
|
57
|
-
}) &&
|
|
58
|
-
node.arguments.length === 3 &&
|
|
59
|
-
types.isFunctionExpression(node.arguments[2])) {
|
|
60
|
-
path
|
|
61
|
-
.get("arguments.2.body")
|
|
62
|
-
.unshiftContainer("body", types.variableDeclaration("var", [
|
|
63
|
-
types.variableDeclarator(types.identifier("undefined")),
|
|
64
|
-
]));
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
}),
|
|
69
|
-
],
|
|
70
|
-
});
|
|
71
|
-
return [(_a = result === null || result === void 0 ? void 0 : result.code) === null || _a === void 0 ? void 0 : _a.split('"use strict";').join(""), code];
|
|
72
|
-
}
|
|
73
|
-
exports.transformFile = transformFile;
|
|
74
|
-
function postProcessFile(fn) {
|
|
75
|
-
const [result, original] = transformFile(fn);
|
|
76
|
-
if (result && original) {
|
|
77
|
-
(0, fs_1.writeFileSync)(fn.replace(".js", ".old"), original, "utf8");
|
|
78
|
-
(0, fs_1.writeFileSync)(fn.replace(".js", ".js"), result, "utf8");
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
exports.postProcessFile = postProcessFile;
|