@jcoreio/toolchain-typescript 5.4.5 → 5.5.1
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 +3 -3
- package/plugins/babelExtensions.cjs +4 -1
- package/plugins/compile.cjs +105 -0
- package/plugins/smokeTestBuild.cjs +11 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jcoreio/toolchain-typescript",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.1",
|
|
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.
|
|
25
|
-
"@jcoreio/toolchain-esnext": "5.
|
|
24
|
+
"@jcoreio/toolchain": "5.5.1",
|
|
25
|
+
"@jcoreio/toolchain-esnext": "5.5.1"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"typescript": "^5.1.0"
|
package/plugins/compile.cjs
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
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')
|
|
7
|
+
const babel = require('@babel/core')
|
|
4
8
|
|
|
5
9
|
module.exports = [
|
|
6
10
|
[
|
|
@@ -12,6 +16,107 @@ module.exports = [
|
|
|
12
16
|
...(toolchainConfig.sourceMaps ? ['--declarationMap'] : []),
|
|
13
17
|
])
|
|
14
18
|
}
|
|
19
|
+
const dtsFiles = await glob(Path.join('dist', '**', '*.d.ts'))
|
|
20
|
+
await Promise.all(
|
|
21
|
+
dtsFiles.map(async (src) => {
|
|
22
|
+
const dest = src.replace(/\.d\.ts$/, '.d.mts')
|
|
23
|
+
// eslint-disable-next-line no-console
|
|
24
|
+
console.error(src, '->', dest)
|
|
25
|
+
const content = await fs.readFile(src, 'utf8')
|
|
26
|
+
const parserOpts = {
|
|
27
|
+
sourceType: 'unambiguous',
|
|
28
|
+
allowImportExportEverywhere: true,
|
|
29
|
+
plugins: [
|
|
30
|
+
'asyncGenerators',
|
|
31
|
+
'bigInt',
|
|
32
|
+
'classProperties',
|
|
33
|
+
'classPrivateProperties',
|
|
34
|
+
'classPrivateMethods',
|
|
35
|
+
'classStaticBlock',
|
|
36
|
+
'dynamicImport',
|
|
37
|
+
'exportNamespaceFrom',
|
|
38
|
+
'exportDefaultFrom',
|
|
39
|
+
'functionSent',
|
|
40
|
+
'importMeta',
|
|
41
|
+
'logicalAssignment',
|
|
42
|
+
'moduleStringNames',
|
|
43
|
+
'nullishCoalescingOperator',
|
|
44
|
+
'numericSeparator',
|
|
45
|
+
'objectRestSpread',
|
|
46
|
+
'optionalCatchBinding',
|
|
47
|
+
'optionalChaining',
|
|
48
|
+
'privateIn',
|
|
49
|
+
'topLevelAwait',
|
|
50
|
+
['typescript', { dts: true }],
|
|
51
|
+
'decorators-legacy',
|
|
52
|
+
],
|
|
53
|
+
}
|
|
54
|
+
const [cts, mts] = await Promise.all([
|
|
55
|
+
babel.transformAsync(content, {
|
|
56
|
+
filename: src,
|
|
57
|
+
babelrc: false,
|
|
58
|
+
sourceMaps: true,
|
|
59
|
+
parserOpts,
|
|
60
|
+
plugins: [
|
|
61
|
+
[
|
|
62
|
+
'@jcoreio/toolchain-esnext/util/babelPluginResolveImports.cjs',
|
|
63
|
+
{ outputExtension: '.js' },
|
|
64
|
+
],
|
|
65
|
+
function ({ types: t }) {
|
|
66
|
+
return {
|
|
67
|
+
visitor: {
|
|
68
|
+
ExportDefaultDeclaration(path) {
|
|
69
|
+
const { declaration } = path.node
|
|
70
|
+
if (declaration.type === 'Identifier') {
|
|
71
|
+
path.replaceWith(t.tsExportAssignment(declaration))
|
|
72
|
+
} else if (
|
|
73
|
+
declaration.id &&
|
|
74
|
+
declaration.id.type === 'Identifier'
|
|
75
|
+
) {
|
|
76
|
+
path.replaceWithMultiple([
|
|
77
|
+
Object.assign(declaration, { declare: true }),
|
|
78
|
+
t.tsExportAssignment(
|
|
79
|
+
t.identifier(declaration.id.name)
|
|
80
|
+
),
|
|
81
|
+
])
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
}),
|
|
89
|
+
await babel.transformAsync(content, {
|
|
90
|
+
filename: src,
|
|
91
|
+
babelrc: false,
|
|
92
|
+
sourceMaps: true,
|
|
93
|
+
parserOpts,
|
|
94
|
+
plugins: [
|
|
95
|
+
[
|
|
96
|
+
'@jcoreio/toolchain-esnext/util/babelPluginResolveImports.cjs',
|
|
97
|
+
{ outputExtension: '.mjs' },
|
|
98
|
+
],
|
|
99
|
+
],
|
|
100
|
+
}),
|
|
101
|
+
])
|
|
102
|
+
cts.map.file = Path.basename(src)
|
|
103
|
+
mts.map.file = Path.basename(dest)
|
|
104
|
+
await Promise.all([
|
|
105
|
+
fs.writeFile(
|
|
106
|
+
src,
|
|
107
|
+
`${cts.code}\n//# sourceMappingURL=${Path.basename(src)}.map`,
|
|
108
|
+
'utf8'
|
|
109
|
+
),
|
|
110
|
+
fs.writeJson(`${src}.map`, cts.map),
|
|
111
|
+
fs.writeFile(
|
|
112
|
+
dest,
|
|
113
|
+
`${mts.code}\n//# sourceMappingURL=${Path.basename(dest)}.map`,
|
|
114
|
+
'utf8'
|
|
115
|
+
),
|
|
116
|
+
fs.writeJson(`${dest}.map`, mts.map),
|
|
117
|
+
])
|
|
118
|
+
})
|
|
119
|
+
)
|
|
15
120
|
},
|
|
16
121
|
{ after: ['@jcoreio/toolchain'], before: ['@jcoreio/toolchain-esnext'] },
|
|
17
122
|
],
|