Skip to content

upgrade typescript, add ts_project angular test #2625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/linker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.main = exports.reduceModules = void 0;
const fs = require("fs");
const path = require("path");
const { runfiles: _defaultRunfiles, _BAZEL_OUT_REGEX } = require('../runfiles/index.js');
Expand Down
2 changes: 2 additions & 0 deletions internal/node/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ generated_file_test(
name = "checked_in_node_patches",
src = "node_patches.js",
generated = "//packages/node-patches:bundle",
# For some reason rollup produces different, non-matching output with --config=no-runfiles
tags = ["fix-windows"],
)
1 change: 1 addition & 0 deletions internal/npm_install/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* THIS FILE GENERATED FROM .ts; see BUILD.bazel */ /* clang-format off */'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
exports.printIndexBzl = exports.printPackageBin = exports.parsePackage = exports.getDirectDependencySet = exports.main = void 0;
const fs = require("fs");
const path = require("path");
const crypto = require("crypto");
Expand Down
54 changes: 31 additions & 23 deletions internal/runfiles/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// clang-format off
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var path = require('path');
var fs = require('fs');

Expand All @@ -11,18 +9,33 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function getDefaultExportFromCjs (x) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only file where the diff seems odd 🤔

getDefaultExportFromCjs is a rollup method, not typescript... why would a typescript update cause this?

and some of this just looks odd, like doing the defineProperty(exports, "__esModule" twice 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's possible and reasonable that rollup does something different when it sees the changed output from TypeScript that resulted from microsoft/TypeScript#37093

Like there is now a default export from this file and wasn't before? https://github.com/bazelbuild/rules_nodejs/blob/stable/packages/runfiles/index.ts

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aeagle@aeagle-a01 rules_nodejs % diff dist/bin/packages/runfiles/index.js /tmp/index.js
2a3
> exports.runfiles = exports._BAZEL_OUT_REGEX = exports.Runfiles = void 0;
4c5
< exports.Runfiles = runfiles_1.Runfiles;
---
> Object.defineProperty(exports, "Runfiles", { enumerable: true, get: function () { return runfiles_1.Runfiles; } });
6c7
< exports._BAZEL_OUT_REGEX = paths_1.BAZEL_OUT_REGEX;
---
> Object.defineProperty(exports, "_BAZEL_OUT_REGEX", { enumerable: true, get: function () { return paths_1.BAZEL_OUT_REGEX; } });

return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}

function createCommonjsModule(fn) {
var module = { exports: {} };
return fn(module, module.exports), module.exports;
}

var paths = createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.BAZEL_OUT_REGEX = void 0;
// NB: on windows thanks to legacy 8-character path segments it might be like
// c:/b/ojvxx6nx/execroot/build_~1/bazel-~1/x64_wi~1/bin/internal/npm_in~1/test
var BAZEL_OUT_REGEX = /(\/bazel-out\/|\/bazel-~1\/x64_wi~1\/)/;
exports.BAZEL_OUT_REGEX = /(\/bazel-out\/|\/bazel-~1\/x64_wi~1\/)/;
});

var runfiles$1 = createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.Runfiles = void 0;


var paths = /*#__PURE__*/Object.defineProperty({
BAZEL_OUT_REGEX: BAZEL_OUT_REGEX
}, '__esModule', {value: true});

/**
* Class that provides methods for resolving Bazel runfiles.
*/
class Runfiles$1 {
class Runfiles {
constructor(_env) {
this._env = _env;
// If Bazel sets a variable pointing to a runfiles manifest,
Expand Down Expand Up @@ -180,25 +193,20 @@ class Runfiles$1 {
return this._resolve(dirname, path__default['default'].join(path__default['default'].basename(moduleBase), moduleTail || ''));
}
}
var Runfiles_1 = Runfiles$1;
exports.Runfiles = Runfiles;
});

var runfiles$1 = /*#__PURE__*/Object.defineProperty({
Runfiles: Runfiles_1
}, '__esModule', {value: true});
var runfiles = createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.runfiles = exports._BAZEL_OUT_REGEX = exports.Runfiles = void 0;

var Runfiles = runfiles$1.Runfiles;
Object.defineProperty(exports, "Runfiles", { enumerable: true, get: function () { return runfiles$1.Runfiles; } });

var _BAZEL_OUT_REGEX = paths.BAZEL_OUT_REGEX;
Object.defineProperty(exports, "_BAZEL_OUT_REGEX", { enumerable: true, get: function () { return paths.BAZEL_OUT_REGEX; } });
/** Instance of the runfile helpers. */
var runfiles_2 = new runfiles$1.Runfiles(process.env);
exports.runfiles = new runfiles$1.Runfiles(process.env);
});

var runfiles = /*#__PURE__*/Object.defineProperty({
Runfiles: Runfiles,
_BAZEL_OUT_REGEX: _BAZEL_OUT_REGEX,
runfiles: runfiles_2
}, '__esModule', {value: true});
var index = /*@__PURE__*/getDefaultExportFromCjs(runfiles);

exports.Runfiles = Runfiles;
exports._BAZEL_OUT_REGEX = _BAZEL_OUT_REGEX;
exports.default = runfiles;
exports.runfiles = runfiles_2;
module.exports = index;
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
"yarn": ">=1.13.0"
},
"devDependencies": {
"@angular/common": "^9.1.0",
"@angular/compiler": "^9.1.0",
"@angular/compiler-cli": "^9.1.0",
"@angular/core": "^9.1.0",
"@angular/common": "^11.2.11",
"@angular/compiler": "^11.2.11",
"@angular/compiler-cli": "^11.2.11",
"@angular/core": "^11.2.11",
"@babel/cli": "^7.6.2",
"@babel/core": "^7.6.2",
"@babel/preset-env": "^7.6.2",
Expand Down Expand Up @@ -92,11 +92,11 @@
"tsickle": "0.38.0",
"tsutils": "2.27.2",
"typeorm": "0.2.18",
"typescript": "^3.7.5",
"typescript": "4.0.2",
"unidiff": "1.0.1",
"yarn": "1.22.0",
"c8": "7.5.0",
"zone.js": "0.8.29"
"zone.js": "^0.11.4"
},
"// resolutions/**/jest-serializer": "need to resolve to a version that doesn't have a /// <reference path='../v8.d.ts' /> in build/index.d.ts which exposes a bug in ts_library",
"resolutions": {
Expand Down
1 change: 1 addition & 0 deletions packages/esbuild/test/typescript/bundle.golden.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var require_module_dynamic = __commonJS((exports, module) => {
})(function(require2, exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", {value: true});
exports2.getId = void 0;
exports2.getId = () => "dynamic-id";
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/protractor/test/protractor/conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ exports.config = {

browser.baseUrl = `http://localhost:${port}`;

return new Promise(resolve => {
return new Promise<void>(resolve => {
app.listen(port, () => {
resolve();
});
Expand Down
1 change: 1 addition & 0 deletions packages/rollup/test/multi_linker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ rollup_bundle(
name = "bundle",
config_file = "rollup.config.js",
entry_point = "main.js",
sourcemap = "hidden",
deps = [
"tsconfig",
"@rollup_test_multi_linker_deps//@rollup/plugin-commonjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/rollup/test/multi_linker/golden.js_
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ function commonjsRequire () {

var lib = createCommonjsModule(function (module, exports) {
exports.__esModule = true;
exports.key = void 0;
exports.key = 'rollup';
});

var key = lib.key;
console.log(key);
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVuZGxlLmpzIiwic291cmNlcyI6WyJsaWIuanMiLCJtYWluLmpzIl0sInNvdXJjZXNDb250ZW50IjpbIlwidXNlIHN0cmljdFwiO1xuZXhwb3J0cy5fX2VzTW9kdWxlID0gdHJ1ZTtcbmV4cG9ydHMua2V5ID0gJ3JvbGx1cCc7XG4iLCJ2YXIga2V5ID0gcmVxdWlyZSgnLi9saWInKS5rZXk7XG5jb25zb2xlLmxvZyhrZXkpO1xuIl0sIm5hbWVzIjpbInJlcXVpcmUkJDAiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7OztBQUNBLGtCQUFrQixHQUFHLElBQUksQ0FBQztBQUMxQixXQUFXLEdBQUcsUUFBUTs7O0FDRnRCLElBQUksR0FBRyxHQUFHQSxHQUFnQixDQUFDLEdBQUcsQ0FBQztBQUMvQixPQUFPLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQyJ9
5 changes: 2 additions & 3 deletions packages/typescript/internal/worker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,13 @@ function getWatchProgram(args) {
return cachedWatchedProgram;
}
function emitOnce(args) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const watchProgram = getWatchProgram(args);
if (consolidateChangesCallback) {
consolidateChangesCallback();
}
workerRequestTimestamp = Date.now();
const result = yield ((_a = watchProgram) === null || _a === void 0 ? void 0 : _a.getProgram().emit(undefined, undefined, {
const result = yield (watchProgram === null || watchProgram === void 0 ? void 0 : watchProgram.getProgram().emit(undefined, undefined, {
isCancellationRequested: function (timestamp) {
return timestamp !== workerRequestTimestamp;
}.bind(null, workerRequestTimestamp),
Expand Down Expand Up @@ -94,7 +93,7 @@ function main() {
argsFilePath = argsFilePath.slice(1);
}
const args = fs.readFileSync(argsFilePath).toString().split('\n');
emitOnce(args).finally(() => { var _a; return (_a = cachedWatchedProgram) === null || _a === void 0 ? void 0 : _a.close(); });
emitOnce(args).finally(() => cachedWatchedProgram === null || cachedWatchedProgram === void 0 ? void 0 : cachedWatchedProgram.close());
}
}
if (require.main === module) {
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript/test/errorchecks/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ts_library(
name = "erroneous",
srcs = glob(["*.ts"]),
expected_diagnostics = [
"TS2322: Type '\"not a number\"' is not assignable to type 'number'",
"TS2322: Type 'string' is not assignable to type 'number'",
"TS2304: Cannot find name 'TypeThatDoesNotExist'",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ describe('googmodule', () => {
});

it('should have es5 in devmode', () => {
expect(fs.readFileSync(devmodeOutput, {
encoding: 'utf-8'
})).toContain(`exports.a = function () { return 'hello world'; };`);
const devoutput = fs.readFileSync(devmodeOutput, {encoding: 'utf-8'});

expect(devoutput).toContain(`a = function () { return 'hello world'; };`);
expect(devoutput).toContain(`exports.a = `);
});

it('should have amd module syntax in prodmode', () => {
Expand All @@ -28,8 +29,9 @@ describe('googmodule', () => {
});

it('should have es5 in prodmode', () => {
expect(fs.readFileSync(prodmodeOutput, {
encoding: 'utf-8'
})).toContain(`exports.a = function () { return 'hello world'; };`);
const prodoutput = fs.readFileSync(prodmodeOutput, {encoding: 'utf-8'});

expect(prodoutput).toContain(`a = function () { return 'hello world'; };`);
expect(prodoutput).toContain(`exports.a = `);
});
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use strict";
exports.__esModule = true;
exports.a = void 0;
exports.a = 'hello world';
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.a = void 0;
exports.a = 'hello world';
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use strict";
exports.__esModule = true;
exports.a = void 0;
exports.a = 'hello world';
1 change: 1 addition & 0 deletions packages/typescript/test/ts_project/outdir/a.golden.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use strict";
exports.__esModule = true;
exports.a = void 0;
exports.a = 1;
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use strict";
exports.__esModule = true;
exports.a = void 0;
exports.a = 'hello';
Loading