Skip to content

chore(dev): remove parcel #3614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.tsbuildinfo
.cache
dist*
/out*/
release/
release-npm-package/
Expand Down
13 changes: 5 additions & 8 deletions ci/build/build-code-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ set -euo pipefail
MINIFY=${MINIFY-true}

main() {
local opts=()
[[ $MINIFY ]] && opts+=("-p" "tinyfy")
cd "$(dirname "${0}")/../.."

tsc
Expand All @@ -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 "$@"
2 changes: 1 addition & 1 deletion ci/build/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
68 changes: 27 additions & 41 deletions ci/dev/watch.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
try {
const watcher = new Watcher()
Expand Down Expand Up @@ -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")
Expand All @@ -65,7 +63,7 @@ class Watcher {
server.kill()
}

Watcher.log("killing bundler")
Watcher.log("killing watch")
process.exit(code || 0)
}

Expand All @@ -86,28 +84,19 @@ 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))
if (plugin) {
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)",
Expand Down Expand Up @@ -150,7 +139,7 @@ class Watcher {
startingVscode = true
} else if (startingVscode && line.includes("Finished compilation")) {
if (startedVscode) {
bundle.then(restartServer)
restartServer()
}
startedVscode = true
}
Expand All @@ -162,7 +151,8 @@ class Watcher {
console.log("[tsc]", original)
}
if (line.includes("Watching for file changes")) {
bundle.then(restartServer)
bundleBrowserCode(browserFiles)
restartServer()
}
})

Expand All @@ -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()
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/browser/pages/error.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ <h2 class="header">{{ERROR_HEADER}}</h2>
</div>
</div>
</div>
<script data-cfasync="false" src="{{CS_STATIC_BASE}}/dist/register.js"></script>
<script data-cfasync="false" src="{{CS_STATIC_BASE}}/out/browser/register.browserified.js"></script>
</body>
</html>
3 changes: 1 addition & 2 deletions src/browser/pages/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,5 @@ <h1 class="main">Welcome to code-server</h1>
</div>
</div>
</body>
<script data-cfasync="false" src="{{CS_STATIC_BASE}}/dist/register.js"></script>
<script data-cfasync="false" src="{{CS_STATIC_BASE}}/dist/pages/login.js"></script>
<script data-cfasync="false" src="{{CS_STATIC_BASE}}/out/browser/pages/login.browserified.js"></script>
</html>
1 change: 1 addition & 0 deletions src/browser/pages/login.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getOptions } from "../../common/util"
import "../register"

const options = getOptions()
const el = document.getElementById("base") as HTMLInputElement
Expand Down
3 changes: 1 addition & 2 deletions src/browser/pages/vscode.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
<body aria-label=""></body>

<!-- Startup (do not modify order of script tags!) -->
<script data-cfasync="false" src="{{CS_STATIC_BASE}}/dist/pages/vscode.js"></script>
<script data-cfasync="false" src="{{CS_STATIC_BASE}}/dist/register.js"></script>
<script data-cfasync="false" src="{{CS_STATIC_BASE}}/out/browser/pages/vscode.browserified.js"></script>
<script data-cfasync="false" src="{{CS_STATIC_BASE}}/lib/vscode/out/vs/loader.js"></script>
<script>
performance.mark("code/willLoadWorkbenchMain")
Expand Down
5 changes: 3 additions & 2 deletions src/browser/pages/vscode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getOptions } from "../../common/util"
import "../register"

const options = getOptions()

Expand Down Expand Up @@ -30,8 +31,8 @@ try {
/* Probably fine. */
}

;(self.require as any) = {
// Without the full URL VS Code will try to load file://.
;(self as any).require = {
// Without the full URL VS Code will try to load file://.w
baseUrl: `${window.location.origin}${options.csStaticBase}/lib/vscode/out`,
recordStats: true,
paths: {
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"compilerOptions": {
"target": "es5",
"target": "es2020",
"module": "commonjs",
"moduleResolution": "node",
"strict": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"forceConsistentCasingInFileNames": true,
"outDir": "./out",
"declaration": true,
"declaration": false,
"experimentalDecorators": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
Expand Down
Loading