@jcoreio/toolchain-typescript 5.4.5 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcoreio/toolchain-typescript",
3
- "version": "5.4.5",
3
+ "version": "5.5.0",
4
4
  "description": "TypeScript JS build toolchain",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,8 +21,8 @@
21
21
  "eslint": "^9.18.0",
22
22
  "json5": "^2.2.1",
23
23
  "typescript-eslint": "^8.29.0",
24
- "@jcoreio/toolchain": "5.4.5",
25
- "@jcoreio/toolchain-esnext": "5.4.5"
24
+ "@jcoreio/toolchain": "5.5.0",
25
+ "@jcoreio/toolchain-esnext": "5.5.0"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "typescript": "^5.1.0"
@@ -1,3 +1,6 @@
1
1
  const hasTSSourcesSync = require('@jcoreio/toolchain/util/hasTSSourcesSync.cjs')
2
2
 
3
- module.exports = hasTSSourcesSync() ? [() => ['.ts', '.tsx']] : []
3
+ module.exports =
4
+ hasTSSourcesSync() ?
5
+ [() => ['.ts', '.tsx', '.cts', '.ctsx', '.mts', '.mtsx']]
6
+ : []
@@ -1,5 +1,8 @@
1
+ const Path = require('path')
1
2
  const { toolchainConfig } = require('@jcoreio/toolchain/util/findUps.cjs')
2
3
  const execa = require('@jcoreio/toolchain/util/execa.cjs')
4
+ const { glob } = require('@jcoreio/toolchain/util/glob.cjs')
5
+ const fs = require('@jcoreio/toolchain/util/projectFs.cjs')
3
6
  const hasTSSourcesSync = require('@jcoreio/toolchain/util/hasTSSourcesSync.cjs')
4
7
 
5
8
  module.exports = [
@@ -11,6 +14,37 @@ module.exports = [
11
14
  'tsconfig.build.json',
12
15
  ...(toolchainConfig.sourceMaps ? ['--declarationMap'] : []),
13
16
  ])
17
+ const dtsFiles = await glob(Path.join('dist', '**', '*.d.ts'))
18
+ await Promise.all(
19
+ dtsFiles.map(async (src) => {
20
+ const dest = src.replace(/\.d\.ts$/, '.d.mts')
21
+ // eslint-disable-next-line no-console
22
+ console.error(src, '->', dest)
23
+ let content = await fs.readFile(src, 'utf8')
24
+ if (
25
+ content.endsWith(`sourceMappingURL=${Path.basename(src)}.map`)
26
+ ) {
27
+ content =
28
+ content.substring(
29
+ 0,
30
+ content.length -
31
+ `sourceMappingURL=${Path.basename(src)}.map`.length
32
+ ) + `sourceMappingURL=${Path.basename(dest)}.map`
33
+ }
34
+ await fs.writeFile(dest, content, 'utf8')
35
+ })
36
+ )
37
+ const mapFiles = await glob(Path.join('dist', '**', '*.d.ts.map'))
38
+ await Promise.all(
39
+ mapFiles.map(async (src) => {
40
+ const dest = src.replace(/\.d\.ts.map$/, '.d.mts.map')
41
+ const map = await fs.readJson(src)
42
+ map.file = Path.basename(dest)
43
+ // eslint-disable-next-line no-console
44
+ console.error(src, '->', dest)
45
+ await fs.writeJson(dest, map)
46
+ })
47
+ )
14
48
  }
15
49
  },
16
50
  { after: ['@jcoreio/toolchain'], before: ['@jcoreio/toolchain-esnext'] },