From 4fecf5a7a65f5b7b4c03fefb9a3da15cee938f02 Mon Sep 17 00:00:00 2001 From: Steven Vachon Date: Wed, 11 Mar 2020 15:30:29 -0400 Subject: [PATCH] @grafana/e2e: correctly exclude dependencies from TypeScript builds (#22732) * maintains support for Grafana core e2e tests * avoids producing declaration files in plugin source directories --- .../cypress/plugins/typescriptPreprocessor.js | 14 ++++++++++++++ packages/grafana-e2e/cypress/tsconfig.json | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/grafana-e2e/cypress/plugins/typescriptPreprocessor.js b/packages/grafana-e2e/cypress/plugins/typescriptPreprocessor.js index 352b660a1a0..e187e63c8d6 100644 --- a/packages/grafana-e2e/cypress/plugins/typescriptPreprocessor.js +++ b/packages/grafana-e2e/cypress/plugins/typescriptPreprocessor.js @@ -1,9 +1,23 @@ +const { resolve } = require('path'); const wp = require('@cypress/webpack-preprocessor'); +const anyNodeModules = /node_modules/; +const packageRoot = resolve(`${__dirname}/../../`); +const packageModules = `${packageRoot}/node_modules`; + const webpackOptions = { module: { rules: [ { + include: modulePath => { + if (!anyNodeModules.test(modulePath)) { + // Is a file within the project + return true; + } else { + // Is a file within this package + return modulePath.startsWith(packageRoot) && !modulePath.startsWith(packageModules); + } + }, test: /\.ts$/, use: [ { diff --git a/packages/grafana-e2e/cypress/tsconfig.json b/packages/grafana-e2e/cypress/tsconfig.json index c5d0b72aed0..347c670a6a7 100644 --- a/packages/grafana-e2e/cypress/tsconfig.json +++ b/packages/grafana-e2e/cypress/tsconfig.json @@ -1,7 +1,9 @@ { "compilerOptions": { + "declaration": false, + "module": "commonjs", "types": ["cypress"] }, - "extends": "../tsconfig.json", + "extends": "@grafana/tsconfig", "include": ["**/*.ts"] }