diff --git a/.gitignore b/.gitignore index 4591083e6d4e..539395506cfe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ .tsbuildinfo .cache -dist* /out*/ release/ release-npm-package/ diff --git a/ci/build/build-code-server.sh b/ci/build/build-code-server.sh index be78d268b6b3..aaaf36979c71 100755 --- a/ci/build/build-code-server.sh +++ b/ci/build/build-code-server.sh @@ -7,6 +7,8 @@ set -euo pipefail MINIFY=${MINIFY-true} main() { + local opts=() + [[ $MINIFY ]] && opts+=("-p" "tinyfy") cd "$(dirname "${0}")/../.." tsc @@ -32,14 +34,9 @@ main() { set -e fi - parcel build \ - --public-url "." \ - --dist-dir dist \ - $([[ $MINIFY ]] || echo --no-optimize) \ - src/browser/register.ts \ - src/browser/serviceWorker.ts \ - src/browser/pages/login.ts \ - src/browser/pages/vscode.ts + yarn browserify "${opts[@]}" src/browser/register.ts -o out/browser/register.browserified.js + yarn browserify "${opts[@]}" src/browser/pages/login.ts -o out/browser/pages/login.browserified.js + yarn browserify "${opts[@]}" src/browser/pages/vscode.ts -o out/browser/pages/vscode.browserified.js } main "$@" diff --git a/ci/build/build-release.sh b/ci/build/build-release.sh index 6e01fe2ac16b..fb5edc3bdeee 100755 --- a/ci/build/build-release.sh +++ b/ci/build/build-release.sh @@ -28,7 +28,7 @@ main() { } bundle_code_server() { - rsync out dist "$RELEASE_PATH" + rsync out "$RELEASE_PATH" # For source maps and images. mkdir -p "$RELEASE_PATH/src/browser" diff --git a/ci/dev/watch.ts b/ci/dev/watch.ts index 39501c68a835..714a12f7e139 100644 --- a/ci/dev/watch.ts +++ b/ci/dev/watch.ts @@ -1,9 +1,8 @@ +import browserify from "browserify" import * as cp from "child_process" -import Parcel from "@parcel/core" +import * as fs from "fs" import * as path from "path" -type FixMeLater = any - async function main(): Promise { try { const watcher = new Watcher() @@ -42,7 +41,6 @@ class Watcher { const plugin = process.env.PLUGIN_DIR ? cp.spawn("yarn", ["build", "--watch"], { cwd: process.env.PLUGIN_DIR }) : undefined - const bundler = this.createBundler() const cleanup = (code?: number | null): void => { Watcher.log("killing vs code watcher") @@ -65,7 +63,7 @@ class Watcher { server.kill() } - Watcher.log("killing bundler") + Watcher.log("killing watch") process.exit(code || 0) } @@ -86,21 +84,6 @@ class Watcher { cleanup(code) }) } - const bundle = bundler.watch((err: FixMeLater, buildEvent: FixMeLater) => { - if (err) { - console.error(err) - Watcher.log("parcel watcher terminated unexpectedly") - cleanup(1) - } - - if (buildEvent.type === "buildEnd") { - console.log("[parcel] bundled") - } - - if (buildEvent.type === "buildError") { - console.error("[parcel]", err) - } - }) vscode.stderr.on("data", (d) => process.stderr.write(d)) tsc.stderr.on("data", (d) => process.stderr.write(d)) @@ -108,6 +91,12 @@ class Watcher { plugin.stderr.on("data", (d) => process.stderr.write(d)) } + const browserFiles = [ + path.join(this.rootPath, "out/browser/register.js"), + path.join(this.rootPath, "out/browser/pages/login.js"), + path.join(this.rootPath, "out/browser/pages/vscode.js"), + ] + // From https://github.com/chalk/ansi-regex const pattern = [ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", @@ -150,7 +139,7 @@ class Watcher { startingVscode = true } else if (startingVscode && line.includes("Finished compilation")) { if (startedVscode) { - bundle.then(restartServer) + restartServer() } startedVscode = true } @@ -162,7 +151,8 @@ class Watcher { console.log("[tsc]", original) } if (line.includes("Watching for file changes")) { - bundle.then(restartServer) + bundleBrowserCode(browserFiles) + restartServer() } }) @@ -173,30 +163,26 @@ class Watcher { console.log("[plugin]", original) } if (line.includes("Watching for file changes")) { - bundle.then(restartServer) + restartServer() } }) } } +} - private createBundler(out = "dist"): FixMeLater { - return new (Parcel as FixMeLater)({ - entries: [ - path.join(this.rootPath, "src/browser/register.ts"), - path.join(this.rootPath, "src/browser/serviceWorker.ts"), - path.join(this.rootPath, "src/browser/pages/login.ts"), - path.join(this.rootPath, "src/browser/pages/vscode.ts"), - ], - cacheDir: path.join(this.rootPath, ".cache"), - logLevel: 1, - defaultConfig: require.resolve("@parcel/config-default"), - defaultTargetOptions: { - publicUrl: ".", - shouldOptimize: !!process.env.MINIFY, - distDir: path.join(this.rootPath, out), - }, - }) - } +function bundleBrowserCode(inputFiles: string[]) { + console.log(`[browser] bundling...`) + inputFiles.forEach(async (path: string) => { + const outputPath = path.replace(".js", ".browserified.js") + browserify() + .add(path) + .bundle() + .on("error", function (error: Error) { + console.error(error.toString()) + }) + .pipe(fs.createWriteStream(outputPath)) + }) + console.log(`[browser] done bundling`) } main() diff --git a/package.json b/package.json index 630982832b5f..0e2f85692511 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "lint": "./ci/dev/lint.sh", "test": "echo 'Run yarn test:unit or yarn test:e2e' && exit 1", "ci": "./ci/dev/ci.sh", - "watch": "VSCODE_IPC_HOOK_CLI= NODE_OPTIONS=--max_old_space_size=32384 ts-node ./ci/dev/watch.ts", + "watch": "VSCODE_IPC_HOOK_CLI= NODE_OPTIONS='--max_old_space_size=32384 --trace-warnings' ts-node ./ci/dev/watch.ts", "icons": "./ci/dev/gen_icons.sh", "coverage": "codecov" }, @@ -42,6 +42,7 @@ "@parcel/types": "^2.0.0-alpha.3", "@schemastore/package": "^0.0.6", "@types/body-parser": "^1.19.0", + "@types/browserify": "^12.0.36", "@types/compression": "^1.7.0", "@types/cookie-parser": "^1.4.2", "@types/express": "^4.17.8", @@ -60,6 +61,7 @@ "@typescript-eslint/eslint-plugin": "^4.7.0", "@typescript-eslint/parser": "^4.7.0", "audit-ci": "^4.0.0", + "browserify": "^17.0.0", "codecov": "^3.8.1", "doctoc": "^2.0.0", "eslint": "^7.7.0", @@ -68,12 +70,12 @@ "eslint-plugin-import": "^2.18.2", "eslint-plugin-prettier": "^3.1.0", "leaked-handles": "^5.2.0", - "parcel": "^2.0.0-beta.3.1", "prettier": "^2.2.1", "prettier-plugin-sh": "^0.6.0", "shellcheck": "^1.0.0", "stylelint": "^13.0.0", "stylelint-config-recommended": "^5.0.0", + "tinyify": "^3.0.0", "ts-node": "^10.0.0", "typescript": "^4.1.3", "wtfnode": "^0.8.4" diff --git a/src/browser/pages/error.html b/src/browser/pages/error.html index 93be58fd9696..56e03e27a628 100644 --- a/src/browser/pages/error.html +++ b/src/browser/pages/error.html @@ -30,6 +30,6 @@

{{ERROR_HEADER}}

- + diff --git a/src/browser/pages/login.html b/src/browser/pages/login.html index f9f3763e58c9..896927e3812c 100644 --- a/src/browser/pages/login.html +++ b/src/browser/pages/login.html @@ -49,6 +49,5 @@

Welcome to code-server

- - + diff --git a/src/browser/pages/login.ts b/src/browser/pages/login.ts index c7fc92d4a0e7..cd3fd0d16542 100644 --- a/src/browser/pages/login.ts +++ b/src/browser/pages/login.ts @@ -1,4 +1,5 @@ import { getOptions } from "../../common/util" +import "../register" const options = getOptions() const el = document.getElementById("base") as HTMLInputElement diff --git a/src/browser/pages/vscode.html b/src/browser/pages/vscode.html index 48a3469940a3..aaae0f691e9a 100644 --- a/src/browser/pages/vscode.html +++ b/src/browser/pages/vscode.html @@ -39,8 +39,7 @@ - - +