@openremote/util 1.8.0-snapshot.20250723094757 → 1.8.0-snapshot.20250725120000
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/cli.js +61 -61
- package/package.json +10 -24
- package/webpack.util.js +275 -302
package/cli.js
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const path = require("path");
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const { spawnSync } = require("child_process");
|
|
5
|
-
const { spawn } = require("child_process");
|
|
6
|
-
|
|
7
|
-
/* THIS IS JUST A WRAPPER THAT LAUNCHES GRADLE TASKS */
|
|
8
|
-
|
|
9
|
-
/* Try and find the gradle wrapper in a parent dir */
|
|
10
|
-
function getGradleDirectory() {
|
|
11
|
-
let dirs = process.cwd().split(path.sep);
|
|
12
|
-
let cwd = dirs.join(path.sep);
|
|
13
|
-
|
|
14
|
-
while (dirs.length > 0 && !fs.existsSync(path.join(cwd, "gradlew"))) {
|
|
15
|
-
dirs.pop();
|
|
16
|
-
cwd = dirs.join(path.sep);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (!fs.existsSync(path.join(cwd, "gradlew"))) {
|
|
20
|
-
console.log("Failed to locate gradlew in a parent directory of: " + process.cwd());
|
|
21
|
-
process.exit(1);
|
|
22
|
-
} else {
|
|
23
|
-
console.log("Located gradlew in parent directory: " + cwd);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return cwd;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (process.argv.length >= 3 && process.argv[2] =="watch") {
|
|
30
|
-
|
|
31
|
-
// Do watch
|
|
32
|
-
let cwd = getWorkingDirectory();
|
|
33
|
-
console.log("Watching model for changes...");
|
|
34
|
-
const child = spawn((process.platform === "win32" ? "gradlew" : "./gradlew"), ["-t", "modelWatch"], {
|
|
35
|
-
cwd: cwd,
|
|
36
|
-
shell: true
|
|
37
|
-
});
|
|
38
|
-
child.stdout.removeAllListeners("data");
|
|
39
|
-
child.stderr.removeAllListeners("data");
|
|
40
|
-
child.stdout.pipe(process.stdout);
|
|
41
|
-
child.stderr.pipe(process.stderr);
|
|
42
|
-
|
|
43
|
-
child.on("exit", function() {
|
|
44
|
-
console.log("gradlew modelWatch finished! Status = " + child.status);
|
|
45
|
-
process.exit(child.status);
|
|
46
|
-
});
|
|
47
|
-
} else {
|
|
48
|
-
|
|
49
|
-
// Do build
|
|
50
|
-
let cwd = getGradleDirectory();
|
|
51
|
-
console.log("Running gradlew modelBuild task in " + cwd + " ...");
|
|
52
|
-
const gradleModelWatch = spawnSync((process.platform === "win32" ? "gradlew" : "./gradlew"), ["modelWatch"], {
|
|
53
|
-
cwd: cwd,
|
|
54
|
-
shell: true
|
|
55
|
-
});
|
|
56
|
-
console.log("gradlew modelWatch finished! Status = " + gradleModelWatch.status);
|
|
57
|
-
if (gradleModelWatch.stderr) {
|
|
58
|
-
console.log(gradleModelWatch.stderr.toString());
|
|
59
|
-
}
|
|
60
|
-
process.exit(gradleModelWatch.status);
|
|
61
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const { spawnSync } = require("child_process");
|
|
5
|
+
const { spawn } = require("child_process");
|
|
6
|
+
|
|
7
|
+
/* THIS IS JUST A WRAPPER THAT LAUNCHES GRADLE TASKS */
|
|
8
|
+
|
|
9
|
+
/* Try and find the gradle wrapper in a parent dir */
|
|
10
|
+
function getGradleDirectory() {
|
|
11
|
+
let dirs = process.cwd().split(path.sep);
|
|
12
|
+
let cwd = dirs.join(path.sep);
|
|
13
|
+
|
|
14
|
+
while (dirs.length > 0 && !fs.existsSync(path.join(cwd, "gradlew"))) {
|
|
15
|
+
dirs.pop();
|
|
16
|
+
cwd = dirs.join(path.sep);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!fs.existsSync(path.join(cwd, "gradlew"))) {
|
|
20
|
+
console.log("Failed to locate gradlew in a parent directory of: " + process.cwd());
|
|
21
|
+
process.exit(1);
|
|
22
|
+
} else {
|
|
23
|
+
console.log("Located gradlew in parent directory: " + cwd);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return cwd;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (process.argv.length >= 3 && process.argv[2] =="watch") {
|
|
30
|
+
|
|
31
|
+
// Do watch
|
|
32
|
+
let cwd = getWorkingDirectory();
|
|
33
|
+
console.log("Watching model for changes...");
|
|
34
|
+
const child = spawn((process.platform === "win32" ? "gradlew" : "./gradlew"), ["-t", "modelWatch"], {
|
|
35
|
+
cwd: cwd,
|
|
36
|
+
shell: true
|
|
37
|
+
});
|
|
38
|
+
child.stdout.removeAllListeners("data");
|
|
39
|
+
child.stderr.removeAllListeners("data");
|
|
40
|
+
child.stdout.pipe(process.stdout);
|
|
41
|
+
child.stderr.pipe(process.stderr);
|
|
42
|
+
|
|
43
|
+
child.on("exit", function() {
|
|
44
|
+
console.log("gradlew modelWatch finished! Status = " + child.status);
|
|
45
|
+
process.exit(child.status);
|
|
46
|
+
});
|
|
47
|
+
} else {
|
|
48
|
+
|
|
49
|
+
// Do build
|
|
50
|
+
let cwd = getGradleDirectory();
|
|
51
|
+
console.log("Running gradlew modelBuild task in " + cwd + " ...");
|
|
52
|
+
const gradleModelWatch = spawnSync((process.platform === "win32" ? "gradlew" : "./gradlew"), ["modelWatch"], {
|
|
53
|
+
cwd: cwd,
|
|
54
|
+
shell: true
|
|
55
|
+
});
|
|
56
|
+
console.log("gradlew modelWatch finished! Status = " + gradleModelWatch.status);
|
|
57
|
+
if (gradleModelWatch.stderr) {
|
|
58
|
+
console.log(gradleModelWatch.stderr.toString());
|
|
59
|
+
}
|
|
60
|
+
process.exit(gradleModelWatch.status);
|
|
61
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openremote/util",
|
|
3
|
-
"version": "1.8.0-snapshot.
|
|
3
|
+
"version": "1.8.0-snapshot.20250725120000",
|
|
4
4
|
"description": "Build Util",
|
|
5
5
|
"author": "OpenRemote",
|
|
6
6
|
"main": "webpack.util.js",
|
|
@@ -9,41 +9,27 @@
|
|
|
9
9
|
},
|
|
10
10
|
"license": "AGPL-3.0-or-later",
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@babel/core": "^7.16.0",
|
|
13
|
-
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
14
|
-
"@babel/plugin-syntax-object-rest-spread": "^7.8.3",
|
|
15
|
-
"@babel/plugin-transform-regenerator": "^7.16.0",
|
|
16
|
-
"@babel/plugin-transform-runtime": "^7.16.4",
|
|
17
|
-
"@babel/preset-env": "^7.16.4",
|
|
18
|
-
"@babel/runtime": "^7.16.3",
|
|
19
12
|
"@custom-elements-manifest/analyzer": "^0.10.4",
|
|
13
|
+
"@rspack/cli": "^1.4.4",
|
|
14
|
+
"@rspack/core": "^1.4.4",
|
|
20
15
|
"@typescript-eslint/eslint-plugin": "^5.9.0",
|
|
21
16
|
"@typescript-eslint/parser": "^5.9.0",
|
|
22
|
-
"babel-loader": "^8.2.3",
|
|
23
|
-
"copy-webpack-plugin": "^10.0.0",
|
|
24
17
|
"cross-env": "^7.0.3",
|
|
25
|
-
"css-loader": "^
|
|
18
|
+
"css-loader": "^7.1.2",
|
|
26
19
|
"eslint": "^8.6.0",
|
|
27
20
|
"eslint-config-prettier": "^8.3.0",
|
|
28
21
|
"eslint-config-standard": "^16.0.3",
|
|
29
22
|
"eslint-plugin-import": "^2.25.4",
|
|
30
23
|
"eslint-plugin-node": "^11.1.0",
|
|
31
24
|
"eslint-plugin-promise": "^6.0.0",
|
|
32
|
-
"
|
|
33
|
-
"file-loader": "^6.2.0",
|
|
34
|
-
"fork-ts-checker-notifier-webpack-plugin": "^9.0.0",
|
|
35
|
-
"fork-ts-checker-webpack-plugin": "^9.0.2",
|
|
36
|
-
"html-webpack-plugin": "^5.5.0",
|
|
25
|
+
"html-webpack-plugin": "^5.6.3",
|
|
37
26
|
"prettier": "^2.5.1",
|
|
38
27
|
"querystring-es3": "^0.2.1",
|
|
39
|
-
"shx": "
|
|
40
|
-
"source-map-loader": "^
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"webpack": "^5.90.1",
|
|
45
|
-
"webpack-cli": "^5.1.4",
|
|
46
|
-
"webpack-dev-server": "^4.15.1"
|
|
28
|
+
"shx": "~0.4.0",
|
|
29
|
+
"source-map-loader": "^5.0.0",
|
|
30
|
+
"ts-loader": "~9.5.2",
|
|
31
|
+
"typescript": "~5.8.3",
|
|
32
|
+
"webpack": "^5.99.8"
|
|
47
33
|
},
|
|
48
34
|
"publishConfig": {
|
|
49
35
|
"access": "public"
|
package/webpack.util.js
CHANGED
|
@@ -1,302 +1,275 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
console.log("");
|
|
52
|
-
console.log("
|
|
53
|
-
console.log("
|
|
54
|
-
console.log("");
|
|
55
|
-
console.log("
|
|
56
|
-
console.log("
|
|
57
|
-
console.log("");
|
|
58
|
-
console.log("
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
//
|
|
120
|
-
config.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
)
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
return
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
const config = {
|
|
278
|
-
entry: entry,
|
|
279
|
-
mode: "production",
|
|
280
|
-
output: {
|
|
281
|
-
filename: "[name].js",
|
|
282
|
-
path: path.resolve(dirname, "dist/umd"),
|
|
283
|
-
library: libName,
|
|
284
|
-
libraryTarget: "umd"
|
|
285
|
-
},
|
|
286
|
-
resolve: {
|
|
287
|
-
extensions: [".ts", ".tsx", "..."],
|
|
288
|
-
fallback: { "vm": false }
|
|
289
|
-
},
|
|
290
|
-
module: {...getStandardModuleRules()},
|
|
291
|
-
externals: generateExternals(bundle)
|
|
292
|
-
};
|
|
293
|
-
|
|
294
|
-
return config;
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
module.exports = {
|
|
299
|
-
getLibName: getLibName,
|
|
300
|
-
generateExports: generateExports,
|
|
301
|
-
getAppConfig: getAppConfig
|
|
302
|
-
};
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const { rspack } = require('@rspack/core');
|
|
4
|
+
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
5
|
+
|
|
6
|
+
function getStandardModuleRules() {
|
|
7
|
+
return {
|
|
8
|
+
rules: [
|
|
9
|
+
{
|
|
10
|
+
test: /(maplibre|mapbox|@material|gridstack|@mdi).*\.css$/, //output css as strings
|
|
11
|
+
type: "asset/source"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
test: /\.css$/, //
|
|
15
|
+
exclude: /(maplibre|mapbox|@material|gridstack|@mdi).*\.css$/,
|
|
16
|
+
use: [
|
|
17
|
+
{ loader: "css-loader" }
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
test: /\.(png|jpg|ico|gif|svg|eot|ttf|woff|woff2|mp4)$/,
|
|
22
|
+
type: "asset",
|
|
23
|
+
generator: {
|
|
24
|
+
filename: 'images/[hash][ext][query]'
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
test: /\.tsx?$/,
|
|
29
|
+
exclude: /node_modules/,
|
|
30
|
+
use: {
|
|
31
|
+
// TODO: Switch to builtin:swc-loader, and remove ts-loader / webpack dependency
|
|
32
|
+
loader: "ts-loader",
|
|
33
|
+
options: {
|
|
34
|
+
projectReferences: true
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function getAppConfig(mode, isDevServer, dirname, managerUrl, keycloakUrl, port) {
|
|
43
|
+
const production = mode === "production";
|
|
44
|
+
port = port || 9000;
|
|
45
|
+
managerUrl = managerUrl || (production && !isDevServer ? undefined : "http://localhost:8080");
|
|
46
|
+
const OUTPUT_PATH = isDevServer ? 'src' : 'dist';
|
|
47
|
+
|
|
48
|
+
if (isDevServer) {
|
|
49
|
+
console.log("");
|
|
50
|
+
console.log("To customise the URL of the manager and/or keycloak use the managerUrl and/or keycloakUrl");
|
|
51
|
+
console.log(" environment arguments e.g: ");
|
|
52
|
+
console.log("");
|
|
53
|
+
console.log("npm run serve -- --env managerUrl=https://localhost");
|
|
54
|
+
console.log("npm run serve -- --env keycloakUrl=https://localhost/auth");
|
|
55
|
+
console.log("");
|
|
56
|
+
console.log("MANAGER URL: " + managerUrl || "");
|
|
57
|
+
console.log("KEYCLOAK URL: " + keycloakUrl || (managerUrl + "/auth"));
|
|
58
|
+
console.log("");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const config = {
|
|
62
|
+
entry: {
|
|
63
|
+
'bundle': './src/index.ts'
|
|
64
|
+
},
|
|
65
|
+
output: {
|
|
66
|
+
path: dirname + "/dist",
|
|
67
|
+
publicPath: isDevServer ? "/" + dirname.split(path.sep).slice(-1)[0] + "/" : "./",
|
|
68
|
+
filename: production ? "[name].[contenthash].js" : "[name].js"
|
|
69
|
+
},
|
|
70
|
+
module: {...getStandardModuleRules()},
|
|
71
|
+
// optimization: {
|
|
72
|
+
// minimize: true,
|
|
73
|
+
// minimizer: [
|
|
74
|
+
// // For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
|
|
75
|
+
// // `...`,
|
|
76
|
+
// new CssMinimizerPlugin(),
|
|
77
|
+
// ],
|
|
78
|
+
// },
|
|
79
|
+
resolve: {
|
|
80
|
+
extensions: [".ts", ".tsx", "..."],
|
|
81
|
+
fallback: {
|
|
82
|
+
"vm": false,
|
|
83
|
+
"querystring": require.resolve("querystring-es3")
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
config.plugins = [
|
|
89
|
+
// Conditional compilation variables
|
|
90
|
+
new rspack.DefinePlugin({
|
|
91
|
+
PRODUCTION: JSON.stringify(production),
|
|
92
|
+
MANAGER_URL: JSON.stringify(managerUrl),
|
|
93
|
+
KEYCLOAK_URL: JSON.stringify(keycloakUrl),
|
|
94
|
+
"process.env": {
|
|
95
|
+
BABEL_ENV: JSON.stringify(mode)
|
|
96
|
+
}
|
|
97
|
+
}),
|
|
98
|
+
// Generate our index page
|
|
99
|
+
new HtmlWebpackPlugin({
|
|
100
|
+
chunksSortMode: 'none',
|
|
101
|
+
inject: false,
|
|
102
|
+
template: 'index.html'
|
|
103
|
+
})
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
if (production) {
|
|
107
|
+
config.module.rules.push(
|
|
108
|
+
{
|
|
109
|
+
test: /\.js$/,
|
|
110
|
+
include: function(modulePath) {
|
|
111
|
+
return /(@webcomponents[\/|\\]shadycss|lit-css|styled-lit-element|lit-element|lit-html|@polymer|@lit|pwa-helpers)/.test(modulePath) || !/node_modules/.test(modulePath);
|
|
112
|
+
},
|
|
113
|
+
loader: 'builtin:swc-loader',
|
|
114
|
+
},
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (isDevServer) {
|
|
119
|
+
// Load source maps generated by typescript
|
|
120
|
+
// config.devtool = 'inline-source-map';
|
|
121
|
+
config.module.rules.push(
|
|
122
|
+
{
|
|
123
|
+
test: /\.js$/,
|
|
124
|
+
use: ["source-map-loader"],
|
|
125
|
+
enforce: "pre",
|
|
126
|
+
exclude: [
|
|
127
|
+
/node_modules/
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Build list of resources to copy
|
|
134
|
+
const patterns = [
|
|
135
|
+
{
|
|
136
|
+
from: path.dirname(require.resolve("@webcomponents/webcomponentsjs")),
|
|
137
|
+
to: "modules/@webcomponents/webcomponentsjs",
|
|
138
|
+
globOptions: {
|
|
139
|
+
ignore: ["!*.js"]
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
];
|
|
143
|
+
// Check if images dir exists
|
|
144
|
+
if (fs.existsSync(path.join(dirname, "images"))) {
|
|
145
|
+
patterns.push(
|
|
146
|
+
{
|
|
147
|
+
from: "./images",
|
|
148
|
+
to: "images"
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
// Check if locales dir exists
|
|
153
|
+
if (fs.existsSync(path.join(dirname, "locales"))) {
|
|
154
|
+
patterns.push(
|
|
155
|
+
{
|
|
156
|
+
from: "./locales",
|
|
157
|
+
to: "locales"
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
// Check if htaccess file exists
|
|
162
|
+
if (fs.existsSync(path.join(dirname, ".htaccess"))) {
|
|
163
|
+
patterns.push(
|
|
164
|
+
{
|
|
165
|
+
from: ".htaccess",
|
|
166
|
+
to: ".htaccess",
|
|
167
|
+
toType: 'file'
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
//Check if .appignore file exists
|
|
172
|
+
if (fs.existsSync(path.join(dirname, ".appignore"))) {
|
|
173
|
+
patterns.push(
|
|
174
|
+
{
|
|
175
|
+
from: ".appignore",
|
|
176
|
+
to: ".appignore",
|
|
177
|
+
toType: 'file'
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Copy unprocessed files
|
|
183
|
+
config.plugins.push(
|
|
184
|
+
new rspack.CopyRspackPlugin({
|
|
185
|
+
patterns: patterns
|
|
186
|
+
})
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
config.devtool = !isDevServer ? false : "inline-source-map";
|
|
190
|
+
config.devServer = {
|
|
191
|
+
historyApiFallback: {
|
|
192
|
+
index: "/" + dirname.split(path.sep).slice(-1)[0] + "/",
|
|
193
|
+
},
|
|
194
|
+
port: port,
|
|
195
|
+
open: false,
|
|
196
|
+
hot: false, // HMR doesn't work with webcomponents at present
|
|
197
|
+
liveReload: true,
|
|
198
|
+
static: OUTPUT_PATH
|
|
199
|
+
};
|
|
200
|
+
config.watchOptions = {
|
|
201
|
+
ignored: ['node_modules']
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return config;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function getLibName(componentName) {
|
|
208
|
+
if (componentName.startsWith("or-")) {
|
|
209
|
+
componentName = componentName.substr(3);
|
|
210
|
+
}
|
|
211
|
+
componentName = componentName.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
|
|
212
|
+
return "OR" + componentName.charAt(0).toUpperCase() + componentName.substring(1);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function ORExternals(context, callback) {
|
|
216
|
+
const match = context.request.match(/^@openremote\/([^\/]*)$/);
|
|
217
|
+
if (match) {
|
|
218
|
+
let component = getLibName(match[1]);
|
|
219
|
+
console.log(context.request + " => " + component);
|
|
220
|
+
return callback(null, "umd " + component);
|
|
221
|
+
}
|
|
222
|
+
callback();
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function generateExternals(bundle) {
|
|
226
|
+
if (!bundle) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const externals = [];
|
|
231
|
+
|
|
232
|
+
if (bundle.excludeOr) {
|
|
233
|
+
externals.push(ORExternals);
|
|
234
|
+
}
|
|
235
|
+
if (bundle.vendor) {
|
|
236
|
+
externals.push(bundle.vendor);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return externals;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function generateExports(dirname) {
|
|
243
|
+
|
|
244
|
+
let libName = getLibName(dirname.split(path.sep).pop());
|
|
245
|
+
|
|
246
|
+
return Object.entries(bundles).map(([name, bundle]) => {
|
|
247
|
+
const entry = {};
|
|
248
|
+
entry[name] = "./src/index.ts";
|
|
249
|
+
|
|
250
|
+
const config = {
|
|
251
|
+
entry: entry,
|
|
252
|
+
mode: "production",
|
|
253
|
+
output: {
|
|
254
|
+
filename: "[name].js",
|
|
255
|
+
path: path.resolve(dirname, "dist/umd"),
|
|
256
|
+
library: libName,
|
|
257
|
+
libraryTarget: "umd"
|
|
258
|
+
},
|
|
259
|
+
resolve: {
|
|
260
|
+
extensions: [".ts", ".tsx", "..."],
|
|
261
|
+
fallback: { "vm": false }
|
|
262
|
+
},
|
|
263
|
+
module: {...getStandardModuleRules()},
|
|
264
|
+
externals: generateExternals(bundle)
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
return config;
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
module.exports = {
|
|
272
|
+
getLibName: getLibName,
|
|
273
|
+
generateExports: generateExports,
|
|
274
|
+
getAppConfig: getAppConfig
|
|
275
|
+
};
|