@jcoreio/toolchain-typescript 5.5.0 → 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/compile.cjs +102 -31
- 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.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.5.
|
|
25
|
-
"@jcoreio/toolchain-esnext": "5.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
|
@@ -4,6 +4,7 @@ const execa = require('@jcoreio/toolchain/util/execa.cjs')
|
|
|
4
4
|
const { glob } = require('@jcoreio/toolchain/util/glob.cjs')
|
|
5
5
|
const fs = require('@jcoreio/toolchain/util/projectFs.cjs')
|
|
6
6
|
const hasTSSourcesSync = require('@jcoreio/toolchain/util/hasTSSourcesSync.cjs')
|
|
7
|
+
const babel = require('@babel/core')
|
|
7
8
|
|
|
8
9
|
module.exports = [
|
|
9
10
|
[
|
|
@@ -14,38 +15,108 @@ module.exports = [
|
|
|
14
15
|
'tsconfig.build.json',
|
|
15
16
|
...(toolchainConfig.sourceMaps ? ['--declarationMap'] : []),
|
|
16
17
|
])
|
|
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
|
-
)
|
|
48
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
|
+
)
|
|
49
120
|
},
|
|
50
121
|
{ after: ['@jcoreio/toolchain'], before: ['@jcoreio/toolchain-esnext'] },
|
|
51
122
|
],
|