oneportal-scripts 3.7.5 → 3.7.7

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.
@@ -19,10 +19,10 @@ class DownloadAndExtractPlugin {
19
19
  const url = `${fontdoorUrl}/${oneenv}/${libPath}/${lib.name}-ts.tgz?v=${Math.random()}`;
20
20
 
21
21
  try {
22
- const response = await axios({ method: "get", url, responseType: "stream" });
22
+ const response = await axios({ method: "get", url, responseType: "stream", timeout: 30000 });
23
23
  await pipeline(response.data, tar.x({ C: destDir }));
24
24
  } catch (err) {
25
- console.error("Error downloading or extracting file:", err);
25
+ console.warn(`Warning: Could not download type definitions for ${lib.name}: ${err.message}`);
26
26
  }
27
27
  }
28
28
 
@@ -1,21 +1,4 @@
1
1
  {
2
- "name": "oneportal-app",
3
- "version": "1.0.0",
4
- "publicPath": "/",
5
- "port": 3000,
6
- "libs": [],
7
- "remotelibs": [],
8
- "activeshared": true,
9
- "eager": false,
10
- "contenthash": true,
11
- "enabledts": false,
12
- "exposes": {
13
- "./App": "./src/App"
14
- },
15
- "environmentVariables": {
16
- "ONEPORTAL_FRONT_DOOR": "https://localhost:3000",
17
- "ONEPORTAL_ENV": "dev"
18
- },
19
2
  "sharedlibrary": {
20
3
  "development": {
21
4
  "href": "https://sharenet.blob.core.windows.net/sharedlibrary"
package/config/paths.js CHANGED
@@ -46,7 +46,7 @@ module.exports = {
46
46
  appPublic: resolveApp("public"),
47
47
  appHtml: resolveApp("public/index.html"),
48
48
  appIndexJs: resolveModule(resolveApp, "src/index"),
49
- extension: resolveApp("config/glasses.json"),
49
+ extension: resolveApp("extension.json"),
50
50
  appPackageJson: resolveApp("package.json"),
51
51
  appSrc: resolveApp("src"),
52
52
  appTsConfig: resolveApp("tsconfig.json"),
@@ -26,65 +26,42 @@ function isValidURL(url) {
26
26
  }
27
27
  }
28
28
 
29
- function loadRemoteEntry(appName, frontDoor, appPath) {
30
- return new Promise((resolve) => {
31
- const scriptId = appName + "-remoteEntry";
32
- const existingScript = document.getElementById(scriptId);
29
+ function dynamicRemote(env, appName, isApp) {
30
+ const appPath = isApp ? `apps/${appName}` : appName;
31
+ const frontDoor = env.ONEPORTAL_FRONT_DOOR;
33
32
 
34
- const makeProxy = () => ({
35
- get: (request) => window[appName].get(request),
36
- init: (arg) => {
37
- try {
38
- return window[appName].init(arg);
39
- } catch (_e) {
40
- console.warn(`Remote container ${appName} failed to initialize.`, _e);
33
+ return `promise new Promise(function(resolve) {
34
+ var scriptId = '${appName}-remoteEntry';
35
+ var existingScript = document.getElementById(scriptId);
36
+ function makeProxy() {
37
+ return {
38
+ get: function(request) { return window['${appName}'].get(request); },
39
+ init: function(arg) {
40
+ try { return window['${appName}'].init(arg); }
41
+ catch(e) { console.warn('Remote container ${appName} failed to initialize.', e); }
41
42
  }
42
- },
43
- });
44
-
43
+ };
44
+ }
45
45
  if (existingScript) {
46
46
  resolve(makeProxy());
47
47
  } else {
48
- const script = document.createElement("script");
48
+ var script = document.createElement('script');
49
49
  script.id = scriptId;
50
-
51
- const localURL = localStorage.getItem(appName);
50
+ var localURL = localStorage.getItem('${appName}');
52
51
  if (localURL) {
53
- script.src = localURL.concat("/remoteEntry.js");
52
+ script.src = localURL + '/remoteEntry.js';
54
53
  } else {
55
- const version = window["oneportalextension"][appName];
56
- const versionApps = window["oneportalextension"]["apps"].find(
57
- (app) => app.name === appName,
58
- );
59
- const oneenv = window["oneportalextension"].env;
60
- script.src =
61
- frontDoor +
62
- "/" +
63
- oneenv +
64
- "/" +
65
- appPath +
66
- "/remoteEntry.js?v=" +
67
- (version ?? versionApps?.version);
54
+ var ext = window['oneportalextension'] || {};
55
+ var version = ext['${appName}'];
56
+ var apps = ext['apps'] || [];
57
+ var versionApp = apps.find(function(a) { return a.name === '${appName}'; });
58
+ var oneenv = ext['env'];
59
+ script.src = '${frontDoor}/' + oneenv + '/${appPath}/remoteEntry.js?v=' + (version !== undefined ? version : (versionApp ? versionApp.version : ''));
68
60
  }
69
-
70
- script.onload = () => resolve(makeProxy());
61
+ script.onload = function() { resolve(makeProxy()); };
71
62
  document.head.appendChild(script);
72
63
  }
73
- });
74
- }
75
-
76
- function toPromiseRemote(fn, ...argValues) {
77
- return () => fn(...argValues);
78
- }
79
-
80
- function dynamicRemote(env, appName, isApp) {
81
- const appPath = isApp ? `apps/${appName}` : appName;
82
- return toPromiseRemote(
83
- loadRemoteEntry,
84
- appName,
85
- env.ONEPORTAL_FRONT_DOOR,
86
- appPath,
87
- );
64
+ })`;
88
65
  }
89
66
 
90
67
  module.exports = function webpackConfig(mode) {
@@ -307,6 +284,7 @@ module.exports = function webpackConfig(mode) {
307
284
  `${config.name}-ts.tgz`,
308
285
  ),
309
286
  fileList: ["types"],
287
+ }),
310
288
  new TarWebpackPlugin({
311
289
  action: "c",
312
290
  gzip: true,
@@ -13,6 +13,13 @@ const sockPath = config.sockPath || "/ws";
13
13
  const sockPort = config.port || 13009;
14
14
 
15
15
  module.exports = function webpackDevServerConfig(proxyConfig, allowedHost) {
16
+ const httpsConfig = getHttpsConfig();
17
+ const serverOption = httpsConfig === false
18
+ ? "http"
19
+ : typeof httpsConfig === "object"
20
+ ? { type: "https", options: httpsConfig }
21
+ : "https";
22
+
16
23
  return {
17
24
  hot: true,
18
25
  allowedHosts:
@@ -46,22 +53,21 @@ module.exports = function webpackDevServerConfig(proxyConfig, allowedHost) {
46
53
  devMiddleware: {
47
54
  publicPath: paths.publicUrlOrPath.slice(0, -1),
48
55
  },
49
- https: getHttpsConfig(),
56
+ server: serverOption,
50
57
  host,
51
58
  historyApiFallback: {
52
59
  disableDotRule: true,
53
60
  index: paths.publicUrlOrPath,
54
61
  },
55
62
  proxy: proxyConfig,
56
- onBeforeSetupMiddleware(devServer) {
57
- devServer.app.use(evalSourceMapMiddleware(devServer));
63
+ setupMiddlewares(middlewares, devServer) {
64
+ middlewares.unshift(evalSourceMapMiddleware(devServer));
58
65
  if (fs.existsSync(paths.proxySetup)) {
59
66
  require(paths.proxySetup)(devServer.app);
60
67
  }
61
- },
62
- onAfterSetupMiddleware(devServer) {
63
- devServer.app.use(redirectServedPath(paths.publicUrlOrPath));
64
- devServer.app.use(noopServiceWorkerMiddleware(paths.publicUrlOrPath));
68
+ middlewares.push(redirectServedPath(paths.publicUrlOrPath));
69
+ middlewares.push(noopServiceWorkerMiddleware(paths.publicUrlOrPath));
70
+ return middlewares;
65
71
  },
66
72
  };
67
73
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oneportal-scripts",
3
- "version": "3.7.5",
3
+ "version": "3.7.7",
4
4
  "description": "Build scripts and configuration for OnePortal micro-frontend projects with Module Federation support.",
5
5
  "engines": {
6
6
  "node": ">=14.0.0"
package/scripts/build.js CHANGED
@@ -42,8 +42,7 @@ function build() {
42
42
  errors: true,
43
43
  });
44
44
 
45
- messages =
46
- typeof statsJson === "string" ? formatWebpackMessages(statsJson) : {};
45
+ messages = formatWebpackMessages(statsJson);
47
46
  }
48
47
 
49
48
  if (messages.errors?.length) {
@@ -89,4 +88,17 @@ function build() {
89
88
  });
90
89
  });
91
90
  }
92
- build();
91
+ build()
92
+ .then(({ warnings }) => {
93
+ if (warnings && warnings.length) {
94
+ console.log(chalk.yellow("Compiled with warnings.\n"));
95
+ console.log(warnings.join("\n\n"));
96
+ } else {
97
+ console.log(chalk.green("Compiled successfully.\n"));
98
+ }
99
+ })
100
+ .catch((err) => {
101
+ console.log(chalk.red("Failed to compile.\n"));
102
+ console.log((err.message || err) + "\n");
103
+ process.exit(1);
104
+ });