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

Commit

Permalink
HARP-6198: Use Typescript project references (experiment).
Browse files Browse the repository at this point in the history
Signed-off-by: Zbigniew Zagorski <ext-zbyszek.zagorski@here.com>
  • Loading branch information
Zbigniew Zagorski committed Sep 14, 2019
1 parent ccf277f commit 350c4c0
Show file tree
Hide file tree
Showing 55 changed files with 640 additions and 101 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Expand Up @@ -4,6 +4,8 @@ doc/
test-npm-packages-app/
.vscode/
.DS_Store


*.d.ts
*.js
*.js.map
tsconfig-build.tsbuildinfo
credentials.js
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"]
}
3 changes: 1 addition & 2 deletions .travis.yml
Expand Up @@ -24,11 +24,10 @@ jobs:
- name: "Test"
script: |
set -ex
npx ts-mocha -r tsconfig-paths/register ./test/*.ts
yarn run tslint
yarn run prettier
yarn run build-tests
npx ts-mocha -r tsconfig-paths/register ./@here/*/test/*.ts
yarn run test
yarn test-browser --headless-firefox
yarn test-browser --headless-chrome
#./scripts/test-npm-packages.sh
Expand Down
19 changes: 19 additions & 0 deletions @here/harp-atlas-tools/tsconfig-build.json
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"lib": ["es2017", "dom"],
"rootDir": "src",
"outDir": "lib",
"sourceMap": true,
"declaration": true,
"strictNullChecks": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": false,
"downlevelIteration": true
},
"exclude": ["node_modules"],
"include": ["src/*.ts"]
}
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 @@ -53,6 +53,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.108.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();
39 changes: 11 additions & 28 deletions @here/harp-examples/webpack.config.js
Expand Up @@ -40,28 +40,7 @@ const commonConfig = {
}
],
resolve: {
extensions: [".webpack.js", ".web.ts", ".ts", ".tsx", ".web.js", ".js"],
alias: {
"react-native": "react-native-web"
}
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
exclude: /node_modules/,
options: {
configFile: path.join(process.cwd(), "tsconfig.json"),
onlyCompileBundledFiles: true,
transpileOnly: prepareOnly,
compilerOptions: {
sourceMap: !prepareOnly,
declaration: false
}
}
}
]
extensions: [".webpack.js", ".web.js", ".js"]
},
output: {
path: path.join(process.cwd(), "dist/examples"),
Expand All @@ -78,20 +57,24 @@ const commonConfig = {
entrypoints: true,
warnings: true
},
mode: process.env.NODE_ENV || "development"
mode: process.env.NODE_ENV || "development",
watchOptions: {
aggregateTimeout: 300,
poll: 1000
}
};

const decoderConfig = merge(commonConfig, {
target: "webworker",
entry: {
decoder: "./decoder/decoder.ts"
decoder: "./decoder/decoder.js"
}
});

const webpackEntries = glob
.sync(path.join(__dirname, "./src/*.{ts,tsx}"))
.sync(path.join(__dirname, "./src/*.{js,jsx}"))
.reduce((result, entry) => {
const name = path.basename(entry).replace(/.tsx?$/, "");
const name = path.basename(entry).replace(/.jsx?$/, "");
if (name.startsWith("common")) {
return result;
}
Expand Down Expand Up @@ -136,13 +119,13 @@ const browserConfig = merge(commonConfig, {

const exampleBrowserConfig = merge(commonConfig, {
entry: {
"example-browser": "./example-browser.ts"
"example-browser": "./example-browser.js"
}
});

const codeBrowserConfig = merge(commonConfig, {
entry: {
codebrowser: "./codebrowser.ts"
codebrowser: "./codebrowser.js"
}
});

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"]
}
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" }
]
}

0 comments on commit 350c4c0

Please sign in to comment.