From 5d2c2e74d343f45e7c5524d866b7e2342017e5f7 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Fri, 8 Mar 2019 14:27:53 +0100 Subject: [PATCH 1/4] chore: copy d.ts files during build --- package.json | 1 + scripts/buildTs.js | 12 ++++++++++++ yarn.lock | 24 ++++++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/package.json b/package.json index 30e53111f386..c024b3534a40 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "camelcase": "^5.0.0", "chalk": "^2.0.1", "codecov": "^3.0.0", + "cp-file": "^6.1.0", "debug": "^4.0.1", "eslint": "^5.6.0", "eslint-config-prettier": "^3.1.0", diff --git a/scripts/buildTs.js b/scripts/buildTs.js index ec5479be5c4b..24075be646ed 100644 --- a/scripts/buildTs.js +++ b/scripts/buildTs.js @@ -12,6 +12,8 @@ const path = require('path'); const chalk = require('chalk'); const execa = require('execa'); +const glob = require('glob'); +const cpFile = require('cp-file'); const {getPackages, adjustToTerminalWidth, OK} = require('./buildUtils'); const packages = getPackages(); @@ -27,6 +29,16 @@ process.stdout.write(adjustToTerminalWidth('Building\n')); try { execa.sync('tsc', args, {stdio: 'inherit'}); + packagesWithTs.forEach(p => { + const srcDir = path.resolve(p, 'src'); + const buildDir = path.resolve(p, 'build'); + + glob.sync(path.join(srcDir, '**/*.d.ts')).forEach(file => { + const resultFile = path.resolve(buildDir, path.relative(srcDir, file)); + + cpFile.sync(file, resultFile); + }); + }); process.stdout.write(`${OK}\n`); } catch (e) { process.stdout.write('\n'); diff --git a/yarn.lock b/yarn.lock index 340a5d50f880..6739385aeabe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4040,6 +4040,17 @@ cosmiconfig@^5.0.5, cosmiconfig@^5.1.0: lodash.get "^4.4.2" parse-json "^4.0.0" +cp-file@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/cp-file/-/cp-file-6.1.0.tgz#b48d2d80577d4c5025c68eb597a38093c1dc9ccf" + integrity sha512-an34I0lJwKncRKjxe3uGWUuiIIVYsHHjBGKld3OQB56hfoPCYom31VysvfuysKqHLbz6drnqP5YrCfLw17I2kw== + dependencies: + graceful-fs "^4.1.2" + make-dir "^2.0.0" + nested-error-stacks "^2.0.0" + pify "^4.0.1" + safe-buffer "^5.0.1" + create-ecdh@^4.0.0: version "4.0.3" resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.3.tgz#c9111b6f33045c4697f144787f9254cdc77c45ff" @@ -8398,6 +8409,14 @@ make-dir@^1.0.0, make-dir@^1.2.0, make-dir@^1.3.0: dependencies: pify "^3.0.0" +make-dir@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5" + integrity sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA== + dependencies: + pify "^4.0.1" + semver "^5.6.0" + make-fetch-happen@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/make-fetch-happen/-/make-fetch-happen-4.0.1.tgz#141497cb878f243ba93136c83d8aba12c216c083" @@ -9117,6 +9136,11 @@ neo-async@^2.5.0: resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.0.tgz#b9d15e4d71c6762908654b5183ed38b753340835" integrity sha512-MFh0d/Wa7vkKO3Y3LlacqAEeHK0mckVqzDieUKTT+KGxi+zIpeVsFxymkIiRpbpDziHc290Xr9A1O4Om7otoRA== +nested-error-stacks@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/nested-error-stacks/-/nested-error-stacks-2.1.0.tgz#0fbdcf3e13fe4994781280524f8b96b0cdff9c61" + integrity sha512-AO81vsIO1k1sM4Zrd6Hu7regmJN1NSiAja10gc4bX3F0wd+9rQmcuHQaHVQCYIEC8iFXnE+mavh23GOt7wBgug== + nice-try@^1.0.4: version "1.0.5" resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" From 912f7319216c1be845d37a5015546e1480cc7d0a Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Fri, 8 Mar 2019 14:32:04 +0100 Subject: [PATCH 2/4] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9983aabc1980..8a66a44d5552 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ ### Chore & Maintenance +- `[*]` Make sure to copy over `d.ts` files to the `build` directory when building ([#8086](https://github.com/facebook/jest/pull/8086)) + ### Performance ## 24.3.1 From 1b02db8c562da01f00ef4759ff50a839f6861547 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Fri, 8 Mar 2019 14:35:46 +0100 Subject: [PATCH 3/4] Revert "chore: copy d.ts files during build" This reverts commit 5d2c2e74d343f45e7c5524d866b7e2342017e5f7. --- package.json | 1 - scripts/buildTs.js | 12 ------------ yarn.lock | 24 ------------------------ 3 files changed, 37 deletions(-) diff --git a/package.json b/package.json index c024b3534a40..30e53111f386 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ "camelcase": "^5.0.0", "chalk": "^2.0.1", "codecov": "^3.0.0", - "cp-file": "^6.1.0", "debug": "^4.0.1", "eslint": "^5.6.0", "eslint-config-prettier": "^3.1.0", diff --git a/scripts/buildTs.js b/scripts/buildTs.js index 24075be646ed..ec5479be5c4b 100644 --- a/scripts/buildTs.js +++ b/scripts/buildTs.js @@ -12,8 +12,6 @@ const path = require('path'); const chalk = require('chalk'); const execa = require('execa'); -const glob = require('glob'); -const cpFile = require('cp-file'); const {getPackages, adjustToTerminalWidth, OK} = require('./buildUtils'); const packages = getPackages(); @@ -29,16 +27,6 @@ process.stdout.write(adjustToTerminalWidth('Building\n')); try { execa.sync('tsc', args, {stdio: 'inherit'}); - packagesWithTs.forEach(p => { - const srcDir = path.resolve(p, 'src'); - const buildDir = path.resolve(p, 'build'); - - glob.sync(path.join(srcDir, '**/*.d.ts')).forEach(file => { - const resultFile = path.resolve(buildDir, path.relative(srcDir, file)); - - cpFile.sync(file, resultFile); - }); - }); process.stdout.write(`${OK}\n`); } catch (e) { process.stdout.write('\n'); diff --git a/yarn.lock b/yarn.lock index 6739385aeabe..340a5d50f880 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4040,17 +4040,6 @@ cosmiconfig@^5.0.5, cosmiconfig@^5.1.0: lodash.get "^4.4.2" parse-json "^4.0.0" -cp-file@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/cp-file/-/cp-file-6.1.0.tgz#b48d2d80577d4c5025c68eb597a38093c1dc9ccf" - integrity sha512-an34I0lJwKncRKjxe3uGWUuiIIVYsHHjBGKld3OQB56hfoPCYom31VysvfuysKqHLbz6drnqP5YrCfLw17I2kw== - dependencies: - graceful-fs "^4.1.2" - make-dir "^2.0.0" - nested-error-stacks "^2.0.0" - pify "^4.0.1" - safe-buffer "^5.0.1" - create-ecdh@^4.0.0: version "4.0.3" resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.3.tgz#c9111b6f33045c4697f144787f9254cdc77c45ff" @@ -8409,14 +8398,6 @@ make-dir@^1.0.0, make-dir@^1.2.0, make-dir@^1.3.0: dependencies: pify "^3.0.0" -make-dir@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5" - integrity sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA== - dependencies: - pify "^4.0.1" - semver "^5.6.0" - make-fetch-happen@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/make-fetch-happen/-/make-fetch-happen-4.0.1.tgz#141497cb878f243ba93136c83d8aba12c216c083" @@ -9136,11 +9117,6 @@ neo-async@^2.5.0: resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.0.tgz#b9d15e4d71c6762908654b5183ed38b753340835" integrity sha512-MFh0d/Wa7vkKO3Y3LlacqAEeHK0mckVqzDieUKTT+KGxi+zIpeVsFxymkIiRpbpDziHc290Xr9A1O4Om7otoRA== -nested-error-stacks@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/nested-error-stacks/-/nested-error-stacks-2.1.0.tgz#0fbdcf3e13fe4994781280524f8b96b0cdff9c61" - integrity sha512-AO81vsIO1k1sM4Zrd6Hu7regmJN1NSiAja10gc4bX3F0wd+9rQmcuHQaHVQCYIEC8iFXnE+mavh23GOt7wBgug== - nice-try@^1.0.4: version "1.0.5" resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" From 9cb98b4071b8db2457d1f79a89a14dec8ca1d3bb Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Fri, 8 Mar 2019 14:37:10 +0100 Subject: [PATCH 4/4] move d.ts files to root of module --- CHANGELOG.md | 2 +- packages/jest-reporters/{src => }/istanbul-api.d.ts | 0 packages/jest-reporters/{src => }/istanbul-lib-coverage.d.ts | 0 packages/jest-reporters/{src => }/node-notifier.d.ts | 0 packages/jest-reporters/src/coverage_reporter.ts | 4 ++-- packages/jest-reporters/src/generateEmptyCoverage.ts | 2 +- packages/jest-reporters/src/notify_reporter.ts | 2 +- packages/jest-serializer/src/index.ts | 2 ++ packages/jest-serializer/{src/global.d.ts => v8.d.ts} | 0 9 files changed, 7 insertions(+), 5 deletions(-) rename packages/jest-reporters/{src => }/istanbul-api.d.ts (100%) rename packages/jest-reporters/{src => }/istanbul-lib-coverage.d.ts (100%) rename packages/jest-reporters/{src => }/node-notifier.d.ts (100%) rename packages/jest-serializer/{src/global.d.ts => v8.d.ts} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a66a44d5552..9917981b308c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ ### Chore & Maintenance -- `[*]` Make sure to copy over `d.ts` files to the `build` directory when building ([#8086](https://github.com/facebook/jest/pull/8086)) +- `[*]` Make sure to include `d.ts` files in the tarball when building ([#8086](https://github.com/facebook/jest/pull/8086)) ### Performance diff --git a/packages/jest-reporters/src/istanbul-api.d.ts b/packages/jest-reporters/istanbul-api.d.ts similarity index 100% rename from packages/jest-reporters/src/istanbul-api.d.ts rename to packages/jest-reporters/istanbul-api.d.ts diff --git a/packages/jest-reporters/src/istanbul-lib-coverage.d.ts b/packages/jest-reporters/istanbul-lib-coverage.d.ts similarity index 100% rename from packages/jest-reporters/src/istanbul-lib-coverage.d.ts rename to packages/jest-reporters/istanbul-lib-coverage.d.ts diff --git a/packages/jest-reporters/src/node-notifier.d.ts b/packages/jest-reporters/node-notifier.d.ts similarity index 100% rename from packages/jest-reporters/src/node-notifier.d.ts rename to packages/jest-reporters/node-notifier.d.ts diff --git a/packages/jest-reporters/src/coverage_reporter.ts b/packages/jest-reporters/src/coverage_reporter.ts index 698abc17e4ff..2799cfd04a31 100644 --- a/packages/jest-reporters/src/coverage_reporter.ts +++ b/packages/jest-reporters/src/coverage_reporter.ts @@ -6,8 +6,8 @@ */ // TODO: Remove this -/// -/// +/// +/// import path from 'path'; import {Config} from '@jest/types'; diff --git a/packages/jest-reporters/src/generateEmptyCoverage.ts b/packages/jest-reporters/src/generateEmptyCoverage.ts index 6ea3567566d9..59e87304dfe3 100644 --- a/packages/jest-reporters/src/generateEmptyCoverage.ts +++ b/packages/jest-reporters/src/generateEmptyCoverage.ts @@ -6,7 +6,7 @@ */ // TODO: Remove this -/// +/// import {Config} from '@jest/types'; import {readInitialCoverage} from 'istanbul-lib-instrument'; diff --git a/packages/jest-reporters/src/notify_reporter.ts b/packages/jest-reporters/src/notify_reporter.ts index 460530a6447d..9022eed40870 100644 --- a/packages/jest-reporters/src/notify_reporter.ts +++ b/packages/jest-reporters/src/notify_reporter.ts @@ -6,7 +6,7 @@ */ // TODO: Remove this -/// +/// import path from 'path'; import util from 'util'; diff --git a/packages/jest-serializer/src/index.ts b/packages/jest-serializer/src/index.ts index c9b3525ea613..bf02f9325227 100644 --- a/packages/jest-serializer/src/index.ts +++ b/packages/jest-serializer/src/index.ts @@ -4,6 +4,8 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ +// TODO: Remove this +/// import fs from 'fs'; import v8 from 'v8'; diff --git a/packages/jest-serializer/src/global.d.ts b/packages/jest-serializer/v8.d.ts similarity index 100% rename from packages/jest-serializer/src/global.d.ts rename to packages/jest-serializer/v8.d.ts