feat(webpack): support tsconfig.app.json when present (#10221)

This commit is contained in:
Igor Randjelovic
2023-03-28 16:17:51 +02:00
committed by GitHub
parent 6059984555
commit ebb827fb8e
4 changed files with 151 additions and 49 deletions

View File

@ -4,7 +4,7 @@ import { existsSync } from 'fs';
import { getTypescript, readTsConfig } from '../helpers/typescript';
import { getDependencyPath } from '../helpers/dependencies';
import { getProjectFilePath } from '../helpers/project';
import { getProjectTSConfigPath } from '../helpers/project';
import { env as _env, IWebpackEnv } from '../index';
import { warnOnce } from '../helpers/log';
import {
@ -18,12 +18,7 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
base(config, env);
const platform = getPlatformName();
const tsConfigPath = [
getProjectFilePath('tsconfig.app.json'),
getProjectFilePath('tsconfig.json'),
].find((path) => existsSync(path));
const tsConfigPath = getProjectTSConfigPath();
const disableAOT = !!env.disableAOT;
// remove default ts rule

View File

@ -15,7 +15,7 @@ import { PlatformSuffixPlugin } from '../plugins/PlatformSuffixPlugin';
import { applyFileReplacements } from '../helpers/fileReplacements';
import { addCopyRule, applyCopyRules } from '../helpers/copyRules';
import { WatchStatePlugin } from '../plugins/WatchStatePlugin';
import { getProjectFilePath } from '../helpers/project';
import { getProjectFilePath, getProjectTSConfigPath } from '../helpers/project';
import { hasDependency } from '../helpers/dependencies';
import { applyDotEnvPlugin } from '../helpers/dotEnv';
import { env as _env, IWebpackEnv } from '../index';
@ -234,6 +234,13 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
.use('nativescript-worker-loader')
.loader('nativescript-worker-loader');
const tsConfigPath = getProjectTSConfigPath();
const configFile = tsConfigPath
? {
configFile: tsConfigPath,
}
: undefined;
// set up ts support
config.module
.rule('ts')
@ -243,7 +250,7 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
.options({
// todo: perhaps we can provide a default tsconfig
// and use that if the project doesn't have one?
// configFile: '',
...configFile,
transpileOnly: true,
allowTsInNodeModules: true,
compilerOptions: {
@ -266,6 +273,7 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
async: !!env.watch,
typescript: {
memoryLimit: 4096,
...configFile,
},
},
]);