Skip to content

Commit 5fbe525

Browse files
authored
Use typescript project references (#356)
- `yarn watch` works across packages - goto definition works across packages - faster incremental builds - unify `tsconfig.json`s See https://www.typescriptlang.org/docs/handbook/project-references.html
1 parent 9d0ee01 commit 5fbe525

File tree

9 files changed

+42
-37
lines changed

9 files changed

+42
-37
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ out/
1515
**/.nyc_output/
1616
.databricks/**
1717
packages/databricks-sdk-js/src/config/testdata/azure/Library
18+
*.d.ts.map
19+
*.js.map
20+
tsconfig.tsbuildinfo

packages/databricks-sdk-js/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"/dist"
1818
],
1919
"scripts": {
20-
"build": "tsc -p tsconfig.json && cp src/fetch.* dist/",
21-
"watch": "tsc -w -p tsconfig.json",
20+
"build": "tsc --build",
21+
"watch": "tsc --build --watch",
2222
"clean": "rm -rf dist node_modules",
2323
"openapi:fetch": "./scripts/fetch_openapi.sh 4609d709fc94a1b8dbe79ac78a1cece281fdaeff",
2424
"openapi:generate": "./scripts/generate_openapi.sh v0.2.0 && yarn run build",

packages/databricks-sdk-js/src/fetch.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// node-fetch@3 is ESM only. Need some trickery to make it work with CommonJS
2-
3-
exports.fetch = async function (url, init) {
4-
const {default: fetch} = await import("node-fetch");
2+
exports.fetch = async function fetch(url, init) {
3+
// hide `import` statement from TypeScript compiler so it doesn't mess with it
4+
const {default: fetch} = await eval(`import("node-fetch")`);
55
const controller = new AbortController();
66
const signal = controller.signal;
77
return {
Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
{
2+
"extends": "../../tsconfig_base.json",
23
"compilerOptions": {
3-
"declaration": true,
4+
"allowJs": true,
45
"types": ["reflect-metadata", "mocha", "node"],
5-
"module": "CommonJS",
6-
"target": "ES2020",
7-
"moduleResolution": "Node",
8-
"esModuleInterop": true,
9-
"isolatedModules": true,
106
"lib": ["ES2020", "DOM", "ES2021.String"],
11-
"sourceMap": true,
127
"rootDir": "src",
13-
"outDir": "dist",
14-
"strict": true /* enable all strict type-checking options */,
15-
"experimentalDecorators": true,
16-
"emitDecoratorMetadata": true,
17-
"forceConsistentCasingInFileNames": true
8+
"outDir": "dist"
189
},
1910
"include": ["src"]
2011
}

packages/databricks-vscode-types/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
},
1515
"homepage": "https://github.com/databricks/databricks-vscode#readme",
1616
"scripts": {
17-
"build": "tsc",
18-
"watch": "tsc -w",
17+
"build": "tsc --build",
18+
"watch": "tsc --build --watch",
1919
"clean": "rm -rf dist node_modules",
2020
"fix": "eslint . --ext ts --fix && prettier . --write",
2121
"test:lint": "eslint . --ext ts && prettier . -c",
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
{
2+
"extends": "../../tsconfig_base.json",
23
"compilerOptions": {
3-
"module": "CommonJS",
4-
"target": "ES2020",
5-
"declaration": true,
6-
"esModuleInterop": true,
7-
"isolatedModules": true,
84
"lib": ["ES2020", "ES2021.String"],
9-
"rootDir": ".",
10-
"strict": true /* enable all strict type-checking options */
5+
"rootDir": "."
116
},
7+
"references": [{"path": "../databricks-sdk-js"}],
128
"include": ["*.ts"]
139
}

packages/databricks-vscode/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,8 @@
522522
"package:compile": "yarn run esbuild:base",
523523
"package:copy-webview-toolkit": "cp ./node_modules/@vscode/webview-ui-toolkit/dist/toolkit.js ./out/toolkit.js",
524524
"esbuild:base": "esbuild ./src/extension.ts --bundle --outfile=out/extension.js --external:vscode --format=cjs --platform=node --sourcemap --target=es2019",
525-
"build": "tsc",
526-
"watch": "yarn run package:copy-webview-toolkit && tsc -w",
525+
"build": "tsc --build",
526+
"watch": "yarn run package:copy-webview-toolkit && tsc --build --watch",
527527
"fix": "eslint src --ext ts --fix && prettier . --write",
528528
"test:lint": "eslint src --ext ts && prettier . -c",
529529
"test:unit": "yarn run build && node ./out/test/runTest.js",
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
{
2+
"extends": "../../tsconfig_base.json",
23
"compilerOptions": {
3-
"module": "CommonJS",
4-
"target": "ES2020",
54
"outDir": "out",
6-
"esModuleInterop": true,
7-
"isolatedModules": true,
85
"lib": ["ES2020", "ES2021.String"],
9-
"sourceMap": true,
10-
"rootDir": "src",
11-
"strict": true /* enable all strict type-checking options */,
12-
"forceConsistentCasingInFileNames": true,
13-
"experimentalDecorators": true
6+
"rootDir": "src"
147
},
8+
"references": [
9+
{"path": "../databricks-sdk-js"},
10+
{"path": "../databricks-vscode-types"}
11+
],
1512
"include": ["src"],
1613
"exclude": ["src/test/e2e/"]
1714
}

tsconfig_base.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
"declaration": true,
5+
"declarationMap": true,
6+
"sourceMap": true,
7+
"allowJs": true,
8+
"module": "CommonJS",
9+
"target": "ES2020",
10+
"moduleResolution": "Node",
11+
"esModuleInterop": true,
12+
"isolatedModules": true,
13+
"strict": true,
14+
"experimentalDecorators": true,
15+
"emitDecoratorMetadata": true,
16+
"forceConsistentCasingInFileNames": true
17+
}
18+
}

0 commit comments

Comments
 (0)