Skip to content

Commit 22f4f66

Browse files
committed
refactor: upgrade to parcel v2
1 parent d8c3ba6 commit 22f4f66

File tree

6 files changed

+1316
-1918
lines changed

6 files changed

+1316
-1918
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ VS Code v0.00.0
6363
### Development
6464

6565
- fix(publish): update cdrci fork in brew-bump.sh #3468 @jsjoeio
66+
- chore(dev): upgrade to parcel v2 #3578 @jsjoeio
6667

6768
## 3.10.2
6869

ci/dev/watch.ts

+27-19
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import * as cp from "child_process"
2-
import Bundler from "parcel-bundler"
2+
import Parcel from "@parcel/core"
33
import * as path from "path"
44

5+
type FixMeLater = any
6+
57
async function main(): Promise<void> {
68
try {
79
const watcher = new Watcher()
@@ -84,15 +86,20 @@ class Watcher {
8486
cleanup(code)
8587
})
8688
}
87-
const bundle = bundler.bundle().catch(() => {
88-
Watcher.log("parcel watcher terminated unexpectedly")
89-
cleanup(1)
90-
})
91-
bundler.on("buildEnd", () => {
92-
console.log("[parcel] bundled")
93-
})
94-
bundler.on("buildError", (error) => {
95-
console.error("[parcel]", error)
89+
const bundle = bundler.watch((err: any, buildEvent: string) => {
90+
if (err) {
91+
console.error(err)
92+
Watcher.log("parcel watcher terminated unexpectedly")
93+
cleanup(1)
94+
}
95+
96+
if (buildEvent === "buildEnd") {
97+
console.log("[parcel] bundled")
98+
}
99+
100+
if (buildEvent === "buildError") {
101+
console.error("[parcel]", err)
102+
}
96103
})
97104

98105
vscode.stderr.on("data", (d) => process.stderr.write(d))
@@ -172,22 +179,23 @@ class Watcher {
172179
}
173180
}
174181

175-
private createBundler(out = "dist"): Bundler {
176-
return new Bundler(
177-
[
182+
private createBundler(out = "dist"): FixMeLater {
183+
return new (Parcel as any)({
184+
entries: [
178185
path.join(this.rootPath, "src/browser/register.ts"),
179186
path.join(this.rootPath, "src/browser/serviceWorker.ts"),
180187
path.join(this.rootPath, "src/browser/pages/login.ts"),
181188
path.join(this.rootPath, "src/browser/pages/vscode.ts"),
182189
],
183-
{
184-
outDir: path.join(this.rootPath, out),
185-
cacheDir: path.join(this.rootPath, ".cache"),
186-
minify: !!process.env.MINIFY,
187-
logLevel: 1,
190+
cacheDir: path.join(this.rootPath, ".cache"),
191+
logLevel: 1,
192+
defaultConfig: require.resolve("@parcel/config-default"),
193+
defaultTargetOptions: {
188194
publicUrl: ".",
195+
shouldOptimize: !!process.env.MINIFY,
196+
distDir: path.join(this.rootPath, out),
189197
},
190-
)
198+
})
191199
}
192200
}
193201

package.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
},
3636
"main": "out/node/entry.js",
3737
"devDependencies": {
38+
"@parcel/core": "^2.0.0-beta.3.1",
39+
"@parcel/types": "^2.0.0-alpha.3",
3840
"@schemastore/package": "^0.0.6",
3941
"@types/body-parser": "^1.19.0",
4042
"@types/compression": "^1.7.0",
@@ -43,7 +45,7 @@
4345
"@types/http-proxy": "^1.17.4",
4446
"@types/js-yaml": "^4.0.0",
4547
"@types/node": "^14.17.1",
46-
"@types/parcel-bundler": "^1.12.1",
48+
"@types/parcel-bundler": "^1.12.3",
4749
"@types/pem": "^1.9.5",
4850
"@types/proxy-from-env": "^1.0.1",
4951
"@types/safe-compare": "^1.1.0",
@@ -64,7 +66,7 @@
6466
"eslint-plugin-import": "^2.18.2",
6567
"eslint-plugin-prettier": "^3.1.0",
6668
"leaked-handles": "^5.2.0",
67-
"parcel-bundler": "^1.12.5",
69+
"parcel": "^2.0.0-beta.3.1",
6870
"prettier": "^2.2.1",
6971
"prettier-plugin-sh": "^0.6.0",
7072
"shellcheck": "^1.0.0",
@@ -79,9 +81,6 @@
7981
"doctoc/underscore": "^1.13.1",
8082
"doctoc/**/trim": "^1.0.0",
8183
"postcss": "^8.2.1",
82-
"parcel-bundler/cssnano": "^5.0.2",
83-
"parcel-bundler/ws": "^7.4.6",
84-
"parcel-bundler/htmlnano/uncss/jsdom/ws": "^7.4.6",
8584
"browserslist": "^4.16.5",
8685
"safe-buffer": "^5.1.1",
8786
"vfile-message": "^2.0.2"

typings/parcel/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module "parcel" {}

typings/parcel__core/index.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
type FixMeLater = any
2+
declare module "@parcel/core" {
3+
export class Parcel {
4+
constructor(options: FixMeLater)
5+
}
6+
}

0 commit comments

Comments
 (0)