From 754d9f09c3673b8afea6bcd61ab1d1cdb509e709 Mon Sep 17 00:00:00 2001 From: Sergio Cinos Date: Tue, 17 Nov 2020 12:32:45 +0100 Subject: [PATCH 01/13] Create a "main" package used as an entrypoint for tsc --- bin/watch-packages-and-rebuild.js | 76 ------------------------------- package.json | 4 +- packages/tsconfig.json | 24 ++++++++++ 3 files changed, 26 insertions(+), 78 deletions(-) delete mode 100644 bin/watch-packages-and-rebuild.js create mode 100644 packages/tsconfig.json diff --git a/bin/watch-packages-and-rebuild.js b/bin/watch-packages-and-rebuild.js deleted file mode 100644 index abfc87620c69a1..00000000000000 --- a/bin/watch-packages-and-rebuild.js +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env node -const path = require( 'path' ); -const chokidar = require( 'chokidar' ); -const chalk = require( 'chalk' ); -const util = require( 'util' ); -const promiseExecFile = util.promisify( require( 'child_process' ).execFile ); -const debounce = require( 'lodash/debounce' ); -const debouncedProcessRebuildQueue = debounce( processRebuildQueue, 100 ); - -const ignoredPathPieces = [ 'node_modules', 'dist', 'test', 'tests' ].join( '|' ); -const ignoredExtensions = [ 'html', 'css', 'md', 'd.ts', 'png', 'svg' ] - .map( ( extension ) => '\\.' + extension ) // Need to escape the dot for regex - .join( '|' ); -const ignoredFiles = [ - '^\\.|/\\.', // Ignores path patterns that start with a dot or have slash dot in sequence - 'Makefile', - 'LICENSE', - 'Dockerfile', - 'packages/calypso-color-schemes/js/index.js', -].join( '|' ); -const ignored = [ ignoredPathPieces, ignoredExtensions, ignoredFiles ].join( '|' ); -const packagesDirectoryPath = path.join( '.', 'packages' ); - -const watcher = chokidar.watch( packagesDirectoryPath, { - ignored: new RegExp( ignored ), - persistent: true, - interval: 200, - ignoreInitial: true, -} ); -watcher.on( 'change', handleChange ).on( 'add', handleChange ).on( 'unlink', handleChange ); - -const rebuildQueue = []; - -async function processRebuildQueue() { - const queueSnapshot = [ ...rebuildQueue ]; - rebuildQueue.length = 0; - await Promise.all( queueSnapshot.map( rebuildPackage ) ); -} - -function handleChange( filePath ) { - console.log( chalk.cyan( 'heard change in' ), filePath ); - const packageDirectory = getPackageDirectoryFromFilePath( filePath ); - if ( packageDirectory && ! rebuildQueue.includes( packageDirectory ) ) { - rebuildQueue.push( packageDirectory ); - debouncedProcessRebuildQueue(); - } -} - -function getPackageDirectoryFromFilePath( filePath ) { - const relativeFilePath = path.relative( '.', filePath ); - const relativeFilePathPieces = relativeFilePath.split( path.sep ); - if ( relativeFilePathPieces.length < 2 ) { - console.error( 'failed to rebuild package: file is outside packages directory', filePath ); - return null; - } - if ( relativeFilePathPieces[ 0 ] !== 'packages' ) { - console.error( 'failed to rebuild package: file is outside packages directory', filePath ); - return null; - } - return path.join( relativeFilePathPieces[ 0 ], relativeFilePathPieces[ 1 ] ); -} - -async function rebuildPackage( packageDirectory ) { - console.log( chalk.cyan( 'rebuilding package: %s' ), packageDirectory ); - try { - const { stdout } = await promiseExecFile( 'yarn', [ 'prepare' ], { - cwd: packageDirectory, - shell: true, - stdio: 'inherit', - } ); - console.info( stdout ); - console.log( chalk.green( 'rebuild complete: %s' ), packageDirectory ); - } catch ( err ) { - console.error( 'rebuild failed:', err ); - } -} diff --git a/package.json b/package.json index 10e848c8611290..ff99a630a2f44e 100644 --- a/package.json +++ b/package.json @@ -90,8 +90,8 @@ "build-client-if-prod": "node -e \"process.env.CALYPSO_ENV === 'production' && process.exit(1)\" || yarn run build-client-both && yarn run build-languages-if-enabled", "build-client-if-desktop": "node -e \"(process.env.CALYPSO_ENV === 'desktop' || process.env.CALYPSO_ENV === 'desktop-development') && process.exit(1)\" || yarn run build-client-fallback", "build-client-stats": "NODE_ENV=production CALYPSO_ENV=production EMIT_STATS=true PROGRESS=true yarn run build-client-evergreen", - "build-packages": "npx lerna run prepare --stream", - "build-packages:watch": "node bin/watch-packages-and-rebuild.js", + "build-packages": "tsc --build packages/tsconfig.json", + "build-packages:watch": "tsc --build packages/tsconfig.json --watch", "build-languages": "yarn run translate && node bin/build-languages.js", "build-languages-if-enabled": "node -e \"(process.env.BUILD_TRANSLATION_CHUNKS === 'true' || process.env.ENABLE_FEATURES === 'use-translation-chunks') && process.exit(1)\" || yarn run build-languages", "calypso-doctor": "./node_modules/.bin/calypso-doctor", diff --git a/packages/tsconfig.json b/packages/tsconfig.json new file mode 100644 index 00000000000000..9b9e0b1eec2133 --- /dev/null +++ b/packages/tsconfig.json @@ -0,0 +1,24 @@ +{ + // Don't actually compile anything + "files": [], + + // Reference all TS packages + "references": [ + { "path": "./browser-data-collector" }, + { "path": "./calypso-analytics" }, + { "path": "./calypso-stripe" }, + { "path": "./components" }, + { "path": "./composite-checkout" }, + { "path": "./data-stores" }, + { "path": "./domain-picker" }, + { "path": "./i18n-utils" }, + { "path": "./language-picker" }, + { "path": "./languages" }, + { "path": "./launch" }, + { "path": "./onboarding" }, + { "path": "./plans-grid" }, + { "path": "./react-i18n" }, + { "path": "./search" }, + { "path": "./shopping-cart" } + ] +} From b1437cb63c5e4968fd9d42e104642723e7b4a405 Mon Sep 17 00:00:00 2001 From: Sergio Cinos Date: Tue, 17 Nov 2020 12:32:57 +0100 Subject: [PATCH 02/13] Add missing tsconfig for CJS --- packages/components/tsconfig-cjs.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 packages/components/tsconfig-cjs.json diff --git a/packages/components/tsconfig-cjs.json b/packages/components/tsconfig-cjs.json new file mode 100644 index 00000000000000..bd64442da990d0 --- /dev/null +++ b/packages/components/tsconfig-cjs.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig", + "compilerOptions": { + "module": "commonjs", + "declaration": false, + "declarationMap": false, + "declarationDir": null, + "outDir": "dist/cjs", + "composite": false, + "incremental": true + } +} From f30a2ee181bcfef2b9725a07170bdd98032a15ac Mon Sep 17 00:00:00 2001 From: Sergio Cinos Date: Tue, 17 Nov 2020 12:33:53 +0100 Subject: [PATCH 03/13] Use new syntax for type-only exports --- packages/data-stores/src/auth/index.ts | 2 +- packages/data-stores/src/domain-suggestions/index.ts | 2 +- packages/data-stores/src/site/index.ts | 2 +- packages/data-stores/src/user/index.ts | 2 +- packages/data-stores/src/verticals-templates/index.ts | 2 +- packages/domain-picker/src/index.tsx | 4 +++- packages/plans-grid/src/index.ts | 3 ++- 7 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/data-stores/src/auth/index.ts b/packages/data-stores/src/auth/index.ts index b35f69f9d7ad04..4a87534c9f85e8 100644 --- a/packages/data-stores/src/auth/index.ts +++ b/packages/data-stores/src/auth/index.ts @@ -17,7 +17,7 @@ import type { DispatchFromMap, SelectFromMap } from '../mapped-types'; import { controls as wpcomRequestControls } from '../wpcom-request-controls'; export * from './types'; -export { State }; +export type { State }; let isRegistered = false; export function register( config: ActionsConfig ): typeof STORE_KEY { diff --git a/packages/data-stores/src/domain-suggestions/index.ts b/packages/data-stores/src/domain-suggestions/index.ts index 38a21207476299..dbd25c10dda3d4 100644 --- a/packages/data-stores/src/domain-suggestions/index.ts +++ b/packages/data-stores/src/domain-suggestions/index.ts @@ -15,7 +15,7 @@ import type { DispatchFromMap, SelectFromMap } from '../mapped-types'; import { controls } from '../wpcom-request-controls'; export * from './types'; -export { State }; +export type { State }; let isRegistered = false; interface StoreConfiguration { diff --git a/packages/data-stores/src/site/index.ts b/packages/data-stores/src/site/index.ts index b5ac2343341acd..bc6a3e3d39b484 100644 --- a/packages/data-stores/src/site/index.ts +++ b/packages/data-stores/src/site/index.ts @@ -16,7 +16,7 @@ import type { WpcomClientCredentials } from '../shared-types'; import { controls } from '../wpcom-request-controls'; export * from './types'; -export { State }; +export type { State }; let isRegistered = false; export function register( clientCreds: WpcomClientCredentials ): typeof STORE_KEY { diff --git a/packages/data-stores/src/user/index.ts b/packages/data-stores/src/user/index.ts index 32c428b6a8dc1c..a8859defad23ea 100644 --- a/packages/data-stores/src/user/index.ts +++ b/packages/data-stores/src/user/index.ts @@ -16,7 +16,7 @@ import type { DispatchFromMap, SelectFromMap } from '../mapped-types'; import type { WpcomClientCredentials } from '../shared-types'; export * from './types'; -export { State }; +export type { State }; let isRegistered = false; export function register( clientCreds: WpcomClientCredentials ): typeof STORE_KEY { diff --git a/packages/data-stores/src/verticals-templates/index.ts b/packages/data-stores/src/verticals-templates/index.ts index 838534bfe799f7..230f7754cb18fa 100644 --- a/packages/data-stores/src/verticals-templates/index.ts +++ b/packages/data-stores/src/verticals-templates/index.ts @@ -15,7 +15,7 @@ import * as selectors from './selectors'; import type { DispatchFromMap, SelectFromMap } from '../mapped-types'; export * from './types'; -export { State }; +export type { State }; let isRegistered = false; export function register(): typeof STORE_KEY { diff --git a/packages/domain-picker/src/index.tsx b/packages/domain-picker/src/index.tsx index 0c6bf006d44098..bbb061f56dc252 100644 --- a/packages/domain-picker/src/index.tsx +++ b/packages/domain-picker/src/index.tsx @@ -1,6 +1,8 @@ /** * Internal dependencies */ -export { default, Props } from './domain-picker'; +export { default } from './domain-picker'; +export type { Props } from './domain-picker'; + export { ITEM_TYPE_RADIO, ITEM_TYPE_BUTTON } from './domain-picker/suggestion-item'; export type { SUGGESTION_ITEM_TYPE } from './domain-picker/suggestion-item'; diff --git a/packages/plans-grid/src/index.ts b/packages/plans-grid/src/index.ts index 4926fb5205d374..b4358e76936969 100644 --- a/packages/plans-grid/src/index.ts +++ b/packages/plans-grid/src/index.ts @@ -1,4 +1,5 @@ /** * Internal dependencies */ -export { default, Props } from './plans-grid'; +export { default } from './plans-grid'; +export type { Props } from './plans-grid'; From 4e6d7ceb782171708f586bc3ed1a0e9ea1fd0cf2 Mon Sep 17 00:00:00 2001 From: Sergio Cinos Date: Tue, 17 Nov 2020 12:34:26 +0100 Subject: [PATCH 04/13] Use the new babel-friendly package structure --- packages/browser-data-collector/package.json | 13 +++++++------ packages/calypso-analytics/package.json | 11 ++++++----- packages/calypso-stripe/package.json | 8 ++++---- packages/components/package.json | 8 +++++--- packages/composite-checkout/package.json | 7 ++++--- packages/data-stores/package.json | 7 ++++--- packages/domain-picker/package.json | 7 ++++--- packages/i18n-utils/package.json | 7 ++++--- packages/language-picker/package.json | 9 ++++----- packages/languages/package.json | 8 ++++---- packages/launch/package.json | 7 ++++--- packages/onboarding/package.json | 7 ++++--- packages/plans-grid/package.json | 7 ++++--- packages/react-i18n/package.json | 7 ++++--- packages/search/package.json | 9 ++++----- packages/shopping-cart/package.json | 7 ++++--- 16 files changed, 70 insertions(+), 59 deletions(-) diff --git a/packages/browser-data-collector/package.json b/packages/browser-data-collector/package.json index 523a8fb8d00d17..2638a958c56740 100644 --- a/packages/browser-data-collector/package.json +++ b/packages/browser-data-collector/package.json @@ -5,8 +5,9 @@ "homepage": "https://github.com/Automattic/wp-calypso", "license": "GPL-2.0-or-later", "author": "Automattic Inc.", - "main": "dist/cjs/index", - "module": "dist/esm/index", + "main": "dist/cjs/index.js", + "module": "dist/esm/index.js", + "calypso:src": "src/index.ts", "repository": { "type": "git", "url": "git+https://github.com/Automattic/wp-calypso.git", @@ -17,10 +18,10 @@ "url": "https://github.com/Automattic/wp-calypso/issues" }, "scripts": { - "clean": "tsc --build ./tsconfig.json --clean && tsc --build ./tsconfig-cjs.json --clean", - "prepublish": "yarn run clean", - "prepare": "tsc --build ./tsconfig.json && tsc --build ./tsconfig-cjs.json", - "watch": "tsc --build ./tsconfig.json --watch" + "clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && npx rimraf dist", + "build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json", + "prepack": "yarn run clean && yarn run build", + "watch": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --watch" }, "dependencies": { "wpcom-proxy-request": "^6.0.0" diff --git a/packages/calypso-analytics/package.json b/packages/calypso-analytics/package.json index c35540cb5bc3b8..26590f950e35f7 100644 --- a/packages/calypso-analytics/package.json +++ b/packages/calypso-analytics/package.json @@ -6,8 +6,9 @@ "license": "GPL-2.0-or-later", "author": "Automattic Inc.", "sideEffects": true, - "main": "dist/cjs/index", - "module": "dist/esm/index", + "main": "dist/cjs/index.js", + "module": "dist/esm/index.js", + "calypso:src": "src/index.ts", "repository": { "type": "git", "url": "git+https://github.com/Automattic/wp-calypso.git", @@ -25,9 +26,9 @@ "url": "https://github.com/Automattic/wp-calypso/issues" }, "scripts": { - "clean": "tsc --build ./tsconfig.json --clean && tsc --build ./tsconfig-cjs.json --clean", - "prepublish": "yarn run clean", - "prepare": "tsc --build ./tsconfig.json && tsc --build ./tsconfig-cjs.json", + "clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && npx rimraf dist", + "build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json", + "prepack": "yarn run clean && yarn run build", "watch": "tsc --build ./tsconfig.json --watch" }, "dependencies": { diff --git a/packages/calypso-stripe/package.json b/packages/calypso-stripe/package.json index 5406934a722d7c..77d6f1db810257 100644 --- a/packages/calypso-stripe/package.json +++ b/packages/calypso-stripe/package.json @@ -5,12 +5,12 @@ "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "types": "dist/types/index.d.ts", + "calypso:src": "index.ts", "sideEffects": false, "scripts": { - "clean": "npx rimraf dist && tsc --build ./tsconfig.json --clean && tsc --build ./tsconfig-cjs.json --clean", - "build:esm": "tsc --build ./tsconfig.json", - "build:cjs": "tsc --build ./tsconfig-cjs.json", - "prepare": "yarn run build:esm", + "clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && npx rimraf dist", + "build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json", + "prepack": "yarn run clean && yarn run build", "watch": "tsc --build ./tsconfig.json --watch" }, "files": [ diff --git a/packages/components/package.json b/packages/components/package.json index 76fe9465b6f8ea..8969a66f04dd3d 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -7,6 +7,7 @@ "author": "Automattic Inc.", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", + "calypso:src": "src/index.js", "sideEffects": [ "*.css", "*.scss" @@ -46,8 +47,9 @@ "ts-loader": "^8.0.8" }, "scripts": { - "clean": "npx rimraf dist && tsc --build --clean", - "prepublish": "yarn run clean", - "prepare": "transpile && tsc --build && copy-assets" + "clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && npx rimraf dist", + "build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json && copy-assets", + "prepare": "yarn run build", + "prepack": "yarn run clean && yarn run build" } } diff --git a/packages/composite-checkout/package.json b/packages/composite-checkout/package.json index 25ae979be64af4..bbc3be63b62689 100644 --- a/packages/composite-checkout/package.json +++ b/packages/composite-checkout/package.json @@ -5,11 +5,12 @@ "main": "dist/cjs/public-api.js", "module": "dist/esm/public-api.js", "types": "dist/types/public-api.d.ts", + "calypso:src": "src/public-api.ts", "sideEffects": false, "scripts": { - "clean": "npx rimraf dist \"../../.tsc-cache/packages__composite-checkout*\"", - "prepare": "tsc --build ./tsconfig.json && tsc --build ./tsconfig-cjs.json", - "prepublish": "yarn run clean", + "clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && npx rimraf dist", + "build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json && copy-assets", + "prepack": "yarn run clean && yarn run build", "watch": "tsc --build ./tsconfig.json --watch" }, "files": [ diff --git a/packages/data-stores/package.json b/packages/data-stores/package.json index 95e0ae536e1c04..55477181c4b6a2 100644 --- a/packages/data-stores/package.json +++ b/packages/data-stores/package.json @@ -7,6 +7,7 @@ "author": "Automattic Inc.", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", + "calypso:src": "src/index.ts", "sideEffects": false, "repository": { "type": "git", @@ -26,9 +27,9 @@ ], "types": "dist/types", "scripts": { - "clean": "tsc --build ./tsconfig.json --clean && tsc --build ./tsconfig-cjs.json --clean", - "prepare": "tsc --build ./tsconfig.json && tsc --build ./tsconfig-cjs.json", - "prepublish": "yarn run clean", + "clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && npx rimraf dist", + "build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json && copy-assets", + "prepack": "yarn run clean && yarn run build", "watch": "tsc --build ./tsconfig.json --watch" }, "dependencies": { diff --git a/packages/domain-picker/package.json b/packages/domain-picker/package.json index cbee42fae91e84..d4bd6023fa8052 100644 --- a/packages/domain-picker/package.json +++ b/packages/domain-picker/package.json @@ -7,6 +7,7 @@ "author": "Automattic Inc.", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", + "calypso:src": "src/index.tsx", "sideEffects": [ "*.css", "*.scss" @@ -24,9 +25,9 @@ }, "types": "dist/types", "scripts": { - "clean": "tsc --build ./tsconfig.json --clean && tsc --build ./tsconfig-cjs.json --clean", - "prepare": "tsc --build ./tsconfig.json && tsc --build ./tsconfig-cjs.json && copy-assets", - "prepublish": "yarn run clean", + "clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && npx rimraf dist", + "build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json && copy-assets", + "prepack": "yarn run clean && yarn run build", "watch": "tsc --build ./tsconfig.json --watch" }, "dependencies": { diff --git a/packages/i18n-utils/package.json b/packages/i18n-utils/package.json index 2ea8ec29ed6738..9427ec04b83b3d 100644 --- a/packages/i18n-utils/package.json +++ b/packages/i18n-utils/package.json @@ -4,6 +4,7 @@ "description": "WordPress.com i18n utils", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", + "calypso:src": "src/index.ts", "types": "dist/types/index.d.ts", "sideEffects": false, "license": "GPL-2.0-or-later", @@ -14,9 +15,9 @@ }, "author": "Automattic Inc.", "scripts": { - "clean": "npx rimraf dist", - "prepublish": "yarn run clean", - "prepare": "tsc --build ./tsconfig.json && tsc --build ./tsconfig-cjs.json", + "clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && npx rimraf dist", + "build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json", + "prepack": "yarn run clean && yarn run build", "watch": "tsc --build ./tsconfig.json --watch", "download": "node bin/download.js", "test": "yarn jest" diff --git a/packages/language-picker/package.json b/packages/language-picker/package.json index 7125b917df9a49..ad8615051f237d 100644 --- a/packages/language-picker/package.json +++ b/packages/language-picker/package.json @@ -7,6 +7,7 @@ "author": "Automattic Inc.", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", + "calypso:src": "src/index.ts", "sideEffects": [ "*.css", "*.scss" @@ -40,10 +41,8 @@ "react-dom": "^16.8" }, "scripts": { - "clean": "npx rimraf dist && tsc --build ./tsconfig.json --clean && tsc --build ./tsconfig-cjs.json --clean", - "build:esm": "tsc --build ./tsconfig.json && copy-assets --esm", - "build:cjs": "tsc --build ./tsconfig-cjs.json && copy-assets --cjs", - "prepare": "yarn run build:esm", - "prepack": "yarn run clean && yarn run build:esm && yarn run build:cjs" + "clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && npx rimraf dist", + "build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json", + "prepack": "yarn run clean && yarn run build" } } diff --git a/packages/languages/package.json b/packages/languages/package.json index 6529c79b4a708a..f3979e9e63a926 100644 --- a/packages/languages/package.json +++ b/packages/languages/package.json @@ -4,6 +4,7 @@ "description": "WordPress.com Language Data", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", + "calypso:src": "src/index.ts", "types": "dist/types/index.d.ts", "sideEffects": false, "license": "GPL-2.0-or-later", @@ -14,10 +15,9 @@ }, "author": "Automattic Inc.", "scripts": { - "clean": "npx rimraf dist", - "prepublish": "yarn run clean", - "prepare": "tsc --build ./tsconfig.json && tsc --build ./tsconfig-cjs.json", - "watch": "tsc --build ./tsconfig.json --watch", + "clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && npx rimraf dist", + "build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json", + "prepack": "yarn run clean && yarn run build", "download": "node bin/download.js", "test": "yarn jest" }, diff --git a/packages/launch/package.json b/packages/launch/package.json index 2de7b44e321a40..f98fc89d4d6230 100644 --- a/packages/launch/package.json +++ b/packages/launch/package.json @@ -7,6 +7,7 @@ "author": "Automattic Inc.", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", + "calypso:src": "src/index.ts", "sideEffects": [ "*.css", "*.scss" @@ -24,9 +25,9 @@ }, "types": "dist/types", "scripts": { - "clean": "tsc --build ./tsconfig.json --clean && tsc --build ./tsconfig-cjs.json --clean", - "prepare": "tsc --build ./tsconfig.json && tsc --build ./tsconfig-cjs.json && copy-assets && npx copyfiles ./styles/** dist", - "prepublish": "yarn run clean", + "clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && npx rimraf dist", + "build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json && copy-assets && npx copyfiles ./styles/** dist", + "prepack": "yarn run clean && yarn run build", "watch": "tsc --build ./tsconfig.json --watch" }, "dependencies": { diff --git a/packages/onboarding/package.json b/packages/onboarding/package.json index 8d6dd7e79509cb..368ed5db848236 100644 --- a/packages/onboarding/package.json +++ b/packages/onboarding/package.json @@ -7,6 +7,7 @@ "author": "Automattic Inc.", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", + "calypso:src": "src/index.ts", "sideEffects": [ "*.css", "*.scss" @@ -24,9 +25,9 @@ }, "types": "dist/types", "scripts": { - "clean": "tsc --build ./tsconfig.json --clean && tsc --build ./tsconfig-cjs.json --clean", - "prepare": "tsc --build ./tsconfig.json && tsc --build ./tsconfig-cjs.json && copy-assets && npx copyfiles ./styles/** dist", - "prepublish": "yarn run clean", + "clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && npx rimraf dist", + "build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json && copy-assets && npx copyfiles ./styles/** dist", + "prepack": "yarn run clean && yarn run build", "watch": "tsc --build ./tsconfig.json --watch" }, "dependencies": { diff --git a/packages/plans-grid/package.json b/packages/plans-grid/package.json index 219bdc815623f1..17c864a442cd68 100644 --- a/packages/plans-grid/package.json +++ b/packages/plans-grid/package.json @@ -7,6 +7,7 @@ "author": "Automattic Inc.", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", + "calypso:src": "src/index.ts", "sideEffects": [ "*.css", "*.scss" @@ -24,9 +25,9 @@ }, "types": "dist/types", "scripts": { - "clean": "tsc --build ./tsconfig.json --clean && tsc --build ./tsconfig-cjs.json --clean", - "prepare": "tsc --build ./tsconfig.json && tsc --build ./tsconfig-cjs.json && copy-assets", - "prepublish": "yarn run clean", + "clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && npx rimraf dist", + "build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json && copy-assets", + "prepack": "yarn run clean && yarn run build", "watch": "tsc --build ./tsconfig.json --watch" }, "dependencies": { diff --git a/packages/react-i18n/package.json b/packages/react-i18n/package.json index 207bf33e48b205..3ad7b6594aae11 100644 --- a/packages/react-i18n/package.json +++ b/packages/react-i18n/package.json @@ -7,6 +7,7 @@ "author": "Automattic Inc.", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", + "calypso:src": "src/index.tsx", "sideEffects": false, "repository": { "type": "git", @@ -25,9 +26,9 @@ ], "types": "dist/types", "scripts": { - "clean": "tsc --build ./tsconfig.json --clean && tsc --build ./tsconfig-cjs.json --clean", - "prepare": "tsc --build ./tsconfig.json && tsc --build ./tsconfig-cjs.json", - "prepublish": "yarn run clean", + "clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && npx rimraf dist", + "build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json", + "prepack": "yarn run clean && yarn run build", "watch": "tsc --build ./tsconfig.json --watch" }, "dependencies": { diff --git a/packages/search/package.json b/packages/search/package.json index 7a67d3cff73edd..62a43680afbd54 100644 --- a/packages/search/package.json +++ b/packages/search/package.json @@ -7,6 +7,7 @@ "author": "Automattic Inc.", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", + "calypso:src": "src/index.ts", "sideEffects": [ "*.css", "*.scss" @@ -46,10 +47,8 @@ "ts-loader": "^8.0.8" }, "scripts": { - "clean": "npx rimraf dist && tsc --build ./tsconfig.json --clean && tsc --build ./tsconfig-cjs.json --clean", - "build:esm": "tsc --build ./tsconfig.json && copy-assets --esm", - "build:cjs": "tsc --build ./tsconfig-cjs.json && copy-assets --cjs", - "prepare": "yarn run build:esm", - "prepack": "yarn run clean && yarn run build:esm && yarn run build:cjs" + "clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && npx rimraf dist", + "build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json && copy-assets", + "prepack": "yarn run clean && yarn run build" } } diff --git a/packages/shopping-cart/package.json b/packages/shopping-cart/package.json index 3fcc60b866b0ae..ba1e175060861b 100644 --- a/packages/shopping-cart/package.json +++ b/packages/shopping-cart/package.json @@ -5,11 +5,12 @@ "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "types": "dist/types/index.d.ts", + "calypso:src": "index.ts", "sideEffects": false, "scripts": { - "clean": "npx rimraf dist \"../../.tsc-cache/packages__shopping-cart*\"", - "prepare": "tsc --build ./tsconfig.json && tsc --build ./tsconfig-cjs.json", - "prepublish": "yarn run clean", + "clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && npx rimraf dist", + "build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json", + "prepack": "yarn run clean && yarn run build", "watch": "tsc --build ./tsconfig.json --watch" }, "files": [ From f3a6ae0d4b574e488e757d354d117d6b11b4acb6 Mon Sep 17 00:00:00 2001 From: Sergio Cinos Date: Tue, 17 Nov 2020 14:13:36 +0100 Subject: [PATCH 05/13] Move prepare script to postinstall --- packages/calypso-color-schemes/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/calypso-color-schemes/package.json b/packages/calypso-color-schemes/package.json index b0b6f144893222..954a8e9229f1ed 100644 --- a/packages/calypso-color-schemes/package.json +++ b/packages/calypso-color-schemes/package.json @@ -25,7 +25,7 @@ }, "scripts": { "clean": "npx rimraf js css src/__color-studio", - "prepare": "node bin/prepare-sass-assets.js && node bin/build-css.js" + "postinstall": "node bin/prepare-sass-assets.js && node bin/build-css.js" }, "devDependencies": { "postcss": "^7.0.32", From 2bb6c25f4abf67b6d41d530b55a2af3e80018c57 Mon Sep 17 00:00:00 2001 From: Sergio Cinos Date: Tue, 17 Nov 2020 14:13:49 +0100 Subject: [PATCH 06/13] Delete unused prepare script --- packages/components/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/components/package.json b/packages/components/package.json index 8969a66f04dd3d..6cd524aecf4159 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -49,7 +49,6 @@ "scripts": { "clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && npx rimraf dist", "build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json && copy-assets", - "prepare": "yarn run build", "prepack": "yarn run clean && yarn run build" } } From 4d29dabd59a8d858c9c9531f7e5e0d1cf57a3a3f Mon Sep 17 00:00:00 2001 From: Sergio Cinos Date: Tue, 17 Nov 2020 14:14:22 +0100 Subject: [PATCH 07/13] Undo watch change --- packages/browser-data-collector/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/browser-data-collector/package.json b/packages/browser-data-collector/package.json index 2638a958c56740..b2fdbfa73da1bd 100644 --- a/packages/browser-data-collector/package.json +++ b/packages/browser-data-collector/package.json @@ -21,7 +21,7 @@ "clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && npx rimraf dist", "build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json", "prepack": "yarn run clean && yarn run build", - "watch": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --watch" + "watch": "tsc --build ./tsconfig.json --watch" }, "dependencies": { "wpcom-proxy-request": "^6.0.0" From b64457bab4840eb18dbd7132cf9b3365305e7ec9 Mon Sep 17 00:00:00 2001 From: Sergio Cinos Date: Tue, 17 Nov 2020 15:17:15 +0100 Subject: [PATCH 08/13] Build @automattic/languages before trying to run it --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ff99a630a2f44e..408039955ffd67 100644 --- a/package.json +++ b/package.json @@ -92,7 +92,7 @@ "build-client-stats": "NODE_ENV=production CALYPSO_ENV=production EMIT_STATS=true PROGRESS=true yarn run build-client-evergreen", "build-packages": "tsc --build packages/tsconfig.json", "build-packages:watch": "tsc --build packages/tsconfig.json --watch", - "build-languages": "yarn run translate && node bin/build-languages.js", + "build-languages": "yarn run translate && yarn workspace @automattic/languages run build && node bin/build-languages.js", "build-languages-if-enabled": "node -e \"(process.env.BUILD_TRANSLATION_CHUNKS === 'true' || process.env.ENABLE_FEATURES === 'use-translation-chunks') && process.exit(1)\" || yarn run build-languages", "calypso-doctor": "./node_modules/.bin/calypso-doctor", "clean": "yarn run clean:packages && yarn run clean:build && yarn run clean:public && yarn run clean:translations", From b35c0c5d2761bec864fd9b288b50df84a451ecec Mon Sep 17 00:00:00 2001 From: Sergio Cinos Date: Wed, 18 Nov 2020 06:09:31 +0100 Subject: [PATCH 09/13] Do not link TS packages --- client/tsconfig.json | 7 ------- package.json | 8 +++----- packages/tsconfig.json | 24 ------------------------ 3 files changed, 3 insertions(+), 36 deletions(-) delete mode 100644 packages/tsconfig.json diff --git a/client/tsconfig.json b/client/tsconfig.json index 8c0a565ef0ab38..a22a1b2b2d4e9e 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -16,13 +16,6 @@ "calypso/*": [ "./*" ] } }, - "references": [ - { "path": "../packages/calypso-analytics" }, - { "path": "../packages/components" }, - { "path": "../packages/data-stores" }, - { "path": "../packages/language-picker" }, - { "path": "../packages/react-i18n" } - ], "include": [ "**/*", "../build-tools/**" ], "exclude": [ "../**/node_modules/**/*", diff --git a/package.json b/package.json index 408039955ffd67..9ffe4e99944544 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "analyze-icfy": "yarn run build-client-stats && node --max-old-space-size=4096 bin/icfy-analyze.js", "autoprefixer": "postcss -u autoprefixer -r --no-map --config packages/calypso-build/postcss.config.js", "postcss": "postcss -r --config packages/calypso-build/postcss.config.js", - "build": "yarn run build-static && yarn run build-packages && yarn run build-css && run-p -s build-devdocs:* && run-p -s build-server build-client-if-prod build-client-if-desktop", + "build": "yarn run build-static && yarn run build-css && run-p -s build-devdocs:* && run-p -s build-server build-client-if-prod build-client-if-desktop", "build-css": "run-p -s build-css:*", "build-css:directly": "node-sass --importer node_modules/node-sass-package-importer/dist/cli.js --include-path client client/assets/stylesheets/directly.scss public/directly.css --output-style compressed && yarn run -s postcss public/directly.css", "build-css:reader-mobile": "node-sass --importer node_modules/node-sass-package-importer/dist/cli.js --include-path client client/assets/stylesheets/reader-mobile.scss public/reader-mobile.css --output-style compressed && yarn run -s postcss public/reader-mobile.css", @@ -90,8 +90,6 @@ "build-client-if-prod": "node -e \"process.env.CALYPSO_ENV === 'production' && process.exit(1)\" || yarn run build-client-both && yarn run build-languages-if-enabled", "build-client-if-desktop": "node -e \"(process.env.CALYPSO_ENV === 'desktop' || process.env.CALYPSO_ENV === 'desktop-development') && process.exit(1)\" || yarn run build-client-fallback", "build-client-stats": "NODE_ENV=production CALYPSO_ENV=production EMIT_STATS=true PROGRESS=true yarn run build-client-evergreen", - "build-packages": "tsc --build packages/tsconfig.json", - "build-packages:watch": "tsc --build packages/tsconfig.json --watch", "build-languages": "yarn run translate && yarn workspace @automattic/languages run build && node bin/build-languages.js", "build-languages-if-enabled": "node -e \"(process.env.BUILD_TRANSLATION_CHUNKS === 'true' || process.env.ENABLE_FEATURES === 'use-translation-chunks') && process.exit(1)\" || yarn run build-languages", "calypso-doctor": "./node_modules/.bin/calypso-doctor", @@ -105,7 +103,7 @@ "docker-jetpack-cloud": "docker run -it --env CALYPSO_ENV=jetpack-cloud-production --name wp-calypso --rm -p 80:3000 wp-calypso", "eslint-branch": "node bin/eslint-branch.js", "install-if-no-packages": "node bin/install-if-no-packages.js", - "postinstall": "test -n \"$DISABLEPOSTINSTALL\" || ((node -e \"process.exit(process.env.CALYPSO_DOCTOR_SKIP !== 'true')\" || yarn run calypso-doctor) && yarn run build-packages)", + "postinstall": "node -e \"process.exit(process.env.CALYPSO_DOCTOR_SKIP !== 'true')\" || yarn run calypso-doctor", "lint": "run-s -s lint:*", "lint:config-defaults": "node bin/validate-config-keys.js", "lint:css": "stylelint \"**/*.scss\" --syntax scss", @@ -114,7 +112,7 @@ "lint:package-json": "npmPkgJsonLint './package.json' './client/package.json' './packages/*/package.json' './apps/*/package.json'", "prestart": "npx check-node-version --package && node bin/welcome.js", "start": "yarn run -s build", - "poststart": "run-p -s start-build-if-web start-build-if-desktop build-packages:watch", + "poststart": "run-p -s start-build-if-web start-build-if-desktop", "start-fallback": "DEV_TARGET=fallback yarn run start", "start-jetpack-cloud": "CALYPSO_ENV=jetpack-cloud-development yarn start", "start-jetpack-cloud-p": "PORT=3001 CALYPSO_ENV=jetpack-cloud-development yarn run build-server", diff --git a/packages/tsconfig.json b/packages/tsconfig.json deleted file mode 100644 index 9b9e0b1eec2133..00000000000000 --- a/packages/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - // Don't actually compile anything - "files": [], - - // Reference all TS packages - "references": [ - { "path": "./browser-data-collector" }, - { "path": "./calypso-analytics" }, - { "path": "./calypso-stripe" }, - { "path": "./components" }, - { "path": "./composite-checkout" }, - { "path": "./data-stores" }, - { "path": "./domain-picker" }, - { "path": "./i18n-utils" }, - { "path": "./language-picker" }, - { "path": "./languages" }, - { "path": "./launch" }, - { "path": "./onboarding" }, - { "path": "./plans-grid" }, - { "path": "./react-i18n" }, - { "path": "./search" }, - { "path": "./shopping-cart" } - ] -} From 6278a0db23252e01c2ed0960b99571bb0533a0b8 Mon Sep 17 00:00:00 2001 From: Sergio Cinos Date: Wed, 18 Nov 2020 06:30:34 +0100 Subject: [PATCH 10/13] Use lerna to run prepare on all packages --- package.json | 7 ++++--- packages/calypso-color-schemes/package.json | 2 +- packages/languages/package.json | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 9ffe4e99944544..539adccceddbb5 100644 --- a/package.json +++ b/package.json @@ -90,12 +90,13 @@ "build-client-if-prod": "node -e \"process.env.CALYPSO_ENV === 'production' && process.exit(1)\" || yarn run build-client-both && yarn run build-languages-if-enabled", "build-client-if-desktop": "node -e \"(process.env.CALYPSO_ENV === 'desktop' || process.env.CALYPSO_ENV === 'desktop-development') && process.exit(1)\" || yarn run build-client-fallback", "build-client-stats": "NODE_ENV=production CALYPSO_ENV=production EMIT_STATS=true PROGRESS=true yarn run build-client-evergreen", - "build-languages": "yarn run translate && yarn workspace @automattic/languages run build && node bin/build-languages.js", + "build-packages": "lerna run prepare --stream", + "build-languages": "yarn run translate && node bin/build-languages.js", "build-languages-if-enabled": "node -e \"(process.env.BUILD_TRANSLATION_CHUNKS === 'true' || process.env.ENABLE_FEATURES === 'use-translation-chunks') && process.exit(1)\" || yarn run build-languages", "calypso-doctor": "./node_modules/.bin/calypso-doctor", "clean": "yarn run clean:packages && yarn run clean:build && yarn run clean:public && yarn run clean:translations", "clean:build": "npx rimraf build client/server/bundler/*.json client/server/devdocs/search-index.js", - "clean:packages": "npx lerna run clean --stream", + "clean:packages": "lerna run clean --stream", "clean:public": "npx rimraf public", "clean:translations": "npx rimraf build/strings calypso-strings.pot chunks-map.*.json", "distclean": "yarn run clean && npx rimraf node_modules client/node_modules desktop/node_modules apps/*/node_modules packages/*/node_modules test/e2e/node_modules .cache apps/*/.cache vendor", @@ -103,7 +104,7 @@ "docker-jetpack-cloud": "docker run -it --env CALYPSO_ENV=jetpack-cloud-production --name wp-calypso --rm -p 80:3000 wp-calypso", "eslint-branch": "node bin/eslint-branch.js", "install-if-no-packages": "node bin/install-if-no-packages.js", - "postinstall": "node -e \"process.exit(process.env.CALYPSO_DOCTOR_SKIP !== 'true')\" || yarn run calypso-doctor", + "postinstall": "test -n \"$DISABLEPOSTINSTALL\" || ((node -e \"process.exit(process.env.CALYPSO_DOCTOR_SKIP !== 'true')\" || yarn run calypso-doctor) && yarn run build-packages)", "lint": "run-s -s lint:*", "lint:config-defaults": "node bin/validate-config-keys.js", "lint:css": "stylelint \"**/*.scss\" --syntax scss", diff --git a/packages/calypso-color-schemes/package.json b/packages/calypso-color-schemes/package.json index 954a8e9229f1ed..b0b6f144893222 100644 --- a/packages/calypso-color-schemes/package.json +++ b/packages/calypso-color-schemes/package.json @@ -25,7 +25,7 @@ }, "scripts": { "clean": "npx rimraf js css src/__color-studio", - "postinstall": "node bin/prepare-sass-assets.js && node bin/build-css.js" + "prepare": "node bin/prepare-sass-assets.js && node bin/build-css.js" }, "devDependencies": { "postcss": "^7.0.32", diff --git a/packages/languages/package.json b/packages/languages/package.json index f3979e9e63a926..1375a62f2644e9 100644 --- a/packages/languages/package.json +++ b/packages/languages/package.json @@ -18,6 +18,7 @@ "clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && npx rimraf dist", "build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json", "prepack": "yarn run clean && yarn run build", + "prepare": "yarn run build", "download": "node bin/download.js", "test": "yarn jest" }, From fcf7ac79fc6ea04dc25f8a5b7ec661dbb530c2a2 Mon Sep 17 00:00:00 2001 From: Sergio Cinos Date: Wed, 18 Nov 2020 06:33:59 +0100 Subject: [PATCH 11/13] Rename build-packages to prepare:packages --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 539adccceddbb5..af43ecdedcdc63 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "build-client-if-prod": "node -e \"process.env.CALYPSO_ENV === 'production' && process.exit(1)\" || yarn run build-client-both && yarn run build-languages-if-enabled", "build-client-if-desktop": "node -e \"(process.env.CALYPSO_ENV === 'desktop' || process.env.CALYPSO_ENV === 'desktop-development') && process.exit(1)\" || yarn run build-client-fallback", "build-client-stats": "NODE_ENV=production CALYPSO_ENV=production EMIT_STATS=true PROGRESS=true yarn run build-client-evergreen", - "build-packages": "lerna run prepare --stream", + "prepare:packages": "lerna run prepare --stream", "build-languages": "yarn run translate && node bin/build-languages.js", "build-languages-if-enabled": "node -e \"(process.env.BUILD_TRANSLATION_CHUNKS === 'true' || process.env.ENABLE_FEATURES === 'use-translation-chunks') && process.exit(1)\" || yarn run build-languages", "calypso-doctor": "./node_modules/.bin/calypso-doctor", @@ -104,7 +104,7 @@ "docker-jetpack-cloud": "docker run -it --env CALYPSO_ENV=jetpack-cloud-production --name wp-calypso --rm -p 80:3000 wp-calypso", "eslint-branch": "node bin/eslint-branch.js", "install-if-no-packages": "node bin/install-if-no-packages.js", - "postinstall": "test -n \"$DISABLEPOSTINSTALL\" || ((node -e \"process.exit(process.env.CALYPSO_DOCTOR_SKIP !== 'true')\" || yarn run calypso-doctor) && yarn run build-packages)", + "postinstall": "test -n \"$DISABLEPOSTINSTALL\" || ((node -e \"process.exit(process.env.CALYPSO_DOCTOR_SKIP !== 'true')\" || yarn run calypso-doctor) && yarn run prepare:packages)", "lint": "run-s -s lint:*", "lint:config-defaults": "node bin/validate-config-keys.js", "lint:css": "stylelint \"**/*.scss\" --syntax scss", From 1712884692dfcd0b669f94131bdf52f8221c4b7e Mon Sep 17 00:00:00 2001 From: Sergio Cinos Date: Wed, 18 Nov 2020 10:02:10 +0100 Subject: [PATCH 12/13] Brign back package build process --- client/tsconfig.json | 1 + package.json | 4 ++-- packages/tsconfig.json | 23 +++++++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 packages/tsconfig.json diff --git a/client/tsconfig.json b/client/tsconfig.json index a22a1b2b2d4e9e..11d5b029cc8d92 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -16,6 +16,7 @@ "calypso/*": [ "./*" ] } }, + "references": [ { "path": "../packages" } ], "include": [ "**/*", "../build-tools/**" ], "exclude": [ "../**/node_modules/**/*", diff --git a/package.json b/package.json index af43ecdedcdc63..5a08937b68b2e0 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "build-client-if-prod": "node -e \"process.env.CALYPSO_ENV === 'production' && process.exit(1)\" || yarn run build-client-both && yarn run build-languages-if-enabled", "build-client-if-desktop": "node -e \"(process.env.CALYPSO_ENV === 'desktop' || process.env.CALYPSO_ENV === 'desktop-development') && process.exit(1)\" || yarn run build-client-fallback", "build-client-stats": "NODE_ENV=production CALYPSO_ENV=production EMIT_STATS=true PROGRESS=true yarn run build-client-evergreen", - "prepare:packages": "lerna run prepare --stream", + "build-packages": "tsc --build packages/tsconfig.json && lerna run prepare --stream", "build-languages": "yarn run translate && node bin/build-languages.js", "build-languages-if-enabled": "node -e \"(process.env.BUILD_TRANSLATION_CHUNKS === 'true' || process.env.ENABLE_FEATURES === 'use-translation-chunks') && process.exit(1)\" || yarn run build-languages", "calypso-doctor": "./node_modules/.bin/calypso-doctor", @@ -104,7 +104,7 @@ "docker-jetpack-cloud": "docker run -it --env CALYPSO_ENV=jetpack-cloud-production --name wp-calypso --rm -p 80:3000 wp-calypso", "eslint-branch": "node bin/eslint-branch.js", "install-if-no-packages": "node bin/install-if-no-packages.js", - "postinstall": "test -n \"$DISABLEPOSTINSTALL\" || ((node -e \"process.exit(process.env.CALYPSO_DOCTOR_SKIP !== 'true')\" || yarn run calypso-doctor) && yarn run prepare:packages)", + "postinstall": "test -n \"$DISABLEPOSTINSTALL\" || ((node -e \"process.exit(process.env.CALYPSO_DOCTOR_SKIP !== 'true')\" || yarn run calypso-doctor) && yarn run build-packages)", "lint": "run-s -s lint:*", "lint:config-defaults": "node bin/validate-config-keys.js", "lint:css": "stylelint \"**/*.scss\" --syntax scss", diff --git a/packages/tsconfig.json b/packages/tsconfig.json new file mode 100644 index 00000000000000..19791f913e78d2 --- /dev/null +++ b/packages/tsconfig.json @@ -0,0 +1,23 @@ +{ + "files": [], + + // Reference all TS packages + "references": [ + { "path": "./browser-data-collector" }, + { "path": "./calypso-analytics" }, + { "path": "./calypso-stripe" }, + { "path": "./components" }, + { "path": "./composite-checkout" }, + { "path": "./data-stores" }, + { "path": "./domain-picker" }, + { "path": "./i18n-utils" }, + { "path": "./language-picker" }, + { "path": "./languages" }, + { "path": "./launch" }, + { "path": "./onboarding" }, + { "path": "./plans-grid" }, + { "path": "./react-i18n" }, + { "path": "./search" }, + { "path": "./shopping-cart" } + ] +} From df001a202c7067bc373f6ebc5266885aab985d66 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 18 Nov 2020 11:05:10 +0100 Subject: [PATCH 13/13] Fix components outDir to dist/esm --- packages/components/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/tsconfig.json b/packages/components/tsconfig.json index 03a8634dce257b..31efbcec188a14 100644 --- a/packages/components/tsconfig.json +++ b/packages/components/tsconfig.json @@ -7,7 +7,7 @@ "jsx": "react", "declaration": true, "declarationDir": "dist/types", - "outDir": "dist/types", + "outDir": "dist/esm", "isolatedModules": true, "strict": true,