Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
Use Typescript project references (experiment).
Browse files Browse the repository at this point in the history
* introduce optional, parallel `tsc --build` based build system

Signed-off-by: Zbigniew Zagorski <ext-zbyszek.zagorski@here.com>
  • Loading branch information
Zbigniew Zagorski committed Oct 30, 2019
1 parent a0e15f8 commit 36ab7d4
Show file tree
Hide file tree
Showing 53 changed files with 611 additions and 40 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Expand Up @@ -5,5 +5,8 @@ test-npm-packages-app/
.vscode/
.DS_Store
.nyc_output/

credentials.js
*.d.ts
*.js
*.js.map
tsconfig-build.tsbuildinfo
5 changes: 5 additions & 0 deletions .mocharc.json
@@ -0,0 +1,5 @@
{
"diff": true,
"spec": ["./test/**/*.js", "./@here/*/test/**/*.js"],
"exclude": ["./@here/harp-mapview/test/resources/testWorker.js"]
}
2 changes: 1 addition & 1 deletion @here/generator-harp.gl/test/test.js
Expand Up @@ -16,7 +16,7 @@ const {
USE_NPMRC=~/.npmrc npx mocha
*/
describe("harp.gl:app", function () {
describe.skip("harp.gl:app", function () {

this.timeout(300000);

Expand Down
12 changes: 12 additions & 0 deletions @here/harp-datasource-protocol/test/tsconfig-build.json
@@ -0,0 +1,12 @@
{
"extends": "../../../tsconfig.settings.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "."
},
"references": [
{ "path": "../tsconfig-build.json" },
{ "path": "../../harp-geoutils/tsconfig-build.json" },
{ "path": "../../harp-utils/tsconfig-build.json" }
]
}
12 changes: 12 additions & 0 deletions @here/harp-datasource-protocol/tsconfig-build.json
@@ -0,0 +1,12 @@
{
"extends": "../../tsconfig.settings.json",
"compilerOptions": {
"outDir": ".",
"rootDir": "."
},
"references": [
{ "path": "../harp-geoutils/tsconfig-build.json" },
{ "path": "../harp-utils/tsconfig-build.json" }
],
"exclude": ["test/**/*.ts"]
}
13 changes: 13 additions & 0 deletions @here/harp-debug-datasource/tsconfig-build.json
@@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.settings.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "."
},
"references": [
{ "path": "../harp-lrucache/tsconfig-build.json" },
{ "path": "../harp-geoutils/tsconfig-build.json" },
{ "path": "../harp-mapview/tsconfig-build.json" }
],
"exclude": ["test/**/*.ts"]
}
1 change: 1 addition & 0 deletions @here/harp-examples/package.json
Expand Up @@ -54,6 +54,7 @@
"highlight.js": "^9.15.8",
"html-webpack-plugin": "^3.2.0",
"ncp": "^2.0.0",
"source-map-loader": "^0.2.4",
"stats.js": "^0.17.0",
"style-loader": "^0.23.0",
"three": "^0.109.0",
Expand Down
31 changes: 31 additions & 0 deletions @here/harp-examples/tsconfig-build.json
@@ -0,0 +1,31 @@
{
"extends": "../../tsconfig.settings.json",
"compilerOptions": {
"rootDir": ".",
"outDir": ".",
"resolveJsonModule": true
},
"references": [
{ "path": "../harp-datasource-protocol/tsconfig-build.json" },
{ "path": "../harp-debug-datasource/tsconfig-build.json" },
{ "path": "../harp-features-datasource/tsconfig-build.json" },
{ "path": "../harp-geojson-datasource/tsconfig-build.json" },
{ "path": "../harp-geoutils/tsconfig-build.json" },
{ "path": "../harp-map-controls/tsconfig-build.json" },
{ "path": "../harp-mapview/tsconfig-build.json" },
{ "path": "../harp-omv-datasource/tsconfig-build.json" },
{ "path": "../harp-text-canvas/tsconfig-build.json" },
{ "path": "../harp-utils/tsconfig-build.json" },
{ "path": "../harp-webtile-datasource/tsconfig-build.json" }
],
"include": [
"./*.ts",
"./src/*.ts",
"./lib/*.ts",
"./resources/*.ts",
"./decoder/*.ts",
"./src/*.tsx",
"./resources/**/*.json"
],
"exclude": ["test/**/*.ts", "dist/**/*.ts"]
}
44 changes: 44 additions & 0 deletions @here/harp-examples/webpack-build.config.js
@@ -0,0 +1,44 @@
/*
* Copyright (C) 2017-2018 HERE Europe B.V.
* Licensed under Apache 2.0, see full license in LICENSE
* SPDX-License-Identifier: Apache-2.0
*/

/**
* This basically downgrades original webpack.config.js to compile
* only JS created by `tsc -b .` (in current folder).
*
* This is much faster in bigger build process as Typescript runs only once.
*
* Usage:
* - Development
* tsc --build tsconfig-build.json --watch --verbose --listEmittedFiles
* webpack-dev-server --config webpack-build.config.js
*
* - CI
* tsc --build tsconfig-build.json
* webpack --config webpack-build.config.js
*/
const configs = require('./webpack.config');

module.exports = configs.map(config => {
config.resolve.extensions = [".webpack.js", ".web.js", ".js"]
config.module.rules = config.module.rules.filter(rule => rule.loader !== "ts-loader")
config.module.rules.push({
rules: [
{
test: /\.js$/,
use: ["source-map-loader"],
enforce: "pre"
}
]
})
for(const entry in config.entries) {
config.entries[entry] = config.entries[entry].replace(/.ts$/, ".js");
}
return config;
})

throw new Foo();
7 changes: 4 additions & 3 deletions @here/harp-examples/webpack.config.js
Expand Up @@ -52,12 +52,13 @@ const commonConfig = {
loader: "ts-loader",
exclude: /node_modules/,
options: {
configFile: path.join(process.cwd(), "tsconfig.json"),
onlyCompileBundledFiles: true,
projectReferences: true,
configFile: path.join(__dirname, "tsconfig-build.json"),
onlyCompileBundledFiles: true,
transpileOnly: prepareOnly,
compilerOptions: {
sourceMap: !prepareOnly,
declaration: false
sourceMap: !prepareOnly
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions @here/harp-features-datasource/tsconfig-build.json
@@ -0,0 +1,14 @@
{
"extends": "../../tsconfig.settings.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "."
},
"references": [
{ "path": "../harp-datasource-protocol/tsconfig-build.json" },
{ "path": "../harp-geojson-datasource/tsconfig-build.json" },
{ "path": "../harp-mapview/tsconfig-build.json" },
{ "path": "../harp-omv-datasource/tsconfig-build.json" }
],
"exclude": ["test/**/*.ts"]
}
8 changes: 8 additions & 0 deletions @here/harp-fetch/test/tsconfig-build.json
@@ -0,0 +1,8 @@
{
"extends": "../../../tsconfig.settings.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "."
},
"references": [{ "path": "../tsconfig-build.json" }]
}
8 changes: 8 additions & 0 deletions @here/harp-fetch/tsconfig-build.json
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.settings.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "."
},
"exclude": ["test/**/*.ts"]
}
18 changes: 18 additions & 0 deletions @here/harp-geojson-datasource/tsconfig-build.json
@@ -0,0 +1,18 @@
{
"extends": "../../tsconfig.settings.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "."
},
"references": [
{ "path": "../harp-datasource-protocol/tsconfig-build.json" },
{ "path": "../harp-fetch/tsconfig-build.json" },
{ "path": "../harp-geoutils/tsconfig-build.json" },
{ "path": "../harp-lines/tsconfig-build.json" },
{ "path": "../harp-mapview/tsconfig-build.json" },
{ "path": "../harp-mapview-decoder/tsconfig-build.json" },
{ "path": "../harp-transfer-manager/tsconfig-build.json" },
{ "path": "../harp-utils/tsconfig-build.json" }
],
"exclude": ["test/**/*.ts"]
}
8 changes: 8 additions & 0 deletions @here/harp-geometry/test/tsconfig-build.json
@@ -0,0 +1,8 @@
{
"extends": "../../../tsconfig.settings.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "."
},
"references": [{ "path": "../tsconfig-build.json" }]
}
9 changes: 9 additions & 0 deletions @here/harp-geometry/tsconfig-build.json
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.settings.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "."
},
"references": [{ "path": "../harp-geoutils/tsconfig-build.json" }],
"exclude": ["test/**/*.ts"]
}
8 changes: 8 additions & 0 deletions @here/harp-geoutils/test/tsconfig-build.json
@@ -0,0 +1,8 @@
{
"extends": "../../../tsconfig.settings.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "."
},
"references": [{ "path": "../tsconfig-build.json" }]
}
8 changes: 8 additions & 0 deletions @here/harp-geoutils/tsconfig-build.json
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.settings.json",
"compilerOptions": {
"outDir": ".",
"rootDir": "."
},
"include": ["lib/**/*.ts", "index.ts"]
}
8 changes: 8 additions & 0 deletions @here/harp-lines/test/tsconfig-build.json
@@ -0,0 +1,8 @@
{
"extends": "../../../tsconfig.settings.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "."
},
"references": [{ "path": "../tsconfig-build.json" }]
}
12 changes: 12 additions & 0 deletions @here/harp-lines/tsconfig-build.json
@@ -0,0 +1,12 @@
{
"extends": "../../tsconfig.settings.json",
"compilerOptions": {
"outDir": ".",
"rootDir": "."
},
"references": [
{ "path": "../harp-utils/tsconfig-build.json" },
{ "path": "../harp-materials/tsconfig-build.json" }
],
"exclude": ["test/**/*.ts"]
}
11 changes: 11 additions & 0 deletions @here/harp-lrucache/test/tsconfig-build.json
@@ -0,0 +1,11 @@
{
"extends": "../../../tsconfig.settings.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "."
},
"references": [
{ "path": "../tsconfig-build.json" },
{ "path": "../../harp-utils/tsconfig-build.json" }
]
}
9 changes: 9 additions & 0 deletions @here/harp-lrucache/tsconfig-build.json
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.settings.json",
"compilerOptions": {
"outDir": ".",
"rootDir": "."
},
"references": [{ "path": "../harp-utils/tsconfig-build.json" }],
"exclude": ["test/**/*.ts"]
}
2 changes: 1 addition & 1 deletion @here/harp-map-controls/test/MapControlsTest.ts
Expand Up @@ -18,7 +18,7 @@ declare const global: any;

const inNodeContext = typeof window === "undefined";

describe("MapControls", function() {
describe.only("MapControls", function() {
let sandbox: sinon.SinonSandbox;

beforeEach(function() {
Expand Down
11 changes: 11 additions & 0 deletions @here/harp-map-controls/test/tsconfig-build.json
@@ -0,0 +1,11 @@
{
"extends": "../../../tsconfig.settings.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "."
},
"references": [
{ "path": "../tsconfig-build.json" },
{ "path": "../../harp-geoutils/tsconfig-build.json" }
]
}
13 changes: 13 additions & 0 deletions @here/harp-map-controls/tsconfig-build.json
@@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.settings.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "."
},
"references": [
{ "path": "../harp-geoutils/tsconfig-build.json" },
{ "path": "../harp-mapview/tsconfig-build.json" },
{ "path": "../harp-utils/tsconfig-build.json" }
],
"exclude": ["test/**/*.ts"]
}
11 changes: 11 additions & 0 deletions @here/harp-mapview-decoder/test/tsconfig-build.json
@@ -0,0 +1,11 @@
{
"extends": "../../../tsconfig.settings.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "."
},
"references": [
{ "path": "../tsconfig-build.json" },
{ "path": "../../harp-test-utils/tsconfig-build.json" }
]
}
16 changes: 16 additions & 0 deletions @here/harp-mapview-decoder/tsconfig-build.json
@@ -0,0 +1,16 @@
{
"extends": "../../tsconfig.settings.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "."
},
"references": [
{ "path": "../harp-datasource-protocol/tsconfig-build.json" },
{ "path": "../harp-fetch/tsconfig-build.json" },
{ "path": "../harp-geoutils/tsconfig-build.json" },
{ "path": "../harp-mapview/tsconfig-build.json" },
{ "path": "../harp-utils/tsconfig-build.json" },
{ "path": "../harp-test-utils/tsconfig-build.json" }
],
"exclude": ["test/**/*.ts"]
}
11 changes: 11 additions & 0 deletions @here/harp-mapview/test/tsconfig-build.json
@@ -0,0 +1,11 @@
{
"extends": "../../../tsconfig.settings.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "."
},
"references": [
{ "path": "../tsconfig-build.json" },
{ "path": "../../harp-test-utils/tsconfig-build.json" }
]
}
18 changes: 18 additions & 0 deletions @here/harp-mapview/tsconfig-build.json
@@ -0,0 +1,18 @@
{
"extends": "../../tsconfig.settings.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "."
},
"references": [
{ "path": "../harp-datasource-protocol/tsconfig-build.json" },
{ "path": "../harp-fetch/tsconfig-build.json" },
{ "path": "../harp-geoutils/tsconfig-build.json" },
{ "path": "../harp-lines/tsconfig-build.json" },
{ "path": "../harp-lrucache/tsconfig-build.json" },
{ "path": "../harp-materials/tsconfig-build.json" },
{ "path": "../harp-text-canvas/tsconfig-build.json" },
{ "path": "../harp-utils/tsconfig-build.json" }
],
"exclude": ["test/**/*.ts"]
}

0 comments on commit 36ab7d4

Please sign in to comment.