2019-12-28 19:37:59 -05:00
|
|
|
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
|
2017-12-17 18:10:54 -05:00
|
|
|
|
2019-01-16 04:19:01 -05:00
|
|
|
package(default_visibility = ["//visibility:public"])
|
|
|
|
|
2021-01-28 15:43:37 -05:00
|
|
|
ts_library(
|
|
|
|
name = "api",
|
|
|
|
srcs = [
|
|
|
|
"api.ts",
|
2021-02-23 13:51:23 -05:00
|
|
|
"index.ts",
|
2021-01-28 15:43:37 -05:00
|
|
|
],
|
build(language-service): use 'export =' syntax for default export (#41165)
Tsserver expects `@angular/language-service` to provide a factory function
as the default export (commonjs-style) of the package.
The current implementation side steps TypeScript's import syntax by using
`module.exports = factory`.
This allows the code to incorrectly re-export other symbols:
```ts
export * from './api';
```
which transpiles to:
```js
var tslib_1 = require("tslib");
tslib_1.__exportStar(require("@angular/language-service/api"), exports);
```
Doing this meant that the package now has a runtime dependency on `tslib`,
which is totally unnecessary.
With the proper `export =` syntax, `tslib` is removed, and no other exports
are allowed.
Output:
```js
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define("@angular/language-service", ["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
return function factory(tsModule) {
var plugin;
return {
create: function (info) {
var config = info.config;
var bundleName = config.ivy ? 'ivy.js' : 'language-service.js';
plugin = require("./bundles/" + bundleName)(tsModule);
return plugin.create(info);
},
getExternalFiles: function (project) {
var _a, _b;
return (_b = (_a = plugin === null || plugin === void 0 ? void 0 : plugin.getExternalFiles) === null || _a === void 0 ? void 0 : _a.call(plugin, project)) !== null && _b !== void 0 ? _b : [];
},
onConfigurationChanged: function (config) {
var _a;
(_a = plugin === null || plugin === void 0 ? void 0 : plugin.onConfigurationChanged) === null || _a === void 0 ? void 0 : _a.call(plugin, config);
},
};
};
});
```
PR Close #41165
2021-03-10 19:06:09 -05:00
|
|
|
prodmode_module = "commonjs",
|
2021-01-28 15:43:37 -05:00
|
|
|
deps = [
|
2021-02-23 13:51:23 -05:00
|
|
|
"@npm//@types/node",
|
2021-01-28 15:43:37 -05:00
|
|
|
"@npm//typescript",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2017-12-17 18:10:54 -05:00
|
|
|
ts_library(
|
|
|
|
name = "language-service",
|
2021-02-23 13:51:23 -05:00
|
|
|
srcs = glob(
|
2017-12-17 18:10:54 -05:00
|
|
|
[
|
|
|
|
"src/**/*.ts",
|
|
|
|
],
|
2020-05-07 11:55:33 -04:00
|
|
|
exclude = [
|
|
|
|
"src/ts_utils.ts",
|
|
|
|
],
|
2017-12-17 18:10:54 -05:00
|
|
|
),
|
|
|
|
deps = [
|
2021-01-28 15:43:37 -05:00
|
|
|
":api",
|
2020-05-07 11:55:33 -04:00
|
|
|
":ts_utils",
|
2017-12-17 18:10:54 -05:00
|
|
|
"//packages:types",
|
|
|
|
"//packages/compiler",
|
|
|
|
"//packages/compiler-cli",
|
|
|
|
"//packages/core",
|
2019-02-20 12:54:42 -05:00
|
|
|
"@npm//@types/node",
|
|
|
|
"@npm//typescript",
|
2017-12-17 18:10:54 -05:00
|
|
|
],
|
|
|
|
)
|
2018-03-13 14:00:53 -04:00
|
|
|
|
2020-05-07 11:55:33 -04:00
|
|
|
ts_library(
|
|
|
|
name = "ts_utils",
|
|
|
|
srcs = ["src/ts_utils.ts"],
|
|
|
|
deps = [
|
|
|
|
"@npm//typescript",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2019-12-28 19:37:59 -05:00
|
|
|
pkg_npm(
|
2018-03-13 14:00:53 -04:00
|
|
|
name = "npm_package",
|
|
|
|
srcs = ["package.json"],
|
2018-03-30 16:48:47 -04:00
|
|
|
tags = [
|
2018-04-03 19:12:25 -04:00
|
|
|
"release-with-framework",
|
|
|
|
],
|
2018-12-11 19:53:42 -05:00
|
|
|
# Do not add more to this list.
|
|
|
|
# Dependencies on the full npm_package cause long re-builds.
|
2020-02-04 14:45:40 -05:00
|
|
|
visibility = [
|
|
|
|
"//integration:__pkg__",
|
|
|
|
],
|
2018-04-03 19:12:25 -04:00
|
|
|
deps = [
|
2021-02-23 13:51:23 -05:00
|
|
|
":api",
|
2019-10-29 17:21:30 -04:00
|
|
|
# min bundle is not used at the moment; omit from package to speed up build
|
2020-07-15 16:58:03 -04:00
|
|
|
"//packages/language-service/bundles:language-service.js",
|
|
|
|
"//packages/language-service/bundles:ivy.js",
|
2018-03-30 16:48:47 -04:00
|
|
|
],
|
2018-03-13 14:00:53 -04:00
|
|
|
)
|