build: Add entry point for Ivy language service (#36864)

This commit adds a new entry point for the Ivy version of language
service. The entry point is just a shell for now, implementation will be
added in subsequent PRs.

The Ivy version of language service could be loaded from the NPM package
via `require(@angular/language-service/bundles/ivy.umd.js)`

PR Close #36864
This commit is contained in:
Keen Yee Liau 2020-04-29 15:08:22 -07:00 committed by Alex Rickabaugh
parent e9300c979e
commit 95a407d9dd
5 changed files with 75 additions and 0 deletions

View File

@ -35,5 +35,6 @@ pkg_npm(
":language-service",
# min bundle is not used at the moment; omit from package to speed up build
"//packages/language-service/bundles:language-service.umd.js",
"//packages/language-service/bundles:ivy.umd.js",
],
)

View File

@ -18,6 +18,21 @@ ls_rollup_bundle(
],
)
ls_rollup_bundle(
name = "ivy",
entry_point = "//packages/language-service/ivy:ts_plugin.ts",
globals = {
"fs": "fs",
"path": "path",
"typescript/lib/tsserverlibrary": "ts",
},
license_banner = ":banner",
visibility = ["//packages/language-service:__pkg__"],
deps = [
"//packages/language-service/ivy",
],
)
genrule(
name = "banner",
srcs = ["banner.js"],

View File

@ -0,0 +1,11 @@
load("//tools:defaults.bzl", "ts_library")
package(default_visibility = ["//visibility:public"])
ts_library(
name = "ivy",
srcs = glob(["*.ts"]),
deps = [
"@npm//typescript",
],
)

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import * as ts from 'typescript/lib/tsserverlibrary';
export class LanguageService {
constructor(private readonly tsLS: ts.LanguageService) {}
getSemanticDiagnostics(fileName: string): ts.Diagnostic[] {
return [];
}
}

View File

@ -0,0 +1,31 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import * as ts from 'typescript/lib/tsserverlibrary';
import {LanguageService} from './language_service';
export function create(info: ts.server.PluginCreateInfo): ts.LanguageService {
const {languageService: tsLS, config} = info;
const angularOnly = config?.angularOnly === true;
const ngLS = new LanguageService(tsLS);
function getSemanticDiagnostics(fileName: string): ts.Diagnostic[] {
const diagnostics: ts.Diagnostic[] = [];
if (!angularOnly) {
diagnostics.push(...tsLS.getSemanticDiagnostics(fileName));
}
diagnostics.push(...ngLS.getSemanticDiagnostics(fileName));
return diagnostics;
}
return {
...tsLS,
getSemanticDiagnostics,
};
}