drop ts_library() requirement in ts/svelte

This commit is contained in:
Damien Elmes 2021-10-18 13:00:55 +10:00
parent bb5053990b
commit fed5c3da0e
3 changed files with 20 additions and 10 deletions

View file

@ -1,28 +1,25 @@
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
load("@npm//@bazel/typescript:index.bzl", "ts_library") load("//ts:typescript.bzl", "typescript")
_deps = [ _deps = [
"@npm//@bazel/worker", "@npm//@bazel/worker",
"@npm//@types/node",
"@npm//sass", "@npm//sass",
"@npm//svelte", "@npm//svelte",
"@npm//svelte-preprocess", "@npm//svelte-preprocess",
"@npm//svelte2tsx", "@npm//svelte2tsx",
"@npm//typescript", "@npm//typescript",
"@npm//@types/node",
] ]
ts_library( typescript(
name = "svelte_bin_ts", name = "svelte_worker_ts",
srcs = ["svelte.ts"], srcs = ["svelte.ts"],
tsconfig = "//ts:tsconfig_bin",
deps = _deps, deps = _deps,
) )
nodejs_binary( nodejs_binary(
name = "svelte_bin", name = "svelte_bin",
data = ["svelte_bin_ts"] + _deps, data = [":svelte_worker_ts"] + _deps,
entry_point = ":svelte.ts", entry_point = ":svelte.js",
# should fix .js files being not found on subsequent worker requests
templated_args = ["--bazel_patch_module_resolver"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )

View file

@ -8,7 +8,7 @@ import { svelte2tsx } from "svelte2tsx";
import preprocess from "svelte-preprocess"; import preprocess from "svelte-preprocess";
import { basename } from "path"; import { basename } from "path";
import * as ts from "typescript"; import * as ts from "typescript";
import * as svelte from "svelte/compiler.js"; import * as svelte from "svelte/compiler";
const parsedCommandLine: ts.ParsedCommandLine = { const parsedCommandLine: ts.ParsedCommandLine = {
fileNames: [], fileNames: [],

13
ts/svelte/tsconfig.json Normal file
View file

@ -0,0 +1,13 @@
{
"extends": "../tsconfig.json",
"include": ["*"],
"references": [],
"compilerOptions": {
// ignore missing optional modules like postcss
"skipLibCheck": true,
// ensure node can run the resulting code
"noEmitHelpers": false,
"importHelpers": false,
"module": "commonjs",
}
}