Skip to content
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

chore: run typescript build as part of typecheck, not normal build #7855

Merged
merged 3 commits into from Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -84,14 +84,14 @@
"lint:md": "yarn --silent lint:md:ci --fix",
"lint:md:ci": "prettylint '**/*.{md,yml,yaml}' --ignore-path .gitignore",
"postinstall": "opencollective postinstall && yarn build",
"publish": "yarn build-clean && yarn build && lerna publish --silent",
"publish": "yarn build-clean && yarn typecheck && yarn build && lerna publish --silent",
SimenB marked this conversation as resolved.
Show resolved Hide resolved
"test-ci-es5-build-in-browser": "karma start --single-run",
"test-ci": "yarn jest-coverage -i --config jest.config.ci.js && yarn test-leak && node scripts/mapCoverage.js && codecov",
"test-ci-partial": "yarn jest -i --config jest.config.ci.js",
"test-pretty-format-perf": "node packages/pretty-format/perf/test.js",
"test-leak": "yarn jest -i --detectLeaks jest-mock jest-diff jest-repl",
"test": "yarn typecheck && yarn lint && yarn jest",
"typecheck": "flow check --include-warnings",
"typecheck": "node scripts/typeScriptBuild && flow check --include-warnings",
SimenB marked this conversation as resolved.
Show resolved Hide resolved
"watch": "yarn build && node ./scripts/watch.js"
},
"workspaces": {
Expand Down
11 changes: 0 additions & 11 deletions scripts/build.js
Expand Up @@ -24,7 +24,6 @@ const fs = require('fs');
const path = require('path');
const glob = require('glob');
const mkdirp = require('mkdirp');
const execa = require('execa');

const babel = require('@babel/core');
const chalk = require('chalk');
Expand Down Expand Up @@ -191,20 +190,10 @@ function buildFile(file, silent) {

const files = process.argv.slice(2);

function compileTypes(packages) {
const packageWithTs = packages.filter(p =>
fs.existsSync(path.resolve(p, 'tsconfig.json'))
);

execa.sync('tsc', ['-b', ...packageWithTs], {stdio: 'inherit'});
}

if (files.length) {
files.forEach(buildFile);
} else {
const packages = getPackages();
process.stdout.write(chalk.inverse(' Typechecking \n'));
compileTypes(packages);
process.stdout.write(`${OK}\n\n`);
process.stdout.write(chalk.inverse(' Building packages \n'));
packages.forEach(buildNodePackage);
Expand Down
24 changes: 24 additions & 0 deletions scripts/typeScriptBuild.js
@@ -0,0 +1,24 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

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

const execa = require('execa');
const getPackages = require('./getPackages');

const packages = getPackages();

const packageWithTs = packages.filter(p =>
SimenB marked this conversation as resolved.
Show resolved Hide resolved
fs.existsSync(path.resolve(p, 'tsconfig.json'))
);

execa.sync('tsc', ['-b', ...packageWithTs, ...process.argv.slice(2)], {
Copy link
Member Author

Choose a reason for hiding this comment

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

Makes node scripts/typeScriptBuild.js --watch work

stdio: 'inherit',
});
7 changes: 0 additions & 7 deletions scripts/watch.js
Expand Up @@ -13,7 +13,6 @@ const fs = require('fs');
const {execSync} = require('child_process');
const path = require('path');
const chalk = require('chalk');
const execa = require('execa');
const getPackages = require('./getPackages');

const BUILD_CMD = `node ${path.resolve(__dirname, './build.js')}`;
Expand Down Expand Up @@ -57,12 +56,6 @@ packages.forEach(p => {
}
});

const packageWithTs = packages.filter(p =>
fs.existsSync(path.resolve(p, 'tsconfig.json'))
);

execa('tsc', ['-b', ...packageWithTs, '--watch'], {stdio: 'inherit'});

setInterval(() => {
const files = Array.from(filesToBuild.keys());
if (files.length) {
Expand Down