@nx/nuxt
Version:
72 lines (71 loc) • 2.42 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createTsConfig = createTsConfig;
const devkit_1 = require("@nx/devkit");
const shared = require("@nx/js/src/utils/typescript/create-ts-config");
function createTsConfig(host, options, relativePathToRootTsConfig) {
createAppTsConfig(host, options);
const json = {
files: [],
include: options.isUsingTsSolutionConfig ? undefined : ['.nuxt/nuxt.d.ts'],
references: [
{
path: './tsconfig.app.json',
},
],
};
if (options.unitTestRunner !== 'none') {
json.references.push({
path: './tsconfig.spec.json',
});
}
// inline tsconfig.base.json into the project
if (options.rootProject) {
json.compileOnSave = false;
json.compilerOptions = {
...shared.tsConfigBaseOptions,
...json.compilerOptions,
};
json.exclude = ['node_modules', 'tmp'];
}
else {
json.extends = './.nuxt/tsconfig.json';
}
(0, devkit_1.writeJson)(host, `${options.projectRoot}/tsconfig.json`, json);
}
function createAppTsConfig(host, options) {
const sourceDir = options.useAppDir ? 'app' : 'src';
// Build include array
const include = ['.nuxt/nuxt.d.ts', `${sourceDir}/**/*`];
if (options.useAppDir) {
include.push('server/**/*');
}
// Build exclude array with test patterns
// Order: extension-grouped (ts, tsx, js, jsx) with test/spec interleaved
const testExcludes = ['ts', 'tsx', 'js', 'jsx'].flatMap((ext) => ['test', 'spec'].map((type) => `${sourceDir}/**/*.${type}.${ext}`));
if (options.useAppDir) {
testExcludes.push(...['ts', 'tsx', 'js', 'jsx'].flatMap((ext) => ['test', 'spec'].map((type) => `server/**/*.${type}.${ext}`)));
}
const exclude = [
'out-tsc',
'dist',
'vite.config.ts',
'vite.config.mts',
'vitest.config.ts',
'vitest.config.mts',
...testExcludes,
'eslint.config.js',
'eslint.config.cjs',
'eslint.config.mjs',
];
const json = {
extends: './tsconfig.json',
compilerOptions: {
composite: true,
rootDir: sourceDir,
},
include,
exclude,
};
(0, devkit_1.writeJson)(host, `${options.projectRoot}/tsconfig.app.json`, json);
}