fix(nextjs): vite workspace libs (#21553)
This commit is contained in:
parent
be1b36b227
commit
b076d728e7
@ -104,10 +104,10 @@ describe('app', () => {
|
||||
|
||||
const tsConfig = readJson(tree, 'tsconfig.json');
|
||||
expect(tsConfig.include).toEqual([
|
||||
'**/*.ts',
|
||||
'**/*.tsx',
|
||||
'**/*.js',
|
||||
'**/*.jsx',
|
||||
'src/**/*.ts',
|
||||
'src/**/*.tsx',
|
||||
'src/**/*.js',
|
||||
'src/**/*.jsx',
|
||||
'.next/types/**/*.ts',
|
||||
`dist/${name}/.next/types/**/*.ts`,
|
||||
'next-env.d.ts',
|
||||
@ -675,6 +675,78 @@ describe('app', () => {
|
||||
`
|
||||
);
|
||||
});
|
||||
|
||||
it('should scope tsconfig to the src/ project directory', async () => {
|
||||
const name = uniq();
|
||||
|
||||
await applicationGenerator(tree, {
|
||||
name,
|
||||
style: 'css',
|
||||
appDir: true,
|
||||
rootProject: true,
|
||||
projectNameAndRootFormat: 'as-provided',
|
||||
src: true,
|
||||
});
|
||||
|
||||
const tsconfigJSON = readJson(tree, `tsconfig.json`);
|
||||
|
||||
expect(tsconfigJSON.include).toEqual([
|
||||
'src/**/*.ts',
|
||||
'src/**/*.tsx',
|
||||
'src/**/*.js',
|
||||
'src/**/*.jsx',
|
||||
'.next/types/**/*.ts',
|
||||
`dist/${name}/.next/types/**/*.ts`,
|
||||
'next-env.d.ts',
|
||||
]);
|
||||
});
|
||||
|
||||
it('should scope tsconfig to the app/ project directory', async () => {
|
||||
const name = uniq();
|
||||
|
||||
await applicationGenerator(tree, {
|
||||
name,
|
||||
style: 'css',
|
||||
appDir: true,
|
||||
rootProject: true,
|
||||
projectNameAndRootFormat: 'as-provided',
|
||||
src: false,
|
||||
});
|
||||
|
||||
const tsconfigJSON = readJson(tree, `tsconfig.json`);
|
||||
|
||||
expect(tsconfigJSON.include).toEqual([
|
||||
'app/**/*.ts',
|
||||
'app/**/*.tsx',
|
||||
'app/**/*.js',
|
||||
'app/**/*.jsx',
|
||||
'.next/types/**/*.ts',
|
||||
`dist/${name}/.next/types/**/*.ts`,
|
||||
'next-env.d.ts',
|
||||
]);
|
||||
});
|
||||
|
||||
it('should scope tsconfig to the pages/ project directory', async () => {
|
||||
const name = uniq();
|
||||
|
||||
await applicationGenerator(tree, {
|
||||
name,
|
||||
style: 'css',
|
||||
appDir: false,
|
||||
rootProject: true,
|
||||
projectNameAndRootFormat: 'as-provided',
|
||||
src: false,
|
||||
});
|
||||
|
||||
const tsconfigJSON = readJson(tree, `tsconfig.json`);
|
||||
expect(tsconfigJSON.include).toEqual([
|
||||
'pages/**/*.ts',
|
||||
'pages/**/*.tsx',
|
||||
'pages/**/*.js',
|
||||
'pages/**/*.jsx',
|
||||
'next-env.d.ts',
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -15,15 +15,15 @@
|
||||
"plugins": [{ "name": "next" }]
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
"**/*.js",
|
||||
"**/*.jsx",
|
||||
"<%= rootPath %>**/*.ts",
|
||||
"<%= rootPath %>**/*.tsx",
|
||||
"<%= rootPath %>**/*.js",
|
||||
"<%= rootPath %>**/*.jsx",
|
||||
<% if (appDir) { %>
|
||||
"<%= layoutTypeSrcPath %>",
|
||||
"<%= layoutTypeDistPath %>",
|
||||
<% } %>
|
||||
"next-env.d.ts"
|
||||
],
|
||||
"exclude": ["node_modules", "jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
|
||||
"exclude": ["node_modules", "jest.config.ts", "<%= rootPath %>**/*.spec.ts", "<%= rootPath %>**/*.test.ts"]
|
||||
}
|
||||
|
||||
@ -29,6 +29,15 @@ export function createApplicationFiles(host: Tree, options: NormalizedSchema) {
|
||||
options.outputPath,
|
||||
'.next/types/**/*.ts'
|
||||
);
|
||||
|
||||
// scope tsconfig to the project directory so that it doesn't include other projects/libs
|
||||
const rootPath = options.rootProject
|
||||
? options.src
|
||||
? 'src/'
|
||||
: options.appDir
|
||||
? 'app/'
|
||||
: 'pages/'
|
||||
: '';
|
||||
const templateVariables = {
|
||||
...names(options.name),
|
||||
...options,
|
||||
@ -36,6 +45,7 @@ export function createApplicationFiles(host: Tree, options: NormalizedSchema) {
|
||||
tmpl: '',
|
||||
offsetFromRoot,
|
||||
layoutTypeSrcPath,
|
||||
rootPath,
|
||||
layoutTypeDistPath,
|
||||
rootTsConfigPath: getRelativePathToRootTsConfig(
|
||||
host,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user