fix(webpack): typescript imports in non-ts projects (#9714)

This commit is contained in:
Igor Randjelovic
2021-12-23 22:48:00 +01:00
committed by GitHub
parent 6ca3d353ea
commit 965ccb4aec
4 changed files with 57 additions and 22 deletions

View File

@ -1,12 +1,11 @@
import { ScriptTarget } from 'typescript';
import { extname, resolve } from 'path';
import Config from 'webpack-chain';
import { existsSync } from 'fs';
import { getTypescript, readTsConfig } from '../helpers/typescript';
import { getDependencyPath } from '../helpers/dependencies';
import { getProjectFilePath } from '../helpers/project';
import { env as _env, IWebpackEnv } from '../index';
import { readTsConfig } from '../helpers/tsconfig';
import { warnOnce } from '../helpers/log';
import {
getEntryDirPath,
@ -179,6 +178,7 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
const buildAngularPath = getDependencyPath('@angular-devkit/build-angular');
if (buildAngularPath) {
const tsConfig = readTsConfig(tsConfigPath);
const { ScriptTarget } = getTypescript();
const scriptTarget = tsConfig.options.target ?? ScriptTarget.ESNext;
const buildAngularOptions: any = {
scriptTarget,