Repository: nuxt/nuxt
File: packages/kit/src/template.ts (TypeScript)

Code before:
  // Resolve dst
  template.dst ||= resolve(buildDir ?? useNuxt().options.buildDir, template.filename)

  return template as ResolvedNuxtTemplate<T>
}

/**
 * Trigger rebuilding Nuxt templates
 *
 * You can pass a filter within the options to selectively regenerate a subset of templates.
 */
export async function updateTemplates (options?: { filter?: (template: ResolvedNuxtTemplate<any>) => boolean }) {
  return await tryUseNuxt()?.hooks.callHook('builder:generateApp', options)
}

export function resolveLayerPaths (dirs: LayerDirectories, projectBuildDir: string) {
  const relativeRootDir = relativeWithDot(projectBuildDir, dirs.root)
  const relativeSrcDir = relativeWithDot(projectBuildDir, dirs.app)
  const relativeModulesDir = relativeWithDot(projectBuildDir, dirs.modules)
  const relativeSharedDir = relativeWithDot(projectBuildDir, dirs.shared)
  return {
    nuxt: [
      join(relativeSrcDir, '**/*'),
      join(relativeModulesDir, `*/runtime/**/*`),
      join(relativeRootDir, `test/**/*`),
      join(relativeRootDir, `tests/**/*`),
      join(relativeRootDir, `layers/*/app/**/*`),
      join(relativeRootDir, `layers/*/modules/*/runtime/**/*`),
    ],
    nitro: [
      join(relativeModulesDir, `*/runtime/server/**/*`),
      join(relativeRootDir, `layers/*/server/**/*`),
      join(relativeRootDir, `layers/*/modules/*/runtime/server/**/*`),
    ],
    node: [
      join(relativeModulesDir, `*.*`),
      join(relativeRootDir, `nuxt.config.*`),
      join(relativeRootDir, `.config/nuxt.*`),
      join(relativeRootDir, `layers/*/nuxt.config.*`),
      join(relativeRootDir, `layers/*/.config/nuxt.*`),
      join(relativeRootDir, `layers/*/modules/**/*`),
    ],
    shared: [
      join(relativeSharedDir, `**/*`),
      join(relativeModulesDir, `*/shared/**/*`),
      join(relativeRootDir, `layers/*/shared/**/*`),
    ],
    sharedDeclarations: [
      join(relativeSharedDir, `**/*.d.ts`),
      join(relativeModulesDir, `*/shared/**/*.d.ts`),
      join(relativeRootDir, `layers/*/shared/**/*.d.ts`),

Review comment (suggestion):
this is slightly safer:

```suggestion
      join(relativeRootDir, `test/nuxt/**/*`),
      join(relativeRootDir, `tests/nuxt/**/*`),
```

... and we can document in the testing.md file how to add other directories if nuxt runtime environment is located elsewhere.

Code after:
  // Resolve dst
  template.dst ||= resolve(buildDir ?? useNuxt().options.buildDir, template.filename)

  return template as ResolvedNuxtTemplate<T>
}

/**
 * Trigger rebuilding Nuxt templates
 *
 * You can pass a filter within the options to selectively regenerate a subset of templates.
 */
export async function updateTemplates (options?: { filter?: (template: ResolvedNuxtTemplate<any>) => boolean }) {
  return await tryUseNuxt()?.hooks.callHook('builder:generateApp', options)
}

export function resolveLayerPaths (dirs: LayerDirectories, projectBuildDir: string) {
  const relativeRootDir = relativeWithDot(projectBuildDir, dirs.root)
  const relativeSrcDir = relativeWithDot(projectBuildDir, dirs.app)
  const relativeModulesDir = relativeWithDot(projectBuildDir, dirs.modules)
  const relativeSharedDir = relativeWithDot(projectBuildDir, dirs.shared)
  return {
    nuxt: [
      join(relativeSrcDir, '**/*'),
      join(relativeModulesDir, `*/runtime/**/*`),
      join(relativeRootDir, `test/nuxt/**/*`),
      join(relativeRootDir, `tests/nuxt/**/*`),
      join(relativeRootDir, `layers/*/app/**/*`),
      join(relativeRootDir, `layers/*/modules/*/runtime/**/*`),
    ],
    nitro: [
      join(relativeModulesDir, `*/runtime/server/**/*`),
      join(relativeRootDir, `layers/*/server/**/*`),
      join(relativeRootDir, `layers/*/modules/*/runtime/server/**/*`),
    ],
    node: [
      join(relativeModulesDir, `*.*`),
      join(relativeRootDir, `nuxt.config.*`),
      join(relativeRootDir, `.config/nuxt.*`),
      join(relativeRootDir, `layers/*/nuxt.config.*`),
      join(relativeRootDir, `layers/*/.config/nuxt.*`),
      join(relativeRootDir, `layers/*/modules/**/*`),
    ],
    shared: [
      join(relativeSharedDir, `**/*`),
      join(relativeModulesDir, `*/shared/**/*`),
      join(relativeRootDir, `layers/*/shared/**/*`),
    ],
    sharedDeclarations: [
      join(relativeSharedDir, `**/*.d.ts`),
      join(relativeModulesDir, `*/shared/**/*.d.ts`),
      join(relativeRootDir, `layers/*/shared/**/*.d.ts`),