chore: 开发流程使用 esbuild

This commit is contained in:
xream 2024-02-03 21:30:27 +08:00
parent 02d54208b0
commit ae1c738f70
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
4 changed files with 39 additions and 3 deletions

View File

@ -84,15 +84,25 @@ Install `pnpm`
Go to `backend` directories, install node dependencies:
```
pnpm install
pnpm i
```
1. In `backend`, run the backend server on http://localhost:3000
babel(old school)
```
pnpm start
```
or
esbuild(experimental)
```
pnpm run --parallel "/^dev:.*/"
```
## LICENSE
This project is under the GPL V3 LICENSE.

24
backend/dev-esbuild.js Normal file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env node
const { build } = require('esbuild');
!(async () => {
const artifacts = [{ src: 'src/main.js', dest: 'sub-store.min.js' }];
for await (const artifact of artifacts) {
await build({
entryPoints: [artifact.src],
bundle: true,
minify: false,
sourcemap: false,
platform: 'node',
format: 'cjs',
outfile: artifact.dest,
});
}
})()
.catch((e) => {
console.log(e);
})
.finally(() => {
console.log('done');
});

View File

@ -8,6 +8,8 @@
"test": "gulp peggy && npx cross-env BABEL_ENV=test mocha src/test/**/*.spec.js --require @babel/register --recursive",
"serve": "node sub-store.min.js",
"start": "nodemon -w src -w package.json --exec babel-node src/main.js",
"dev:esbuild": "nodemon -w src -w package.json dev-esbuild.js",
"dev:run": "nodemon -w sub-store.json -w sub-store.min.js sub-store.min.js",
"build": "gulp",
"bundle": "node bundle.js"
},

View File

@ -63,7 +63,7 @@ function parse(raw) {
return proxies;
}
async function process(proxies, operators = [], targetPlatform, source) {
async function processFn(proxies, operators = [], targetPlatform, source) {
for (const item of operators) {
// process script
let script;
@ -188,7 +188,7 @@ function produce(proxies, targetPlatform, type, opts = {}) {
export const ProxyUtils = {
parse,
process,
process: processFn,
produce,
isIPv4,
isIPv6,