wirejs-scripts 3.0.185 → 3.0.186
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/bin.js +11 -5
- package/package.json +3 -3
package/bin.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import process from 'process';
|
|
4
|
-
import { execSync, spawn } from 'child_process';
|
|
4
|
+
import { exec, execSync, spawn } from 'child_process';
|
|
5
5
|
import fs from 'fs';
|
|
6
6
|
import { builtinModules } from 'module';
|
|
7
7
|
import os from 'os';
|
|
8
8
|
import path from 'path';
|
|
9
9
|
import { fileURLToPath } from 'url';
|
|
10
|
+
import { promisify } from 'util';
|
|
10
11
|
|
|
11
12
|
import { rimraf } from 'rimraf';
|
|
12
13
|
import esbuild from 'esbuild';
|
|
@@ -22,6 +23,8 @@ import nodeCron from 'node-cron';
|
|
|
22
23
|
import * as DefaultGateway from 'default-gateway';
|
|
23
24
|
import * as NatPmp from 'nat-pmp';
|
|
24
25
|
|
|
26
|
+
const execPromise = promisify(exec);
|
|
27
|
+
|
|
25
28
|
const CWD = process.cwd();
|
|
26
29
|
const __filename = fileURLToPath(import.meta.url);
|
|
27
30
|
const __dirname = path.dirname(__filename);
|
|
@@ -363,24 +366,27 @@ async function compile(watch = false) {
|
|
|
363
366
|
external: browserExternal,
|
|
364
367
|
sourcemap: true,
|
|
365
368
|
});
|
|
369
|
+
}
|
|
366
370
|
|
|
371
|
+
await Promise.all(ssgFiles.map(async ssgFile => {
|
|
367
372
|
// 3. Run ssg.js on each server-side bundle to produce HTML.
|
|
368
373
|
// Pass CWD/pre-dist as SRC_DIR so ssg.js strips the correct prefix
|
|
369
374
|
// when building the hydration <script src="..."> path (e.g. /index.js).
|
|
370
375
|
const compiledSsgFile = path.join(preSsgDir, path.relative(ssgDir, ssgFile)).replace(/\.[^.]+$/, '.js');
|
|
371
376
|
try {
|
|
372
|
-
const
|
|
377
|
+
const relative = path.relative(preSsgDir, compiledSsgFile).replace(/\.js$/, '.html');
|
|
378
|
+
console.log(`Generating ${relative}`);
|
|
379
|
+
const html = (await execPromise(
|
|
373
380
|
`node ${path.join(__dirname, 'ssg.js')} ${preDist} ${compiledSsgFile}`,
|
|
374
381
|
{ stdio: ['pipe', 'pipe', 'pipe'] }
|
|
375
|
-
).toString();
|
|
376
|
-
const relative = path.relative(preSsgDir, compiledSsgFile).replace(/\.js$/, '.html');
|
|
382
|
+
)).stdout.toString();
|
|
377
383
|
const htmlOut = path.join(distDir, relative);
|
|
378
384
|
await fs.promises.mkdir(path.dirname(htmlOut), { recursive: true });
|
|
379
385
|
await fs.promises.writeFile(htmlOut, html);
|
|
380
386
|
} catch (err) {
|
|
381
387
|
logger.error(`Could not generate SSG page ${compiledSsgFile}`, err);
|
|
382
388
|
}
|
|
383
|
-
}
|
|
389
|
+
}));
|
|
384
390
|
}
|
|
385
391
|
|
|
386
392
|
if (watch) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wirejs-scripts",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.186",
|
|
4
4
|
"description": "Basic build and start commands for wirejs apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"node-cron": "^4.2.1",
|
|
29
29
|
"rimraf": "^6.0.1",
|
|
30
30
|
"wirejs-dom": "^1.0.44",
|
|
31
|
-
"wirejs-hosting": "^0.1.
|
|
32
|
-
"wirejs-resources": "^0.1.
|
|
31
|
+
"wirejs-hosting": "^0.1.188",
|
|
32
|
+
"wirejs-resources": "^0.1.188"
|
|
33
33
|
}
|
|
34
34
|
}
|