From d17f86399e21330d856b944fe0ef255a419bc4cb Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Tue, 12 Oct 2021 17:18:42 +0200 Subject: [PATCH 1/4] test: allow for lsp tests to work with windows --- integration/lsp/ivy_spec.ts | 4 ++-- integration/lsp/test_utils.ts | 7 ++++++- integration/test_constants.ts | 7 ++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/integration/lsp/ivy_spec.ts b/integration/lsp/ivy_spec.ts index 765556fc63..9193e78a9c 100644 --- a/integration/lsp/ivy_spec.ts +++ b/integration/lsp/ivy_spec.ts @@ -17,7 +17,7 @@ import {NgccProgress, NgccProgressToken, NgccProgressType} from '../../common/pr import {GetComponentsWithTemplateFile, GetTcbRequest, GetTemplateLocationForComponent, IsInAngularProject} from '../../common/requests'; import {APP_COMPONENT, APP_COMPONENT_URI, FOO_COMPONENT, FOO_COMPONENT_URI, FOO_TEMPLATE, FOO_TEMPLATE_URI, PROJECT_PATH, TSCONFIG} from '../test_constants'; -import {createConnection, createTracer, initializeServer, openTextDocument} from './test_utils'; +import {convertPathToFileUrl, createConnection, createTracer, initializeServer, openTextDocument} from './test_utils'; const setTimeoutP = promisify(setTimeout); @@ -603,7 +603,7 @@ function getDiagnosticsForFile( return new Promise(resolve => { client.onNotification( lsp.PublishDiagnosticsNotification.type, (params: lsp.PublishDiagnosticsParams) => { - if (params.uri === `file://${fileName}`) { + if (params.uri === convertPathToFileUrl(fileName)) { resolve(params.diagnostics); } }); diff --git a/integration/lsp/test_utils.ts b/integration/lsp/test_utils.ts index 80b6a50f98..b868d03f13 100644 --- a/integration/lsp/test_utils.ts +++ b/integration/lsp/test_utils.ts @@ -10,6 +10,7 @@ import {fork} from 'child_process'; import * as fs from 'fs'; import {createMessageConnection, IPCMessageReader, IPCMessageWriter, MessageConnection} from 'vscode-jsonrpc/node'; import * as lsp from 'vscode-languageserver-protocol'; +import {URI} from 'vscode-uri'; import {PROJECT_PATH, SERVER_PATH} from '../test_constants'; @@ -79,7 +80,7 @@ export function openTextDocument(client: MessageConnection, filePath: string, ne } client.sendNotification(lsp.DidOpenTextDocumentNotification.type, { textDocument: { - uri: `file://${filePath}`, + uri: convertPathToFileUrl(filePath), languageId, version: 1, text: newText ?? fs.readFileSync(filePath, 'utf-8'), @@ -87,6 +88,10 @@ export function openTextDocument(client: MessageConnection, filePath: string, ne }); } +export function convertPathToFileUrl(filePath: string): string { + return URI.file(filePath).toString(); +} + export function createTracer(): lsp.Tracer { return { log(messageOrDataObject: string|any, data?: string) { diff --git a/integration/test_constants.ts b/integration/test_constants.ts index 64d4d16caf..4c243aad11 100644 --- a/integration/test_constants.ts +++ b/integration/test_constants.ts @@ -1,12 +1,13 @@ import {join, resolve} from 'path'; +import {convertPathToFileUrl} from './lsp/test_utils'; export const PACKAGE_ROOT = resolve(__dirname, '../..'); export const SERVER_PATH = join(PACKAGE_ROOT, 'dist', 'npm', 'server', 'index.js'); export const PROJECT_PATH = join(PACKAGE_ROOT, 'integration', 'project'); export const APP_COMPONENT = join(PROJECT_PATH, 'app', 'app.component.ts'); -export const APP_COMPONENT_URI = `file://${APP_COMPONENT}`; +export const APP_COMPONENT_URI = convertPathToFileUrl(APP_COMPONENT); export const FOO_TEMPLATE = join(PROJECT_PATH, 'app', 'foo.component.html'); -export const FOO_TEMPLATE_URI = `file://${FOO_TEMPLATE}`; +export const FOO_TEMPLATE_URI = convertPathToFileUrl(FOO_TEMPLATE); export const FOO_COMPONENT = join(PROJECT_PATH, 'app', 'foo.component.ts'); -export const FOO_COMPONENT_URI = `file://${FOO_COMPONENT}`; +export const FOO_COMPONENT_URI = convertPathToFileUrl(FOO_COMPONENT); export const TSCONFIG = join(PROJECT_PATH, 'tsconfig.json'); \ No newline at end of file From 924b5e50541633881e62b8850cbd75579ca9a779 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Tue, 12 Oct 2021 17:49:45 +0200 Subject: [PATCH 2/4] refactor: update to angular v13 with APF v13 output Updates to an Angular v13 version which comes with the APF v13 output where all FW packages are strict ESM. This required some changes in the ngcc lookup logic to properly work with strict ESM and the new `package.json` `exports` field. --- integration/project/package.json | 8 ++-- integration/project/yarn.lock | 70 +++++++++++++----------------- integration/workspace/package.json | 7 +-- integration/workspace/yarn.lock | 67 ++++++++++++++-------------- package.json | 2 +- scripts/test.sh | 6 --- server/src/ngcc.ts | 2 +- server/src/session.ts | 1 - server/src/version_provider.ts | 33 +++++++++++++- yarn.lock | 8 ++-- 10 files changed, 109 insertions(+), 95 deletions(-) diff --git a/integration/project/package.json b/integration/project/package.json index 689ccd812d..90487e3594 100644 --- a/integration/project/package.json +++ b/integration/project/package.json @@ -2,10 +2,10 @@ "name": "angular-ls-integration-test-project", "private": true, "dependencies": { - "@angular/common": "12.2.3", - "@angular/compiler": "12.2.3", - "@angular/compiler-cli": "12.2.3", - "@angular/core": "12.2.3", + "@angular/common": "13.0.0-next.15", + "@angular/compiler": "13.0.0-next.15", + "@angular/compiler-cli": "13.0.0-next.15", + "@angular/core": "13.0.0-next.15", "rxjs": "6.6.7", "zone.js": "0.11.4" } diff --git a/integration/project/yarn.lock b/integration/project/yarn.lock index c221735b4b..2fdae71a76 100644 --- a/integration/project/yarn.lock +++ b/integration/project/yarn.lock @@ -2,46 +2,43 @@ # yarn lockfile v1 -"@angular/common@12.2.3": - version "12.2.3" - resolved "https://registry.yarnpkg.com/@angular/common/-/common-12.2.3.tgz#deb11b2cc0e0e3056af4b0318098aecbc67fa561" - integrity sha512-AkOeknm35kzLqqh5dIz1143e3Q1MjWgi7THlY3StY63yphseQUUvGQSNHkDSIpfwBN8Mt+ZykKFjhY+cNFYt7w== +"@angular/common@13.0.0-next.15": + version "13.0.0-next.15" + resolved "https://registry.yarnpkg.com/@angular/common/-/common-13.0.0-next.15.tgz#9d55f51fbda235bea9510ca30a2f6389b22a19c2" + integrity sha512-T0LPfZ4kKbcoT0QVluyT1Jo7J5ZK3vVSKSYMEHxqE21pFqlI5MMGdqn9X+SDlIEvEikARXG4w10Q3uJuAaaS5Q== dependencies: - tslib "^2.2.0" + tslib "^2.3.0" -"@angular/compiler-cli@12.2.3": - version "12.2.3" - resolved "https://registry.yarnpkg.com/@angular/compiler-cli/-/compiler-cli-12.2.3.tgz#77774b219276ef45b269743093a40166299b6da6" - integrity sha512-8yw13AqfRSY9YV4zb6PfuJizPa5/lh4DNbc6gQkw1Dmh/Af+U2bxrtZhQCgXWJAys1sd+PN/gTQOc7/YzDNVLQ== +"@angular/compiler-cli@13.0.0-next.15": + version "13.0.0-next.15" + resolved "https://registry.yarnpkg.com/@angular/compiler-cli/-/compiler-cli-13.0.0-next.15.tgz#4f25b6d3feb1dbb0a6dd0f7d5445f24d20b49709" + integrity sha512-15w0fFrqFfHNbQ7nrzTB4rrObsIpmsbGAlrKoFPdWN2LbAYUEauUhRIPi1Et+4A1eh9beIUHpofwb+VRrUhuLw== dependencies: "@babel/core" "^7.8.6" - "@babel/types" "^7.8.6" canonical-path "1.0.0" chokidar "^3.0.0" convert-source-map "^1.5.1" dependency-graph "^0.11.0" magic-string "^0.25.0" - minimist "^1.2.0" reflect-metadata "^0.1.2" semver "^7.0.0" - source-map "^0.6.1" sourcemap-codec "^1.4.8" - tslib "^2.2.0" - yargs "^17.0.0" + tslib "^2.3.0" + yargs "^17.2.1" -"@angular/compiler@12.2.3": - version "12.2.3" - resolved "https://registry.yarnpkg.com/@angular/compiler/-/compiler-12.2.3.tgz#a528dcda48c17c9b844caba5b61cfd119e515d17" - integrity sha512-jlS7XUokGb4eH6aYEIanrq6a7ZxcMI9GmMr5tBAdIHusH3b40dcMpZVXIxoGzv1Ws47m2izDCrjWjkFKeXPavQ== +"@angular/compiler@13.0.0-next.15": + version "13.0.0-next.15" + resolved "https://registry.yarnpkg.com/@angular/compiler/-/compiler-13.0.0-next.15.tgz#bd9eaf5edc017112cf0c43de584f4167c6a3008f" + integrity sha512-R2rKkSvONDuSW7D7WsN4nBH1fmZ9YagSiAb4F7cch5408DOMT6OlEgJDWAp69eWXiVDagd8R3e6K8j8StoZ6PQ== dependencies: - tslib "^2.2.0" + tslib "^2.3.0" -"@angular/core@12.2.3": - version "12.2.3" - resolved "https://registry.yarnpkg.com/@angular/core/-/core-12.2.3.tgz#74f53915da3134f7e3a205219107b2eb4adcf8a6" - integrity sha512-gv3FJPiwDKugySzPepBzXrbr8HxeK2enotEmducNv3IdtGZPS0/qrbDVt7W0woRt7BGAeWaZKEaPoFzMZeEbCw== +"@angular/core@13.0.0-next.15": + version "13.0.0-next.15" + resolved "https://registry.yarnpkg.com/@angular/core/-/core-13.0.0-next.15.tgz#0d6083c7154bedf9a825e6270f41b83bacb325b3" + integrity sha512-lBjH+dUWCj+Ki4najMRF4yoXq0p6MF+4hEQEwimlvUo3BFRMRTl9CMv82oSBeSYJkZlov1w5zhaA1PQO6zjyKQ== dependencies: - tslib "^2.2.0" + tslib "^2.3.0" "@babel/code-frame@^7.10.4": version "7.10.4" @@ -209,7 +206,7 @@ globals "^11.1.0" lodash "^4.17.19" -"@babel/types@^7.10.4", "@babel/types@^7.11.0", "@babel/types@^7.12.1", "@babel/types@^7.12.5", "@babel/types@^7.8.6": +"@babel/types@^7.10.4", "@babel/types@^7.11.0", "@babel/types@^7.12.1", "@babel/types@^7.12.5": version "7.12.6" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.6.tgz#ae0e55ef1cce1fbc881cd26f8234eb3e657edc96" integrity sha512-hwyjw6GvjBLiyy3W0YQf0Z5Zf4NpYejUnKFcfcUhZCSffoBBp30w6wP2Wn6pk31jMYZvcOrB/1b7cGXvEoKogA== @@ -482,7 +479,7 @@ magic-string@^0.25.0: dependencies: sourcemap-codec "^1.4.4" -minimist@^1.2.0, minimist@^1.2.5: +minimist@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== @@ -561,11 +558,6 @@ source-map@^0.5.0: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= -source-map@^0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - sourcemap-codec@^1.4.4, sourcemap-codec@^1.4.8: version "1.4.8" resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" @@ -616,10 +608,10 @@ tslib@^2.0.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.0.1.tgz#410eb0d113e5b6356490eec749603725b021b43e" integrity sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ== -tslib@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.0.tgz#803b8cdab3e12ba581a4ca41c8839bbb0dacb09e" - integrity sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg== +tslib@^2.3.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01" + integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw== wrap-ansi@^7.0.0: version "7.0.0" @@ -645,10 +637,10 @@ yargs-parser@^20.2.2: resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== -yargs@^17.0.0: - version "17.0.1" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.0.1.tgz#6a1ced4ed5ee0b388010ba9fd67af83b9362e0bb" - integrity sha512-xBBulfCc8Y6gLFcrPvtqKz9hz8SO0l1Ni8GgDekvBX2ro0HRQImDGnikfc33cgzcYUSncapnNcZDjVFIH3f6KQ== +yargs@^17.2.1: + version "17.2.1" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.2.1.tgz#e2c95b9796a0e1f7f3bf4427863b42e0418191ea" + integrity sha512-XfR8du6ua4K6uLGm5S6fA+FIJom/MdJcFNVY8geLlp2v8GYbOXD4EB1tPNZsRn4vBzKGMgb5DRZMeWuFc2GO8Q== dependencies: cliui "^7.0.2" escalade "^3.1.1" diff --git a/integration/workspace/package.json b/integration/workspace/package.json index 0d6d64eaf7..2fbda1349b 100644 --- a/integration/workspace/package.json +++ b/integration/workspace/package.json @@ -2,9 +2,10 @@ "name": "workspace", "private": true, "dependencies": { - "@angular/common": "12.2.3", - "@angular/compiler-cli": "12.2.3", - "@angular/core": "12.2.3", + "@angular/common": "13.0.0-next.15", + "@angular/compiler": "13.0.0-next.15", + "@angular/compiler-cli": "13.0.0-next.15", + "@angular/core": "13.0.0-next.15", "rxjs": "6.6.7", "zone.js": "0.11.4" } diff --git a/integration/workspace/yarn.lock b/integration/workspace/yarn.lock index 76260db45c..71e2f1b0de 100644 --- a/integration/workspace/yarn.lock +++ b/integration/workspace/yarn.lock @@ -2,39 +2,43 @@ # yarn lockfile v1 -"@angular/common@12.2.3": - version "12.2.3" - resolved "https://registry.yarnpkg.com/@angular/common/-/common-12.2.3.tgz#deb11b2cc0e0e3056af4b0318098aecbc67fa561" - integrity sha512-AkOeknm35kzLqqh5dIz1143e3Q1MjWgi7THlY3StY63yphseQUUvGQSNHkDSIpfwBN8Mt+ZykKFjhY+cNFYt7w== +"@angular/common@13.0.0-next.15": + version "13.0.0-next.15" + resolved "https://registry.yarnpkg.com/@angular/common/-/common-13.0.0-next.15.tgz#9d55f51fbda235bea9510ca30a2f6389b22a19c2" + integrity sha512-T0LPfZ4kKbcoT0QVluyT1Jo7J5ZK3vVSKSYMEHxqE21pFqlI5MMGdqn9X+SDlIEvEikARXG4w10Q3uJuAaaS5Q== dependencies: - tslib "^2.2.0" + tslib "^2.3.0" -"@angular/compiler-cli@12.2.3": - version "12.2.3" - resolved "https://registry.yarnpkg.com/@angular/compiler-cli/-/compiler-cli-12.2.3.tgz#77774b219276ef45b269743093a40166299b6da6" - integrity sha512-8yw13AqfRSY9YV4zb6PfuJizPa5/lh4DNbc6gQkw1Dmh/Af+U2bxrtZhQCgXWJAys1sd+PN/gTQOc7/YzDNVLQ== +"@angular/compiler-cli@13.0.0-next.15": + version "13.0.0-next.15" + resolved "https://registry.yarnpkg.com/@angular/compiler-cli/-/compiler-cli-13.0.0-next.15.tgz#4f25b6d3feb1dbb0a6dd0f7d5445f24d20b49709" + integrity sha512-15w0fFrqFfHNbQ7nrzTB4rrObsIpmsbGAlrKoFPdWN2LbAYUEauUhRIPi1Et+4A1eh9beIUHpofwb+VRrUhuLw== dependencies: "@babel/core" "^7.8.6" - "@babel/types" "^7.8.6" canonical-path "1.0.0" chokidar "^3.0.0" convert-source-map "^1.5.1" dependency-graph "^0.11.0" magic-string "^0.25.0" - minimist "^1.2.0" reflect-metadata "^0.1.2" semver "^7.0.0" - source-map "^0.6.1" sourcemap-codec "^1.4.8" - tslib "^2.2.0" - yargs "^17.0.0" + tslib "^2.3.0" + yargs "^17.2.1" -"@angular/core@12.2.3": - version "12.2.3" - resolved "https://registry.yarnpkg.com/@angular/core/-/core-12.2.3.tgz#74f53915da3134f7e3a205219107b2eb4adcf8a6" - integrity sha512-gv3FJPiwDKugySzPepBzXrbr8HxeK2enotEmducNv3IdtGZPS0/qrbDVt7W0woRt7BGAeWaZKEaPoFzMZeEbCw== +"@angular/compiler@13.0.0-next.15": + version "13.0.0-next.15" + resolved "https://registry.yarnpkg.com/@angular/compiler/-/compiler-13.0.0-next.15.tgz#bd9eaf5edc017112cf0c43de584f4167c6a3008f" + integrity sha512-R2rKkSvONDuSW7D7WsN4nBH1fmZ9YagSiAb4F7cch5408DOMT6OlEgJDWAp69eWXiVDagd8R3e6K8j8StoZ6PQ== dependencies: - tslib "^2.2.0" + tslib "^2.3.0" + +"@angular/core@13.0.0-next.15": + version "13.0.0-next.15" + resolved "https://registry.yarnpkg.com/@angular/core/-/core-13.0.0-next.15.tgz#0d6083c7154bedf9a825e6270f41b83bacb325b3" + integrity sha512-lBjH+dUWCj+Ki4najMRF4yoXq0p6MF+4hEQEwimlvUo3BFRMRTl9CMv82oSBeSYJkZlov1w5zhaA1PQO6zjyKQ== + dependencies: + tslib "^2.3.0" "@babel/code-frame@^7.10.4": version "7.12.11" @@ -201,7 +205,7 @@ globals "^11.1.0" lodash "^4.17.19" -"@babel/types@^7.12.1", "@babel/types@^7.12.10", "@babel/types@^7.12.11", "@babel/types@^7.12.5", "@babel/types@^7.12.7", "@babel/types@^7.8.6": +"@babel/types@^7.12.1", "@babel/types@^7.12.10", "@babel/types@^7.12.11", "@babel/types@^7.12.5", "@babel/types@^7.12.7": version "7.12.11" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.11.tgz#a86e4d71e30a9b6ee102590446c98662589283ce" integrity sha512-ukA9SQtKThINm++CX1CwmliMrE54J6nIYB5XTwL5f/CLFW9owfls+YSU8tVW15RQ2w+a3fSbPjC6HdQNtWZkiA== @@ -449,7 +453,7 @@ magic-string@^0.25.0: dependencies: sourcemap-codec "^1.4.4" -minimist@^1.2.0, minimist@^1.2.5: +minimist@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== @@ -515,11 +519,6 @@ source-map@^0.5.0: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= -source-map@^0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - sourcemap-codec@^1.4.4, sourcemap-codec@^1.4.8: version "1.4.8" resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" @@ -570,10 +569,10 @@ tslib@^2.0.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.0.3.tgz#8e0741ac45fc0c226e58a17bfc3e64b9bc6ca61c" integrity sha512-uZtkfKblCEQtZKBF6EBXVZeQNl82yqtDQdv+eck8u7tdPxjLu2/lp5/uPW+um2tpuxINHWy3GhiccY7QgEaVHQ== -tslib@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.0.tgz#803b8cdab3e12ba581a4ca41c8839bbb0dacb09e" - integrity sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg== +tslib@^2.3.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01" + integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw== wrap-ansi@^7.0.0: version "7.0.0" @@ -599,10 +598,10 @@ yargs-parser@^20.2.2: resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== -yargs@^17.0.0: - version "17.0.1" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.0.1.tgz#6a1ced4ed5ee0b388010ba9fd67af83b9362e0bb" - integrity sha512-xBBulfCc8Y6gLFcrPvtqKz9hz8SO0l1Ni8GgDekvBX2ro0HRQImDGnikfc33cgzcYUSncapnNcZDjVFIH3f6KQ== +yargs@^17.2.1: + version "17.2.1" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.2.1.tgz#e2c95b9796a0e1f7f3bf4427863b42e0418191ea" + integrity sha512-XfR8du6ua4K6uLGm5S6fA+FIJom/MdJcFNVY8geLlp2v8GYbOXD4EB1tPNZsRn4vBzKGMgb5DRZMeWuFc2GO8Q== dependencies: cliui "^7.0.2" escalade "^3.1.1" diff --git a/package.json b/package.json index 0b44a0fa44..b0ffd4760c 100644 --- a/package.json +++ b/package.json @@ -183,7 +183,7 @@ "test:syntaxes": "yarn compile:syntaxes-test && yarn build:syntaxes && jasmine dist/syntaxes/test/driver.js" }, "dependencies": { - "@angular/language-service": "13.0.0-next.9", + "@angular/language-service": "13.0.0-next.15", "typescript": "4.4.3", "vscode-jsonrpc": "6.0.0", "vscode-languageclient": "7.0.0", diff --git a/scripts/test.sh b/scripts/test.sh index fc5fe17fb8..623b2f5d69 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -8,12 +8,6 @@ if [[ -z "${CI}" ]]; then (cd integration/workspace && yarn) fi -# Run ngcc before test starts -( - cd integration/project - yarn ngcc -) - # Server unit tests yarn run test diff --git a/server/src/ngcc.ts b/server/src/ngcc.ts index 835cbfb0f2..fe30320b49 100644 --- a/server/src/ngcc.ts +++ b/server/src/ngcc.ts @@ -23,7 +23,7 @@ interface Progress { */ export async function resolveAndRunNgcc(tsconfig: string, progress: Progress): Promise { const directory = dirname(tsconfig); - const ngcc = resolveNgcc(directory); + const ngcc = await resolveNgcc(directory); if (!ngcc) { throw new Error(`Failed to resolve ngcc from ${directory}`); } diff --git a/server/src/session.ts b/server/src/session.ts index 341e4420f0..8a9771726a 100644 --- a/server/src/session.ts +++ b/server/src/session.ts @@ -148,7 +148,6 @@ export class Session { // TODO(atscott): The Ivy flag was removed in v13. We need to include a legacy version (some // v12) of the language service in order to continue supporting view engine. const pluginConfig: PluginConfig = { - ivy: true, angularOnly: true, }; if (options.host.isG3) { diff --git a/server/src/version_provider.ts b/server/src/version_provider.ts index 9bda3b21fc..33dd32781b 100644 --- a/server/src/version_provider.ts +++ b/server/src/version_provider.ts @@ -8,6 +8,7 @@ import * as fs from 'fs'; import * as path from 'path'; +import url from 'url'; import {NodeModule, resolve, Version} from '../common/resolver'; @@ -84,6 +85,22 @@ function resolveTsServerFromTsdk(tsdk: string): NodeModule|undefined { } } +/** + * This uses a dynamic import to load a module which may be ESM. + * CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript + * will currently, unconditionally downlevel dynamic import into a require call. + * require calls cannot load ESM code and will result in a runtime error. To workaround + * this, a Function constructor is used to prevent TypeScript from changing the dynamic import. + * Once TypeScript provides support for keeping the dynamic import this workaround can + * be dropped. + * + * @param modulePath The path of the module to load. + * @returns A Promise that resolves to the dynamically imported module. + */ +export function loadEsmModule(modulePath: string|URL): Promise { + return new Function('modulePath', `return import(modulePath);`)(modulePath) as Promise; +} + /** * Resolve `@angular/language-service` from the given locations. * @param probeLocations locations from which resolution is attempted @@ -93,6 +110,18 @@ export function resolveNgLangSvc(probeLocations: string[]): NodeModule { return resolveWithMinVersion(ngls, MIN_NG_VERSION, probeLocations, ngls); } -export function resolveNgcc(directory: string): NodeModule|undefined { - return resolve('@angular/compiler-cli/ngcc/main-ngcc.js', directory, '@angular/compiler-cli'); +export async function resolveNgcc(directory: string): Promise { + const ngcc = resolve('@angular/compiler-cli/ngcc', directory, '@angular/compiler-cli'); + if (ngcc === undefined) { + return undefined; + } + + // The Angular compiler-CLI package is strict ESM as of v13. + const ngccModule = await loadEsmModule( + url.pathToFileURL(ngcc.resolvedPath)); + + return { + ...ngcc, + resolvedPath: ngccModule.ngccMainFilePath, + }; } diff --git a/yarn.lock b/yarn.lock index fe6bd95d0e..d7c8ff8482 100644 --- a/yarn.lock +++ b/yarn.lock @@ -52,10 +52,10 @@ yaml "^1.10.0" yargs "^17.0.0" -"@angular/language-service@13.0.0-next.9": - version "13.0.0-next.9" - resolved "https://registry.yarnpkg.com/@angular/language-service/-/language-service-13.0.0-next.9.tgz#4a7ad7b1d703d41354796a918b46555d7e31a497" - integrity sha512-QuxolblOcGFXP/wPBIM4HRZ6HaFtOAGhwy4L5ZMaYGLsPIQ2nSYkicHy2pTiVwxNpXmfwSc80c11XrJTVPqBTQ== +"@angular/language-service@13.0.0-next.15": + version "13.0.0-next.15" + resolved "https://registry.yarnpkg.com/@angular/language-service/-/language-service-13.0.0-next.15.tgz#3839fca225b02ad41bf1e35e79abc95934b9e074" + integrity sha512-L0T+Ov9TchY9H76LJl0ZCAIsNv89jpXbhkZSyg4WvO3fcOx7WPfo0xW3ymM+4kofF8u1l6WRBaqCDM+350DG3A== "@babel/code-frame@^7.0.0": version "7.12.13" From 5df07f1f85dd610a472844220e1cf09840d7cac8 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Tue, 12 Oct 2021 17:53:37 +0200 Subject: [PATCH 3/4] build: update circleci node version to v16.10.0 --- .circleci/config.yml | 5 ++--- scripts/build.sh | 6 +++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4a959560a5..1ba1e3a7fa 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,9 +3,8 @@ orbs: node: circleci/node@4.4.0 jobs: build-and-test: - executor: - name: node/default - tag: '12.18' + docker: + - image: cimg/node:16.10.0-browsers@sha256:83ff2dcad3043c4b3f7f58513805a0c8757ba5541a1f3c213f80bd242a3c77ac steps: - checkout - node/install-packages: diff --git a/scripts/build.sh b/scripts/build.sh index 087c6bba45..c5af79b648 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -25,7 +25,11 @@ cp syntaxes/!(tsconfig).json dist/npm/syntaxes pushd dist/npm # TODO(kyliau): vsce does not bundle nested node_modules due to bug # https://github.com/microsoft/vscode-vsce/issues/432 so install using NPM for now. -npm install --production --ignore-scripts +# Note: We also use `--force` as NPM incorrectly checks the dev dependencies even +# though we have limited the install to production-only dependencies. We know that +# our versions are compatible from the Yarn install, so it's acceptable to force proceed +# on peer dependency conflicts (like `tslint@6` not being supported by `tslint-eslint-rules`). +npm install --production --ignore-scripts --force sed -i -e 's#./dist/client/extension#./index#' package.json ../../node_modules/.bin/vsce package From 3d9947a2d21ce8364d36a69c5836eaeb4bee7d03 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Tue, 12 Oct 2021 13:44:39 -0700 Subject: [PATCH 4/4] fixup! refactor: update to angular v13 with APF v13 output --- server/src/tests/ngcc_spec.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/server/src/tests/ngcc_spec.ts b/server/src/tests/ngcc_spec.ts index 49c95a7552..e1d94b886a 100644 --- a/server/src/tests/ngcc_spec.ts +++ b/server/src/tests/ngcc_spec.ts @@ -9,6 +9,8 @@ import * as child_process from 'child_process'; import {EventEmitter} from 'events'; import {join, resolve} from 'path'; +import {interval, Subject} from 'rxjs'; +import {takeUntil} from 'rxjs/operators'; import {resolveAndRunNgcc} from '../ngcc'; @@ -17,13 +19,22 @@ const WORKSPACE_ROOT = join(PACKAGE_ROOT, 'integration', 'workspace'); const PROJECT = join(WORKSPACE_ROOT, 'projects', 'demo'); describe('resolveAndRunNgcc', () => { + const afterEach$ = new Subject(); + afterEach(() => { + afterEach$.next(); + }); + it('runs ngcc from node_modules where ngcc is resolved to', async () => { const fakeChild = new EventEmitter(); const spy = spyOn(child_process, 'fork').and.returnValue(fakeChild as any); // Note that tsconfig.json is in the project directory const tsconfig = join(PROJECT, 'tsconfig.json'); + // Because resolveNgcc is async, we need to periodically emit `close` from the child since + // `resolveAndRunNgcc` subscribes after the async resolveNgcc. + interval(500).pipe(takeUntil(afterEach$)).subscribe(() => { + fakeChild.emit('close', 0 /* exit code */); + }); const promise = resolveAndRunNgcc(tsconfig, {report() {}}); - fakeChild.emit('close', 0 /* exit code */); await expectAsync(promise).toBeResolved(); expect(spy.calls.count()).toBe(1); // First arg is the ngcc binary, second arg is program arguments, third