Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: conditional type exports (T1177805) (#3661)
* conditional type exports * Fix the filename regexp Co-authored-by: Timofey Traynenkov <timbset@gmail.com> * typings copying now works for dx-react-grid-export * address Timpohey's remarks * refactor utils -> getPackageInfo --------- Co-authored-by: Timofey Traynenkov <timbset@gmail.com>
- Loading branch information
1 parent
6f6588a
commit db3373d
Showing
20 changed files
with
165 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
import { fileURLToPath } from 'url'; | ||
import { dirname } from 'path'; | ||
import { dirname, join } from 'path'; | ||
|
||
import buildDefinitions from '../../scripts/merge-dts.js'; | ||
import { copyCommonJsTypes, getPackageInfo } from '../../scripts/utils.js'; | ||
|
||
buildDefinitions(dirname(fileURLToPath(import.meta.url)), true); | ||
const packageDirectory = dirname(fileURLToPath(import.meta.url)); | ||
const pkg = getPackageInfo(packageDirectory); | ||
const dtsOutFile = join(packageDirectory, pkg.types); | ||
|
||
buildDefinitions(packageDirectory, true); | ||
copyCommonJsTypes(dtsOutFile); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { existsSync, copyFileSync, readFileSync } from 'fs'; | ||
import { join } from 'path'; | ||
|
||
const getCommonJsTypesPath = dtsPath => dtsPath.replace(/\.ts$/, '.cts'); | ||
|
||
export const copyCommonJsTypes = (dtsPath) => { | ||
if (existsSync(dtsPath)) { | ||
copyFileSync(dtsPath, getCommonJsTypesPath(dtsPath)); | ||
} | ||
}; | ||
|
||
export const getPackageInfo = (packageDir) => { | ||
const packagePath = join(packageDir, 'package.json'); | ||
const packageData = readFileSync(packagePath); | ||
|
||
return JSON.parse(packageData); | ||
}; |