Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dgp1130 committed Apr 10, 2021
1 parent d32c0e8 commit 27eb205
Show file tree
Hide file tree
Showing 9 changed files with 937 additions and 2,048 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -627,3 +627,20 @@ To actually publish a release to NPM, follow these steps:
[releases](https://github.com/dgp1130/rules_prerender/releases) to edit the
automatically created release to add a changelog or other relevant
information.
## Updating `tsc_wrapped` patch
`@bazel/typescript` is patched to load `//packages/tsc_plugin`. The patch itself
lives at
[`patches/@bazel+typescript+3.0.0.patch`](patches/@bazel+typescript+3.0.0.patch)
and is automatically applied via a `postinstall` script. If you want to change
the patch, the easiest way to do this is by making the edits you want in
`node_modules/@bazel/typescript/` and then running:
```shell
npx [email protected] @bazel/typescript && bazel run //path/to/pkg:target
```
This will update the `.patch` file to reflect your changes to `node_modules/`.
`bazel` will pick up this change and rerun `npm install` followed by applying
the patch and then building and running the desired target.
1 change: 1 addition & 0 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ npm_install(
package_lock_json = "//:package-lock.json",
# Needed for `rules_postcss` to be able to resolve its NPM dependencies.
strict_visibility = False,
data = ["//:patches/@bazel+typescript+3.0.0.patch"],
)

# Load bazel_skylib.
Expand Down
2,310 changes: 264 additions & 2,046 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"ibazel": "ibazel",
"build": "bazel build //...",
"test": "bazel test //...",
"release": "bazel run //:pkg.publish --config release --"
"release": "bazel run //:pkg.publish --config release --",
"postinstall": "patch-package"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -55,11 +56,13 @@
"@types/yargs": "^15.0.11",
"http-status-codes": "^2.1.4",
"jasmine": "^3.6.3",
"patch-package": "^6.4.7",
"puppeteer": "^5.5.0",
"tree-kill": "^1.2.2",
"typescript": "^3.9.7"
},
"peerDependencies": {
"@bazel/typescript": "^3.0.0"
"@bazel/typescript": "^3.0.0",
"typescript": "^3.9.7"
}
}
1 change: 1 addition & 0 deletions packages/rules_prerender/prerender_component.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def prerender_component(
srcs = srcs,
tsconfig = tsconfig,
data = data,
compiler = "@npm//@bazel/typescript/internal:tsc_wrapped_with_rules_prerender_plugin",
deps = lib_deps + ["%s_prerender" % absolute(dep) for dep in deps],
testonly = testonly,
visibility = visibility,
Expand Down
18 changes: 18 additions & 0 deletions packages/tsc_plugin/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
load("@npm//@bazel/typescript:index.bzl", "ts_library")

ts_library(
name = "tsc_plugin",
srcs = ["index.ts"],
module_name = "rules_prerender_tsc_plugin",
visibility = ["//visibility:public"],
deps = [":prerender_plugin"],
)

ts_library(
name = "prerender_plugin",
srcs = ["prerender_plugin.ts"],
deps = [
"@npm//typescript",
"@npm//@bazel/typescript"
],
)
1 change: 1 addition & 0 deletions packages/tsc_plugin/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { PrerenderPlugin } from './prerender_plugin';
26 changes: 26 additions & 0 deletions packages/tsc_plugin/prerender_plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as ts from 'typescript';
import { DiagnosticPlugin } from '@bazel/typescript';

export class PrerenderPlugin implements DiagnosticPlugin {
public readonly name = 'PrerenderPlugin';

private constructor() { }

public static of(): PrerenderPlugin {
return new PrerenderPlugin();
}

public getDiagnostics(sourceFile: ts.SourceFile):
readonly Readonly<ts.Diagnostic>[] {
return [
{
messageText: 'Strict deps violation from rules_prerender!',
category: ts.DiagnosticCategory.Error,
code: 0,
file: sourceFile,
start: 0,
length: 5,
},
];
}
}
Loading

0 comments on commit 27eb205

Please sign in to comment.