From 0fab74f4af97e6faf0eee0ba44f935af7c4ccbb5 Mon Sep 17 00:00:00 2001 From: Nico Jansen Date: Mon, 18 May 2020 10:30:56 +0200 Subject: [PATCH] fix(ts): support ts 3.9 on windows in the typescript-transpiler (#2215) --- .github/workflows/ci.yml | 16 +++++++++------- e2e/package-lock.json | 6 +++--- e2e/package.json | 2 +- e2e/test/jest-react/stryker.conf.js | 1 + package.json | 3 --- .../src/transpiler/TranspilingLanguageService.ts | 10 ++++++---- packages/wct-runner/package.json | 2 +- 7 files changed, 21 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09a05a8e3e..6e86bdd679 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,12 +8,13 @@ on: jobs: build_and_test: - runs-on: ubuntu-latest - strategy: fail-fast: false matrix: node-version: [10.x, 12.x] + os: ['ubuntu-latest', 'windows-latest'] + + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v1 @@ -29,17 +30,18 @@ jobs: run: npm run all e2e: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: ['ubuntu-latest', 'windows-latest'] steps: - uses: actions/checkout@v1 - - name: Use Node.js 12.x - uses: actions/setup-node@v1 - with: - node-version: 12.x - name: Install dependencies run: npm install - name: Build packages run: npm run build - name: Run e2e tests run: npm run e2e + diff --git a/e2e/package-lock.json b/e2e/package-lock.json index d7542d65b2..bc2c49b589 100644 --- a/e2e/package-lock.json +++ b/e2e/package-lock.json @@ -12208,9 +12208,9 @@ } }, "typescript": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz", - "integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==", + "version": "3.9.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.2.tgz", + "integrity": "sha512-q2ktq4n/uLuNNShyayit+DTobV2ApPEo/6so68JaD5ojvc/6GClBipedB9zNWYxRSAlZXAe405Rlijzl6qDiSw==", "dev": true }, "ua-parser-js": { diff --git a/e2e/package.json b/e2e/package.json index 11375413af..42817cc082 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -34,7 +34,7 @@ "ts-jest": "^25.4.0", "ts-loader": "^7.0.3", "ts-node": "~7.0.0", - "typescript": "~3.7.2", + "typescript": "~3.9.2", "webpack": "~4.41.2" }, "scripts": { diff --git a/e2e/test/jest-react/stryker.conf.js b/e2e/test/jest-react/stryker.conf.js index 4bd3ba8b14..8df701c6e6 100644 --- a/e2e/test/jest-react/stryker.conf.js +++ b/e2e/test/jest-react/stryker.conf.js @@ -4,6 +4,7 @@ module.exports = function (config) { mutator: "javascript", transpilers: [], reporters: ["event-recorder"], + tempDirName: "stryker-tmp", coverageAnalysis: "off", timeoutMS: 60000, // High timeout to survive high build server load. Mutants created here should never timeout mutate: ["src/{Alert,Badge,Breadcrumb}.js"], diff --git a/package.json b/package.json index 68c86027af..c611586111 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "eslint-plugin-prettier": "3.1.3", "execa": "^3.2.0", "glob": "^7.1.1", - "if-node-version": "^1.1.1", "install-local": "~2.0.0", "jasmine": "^3.1.0", "jasmine-core": "^3.1.0", @@ -38,11 +37,9 @@ "nyc": "^15.0.0", "prettier": "2.0.5", "rimraf": "^3.0.0", - "rxjs": "^6.4.0", "sinon": "^9.0.0", "sinon-chai": "3.5.0", "source-map-support": "^0.5.6", - "ts-json-schema-generator": "^0.68.0", "typescript": "~3.9.2" }, "scripts": { diff --git a/packages/typescript/src/transpiler/TranspilingLanguageService.ts b/packages/typescript/src/transpiler/TranspilingLanguageService.ts index 1fcee98ea5..8e128b86a9 100644 --- a/packages/typescript/src/transpiler/TranspilingLanguageService.ts +++ b/packages/typescript/src/transpiler/TranspilingLanguageService.ts @@ -34,7 +34,7 @@ export default class TranspilingLanguageService { getLogger: LoggerFactoryMethod ) { this.compilerOptions = this.adaptCompilerOptions(compilerOptions); - rootFiles.forEach((file) => (this.files[file.name] = new ScriptFile(file.name, file.textContent))); + rootFiles.forEach((file) => (this.files[normalizeFileForTypescript(file.name)] = new ScriptFile(file.name, file.textContent))); const host = this.createLanguageServiceHost(); this.languageService = ts.createLanguageService(host); this.logger = getLogger(TranspilingLanguageService.name); @@ -63,7 +63,7 @@ export default class TranspilingLanguageService { * @param mutantCandidate The mutant used to replace the original source */ public replace(replacements: readonly File[]) { - replacements.forEach((replacement) => this.files[replacement.name].replace(replacement.textContent)); + replacements.forEach((replacement) => this.files[normalizeFileForTypescript(replacement.name)].replace(replacement.textContent)); } public getSemanticDiagnostics(files: readonly File[]) { @@ -79,7 +79,7 @@ export default class TranspilingLanguageService { * If all output files are bundled together, only returns the output file once using the first file as key */ public emit(fileName: string): EmitOutput { - const emittedFiles = this.languageService.getEmitOutput(fileName).outputFiles; + const emittedFiles = this.languageService.getEmitOutput(normalizeFileForTypescript(fileName)).outputFiles; const jsFile = emittedFiles.find(isJavaScriptFile); const mapFile = emittedFiles.find(isMapFile); if (jsFile) { @@ -101,7 +101,9 @@ export default class TranspilingLanguageService { getCurrentDirectory: () => path.resolve(this.projectDirectory), getDefaultLibFileName: ts.getDefaultLibFileName, getDirectories: ts.sys.getDirectories, - getScriptFileNames: () => Object.keys(this.files), + getScriptFileNames: () => { + return Object.keys(this.files); + }, getScriptSnapshot: (fileName) => { this.pullFileIntoMemoryIfNeeded(fileName); return this.files[fileName] && ts.ScriptSnapshot.fromString(this.files[fileName].content); diff --git a/packages/wct-runner/package.json b/packages/wct-runner/package.json index c10206b5e0..d0ec310978 100644 --- a/packages/wct-runner/package.json +++ b/packages/wct-runner/package.json @@ -5,7 +5,7 @@ "main": "src/index.js", "scripts": { "test": "cross-env LAUNCHPAD_BROWSERS=chrome nyc --reporter=html --report-dir=reports/coverage --lines 95 --functions 95 --branches 95 npm run mocha", - "mocha": "mocha \"test/helpers/**/*.js\" \"test/unit/**/*.js\" && if-node-version \">=8\" mocha --timeout 120000 --exit \"test/helpers/**/*.js\" \"test/integration/**/*.js\"", + "mocha": "mocha \"test/helpers/**/*.js\" \"test/unit/**/*.js\" && mocha --timeout 120000 --exit \"test/helpers/**/*.js\" \"test/integration/**/*.js\"", "stryker": "node ../core/bin/stryker run" }, "repository": {