Skip to content

Commit 92bfd51

Browse files
authored
Enable TypeScript for Hello World extension (#377)
The extension should generally work the same as before, but a `yarn build` will be needed to compile the TypeScript code to a runnable extension.
1 parent 9599346 commit 92bfd51

File tree

19 files changed

+101
-40
lines changed

19 files changed

+101
-40
lines changed

workspaces/adventure-pack/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"@code-chronicles/eslint-config": "0.0.1",
6868
"@code-chronicles/util": "0.0.1",
6969
"@jest/globals": "29.7.0",
70-
"@types/node": "22.2.0",
70+
"@types/node": "22.5.0",
7171
"@types/react": "18.3.3",
7272
"@types/react-dom": "18.3.0",
7373
"@types/react-syntax-highlighter": "15.5.13",
@@ -84,7 +84,7 @@
8484
"tsx": "4.17.0",
8585
"type-fest": "4.24.0",
8686
"typescript": "5.5.4",
87-
"webpack": "5.93.0",
87+
"webpack": "5.94.0",
8888
"webpack-cli": "5.1.4",
8989
"zod": "3.23.8"
9090
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
export { default } from "@code-chronicles/eslint-config";
1+
import config from "@code-chronicles/eslint-config";
2+
3+
export default [...config, { ignores: ["dist/"] }];
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<html>
22
<body>
33
<h1>Hello Extensions</h1>
4-
<script src="popup.js"></script>
4+
<script src="dist/main.js"></script>
55
</body>
66
</html>

workspaces/chrome-extension-hello-world/package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@
77
"url": "https://github.com/code-chronicles-code/leetcode-curriculum.git",
88
"directory": "workspaces/chrome-extension-hello-world"
99
},
10+
"main": "src/main.ts",
1011
"scripts": {
12+
"build": "webpack",
1113
"format": "prettier --color --write .",
12-
"lint": "eslint --color --max-warnings=0 ."
14+
"lint": "eslint --color --max-warnings=0 .",
15+
"typecheck": "tsc --pretty --project ."
1316
},
1417
"devDependencies": {
1518
"@code-chronicles/eslint-config": "0.0.1",
16-
"prettier": "3.3.3"
19+
"@types/node": "22.5.0",
20+
"prettier": "3.3.3",
21+
"ts-loader": "9.5.1",
22+
"typescript": "5.5.4",
23+
"webpack": "5.94.0",
24+
"webpack-cli": "5.1.4"
1725
}
1826
}

workspaces/chrome-extension-hello-world/popup.js

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
alert("This is a TypeScript popup!");
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "../../tsconfig-base.json"
3+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import path from "node:path";
2+
3+
import type { Configuration } from "webpack";
4+
5+
import packageJson from "./package.json";
6+
7+
const config: Configuration = {
8+
target: "web",
9+
entry: path.resolve(__dirname, packageJson.main),
10+
output: {
11+
filename: "[name].js",
12+
path: path.resolve(__dirname, "dist"),
13+
},
14+
15+
module: {
16+
rules: [
17+
{
18+
test: /\.tsx?$/,
19+
use: [
20+
{
21+
loader: "ts-loader",
22+
options: {
23+
compilerOptions: {
24+
noEmit: false,
25+
},
26+
},
27+
},
28+
],
29+
exclude: /\bnode_modules\b/,
30+
},
31+
],
32+
},
33+
34+
resolve: {
35+
extensions: [".tsx", ".ts", "..."],
36+
},
37+
38+
optimization: {
39+
splitChunks: {
40+
cacheGroups: {
41+
dependencies: {
42+
test: /\bnode_modules\b/,
43+
name: "dependencies",
44+
chunks: "all",
45+
},
46+
},
47+
},
48+
},
49+
};
50+
51+
export default config;

workspaces/download-leetcode-submissions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"devDependencies": {
2929
"@code-chronicles/eslint-config": "0.0.1",
30-
"@types/node": "22.2.0",
30+
"@types/node": "22.5.0",
3131
"eslint": "9.9.0",
3232
"prettier": "3.3.3",
3333
"typescript": "5.5.4"

0 commit comments

Comments
 (0)