Skip to content

Commit

Permalink
fix(promiselike): Revert typeRoots tsconfig change, move types to src…
Browse files Browse the repository at this point in the history
…/types and add KLUDGE to expose them in the @spinnaker/core bundle
  • Loading branch information
christopherthielen authored and mergify[bot] committed Oct 28, 2020
1 parent 2c0d0f6 commit a929d3f
Show file tree
Hide file tree
Showing 21 changed files with 42 additions and 15 deletions.
1 change: 1 addition & 0 deletions app/scripts/app.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
///<reference path="./modules/core/src/types/index.d.ts" />
import 'jquery'; // ensures jQuery is loaded before Angular so Angular does not use jqlite
import { module } from 'angular';
import './strictDi';
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/modules/amazon/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"declarationDir": "lib",
"outDir": "lib",
"rootDir": "./src",
"typeRoots": ["../../../../node_modules/@types", "../../../types"],
"typeRoots": ["../../../../node_modules/@types"],
"paths": {
"@spinnaker/core": ["../../core/lib"],
"core/*": ["../../core/lib/*"],
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/modules/appengine/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"declarationDir": "lib",
"outDir": "lib",
"rootDir": "./src",
"typeRoots": ["../../../../node_modules/@types", "../../../types"],
"typeRoots": ["../../../../node_modules/@types"],
"paths": {
"@spinnaker/core": ["../../core/lib"],
"core/*": ["../../core/lib/*"],
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/modules/azure/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"declarationDir": "lib",
"outDir": "lib",
"rootDir": "./src",
"typeRoots": ["../../../../node_modules/@types", "../../../types"],
"typeRoots": ["../../../../node_modules/@types"],
"paths": {
"@spinnaker/core": ["../../core/lib"],
"core/*": ["../../core/lib/*"]
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/modules/cloudfoundry/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"declarationDir": "lib",
"outDir": "lib",
"rootDir": "./src",
"typeRoots": ["../../../../node_modules/@types", "../../../types"],
"typeRoots": ["../../../../node_modules/@types"],
"paths": {
"@spinnaker/core": ["../../core/lib"],
"core/*": ["../../core/lib/*"],
Expand Down
2 changes: 2 additions & 0 deletions app/scripts/modules/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference path="./types/index.d.ts" />

import './utils/failedToInstantiateModule';

export * from './account';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/scripts/modules/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"declarationDir": "lib",
"outDir": "lib",
"rootDir": "./src",
"typeRoots": ["../../../../node_modules/@types", "../../../types"],
"typeRoots": ["../../../../node_modules/@types"],
"paths": {
"@spinnaker/core": ["."],
"core/*": ["*"],
Expand Down
25 changes: 25 additions & 0 deletions app/scripts/modules/core/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
'use strict';

const path = require('path');
const fs = require('fs');
const corePath = __dirname;
const basePath = path.join(__dirname, '..', '..', '..', '..');
const NODE_MODULE_PATH = path.join(basePath, 'node_modules');
const nodeExternals = require('webpack-node-externals');
const TerserPlugin = require('terser-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const exclusionPattern = /(node_modules|\.\.\/deck)/;
const WEBPACK_THREADS = Math.max(require('physical-cpu-count') - 1, 1);

const WATCH = process.env.WATCH === 'true';
const WEBPACK_MODE = WATCH ? 'development' : 'production';
const IS_PRODUCTION = WEBPACK_MODE === 'production';

// In index.ts, the triple slash reference to global namespace types get re-written to match the 'core' alias
// This kludge re-re-writes them back to a relative path
// Likely related to https://github.com/microsoft/TypeScript/issues/36763
class KLUDGE_FixTypesReferencePlugin {
apply(compiler) {
compiler.hooks.afterEmit.tap('KLUDGE_FixTypesReferencePlugin', (file, rest) => {
// eslint-disable-next-line no-console
console.log('Fixing up core/index.d.ts...');
const dts = path.join(corePath, 'lib', 'index.d.ts');
const fixedup = fs
.readFileSync(dts)
.toString()
.replace(/types="core\/types"/, 'types="./types"');
fs.writeFileSync(dts, fixedup);
});
}
}

module.exports = {
context: basePath,
mode: WEBPACK_MODE,
Expand Down Expand Up @@ -118,5 +139,9 @@ module.exports = {
},
],
},
plugins: [
new CopyWebpackPlugin([{ from: `${corePath}/src/types`, to: `types` }]),
new KLUDGE_FixTypesReferencePlugin(),
],
externals: ['root/version.json', nodeExternals({ modulesDir: '../../../../node_modules' })],
};
2 changes: 1 addition & 1 deletion app/scripts/modules/docker/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"declarationDir": "lib",
"outDir": "lib",
"rootDir": "./src",
"typeRoots": ["../../../../node_modules/@types", "../../../types"],
"typeRoots": ["../../../../node_modules/@types"],
"paths": {
"@spinnaker/core": ["../../core/lib"],
"core/*": ["core/src/*"]
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/modules/ecs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"declarationDir": "lib",
"outDir": "lib",
"rootDir": "./src",
"typeRoots": ["../../../../node_modules/@types", "../../../types"],
"typeRoots": ["../../../../node_modules/@types"],
"paths": {
"@spinnaker/core": ["../../core/lib"],
"core/*": ["../../core/lib/*"],
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/modules/google/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"declarationDir": "lib",
"outDir": "lib",
"rootDir": "./src",
"typeRoots": ["../../../../node_modules/@types", "../../../types"],
"typeRoots": ["../../../../node_modules/@types"],
"paths": {
"@spinnaker/core": ["../../core/lib"],
"core/*": ["../../core/lib/*"],
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/modules/huaweicloud/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"declarationDir": "lib",
"outDir": "lib",
"rootDir": "./src",
"typeRoots": ["../../../../node_modules/@types", "../../../types"],
"typeRoots": ["../../../../node_modules/@types"],
"paths": {
"@spinnaker/core": ["../../core/lib"],
"core/*": ["../../core/lib/*"]
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/modules/kubernetes/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"declarationDir": "lib",
"outDir": "lib",
"rootDir": "./src",
"typeRoots": ["../../../../node_modules/@types", "../../../types"],
"typeRoots": ["../../../../node_modules/@types"],
"paths": {
"@spinnaker/core": ["../../core/lib"],
"core/*": ["../../core/lib/*"],
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/modules/oracle/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"declarationDir": "lib",
"outDir": "lib",
"rootDir": "./src",
"typeRoots": ["../../../../node_modules/@types", "../../../types"],
"typeRoots": ["../../../../node_modules/@types"],
"paths": {
"@spinnaker/core": ["../../core/lib"],
"core/*": ["../../core/lib/*"],
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/modules/tencentcloud/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"declarationDir": "lib",
"outDir": "lib",
"rootDir": "./src",
"typeRoots": ["../../../../node_modules/@types", "../../../types"],
"typeRoots": ["../../../../node_modules/@types"],
"paths": {
"@spinnaker/core": ["../../core/lib"],
"core/*": ["../../core/lib/*"],
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/modules/titus/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"declarationDir": "lib",
"outDir": "lib",
"rootDir": "./src",
"typeRoots": ["../../../../node_modules/@types", "../../../types"],
"typeRoots": ["../../../../node_modules/@types"],
"paths": {
"@spinnaker/core": ["../../core/lib"],
"core/*": ["../../core/lib/*"],
Expand Down
1 change: 0 additions & 1 deletion app/types/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"sourceMap": true,
"strictNullChecks": false, // should really get to a place where we can turn this on
"target": "es6",
"typeRoots": ["node_modules/@types", "app/types"]
"typeRoots": ["node_modules/@types"]
},
"exclude": ["build", "node", "node_modules", "transpiled"],
"include": ["test/helpers/custom-matchers.d.ts", "app/scripts/modules/**/*.ts", "app/scripts/modules/**/*.tsx"]
Expand Down

0 comments on commit a929d3f

Please sign in to comment.