diff --git a/README.md b/README.md index 3d9e73e..a0e99b1 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/backend/dev-esbuild.js b/backend/dev-esbuild.js new file mode 100644 index 0000000..dd44c57 --- /dev/null +++ b/backend/dev-esbuild.js @@ -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'); + }); diff --git a/backend/package.json b/backend/package.json index 71e7100..0d0e425 100644 --- a/backend/package.json +++ b/backend/package.json @@ -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" }, diff --git a/backend/src/core/proxy-utils/index.js b/backend/src/core/proxy-utils/index.js index 4b535c4..89cc328 100644 --- a/backend/src/core/proxy-utils/index.js +++ b/backend/src/core/proxy-utils/index.js @@ -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,