updates to gulp file

This commit is contained in:
MathMan05 2025-01-20 22:56:06 -06:00
parent 5e5da7d10a
commit 731e5d5ee7
2 changed files with 77 additions and 97 deletions

View file

@ -1,40 +1,12 @@
const gulp = require("gulp"); const gulp = require("gulp");
const ts = require("gulp-typescript"); const ts = require("gulp-typescript");
const swc = require("gulp-swc");
const tsProject = ts.createProject("tsconfig.json"); const tsProject = ts.createProject("tsconfig.json");
const argv = require("yargs").argv; const argv = require("yargs").argv;
const rimraf = require("rimraf"); const rimraf = require("rimraf");
const plumber = require("gulp-plumber"); const plumber = require("gulp-plumber");
const sourcemaps = require("gulp-sourcemaps"); const sourcemaps = require("gulp-sourcemaps");
const fs = require("fs"); const fs = require("fs");
const swcOptions = { const {swcDir} = require("@swc/cli");
jsc: {
parser: {
syntax: "typescript",
tsx: false,
decorators: true,
dynamicImport: true,
},
transform: {
react: {
runtime: "automatic",
},
},
target: "es2022",
loose: false,
externalHelpers: false,
keepClassNames: true,
},
module: {
type: "es6",
strict: true,
strictMode: true,
lazy: false,
noInterop: false,
},
sourceMaps: true,
minify: false,
};
gulp.task( gulp.task(
"watch", "watch",
@ -49,25 +21,34 @@ gulp.task(
gulp.task("clean", (cb) => { gulp.task("clean", (cb) => {
return rimraf.rimraf("dist").then(cb()); return rimraf.rimraf("dist").then(cb());
}); });
const exec = require("child_process").exec;
// Task to compile TypeScript files using SWC // Task to compile TypeScript files using SWC
gulp.task("scripts", async () => { gulp.task("scripts", async () => {
if (argv.swc) { if (argv.swc || argv.bunswc) {
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 if (argv.bunswc) {
return await new Promise((ret) => { return await new Promise((ret) => {
exec("bun swc --strip-leading-paths ./src -s -d ./dist/ -C jsc.target=es2022").on( swcDir({
"exit", cliOptions: {
function (code) { outDir: "./dist",
ret(); watch: true,
filenames: ["./src"],
extensions: [".ts"],
stripLeadingPaths: true,
"no-swcrc": true,
}, },
); callbacks: {
onSuccess: (e) => {
ret();
console.log(e);
},
onFail: (e) => {
for ([, reason] of e.reasons) {
console.log(reason);
}
ret();
},
onWatchReady: () => {},
},
});
}); });
} else { } else {
console.warn("[WARN] Using TSC compiler, will be slower than SWC"); console.warn("[WARN] Using TSC compiler, will be slower than SWC");

View file

@ -1,55 +1,54 @@
{ {
"name": "jankclient", "name": "jankclient",
"version": "0.2.0", "version": "0.2.0",
"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.", "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", "main": ".dist/index.js",
"type": "module", "type": "module",
"scripts": { "scripts": {
"lint": "eslint .", "lint": "eslint .",
"build": "npx gulp", "build": "npx gulp",
"start": "node dist/index.js" "start": "node dist/index.js"
}, },
"author": "MathMan05", "author": "MathMan05",
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"compression": "^1.7.4", "compression": "^1.7.4",
"express": "^4.19.2", "express": "^4.19.2",
"gulp-sourcemaps": "^2.6.5", "gulp-sourcemaps": "^2.6.5",
"gulp-swc": "^2.2.0", "prettier": "^3.4.2",
"prettier": "^3.4.2", "rimraf": "^6.0.1"
"rimraf": "^6.0.1" },
}, "prettier": {
"prettier":{ "useTabs": true,
"useTabs":true, "printWidth": 100,
"printWidth":100, "semi": true,
"semi":true, "bracketSpacing": false
"bracketSpacing":false },
}, "devDependencies": {
"devDependencies": { "@eslint/js": "^9.10.0",
"@eslint/js": "^9.10.0", "@html-eslint/eslint-plugin": "^0.25.0",
"@html-eslint/eslint-plugin": "^0.25.0", "@html-eslint/parser": "^0.27.0",
"@html-eslint/parser": "^0.27.0", "@rsbuild/core": "^1.1.4",
"@rsbuild/core": "^1.1.4", "@rsbuild/plugin-node-polyfill": "^1.2.0",
"@rsbuild/plugin-node-polyfill": "^1.2.0", "@stylistic/eslint-plugin": "^2.3.0",
"@stylistic/eslint-plugin": "^2.3.0", "@stylistic/eslint-plugin-js": "^2.8.0",
"@stylistic/eslint-plugin-js": "^2.8.0", "@swc/cli": "^0.5.2",
"@swc/cli": "^0.5.2", "@swc/core": "^1.10.1",
"@swc/core": "^1.10.1", "@types/compression": "^1.7.5",
"@types/compression": "^1.7.5", "@types/eslint__js": "^8.42.3",
"@types/eslint__js": "^8.42.3", "@types/express": "^4.17.21",
"@types/express": "^4.17.21", "@types/node-fetch": "^2.6.11",
"@types/node-fetch": "^2.6.11", "@typescript-eslint/eslint-plugin": "^8.14.0",
"@typescript-eslint/eslint-plugin": "^8.14.0", "@typescript-eslint/parser": "^8.14.0",
"@typescript-eslint/parser": "^8.14.0", "eslint": "^8.57.1",
"eslint": "^8.57.1", "eslint-plugin-html": "^8.1.1",
"eslint-plugin-html": "^8.1.1", "eslint-plugin-sonarjs": "^1.0.4",
"eslint-plugin-sonarjs": "^1.0.4", "eslint-plugin-unicorn": "^55.0.0",
"eslint-plugin-unicorn": "^55.0.0", "gulp": "^5.0.0",
"gulp": "^5.0.0", "gulp-copy": "^5.0.0",
"gulp-copy": "^5.0.0", "gulp-plumber": "^1.2.1",
"gulp-plumber": "^1.2.1", "gulp-typescript": "^6.0.0-alpha.1",
"gulp-typescript": "^6.0.0-alpha.1", "typescript": "^5.6.2",
"typescript": "^5.6.2", "typescript-eslint": "^8.14.0"
"typescript-eslint": "^8.14.0" }
}
} }