File size: 1,238 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import * as fs from 'fs-extra';

import { paths } from './constants';

/*
  This was originally needed because the default
  tsconfig.compilerOptions.rootDir was set to './' instead of './src'.
  Now that it's set to './src', this is now deprecated.
  To ensure a stable upgrade path for users, leave the warning in for
  6 months - 1 year, then change it to an error in a breaking bump and leave
  that in for some time too.
*/
export async function moveTypes() {
  const appDistSrc = paths.appDist + '/src';

  const pathExists = await fs.pathExists(appDistSrc);
  if (!pathExists) return;

  // see note above about deprecation window
  console.warn(
    '[tsdx]: Your rootDir is currently set to "./". Please change your ' +
      'rootDir to "./src".\n' +
      'TSDX has deprecated setting tsconfig.compilerOptions.rootDir to ' +
      '"./" as it caused buggy output for declarationMaps and more.\n' +
      'You may also need to change your include to remove "test", which also ' +
      'caused declarations to be unnecessarily created for test files.'
  );

  // Move the type declarations to the base of the ./dist folder
  await fs.copy(appDistSrc, paths.appDist, {
    overwrite: true,
  });
  await fs.remove(appDistSrc);
}