olum-compiler 1.6.0 → 1.6.2
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 +1 -1
- package/bin/index.js +4 -2
- package/bin/server.js +5 -3
- package/bin/start.js +20 -0
- package/lib/changes.txt +2 -0
- package/package.json +1 -1
- package/.claude/settings.local.json +0 -13
package/README.md
CHANGED
package/bin/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
const path = require("path");
|
|
2
3
|
const spawn = require("../lib/cross-spawn");
|
|
3
4
|
const script = process.argv[2];
|
|
4
5
|
|
|
5
6
|
if (script == "dev") process.env.NODE_ENV = "development";
|
|
6
|
-
else if (
|
|
7
|
+
else if (["build", "start"].includes(script))
|
|
8
|
+
process.env.NODE_ENV = "production";
|
|
7
9
|
|
|
8
|
-
if (typeof script !== undefined && ["dev", "build"].includes(script)) {
|
|
10
|
+
if (typeof script !== undefined && ["dev", "build", "start"].includes(script)) {
|
|
9
11
|
const result = spawn.sync("node", [path.resolve(__dirname, script + ".js")], {
|
|
10
12
|
stdio: "inherit",
|
|
11
13
|
});
|
package/bin/server.js
CHANGED
|
@@ -40,7 +40,7 @@ function getPath(entry, url) {
|
|
|
40
40
|
return null;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
function serve(entry, port) {
|
|
43
|
+
function serve(entry, port, mode = "development") {
|
|
44
44
|
return new Promise((resolve, reject) => {
|
|
45
45
|
const PORT = Number(port || process.env.PORT || 3000);
|
|
46
46
|
|
|
@@ -60,8 +60,10 @@ function serve(entry, port) {
|
|
|
60
60
|
}
|
|
61
61
|
const dom = new jsdom.JSDOM(content.toString()).window.document;
|
|
62
62
|
const html = dom.querySelector("html");
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
if (mode == "development") {
|
|
64
|
+
const wsContent = handleWsFile();
|
|
65
|
+
dom.body.insertAdjacentHTML("beforeend", wsContent);
|
|
66
|
+
}
|
|
65
67
|
res.writeHead(200, {
|
|
66
68
|
"content-type": "text/html",
|
|
67
69
|
"cache-control": "no-cache",
|
package/bin/start.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const serve = require("./server");
|
|
2
|
+
const colors = require("../lib/colors");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
const cwd = process.cwd();
|
|
6
|
+
const root = cwd.replace(/\/module$/, "");
|
|
7
|
+
const outDir = path.resolve(root, "dist");
|
|
8
|
+
|
|
9
|
+
serve(outDir, undefined, "production").then(({ server, PORT, log }) => {
|
|
10
|
+
const bootAt = Date.now();
|
|
11
|
+
server.on("error", (e) => {
|
|
12
|
+
if (e.code === "EADDRINUSE") server.listen(++PORT);
|
|
13
|
+
});
|
|
14
|
+
server.listen(PORT, () =>
|
|
15
|
+
console.log(
|
|
16
|
+
log.replace(/port \d+/, "port " + PORT),
|
|
17
|
+
colors("white", `(ready in ${Date.now() - bootAt}ms)`),
|
|
18
|
+
),
|
|
19
|
+
);
|
|
20
|
+
});
|
package/lib/changes.txt
CHANGED
package/package.json
CHANGED