make source maps

This commit is contained in:
MathMan05 2024-09-24 11:58:42 -05:00
parent d88de12840
commit 71f092612d
3 changed files with 35 additions and 9 deletions

View file

@ -5,7 +5,7 @@ const tsProject = ts.createProject("tsconfig.json");
const argv = require("yargs").argv;
const rimraf = require("rimraf");
const plumber = require("gulp-plumber");
const sourcemaps = require('gulp-sourcemaps');
const swcOptions = {
jsc: {
parser: {
@ -31,7 +31,7 @@ const swcOptions = {
lazy: false,
noInterop: false,
},
sourceMaps: "inline",
sourceMaps: true,
minify: false,
};
@ -45,15 +45,19 @@ gulp.task("scripts", () => {
if (argv.swc) {
return gulp
.src("src/**/*.ts")
.pipe(sourcemaps.init())
.pipe(plumber()) // Prevent pipe breaking caused by errors
.pipe(swc(swcOptions))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest("dist"));
} else {
console.warn("[WARN] Using TSC compiler, will be slower than SWC");
return gulp
.src("src/**/*.ts")
.pipe(sourcemaps.init())
.pipe(plumber()) // Prevent pipe breaking caused by errors
.pipe(tsProject())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest("dist"));
}
});

View file

@ -1,7 +1,7 @@
{
"name": "jankclient",
"version": "0.1.0",
"description": "A SpaceBar Client written in JS HTML and CSS to run, clone the repo and do either `node index.js` or `bun index.js` both bun and node are supported, and both should function as expected, if there are any problems with Jank Client on things that aren't linux, please let me know. To access Jank Client after init simply go to http://localhost:8080/login and login with your username and password.",
"description": "A SpaceBar Client written in TS HTML and CSS to run, clone the repo and do either `npm start` or `bun start` both bun and node are supported, and both should function as expected. To access Jank Client after init simply go to http://localhost:8080/login and login with your username and password.",
"main": ".dist/index.js",
"type": "module",
"scripts": {
@ -23,7 +23,8 @@
"gulp-swc": "^2.2.0",
"node-fetch": "^3.3.2",
"rimraf": "^6.0.1",
"ts-to-jsdoc": "^2.2.0"
"ts-to-jsdoc": "^2.2.0",
"gulp-sourcemaps":"^3.0.0"
},
"devDependencies": {
"@eslint/js": "^9.10.0",

View file

@ -8,7 +8,7 @@ import path from"node:path";
import{ observe, uptime }from"./stats.js";
import{ getApiUrls, inviteResponse }from"./utils.js";
import{ fileURLToPath }from"node:url";
const devmode = (process.env.NODE_ENV || 'development')==='development';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
@ -34,9 +34,7 @@ async function updateInstances(): Promise<void>{
);
const json = (await response.json()) as Instance[];
for(const instance of json){
if(!instanceNames.has(instance.name)){
instances.push(instance as any);
}else{
if(instanceNames.has(instance.name)){
const existingInstance = instanceNames.get(instance.name);
if(existingInstance){
for(const key of Object.keys(instance)){
@ -45,6 +43,8 @@ async function updateInstances(): Promise<void>{
}
}
}
}else{
instances.push(instance as any);
}
}
observe(instances);
@ -53,7 +53,7 @@ async function updateInstances(): Promise<void>{
}
}
updateInstances();
//updateInstances();
app.use("/getupdates", (_req: Request, res: Response)=>{
try{
@ -104,10 +104,31 @@ app.use("/", async (req: Request, res: Response)=>{
const filePath = path.join(__dirname, "webpage", req.path);
if(fs.existsSync(filePath)){
if(devmode){
const filePath2 = path.join(__dirname, "../src/webpage", req.path);
if(fs.existsSync(filePath2)){
res.sendFile(filePath2);
return;
}
}
res.sendFile(filePath);
}else if(fs.existsSync(`${filePath}.html`)){
if(devmode){
const filePath2 = path.join(__dirname, "../src/webpage", req.path);
if(fs.existsSync(filePath2+".html")){
res.sendFile(filePath2+".html");
return;
}
}
res.sendFile(`${filePath}.html`);
}else{
if(req.path.startsWith("/src/webpage")){
const filePath2 = path.join(__dirname, "..", req.path);
if(fs.existsSync(`${filePath2}`)){
res.sendFile(filePath2);
return;
}
}
res.sendFile(path.join(__dirname, "webpage", "index.html"));
}
});