Skip to content

Commit

Permalink
chore: Use typescript project references.
Browse files Browse the repository at this point in the history
Project references allow typescript to efficiently build and watch dependencies
across TypeScript project boundaries.

There is a new tsconfig.json in packages that builds all the (non-ember)
typescript with a single compiler. This makes incremental builds work for all packages
based on what has changed.

Another great feature that TypeScript supports is also now enabled:
Type definition maps. This means that code navigation across packages will now
take you directly to the source instead of to the intermediate type
defintion from the compile. 🎉

The following new scripts are available:

* Top Level:
  * `yarn compile` - Build (or re-build) all typescript.
  * `yarn compile:clean` - Remove all compiled output and then compile.
  * `yarn compile:watch` - Start the typescript watcher for all
    typescript packages.
  * `yarn test:all` - Run all tests. This assumes the typescript has
    already been compiled.

* In each package:
  * `yarn compile` - Builds all typescript for the package and, if
    necessary, the local typescript projects that it depends on.
  * `yarn test` - Compile and run tests.
  * `yarn test:runner` - Run tests without compiling.
  • Loading branch information
chriseppstein committed Apr 16, 2019
1 parent 4548d90 commit c622d42
Show file tree
Hide file tree
Showing 24 changed files with 76 additions and 36 deletions.
7 changes: 6 additions & 1 deletion package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
"commitmsg": "commitlint --edit $GIT_PARAMS", "commitmsg": "commitlint --edit $GIT_PARAMS",
"ci": "lerna run test", "ci": "lerna run test",
"docs": "typedoc", "docs": "typedoc",
"toc": "markdown-toc -i --maxdepth 2 README.md" "toc": "markdown-toc -i --maxdepth 2 README.md",
"compile": "tsc -b packages",
"compile:watch": "tsc -b packages --watch",
"test:all": "lerna run test:runner",
"compile:clean": "rm -rf packages/@css-blocks/*/dist && yarn run compile",
"install:clean": "rm -rf node_modules packages/@css-blocks/*/node_modules && yarn"
}, },
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^6.1.0", "@commitlint/cli": "^6.1.0",
Expand Down
7 changes: 4 additions & 3 deletions packages/@css-blocks/broccoli/package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
"broccoli-plugin" "broccoli-plugin"
], ],
"scripts": { "scripts": {
"test": "mocha --opts test/mocha.opts dist/test", "test": "yarn run test:runner",
"compile": "rm -rf dist && tsc -p tsconfig.json", "test:runner": "mocha --opts test/mocha.opts dist/test",
"compile": "tsc --build",
"pretest": "yarn run compile", "pretest": "yarn run compile",
"posttest": "yarn run lint", "posttest": "yarn run lint",
"prepublish": "yarn run compile && yarn run lintall", "prepublish": "rm -rf dist && yarn run compile && yarn run lintall",
"lint": "tslint -t msbuild --project . -c tslint.cli.json", "lint": "tslint -t msbuild --project . -c tslint.cli.json",
"lintall": "tslint -t msbuild --project . -c tslint.release.json", "lintall": "tslint -t msbuild --project . -c tslint.release.json",
"lintfix": "tslint -t msbuild --project . -c tslint.cli.json --fix", "lintfix": "tslint -t msbuild --project . -c tslint.cli.json --fix",
Expand Down
6 changes: 0 additions & 6 deletions packages/@css-blocks/broccoli/tsconfig.build.json

This file was deleted.

5 changes: 5 additions & 0 deletions packages/@css-blocks/broccoli/tsconfig.json
Original file line number Original file line Diff line number Diff line change
@@ -1,9 +1,14 @@
{ {
"extends": "../../../tsconfig.json", "extends": "../../../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"composite": true,
"outDir": "dist", "outDir": "dist",
"baseUrl": "dist" "baseUrl": "dist"
}, },
"references": [
{"path": "../glimmer"},
{"path": "../core"}
],
"include": [ "include": [
"src", "src",
"test" "test"
Expand Down
1 change: 1 addition & 0 deletions packages/@css-blocks/code-style/package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"pretest": "yarn run compile", "pretest": "yarn run compile",
"prepublish": "yarn run compile", "prepublish": "yarn run compile",
"test": "echo 'nothing to test'", "test": "echo 'nothing to test'",
"test:runner": "echo 'nothing to test'",
"lint": "tslint -t msbuild -p . -c tslint.cli.json", "lint": "tslint -t msbuild -p . -c tslint.cli.json",
"lintfix": "tslint -t msbuild -p . --fix -c tslint.cli.json", "lintfix": "tslint -t msbuild -p . --fix -c tslint.cli.json",
"lintall": "tslint -t msbuild -p . -c tslint.release.json" "lintall": "tslint -t msbuild -p . -c tslint.release.json"
Expand Down
7 changes: 4 additions & 3 deletions packages/@css-blocks/core/package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
"description": "Fast, maintainable, optimal, component-oriented CSS.", "description": "Fast, maintainable, optimal, component-oriented CSS.",
"main": "dist/src/index.js", "main": "dist/src/index.js",
"scripts": { "scripts": {
"compile": "tsc --version && rm -rf dist && tsc", "compile": "tsc --version && tsc --build",
"pretest": "yarn run compile", "pretest": "yarn run compile",
"test": "mocha dist/test --opts test/mocha.opts", "test": "yarn run test:runner",
"test:runner": "mocha dist/test --opts test/mocha.opts",
"posttest": "yarn run lint", "posttest": "yarn run lint",
"prepublish": "yarn run compile && yarn run lintall", "prepublish": "rm -rf dist && yarn run compile && yarn run lintall",
"lint": "tslint -t msbuild --project . -c tslint.cli.json", "lint": "tslint -t msbuild --project . -c tslint.cli.json",
"lintall": "tslint -t msbuild --project . -c tslint.release.json", "lintall": "tslint -t msbuild --project . -c tslint.release.json",
"lintfix": "tslint -t msbuild --project . -c tslint.cli.json --fix", "lintfix": "tslint -t msbuild --project . -c tslint.cli.json --fix",
Expand Down
1 change: 1 addition & 0 deletions packages/@css-blocks/core/tsconfig.json
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,7 @@
{ {
"extends": "../../../tsconfig.json", "extends": "../../../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"composite": true,
"outDir": "dist", "outDir": "dist",
"baseUrl": "dist", "baseUrl": "dist",
"paths": { "paths": {
Expand Down
1 change: 1 addition & 0 deletions packages/@css-blocks/ember-cli/package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"lint:js": "eslint ./*.js addon addon-test-support app blueprints config lib server test-support tests", "lint:js": "eslint ./*.js addon addon-test-support app blueprints config lib server test-support tests",
"start": "ember serve", "start": "ember serve",
"test": "ember test", "test": "ember test",
"test:runner": "ember test",
"test:all": "ember try:each" "test:all": "ember try:each"
}, },
"dependencies": { "dependencies": {
Expand Down
7 changes: 4 additions & 3 deletions packages/@css-blocks/glimmer/package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
"types-local" "types-local"
], ],
"scripts": { "scripts": {
"test": "mocha --opts test/mocha.opts dist/cjs/test", "test": "yarn run test:runner",
"compile": "rm -rf dist && tsc --version && tsc -p tsconfig.json && tsc -p tsconfig.amd.json -m AMD", "test:runner": "mocha --opts test/mocha.opts dist/cjs/test",
"compile": "tsc --version && tsc --build && tsc --build tsconfig.amd.json",
"pretest": "yarn run compile", "pretest": "yarn run compile",
"posttest": "yarn run lint", "posttest": "yarn run lint",
"prepublish": "yarn run compile && yarn run lintall", "prepublish": "rm -rf dist && yarn run compile && yarn run lintall",
"lint": "tslint -t msbuild --project . -c tslint.cli.json", "lint": "tslint -t msbuild --project . -c tslint.cli.json",
"lintall": "tslint -t msbuild --project . -c tslint.release.json", "lintall": "tslint -t msbuild --project . -c tslint.release.json",
"lintfix": "tslint -t msbuild --project . -c tslint.cli.json --fix", "lintfix": "tslint -t msbuild --project . -c tslint.cli.json --fix",
Expand Down
4 changes: 2 additions & 2 deletions packages/@css-blocks/glimmer/tsconfig.amd.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"compilerOptions": { "compilerOptions": {
"outDir": "dist/amd/src/helpers", "outDir": "dist/amd/src/helpers",
"baseUrl": "dist/amd/src/helpers", "baseUrl": "dist/amd/src/helpers",
"target": "es5" "target": "es5",
"module": "amd"
}, },
"module": "AMD",
"include": [ "include": [
"src/helpers" "src/helpers"
], ],
Expand Down
6 changes: 0 additions & 6 deletions packages/@css-blocks/glimmer/tsconfig.build.json

This file was deleted.

4 changes: 4 additions & 0 deletions packages/@css-blocks/glimmer/tsconfig.json
Original file line number Original file line Diff line number Diff line change
@@ -1,9 +1,13 @@
{ {
"extends": "../../../tsconfig.json", "extends": "../../../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"composite": true,
"outDir": "dist/cjs", "outDir": "dist/cjs",
"baseUrl": "dist/cjs" "baseUrl": "dist/cjs"
}, },
"references": [
{"path": "../core"}
],
"include": [ "include": [
"src", "src",
"test" "test"
Expand Down
7 changes: 4 additions & 3 deletions packages/@css-blocks/jsx/package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
"scripts": { "scripts": {
"pretest": "yarn run compile", "pretest": "yarn run compile",
"posttest": "yarn run lint", "posttest": "yarn run lint",
"test": "mocha dist/test --recursive --opts test/mocha.opts && yarn run lint", "test": "yarn run test:runner",
"compile": "rm -rf dist && tsc --jsx preserve -p tsconfig.json", "test:runner": "mocha dist/test --recursive --opts test/mocha.opts && yarn run lint",
"prepublish": "yarn run compile && yarn run lintall", "compile": "tsc --build",
"prepublish": "rm -rf dist && yarn run compile && yarn run lintall",
"watch": "watch 'yarn run test' './src' './test' --wait=3", "watch": "watch 'yarn run test' './src' './test' --wait=3",
"lint": "tslint -t msbuild -c tslint.cli.json --project .", "lint": "tslint -t msbuild -c tslint.cli.json --project .",
"lintall": "tslint -t msbuild --project . -c tslint.release.json", "lintall": "tslint -t msbuild --project . -c tslint.release.json",
Expand Down
6 changes: 6 additions & 0 deletions packages/@css-blocks/jsx/tsconfig.json
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,7 @@
{ {
"extends": "../../../tsconfig.json", "extends": "../../../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"composite": true,
"jsx": "preserve", "jsx": "preserve",
"jsxFactory": "h", "jsxFactory": "h",


Expand All @@ -21,5 +22,10 @@
"dist", "dist",
"test/fixtures", "test/fixtures",
"node_modules" "node_modules"
],
"references": [
{"path": "../test-utils"},
{"path": "../core"},
{"path": "../runtime"},
] ]
} }
3 changes: 2 additions & 1 deletion packages/@css-blocks/playground/package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"scripts": { "scripts": {
"build": "ember build -prod", "build": "ember build -prod",
"start": "ember server", "start": "ember server",
"test": "ember test" "test": "ember test",
"test:runner": "ember test"
}, },
"devDependencies": { "devDependencies": {
"@css-blocks/ember-cli": "^0.21.0", "@css-blocks/ember-cli": "^0.21.0",
Expand Down
7 changes: 4 additions & 3 deletions packages/@css-blocks/runtime/package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
"scripts": { "scripts": {
"pretest": "yarn run compile", "pretest": "yarn run compile",
"posttest": "yarn run lint", "posttest": "yarn run lint",
"test": "mocha dist/test --opts test/mocha.opts", "test": "yarn run test:runner",
"watch": "watch 'yarn run test' './src' './test' --wait=1", "watch": "watch 'yarn run test' './src' './test' --wait=1",
"compile": "rm -rf dist && tsc", "compile": "tsc --build",
"prepublish": "yarn run compile && yarn run lintall", "prepublish": "rm -rf dist && yarn run compile && yarn run lintall",
"test:runner": "mocha dist/test --opts test/mocha.opts",
"lint": "tslint -t msbuild -c tslint.cli.json --project .", "lint": "tslint -t msbuild -c tslint.cli.json --project .",
"lintall": "tslint -t msbuild --project . -c tslint.release.json", "lintall": "tslint -t msbuild --project . -c tslint.release.json",
"lintfix": "tslint -t msbuild -c tslint.cli.json --project . --fix" "lintfix": "tslint -t msbuild -c tslint.cli.json --project . --fix"
Expand Down
1 change: 1 addition & 0 deletions packages/@css-blocks/runtime/tsconfig.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Runtime output is very different. // Runtime output is very different.
{ {
"compilerOptions": { "compilerOptions": {
"composite": true,
// Compilation Configuration // Compilation Configuration
"target": "es5", "target": "es5",
"inlineSources": false, "inlineSources": false,
Expand Down
3 changes: 2 additions & 1 deletion packages/@css-blocks/test-utils/package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"scripts": { "scripts": {
"compile": "tsc --version && rm -rf dist && tsc", "compile": "tsc --version && rm -rf dist && tsc",
"pretest": "yarn run compile", "pretest": "yarn run compile",
"test": "mocha dist/test --opts test/mocha.opts", "test": "yarn run test:runner",
"test:runner": "mocha dist/test --opts test/mocha.opts",
"posttest": "yarn run lint", "posttest": "yarn run lint",
"prepublish": "yarn run compile && yarn run lintall", "prepublish": "yarn run compile && yarn run lintall",
"lint": "tslint -t msbuild --project . -c tslint.cli.json", "lint": "tslint -t msbuild --project . -c tslint.cli.json",
Expand Down
1 change: 1 addition & 0 deletions packages/@css-blocks/test-utils/tsconfig.json
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,7 @@
{ {
"extends": "../../../tsconfig.json", "extends": "../../../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"composite": true,
"outDir": "dist", "outDir": "dist",
"baseUrl": "dist" "baseUrl": "dist"
}, },
Expand Down
7 changes: 4 additions & 3 deletions packages/@css-blocks/webpack/package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
"description": "Webpack plugin for css-blocks.", "description": "Webpack plugin for css-blocks.",
"main": "dist/src/index.js", "main": "dist/src/index.js",
"scripts": { "scripts": {
"prepublish": "yarn run compile && yarn run lintall", "prepublish": "rm -rf dist && yarn run compile && yarn run lintall",
"compile": "rm -rf dist && tsc -p tsconfig.json", "compile": "tsc --build",
"pretest": "yarn run compile", "pretest": "yarn run compile",
"posttest": "yarn run lint", "posttest": "yarn run lint",
"lint": "tslint -t msbuild -c tslint.cli.json --project .", "lint": "tslint -t msbuild -c tslint.cli.json --project .",
"lintall": "tslint -t msbuild --project . -c tslint.release.json", "lintall": "tslint -t msbuild --project . -c tslint.release.json",
"lintfix": "tslint -t msbuild -c tslint.cli.json --project . --fix", "lintfix": "tslint -t msbuild -c tslint.cli.json --project . --fix",
"test": "mocha dist/test --opts test/mocha.opts", "test": "yarn run test:runner",
"test:runner": "mocha dist/test --opts test/mocha.opts",
"coverage": "istanbul cover -i dist/src/**/*.js --dir ./build/coverage node_modules/mocha/bin/_mocha -- dist/test --opts test/mocha.opts", "coverage": "istanbul cover -i dist/src/**/*.js --dir ./build/coverage node_modules/mocha/bin/_mocha -- dist/test --opts test/mocha.opts",
"remap": "remap-istanbul -i build/coverage/coverage.json -o coverage -t html", "remap": "remap-istanbul -i build/coverage/coverage.json -o coverage -t html",
"watch": "watch 'yarn run test' './src' './test' --wait=3" "watch": "watch 'yarn run test' './src' './test' --wait=3"
Expand Down
4 changes: 4 additions & 0 deletions packages/@css-blocks/webpack/tsconfig.json
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,7 @@
{ {
"extends": "../../../tsconfig.json", "extends": "../../../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"composite": true,
"outDir": "dist", "outDir": "dist",
"baseUrl": "dist", "baseUrl": "dist",
"paths": { "paths": {
Expand All @@ -9,6 +10,9 @@
] ]
} }
}, },
"references": [
{"path": "../core"}
],
"include": [ "include": [
"src", "src",
"test" "test"
Expand Down
3 changes: 2 additions & 1 deletion packages/@css-blocks/website/package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@
"start": "node scripts/start.js", "start": "node scripts/start.js",
"build": "node scripts/build.js", "build": "node scripts/build.js",
"compile": "yarn run build", "compile": "yarn run build",
"test": "echo 'nothing to test'", "test": "yarn run test:runner",
"serve": "node server.js", "serve": "node server.js",
"snyk-protect": "snyk protect", "snyk-protect": "snyk protect",
"test:runner": "echo 'nothing to test'",
"prepublish": "npm run snyk-protect" "prepublish": "npm run snyk-protect"
}, },
"jest": { "jest": {
Expand Down
13 changes: 13 additions & 0 deletions packages/tsconfig.json
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"files": [],
"references": [
{"path": "@css-blocks/broccoli"},
{"path": "@css-blocks/core"},
{"path": "@css-blocks/glimmer"},
{"path": "@css-blocks/glimmer/tsconfig.amd.json"},
{"path": "@css-blocks/jsx"},
{"path": "@css-blocks/runtime"},
{"path": "@css-blocks/test-utils"},
{"path": "@css-blocks/webpack"},
]
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@


// output options // output options
"preserveConstEnums": false, "preserveConstEnums": false,
"declarationMap": true,
"newLine": "LF", "newLine": "LF",
"traceResolution": false, "traceResolution": false,
"module": "commonjs", "module": "commonjs",
Expand Down

0 comments on commit c622d42

Please sign in to comment.