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');
|
const tsConfig = readJson(tree, 'tsconfig.json');
|
||||||
expect(tsConfig.include).toEqual([
|
expect(tsConfig.include).toEqual([
|
||||||
'**/*.ts',
|
'src/**/*.ts',
|
||||||
'**/*.tsx',
|
'src/**/*.tsx',
|
||||||
'**/*.js',
|
'src/**/*.js',
|
||||||
'**/*.jsx',
|
'src/**/*.jsx',
|
||||||
'.next/types/**/*.ts',
|
'.next/types/**/*.ts',
|
||||||
`dist/${name}/.next/types/**/*.ts`,
|
`dist/${name}/.next/types/**/*.ts`,
|
||||||
'next-env.d.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" }]
|
"plugins": [{ "name": "next" }]
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"**/*.ts",
|
"<%= rootPath %>**/*.ts",
|
||||||
"**/*.tsx",
|
"<%= rootPath %>**/*.tsx",
|
||||||
"**/*.js",
|
"<%= rootPath %>**/*.js",
|
||||||
"**/*.jsx",
|
"<%= rootPath %>**/*.jsx",
|
||||||
<% if (appDir) { %>
|
<% if (appDir) { %>
|
||||||
"<%= layoutTypeSrcPath %>",
|
"<%= layoutTypeSrcPath %>",
|
||||||
"<%= layoutTypeDistPath %>",
|
"<%= layoutTypeDistPath %>",
|
||||||
<% } %>
|
<% } %>
|
||||||
"next-env.d.ts"
|
"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,
|
options.outputPath,
|
||||||
'.next/types/**/*.ts'
|
'.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 = {
|
const templateVariables = {
|
||||||
...names(options.name),
|
...names(options.name),
|
||||||
...options,
|
...options,
|
||||||
@ -36,6 +45,7 @@ export function createApplicationFiles(host: Tree, options: NormalizedSchema) {
|
|||||||
tmpl: '',
|
tmpl: '',
|
||||||
offsetFromRoot,
|
offsetFromRoot,
|
||||||
layoutTypeSrcPath,
|
layoutTypeSrcPath,
|
||||||
|
rootPath,
|
||||||
layoutTypeDistPath,
|
layoutTypeDistPath,
|
||||||
rootTsConfigPath: getRelativePathToRootTsConfig(
|
rootTsConfigPath: getRelativePathToRootTsConfig(
|
||||||
host,
|
host,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user