@nebula.js/cli-serve 3.0.0-rc.2 → 3.0.0-rc.3
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/README.md +47 -0
- package/dist/eDev.js +9 -9
- package/dist/eDev.js.LICENSE.txt +1 -1
- package/dist/eHub.js +9 -9
- package/dist/eHub.js.LICENSE.txt +1 -1
- package/dist/eRender.js +9 -9
- package/dist/eRender.js.LICENSE.txt +1 -1
- package/lib/init-config.js +5 -0
- package/lib/serve.js +5 -4
- package/lib/webpack.serve.js +58 -9
- package/package.json +12 -12
package/lib/init-config.js
CHANGED
|
@@ -67,6 +67,11 @@ const options = {
|
|
|
67
67
|
default: 'test/component',
|
|
68
68
|
description: 'Path to a folder that will be used as basis when locating fixtures',
|
|
69
69
|
},
|
|
70
|
+
mfe: {
|
|
71
|
+
type: 'boolean',
|
|
72
|
+
default: false,
|
|
73
|
+
describe: 'Serves bundle to use in micro frontend',
|
|
74
|
+
},
|
|
70
75
|
};
|
|
71
76
|
|
|
72
77
|
module.exports = (yargs) =>
|
package/lib/serve.js
CHANGED
|
@@ -47,7 +47,7 @@ const initiateWatch = async ({ snPath, snName, host }) => {
|
|
|
47
47
|
const cache = {};
|
|
48
48
|
|
|
49
49
|
return {
|
|
50
|
-
addRoutes(app) {
|
|
50
|
+
addRoutes(app, options) {
|
|
51
51
|
app.get('/pkg/:name', async (req, res) => {
|
|
52
52
|
const { name } = req.params;
|
|
53
53
|
await done;
|
|
@@ -77,6 +77,7 @@ const initiateWatch = async ({ snPath, snName, host }) => {
|
|
|
77
77
|
|
|
78
78
|
if (fs.existsSync(file)) {
|
|
79
79
|
const f = fs.readFileSync(file);
|
|
80
|
+
res.set(options.headers);
|
|
80
81
|
res.send(f);
|
|
81
82
|
} else {
|
|
82
83
|
res.sendStatus('404');
|
|
@@ -130,14 +131,14 @@ module.exports = async (argv) => {
|
|
|
130
131
|
if (runFromDirectory) {
|
|
131
132
|
if (serveConfig.build !== false) {
|
|
132
133
|
watcher = await build({
|
|
133
|
-
watch:
|
|
134
|
+
watch: serveConfig.mfe ? 'systemjs' : 'umd',
|
|
134
135
|
config: serveConfig.config,
|
|
135
136
|
cwd: context,
|
|
136
137
|
});
|
|
137
138
|
}
|
|
138
139
|
try {
|
|
139
140
|
const externalPkg = require(path.resolve(context, 'package.json')); // eslint-disable-line global-require
|
|
140
|
-
const externalEntry = externalPkg.main;
|
|
141
|
+
const externalEntry = serveConfig.mfe ? externalPkg.systemjs : externalPkg.main;
|
|
141
142
|
snName = externalPkg.name;
|
|
142
143
|
snPath = path.resolve(context, externalEntry);
|
|
143
144
|
} catch (e) {
|
|
@@ -156,7 +157,7 @@ module.exports = async (argv) => {
|
|
|
156
157
|
snName: serveConfig.type || snName,
|
|
157
158
|
snUrl,
|
|
158
159
|
dev: process.env.MONO === 'true',
|
|
159
|
-
open: serveConfig.open !== false,
|
|
160
|
+
open: serveConfig.open !== false && !serveConfig.mfe,
|
|
160
161
|
entryWatcher: ww,
|
|
161
162
|
watcher,
|
|
162
163
|
serveConfig,
|
package/lib/webpack.serve.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const chalk = require('chalk');
|
|
4
4
|
const express = require('express');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const homedir = require('os').homedir();
|
|
5
7
|
|
|
6
8
|
const webpack = require('webpack');
|
|
7
9
|
const WebpackDevServer = require('webpack-dev-server');
|
|
@@ -9,6 +11,9 @@ const WebpackDevServer = require('webpack-dev-server');
|
|
|
9
11
|
const snapshooterFn = require('./snapshot-server');
|
|
10
12
|
const snapshotRouter = require('./snapshot-router');
|
|
11
13
|
|
|
14
|
+
const httpsKeyPath = path.join(homedir, '.certs/key.pem');
|
|
15
|
+
const httpsCertPath = path.join(homedir, '.certs/cert.pem');
|
|
16
|
+
|
|
12
17
|
module.exports = async ({
|
|
13
18
|
host,
|
|
14
19
|
port,
|
|
@@ -25,18 +30,29 @@ module.exports = async ({
|
|
|
25
30
|
}) => {
|
|
26
31
|
let config;
|
|
27
32
|
let contentBase;
|
|
33
|
+
const HTTPS = serveConfig.mfe;
|
|
34
|
+
const url = `${HTTPS ? 'https' : 'http'}://${host}:${port}`;
|
|
35
|
+
|
|
36
|
+
if (HTTPS) {
|
|
37
|
+
if (!fs.existsSync(httpsKeyPath)) {
|
|
38
|
+
throw new Error(`Failed to start using HTTPS. Missing key cert at path ${httpsKeyPath}`);
|
|
39
|
+
}
|
|
40
|
+
if (!fs.existsSync(httpsCertPath)) {
|
|
41
|
+
throw new Error(`Failed to start using HTTPS. Missing cert at path ${httpsCertPath}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
28
44
|
|
|
29
45
|
const snapshotRoute = '/njs';
|
|
30
46
|
|
|
31
|
-
const snapshooter = snapshooterFn({ snapshotUrl:
|
|
47
|
+
const snapshooter = snapshooterFn({ snapshotUrl: `${url}/eRender.html` });
|
|
32
48
|
|
|
33
49
|
(serveConfig.snapshots || []).forEach((s) => {
|
|
34
50
|
snapshooter.storeSnapshot(s);
|
|
35
51
|
});
|
|
36
52
|
|
|
37
53
|
const snapRouter = snapshotRouter({
|
|
38
|
-
base:
|
|
39
|
-
snapshotUrl:
|
|
54
|
+
base: `${url}${snapshotRoute}`,
|
|
55
|
+
snapshotUrl: `${url}/eRender.html`,
|
|
40
56
|
snapshooter,
|
|
41
57
|
});
|
|
42
58
|
|
|
@@ -80,7 +96,8 @@ module.exports = async ({
|
|
|
80
96
|
historyApiFallback: {
|
|
81
97
|
index: '/eHub.html',
|
|
82
98
|
},
|
|
83
|
-
|
|
99
|
+
// Disable nebula serve dev env when in MFE mode
|
|
100
|
+
static: !serveConfig.mfe && {
|
|
84
101
|
directory: contentBase,
|
|
85
102
|
watch: {
|
|
86
103
|
ignored: /node_modules/,
|
|
@@ -91,7 +108,7 @@ module.exports = async ({
|
|
|
91
108
|
app.use(snapshotRoute, snapRouter);
|
|
92
109
|
|
|
93
110
|
if (entryWatcher) {
|
|
94
|
-
entryWatcher.addRoutes(app);
|
|
111
|
+
entryWatcher.addRoutes(app, devServer.options);
|
|
95
112
|
}
|
|
96
113
|
|
|
97
114
|
app.get('/themes', (req, res) => {
|
|
@@ -122,6 +139,7 @@ module.exports = async ({
|
|
|
122
139
|
});
|
|
123
140
|
|
|
124
141
|
app.get('/info', (req, res) => {
|
|
142
|
+
res.set(devServer.options.headers);
|
|
125
143
|
res.json({
|
|
126
144
|
enigma: enigmaConfig,
|
|
127
145
|
webIntegrationId,
|
|
@@ -148,17 +166,31 @@ module.exports = async ({
|
|
|
148
166
|
proxy: [
|
|
149
167
|
{
|
|
150
168
|
context: '/render',
|
|
151
|
-
target:
|
|
169
|
+
target: `${url}/eRender.html`,
|
|
152
170
|
ignorePath: true,
|
|
153
171
|
logLevel: 'error',
|
|
154
172
|
},
|
|
155
173
|
{
|
|
156
174
|
context: '/dev',
|
|
157
|
-
target:
|
|
175
|
+
target: `${url}/eDev.html`,
|
|
158
176
|
ignorePath: true,
|
|
159
177
|
logLevel: 'error',
|
|
160
178
|
},
|
|
161
179
|
],
|
|
180
|
+
server: HTTPS
|
|
181
|
+
? {
|
|
182
|
+
type: 'https',
|
|
183
|
+
options: {
|
|
184
|
+
key: httpsKeyPath,
|
|
185
|
+
cert: httpsCertPath,
|
|
186
|
+
},
|
|
187
|
+
}
|
|
188
|
+
: {},
|
|
189
|
+
headers: {
|
|
190
|
+
'Access-Control-Allow-Credentials': 'true',
|
|
191
|
+
'Access-Control-Allow-Origin': '*',
|
|
192
|
+
'Access-Control-Allow-Headers': 'x-qlik-xrfkey,qlik-csrf-token',
|
|
193
|
+
},
|
|
162
194
|
};
|
|
163
195
|
|
|
164
196
|
const compiler = webpack(config);
|
|
@@ -192,8 +224,25 @@ module.exports = async ({
|
|
|
192
224
|
compiler.hooks.done.tap('nebula serve', (stats) => {
|
|
193
225
|
if (!initiated) {
|
|
194
226
|
initiated = true;
|
|
195
|
-
|
|
196
|
-
console.log(`
|
|
227
|
+
|
|
228
|
+
console.log(` _ _________ __ ____ ___
|
|
229
|
+
/ |/ / __/ _ )/ / / / / / _ |
|
|
230
|
+
/ / _// _ / /_/ / /__/ __ |
|
|
231
|
+
/_/|_/___/____/\\____/____/_/ |_|
|
|
232
|
+
/ __/ __/ _ \\ | / / __/
|
|
233
|
+
_\\ \\/ _// , _/ |/ / _/
|
|
234
|
+
/___/___/_/|_||___/___/
|
|
235
|
+
`);
|
|
236
|
+
|
|
237
|
+
if (serveConfig.mfe) {
|
|
238
|
+
const bundleUrl = `${url}/pkg/${snName}`;
|
|
239
|
+
console.log('Development server running in MFE mode');
|
|
240
|
+
console.log(`Bundle served at ${chalk.green(bundleUrl)}`);
|
|
241
|
+
console.log('');
|
|
242
|
+
console.log('Use the bundle when overriding the import map');
|
|
243
|
+
} else {
|
|
244
|
+
console.log(`Development server running at ${chalk.green(url)}`);
|
|
245
|
+
}
|
|
197
246
|
|
|
198
247
|
resolve({
|
|
199
248
|
context: '',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nebula.js/cli-serve",
|
|
3
|
-
"version": "3.0.0-rc.
|
|
3
|
+
"version": "3.0.0-rc.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "QlikTech International AB",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"prepublishOnly": "rm -rf dist && yarn run build"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@nebula.js/cli-build": "^3.0.0-rc.
|
|
30
|
+
"@nebula.js/cli-build": "^3.0.0-rc.3",
|
|
31
31
|
"body-parser": "1.20.0",
|
|
32
32
|
"chalk": "4.1.2",
|
|
33
33
|
"chokidar": "3.5.3",
|
|
@@ -35,25 +35,25 @@
|
|
|
35
35
|
"express": "4.18.1",
|
|
36
36
|
"extend": "3.0.2",
|
|
37
37
|
"html-webpack-plugin": "5.5.0",
|
|
38
|
-
"portfinder": "1.0.
|
|
38
|
+
"portfinder": "1.0.32",
|
|
39
39
|
"puppeteer": "14.4.1",
|
|
40
40
|
"regenerator-runtime": "0.13.9",
|
|
41
41
|
"source-map-loader": "4.0.0",
|
|
42
42
|
"webpack": "5.74.0",
|
|
43
|
-
"webpack-dev-server": "4.
|
|
43
|
+
"webpack-dev-server": "4.10.1",
|
|
44
44
|
"ws": "8.8.1",
|
|
45
45
|
"yargs": "17.5.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@babel/core": "7.18.
|
|
48
|
+
"@babel/core": "7.18.13",
|
|
49
49
|
"@babel/preset-env": "7.18.10",
|
|
50
50
|
"@babel/preset-react": "7.18.6",
|
|
51
|
-
"@mui/material": "^5.
|
|
52
|
-
"@nebula.js/enigma-mocker": "^3.0.0-rc.
|
|
53
|
-
"@nebula.js/nucleus": "^3.0.0-rc.
|
|
54
|
-
"@nebula.js/snapshooter": "^3.0.0-rc.
|
|
55
|
-
"@nebula.js/stardust": "^3.0.0-rc.
|
|
56
|
-
"@nebula.js/ui": "^3.0.0-rc.
|
|
51
|
+
"@mui/material": "^5.10.3",
|
|
52
|
+
"@nebula.js/enigma-mocker": "^3.0.0-rc.3",
|
|
53
|
+
"@nebula.js/nucleus": "^3.0.0-rc.3",
|
|
54
|
+
"@nebula.js/snapshooter": "^3.0.0-rc.3",
|
|
55
|
+
"@nebula.js/stardust": "^3.0.0-rc.3",
|
|
56
|
+
"@nebula.js/ui": "^3.0.0-rc.3",
|
|
57
57
|
"autosuggest-highlight": "3.3.4",
|
|
58
58
|
"babel-loader": "8.2.5",
|
|
59
59
|
"d3-require": "1.3.0",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"react-dom": "18.2.0",
|
|
68
68
|
"webpack-cli": "4.10.0"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "6ffc4105c1f52e785a67e1c87bd64ff2f0351b52"
|
|
71
71
|
}
|