Skip to content

Commit

Permalink
Adds ts_project() macro.
Browse files Browse the repository at this point in the history
Refs #50.

This is just a `ts_project()` with some better defaults to reduce boilerplate. Also updates the `tsconfig.json` to set up `rootDirs` correctly and remove the WebDriverIO type which apparently isn't necessary.
  • Loading branch information
dgp1130 committed Jul 4, 2022
1 parent 77026a4 commit 6b38dc2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
11 changes: 11 additions & 0 deletions tools/typescript.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
load("@npm//@bazel/typescript:index.bzl", _ts_project = "ts_project")

def ts_project(name, tsconfig = None, **kwargs):
_ts_project(
name = name,
tsconfig = tsconfig or "//:tsconfig.json",
link_workspace_root = True,
declaration = True,
source_map = True,
**kwargs
)
22 changes: 15 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
"declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
Expand All @@ -38,16 +38,24 @@
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
"baseUrl": "./", /* Base directory to resolve non-absolute module names. */
"paths": { /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// Set up absolute imports per:
// https://bazelbuild.github.io/rules_nodejs/TypeScript.html#writing-typescript-code-for-ts_library
// Set up absolute imports per: https://bazelbuild.github.io/rules_nodejs/TypeScript.html#ts_project
"rules_prerender": ["packages/rules_prerender"], // Map `rules_prerender` module to its implementation.
"rules_prerender/*": ["*"] // Map workspace-relative imports.
},
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
"rootDirs": [ /* List of root folders whose combined content represents the structure of the project at runtime. */
".",
// List out generated directories for module resolution.
// https://bazelbuild.github.io/rules_nodejs/TypeScript.html#ts_project
"./bazel-out/host/bin",
"./bazel-out/darwin-fastbuild/bin",
"./bazel-out/k8-fastbuild/bin",
"./bazel-out/x64_windows-fastbuild/bin",
"./bazel-out/darwin-dbg/bin",
"./bazel-out/k8-dbg/bin",
"./bazel-out/x64_windows-dbg/bin",
],
// "typeRoots": [], /* List of folders to include type definitions from. */
"types": [ /* Type declaration files to be included in compilation. */
"webdriverio/async" // Needed because WebDriver requires global types (even if you import the type you want, it depends on other global types).
],
// "types": [], /* Automatically managed by `ts_project()`. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
Expand Down

0 comments on commit 6b38dc2

Please sign in to comment.