ttsc 0.7.2 → 0.8.0-dev.20260505
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/README.md +5 -5
- package/cmd/platform/main.go +86 -76
- package/cmd/ttsc/api_compile.go +122 -105
- package/cmd/ttsc/api_transform.go +57 -49
- package/cmd/ttsc/build.go +116 -103
- package/cmd/ttsc/main.go +117 -117
- package/cmd/ttsc/main_test.go +191 -191
- package/driver/host.go +9 -9
- package/driver/program.go +285 -285
- package/driver/rewrite.go +266 -219
- package/lib/compiler/internal/compileProjectInMemory.js +3 -3
- package/lib/compiler/internal/compileProjectInMemory.js.map +1 -1
- package/lib/compiler/internal/resolveEmittedJavaScript.js +2 -1
- package/lib/compiler/internal/resolveEmittedJavaScript.js.map +1 -1
- package/lib/compiler/internal/resolveTsgo.js.map +1 -1
- package/lib/compiler/internal/runBuild.js +47 -49
- package/lib/compiler/internal/runBuild.js.map +1 -1
- package/lib/compiler/internal/transformProjectInMemory.js +44 -4
- package/lib/compiler/internal/transformProjectInMemory.js.map +1 -1
- package/lib/launcher/internal/getCompilerVersionText.js +1 -2
- package/lib/launcher/internal/getCompilerVersionText.js.map +1 -1
- package/lib/launcher/internal/prepareExecution.js +6 -4
- package/lib/launcher/internal/prepareExecution.js.map +1 -1
- package/lib/launcher/internal/runTtsc.js +49 -5
- package/lib/launcher/internal/runTtsc.js.map +1 -1
- package/lib/launcher/internal/runTtsx.js +7 -2
- package/lib/launcher/internal/runTtsx.js.map +1 -1
- package/lib/plugin/internal/buildSourcePlugin.js +6 -0
- package/lib/plugin/internal/buildSourcePlugin.js.map +1 -1
- package/lib/plugin/internal/loadProjectPlugins.js +55 -2
- package/lib/plugin/internal/loadProjectPlugins.js.map +1 -1
- package/lib/structures/ITtscPlugin.d.ts +19 -3
- package/lib/structures/ITtscPlugin.js +4 -0
- package/lib/structures/ITtscPlugin.js.map +1 -1
- package/lib/structures/TtscPluginStage.d.ts +4 -10
- package/lib/structures/internal/ITtscLoadedNativePlugin.d.ts +5 -0
- package/package.json +11 -10
- package/shim/ast/lint.go +172 -171
- package/shim/ast/shim.go +84 -83
- package/shim/bundled/shim.go +5 -1
- package/shim/checker/shim.go +79 -79
- package/shim/compiler/emit_hooks.go +494 -0
- package/shim/compiler/shim.go +16 -1
- package/shim/core/shim.go +13 -10
- package/shim/diagnosticwriter/lint.go +79 -79
- package/shim/diagnosticwriter/shim.go +19 -19
- package/shim/parser/shim.go +7 -1
- package/shim/scanner/shim.go +39 -1
- package/shim/tsoptions/shim.go +51 -1
- package/shim/tspath/shim.go +72 -1
- package/shim/vfs/cachedvfs/shim.go +1 -1
- package/shim/vfs/osvfs/shim.go +1 -1
- package/shim/vfs/shim.go +4 -1
- package/src/compiler/internal/compileProjectInMemory.ts +6 -3
- package/src/compiler/internal/resolveEmittedJavaScript.ts +2 -1
- package/src/compiler/internal/resolveTsgo.ts +0 -1
- package/src/compiler/internal/runBuild.ts +58 -86
- package/src/compiler/internal/transformProjectInMemory.ts +51 -6
- package/src/launcher/internal/getCompilerVersionText.ts +1 -2
- package/src/launcher/internal/prepareExecution.ts +6 -6
- package/src/launcher/internal/runTtsc.ts +52 -5
- package/src/launcher/internal/runTtsx.ts +16 -5
- package/src/plugin/internal/buildSourcePlugin.ts +30 -2
- package/src/plugin/internal/loadProjectPlugins.ts +81 -2
- package/src/structures/ITtscPlugin.ts +30 -3
- package/src/structures/TtscPluginStage.ts +4 -10
- package/src/structures/internal/ITtscLoadedNativePlugin.ts +5 -0
- package/test/compiler.test.ts +3 -3
- package/test/platform.test.ts +1 -3
- package/test/tsgo.test.ts +15 -7
- package/tools/gen_shims/main.go +409 -409
- package/utility/host.go +707 -0
package/shim/tspath/shim.go
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
// Code generated by packages/ttsc/tools/gen_shims. DO NOT EDIT.
|
|
3
2
|
|
|
4
3
|
package tspath
|
|
@@ -8,43 +7,62 @@ import _ "unsafe"
|
|
|
8
7
|
|
|
9
8
|
var AllSupportedExtensions = tspath.AllSupportedExtensions
|
|
10
9
|
var AllSupportedExtensionsWithJson = tspath.AllSupportedExtensionsWithJson
|
|
10
|
+
|
|
11
11
|
//go:linkname ChangeAnyExtension github.com/microsoft/typescript-go/internal/tspath.ChangeAnyExtension
|
|
12
12
|
func ChangeAnyExtension(path string, ext string, extensions []string, ignoreCase bool) string
|
|
13
|
+
|
|
13
14
|
//go:linkname ChangeExtension github.com/microsoft/typescript-go/internal/tspath.ChangeExtension
|
|
14
15
|
func ChangeExtension(path string, newExtension string) string
|
|
16
|
+
|
|
15
17
|
//go:linkname ChangeFullExtension github.com/microsoft/typescript-go/internal/tspath.ChangeFullExtension
|
|
16
18
|
func ChangeFullExtension(path string, newExtension string) string
|
|
19
|
+
|
|
17
20
|
//go:linkname CombinePaths github.com/microsoft/typescript-go/internal/tspath.CombinePaths
|
|
18
21
|
func CombinePaths(firstPath string, paths ...string) string
|
|
22
|
+
|
|
19
23
|
//go:linkname CompareNumberOfDirectorySeparators github.com/microsoft/typescript-go/internal/tspath.CompareNumberOfDirectorySeparators
|
|
20
24
|
func CompareNumberOfDirectorySeparators(path1 string, path2 string) int
|
|
25
|
+
|
|
21
26
|
//go:linkname ComparePaths github.com/microsoft/typescript-go/internal/tspath.ComparePaths
|
|
22
27
|
func ComparePaths(a string, b string, options tspath.ComparePathsOptions) int
|
|
28
|
+
|
|
23
29
|
//go:linkname ComparePathsCaseInsensitive github.com/microsoft/typescript-go/internal/tspath.ComparePathsCaseInsensitive
|
|
24
30
|
func ComparePathsCaseInsensitive(a string, b string, currentDirectory string) int
|
|
31
|
+
|
|
25
32
|
//go:linkname ComparePathsCaseSensitive github.com/microsoft/typescript-go/internal/tspath.ComparePathsCaseSensitive
|
|
26
33
|
func ComparePathsCaseSensitive(a string, b string, currentDirectory string) int
|
|
34
|
+
|
|
27
35
|
type ComparePathsOptions = tspath.ComparePathsOptions
|
|
36
|
+
|
|
28
37
|
//go:linkname ContainsIgnoredPath github.com/microsoft/typescript-go/internal/tspath.ContainsIgnoredPath
|
|
29
38
|
func ContainsIgnoredPath(path string) bool
|
|
39
|
+
|
|
30
40
|
//go:linkname ContainsPath github.com/microsoft/typescript-go/internal/tspath.ContainsPath
|
|
31
41
|
func ContainsPath(parent string, child string, options tspath.ComparePathsOptions) bool
|
|
42
|
+
|
|
32
43
|
//go:linkname ConvertToRelativePath github.com/microsoft/typescript-go/internal/tspath.ConvertToRelativePath
|
|
33
44
|
func ConvertToRelativePath(absoluteOrRelativePath string, options tspath.ComparePathsOptions) string
|
|
45
|
+
|
|
34
46
|
const DirectorySeparator = tspath.DirectorySeparator
|
|
47
|
+
|
|
35
48
|
//go:linkname EnsurePathIsNonModuleName github.com/microsoft/typescript-go/internal/tspath.EnsurePathIsNonModuleName
|
|
36
49
|
func EnsurePathIsNonModuleName(path string) string
|
|
50
|
+
|
|
37
51
|
//go:linkname EnsureTrailingDirectorySeparator github.com/microsoft/typescript-go/internal/tspath.EnsureTrailingDirectorySeparator
|
|
38
52
|
func EnsureTrailingDirectorySeparator(path string) string
|
|
53
|
+
|
|
39
54
|
const ExtensionCjs = tspath.ExtensionCjs
|
|
40
55
|
const ExtensionCts = tspath.ExtensionCts
|
|
41
56
|
const ExtensionDcts = tspath.ExtensionDcts
|
|
42
57
|
const ExtensionDmts = tspath.ExtensionDmts
|
|
43
58
|
const ExtensionDts = tspath.ExtensionDts
|
|
59
|
+
|
|
44
60
|
//go:linkname ExtensionIsOneOf github.com/microsoft/typescript-go/internal/tspath.ExtensionIsOneOf
|
|
45
61
|
func ExtensionIsOneOf(ext string, extensions []string) bool
|
|
62
|
+
|
|
46
63
|
//go:linkname ExtensionIsTs github.com/microsoft/typescript-go/internal/tspath.ExtensionIsTs
|
|
47
64
|
func ExtensionIsTs(ext string) bool
|
|
65
|
+
|
|
48
66
|
const ExtensionJs = tspath.ExtensionJs
|
|
49
67
|
const ExtensionJson = tspath.ExtensionJson
|
|
50
68
|
const ExtensionJsx = tspath.ExtensionJsx
|
|
@@ -53,100 +71,149 @@ const ExtensionMts = tspath.ExtensionMts
|
|
|
53
71
|
const ExtensionTs = tspath.ExtensionTs
|
|
54
72
|
const ExtensionTsBuildInfo = tspath.ExtensionTsBuildInfo
|
|
55
73
|
const ExtensionTsx = tspath.ExtensionTsx
|
|
74
|
+
|
|
56
75
|
var ExtensionsNotSupportingExtensionlessResolution = tspath.ExtensionsNotSupportingExtensionlessResolution
|
|
76
|
+
|
|
57
77
|
//go:linkname FileExtensionIs github.com/microsoft/typescript-go/internal/tspath.FileExtensionIs
|
|
58
78
|
func FileExtensionIs(path string, extension string) bool
|
|
79
|
+
|
|
59
80
|
//go:linkname FileExtensionIsOneOf github.com/microsoft/typescript-go/internal/tspath.FileExtensionIsOneOf
|
|
60
81
|
func FileExtensionIsOneOf(path string, extensions []string) bool
|
|
82
|
+
|
|
61
83
|
//go:linkname GetAnyExtensionFromPath github.com/microsoft/typescript-go/internal/tspath.GetAnyExtensionFromPath
|
|
62
84
|
func GetAnyExtensionFromPath(path string, extensions []string, ignoreCase bool) string
|
|
85
|
+
|
|
63
86
|
//go:linkname GetBaseFileName github.com/microsoft/typescript-go/internal/tspath.GetBaseFileName
|
|
64
87
|
func GetBaseFileName(path string) string
|
|
88
|
+
|
|
65
89
|
//go:linkname GetCanonicalFileName github.com/microsoft/typescript-go/internal/tspath.GetCanonicalFileName
|
|
66
90
|
func GetCanonicalFileName(fileName string, useCaseSensitiveFileNames bool) string
|
|
91
|
+
|
|
67
92
|
//go:linkname GetCommonParents github.com/microsoft/typescript-go/internal/tspath.GetCommonParents
|
|
68
93
|
func GetCommonParents(paths []string, minComponents int, getPathComponents func(path string, currentDirectory string) []string, options tspath.ComparePathsOptions) (parents []string, ignored map[string]struct{})
|
|
94
|
+
|
|
69
95
|
//go:linkname GetDeclarationEmitExtensionForPath github.com/microsoft/typescript-go/internal/tspath.GetDeclarationEmitExtensionForPath
|
|
70
96
|
func GetDeclarationEmitExtensionForPath(path string) string
|
|
97
|
+
|
|
71
98
|
//go:linkname GetDeclarationFileExtension github.com/microsoft/typescript-go/internal/tspath.GetDeclarationFileExtension
|
|
72
99
|
func GetDeclarationFileExtension(fileName string) string
|
|
100
|
+
|
|
73
101
|
//go:linkname GetDirectoryPath github.com/microsoft/typescript-go/internal/tspath.GetDirectoryPath
|
|
74
102
|
func GetDirectoryPath(path string) string
|
|
103
|
+
|
|
75
104
|
//go:linkname GetEncodedRootLength github.com/microsoft/typescript-go/internal/tspath.GetEncodedRootLength
|
|
76
105
|
func GetEncodedRootLength(path string) int
|
|
106
|
+
|
|
77
107
|
//go:linkname GetNormalizedAbsolutePath github.com/microsoft/typescript-go/internal/tspath.GetNormalizedAbsolutePath
|
|
78
108
|
func GetNormalizedAbsolutePath(fileName string, currentDirectory string) string
|
|
109
|
+
|
|
79
110
|
//go:linkname GetNormalizedAbsolutePathWithoutRoot github.com/microsoft/typescript-go/internal/tspath.GetNormalizedAbsolutePathWithoutRoot
|
|
80
111
|
func GetNormalizedAbsolutePathWithoutRoot(fileName string, currentDirectory string) string
|
|
112
|
+
|
|
81
113
|
//go:linkname GetNormalizedPathComponents github.com/microsoft/typescript-go/internal/tspath.GetNormalizedPathComponents
|
|
82
114
|
func GetNormalizedPathComponents(path string, currentDirectory string) []string
|
|
115
|
+
|
|
83
116
|
//go:linkname GetPathComponents github.com/microsoft/typescript-go/internal/tspath.GetPathComponents
|
|
84
117
|
func GetPathComponents(path string, currentDirectory string) []string
|
|
118
|
+
|
|
85
119
|
//go:linkname GetPathComponentsRelativeTo github.com/microsoft/typescript-go/internal/tspath.GetPathComponentsRelativeTo
|
|
86
120
|
func GetPathComponentsRelativeTo(from string, to string, options tspath.ComparePathsOptions) []string
|
|
121
|
+
|
|
87
122
|
//go:linkname GetPathFromPathComponents github.com/microsoft/typescript-go/internal/tspath.GetPathFromPathComponents
|
|
88
123
|
func GetPathFromPathComponents(pathComponents []string) string
|
|
124
|
+
|
|
89
125
|
//go:linkname GetPossibleOriginalInputExtensionForExtension github.com/microsoft/typescript-go/internal/tspath.GetPossibleOriginalInputExtensionForExtension
|
|
90
126
|
func GetPossibleOriginalInputExtensionForExtension(path string) []string
|
|
127
|
+
|
|
91
128
|
//go:linkname GetRelativePathFromDirectory github.com/microsoft/typescript-go/internal/tspath.GetRelativePathFromDirectory
|
|
92
129
|
func GetRelativePathFromDirectory(fromDirectory string, to string, options tspath.ComparePathsOptions) string
|
|
130
|
+
|
|
93
131
|
//go:linkname GetRelativePathFromFile github.com/microsoft/typescript-go/internal/tspath.GetRelativePathFromFile
|
|
94
132
|
func GetRelativePathFromFile(from string, to string, options tspath.ComparePathsOptions) string
|
|
133
|
+
|
|
95
134
|
//go:linkname GetRelativePathToDirectoryOrUrl github.com/microsoft/typescript-go/internal/tspath.GetRelativePathToDirectoryOrUrl
|
|
96
135
|
func GetRelativePathToDirectoryOrUrl(directoryPathOrUrl string, relativeOrAbsolutePath string, isAbsolutePathAnUrl bool, options tspath.ComparePathsOptions) string
|
|
136
|
+
|
|
97
137
|
//go:linkname GetRootLength github.com/microsoft/typescript-go/internal/tspath.GetRootLength
|
|
98
138
|
func GetRootLength(path string) int
|
|
139
|
+
|
|
99
140
|
//go:linkname HasExtension github.com/microsoft/typescript-go/internal/tspath.HasExtension
|
|
100
141
|
func HasExtension(fileName string) bool
|
|
142
|
+
|
|
101
143
|
//go:linkname HasImplementationTSFileExtension github.com/microsoft/typescript-go/internal/tspath.HasImplementationTSFileExtension
|
|
102
144
|
func HasImplementationTSFileExtension(path string) bool
|
|
145
|
+
|
|
103
146
|
//go:linkname HasJSFileExtension github.com/microsoft/typescript-go/internal/tspath.HasJSFileExtension
|
|
104
147
|
func HasJSFileExtension(path string) bool
|
|
148
|
+
|
|
105
149
|
//go:linkname HasJSONFileExtension github.com/microsoft/typescript-go/internal/tspath.HasJSONFileExtension
|
|
106
150
|
func HasJSONFileExtension(path string) bool
|
|
151
|
+
|
|
107
152
|
//go:linkname HasTSFileExtension github.com/microsoft/typescript-go/internal/tspath.HasTSFileExtension
|
|
108
153
|
func HasTSFileExtension(path string) bool
|
|
154
|
+
|
|
109
155
|
//go:linkname HasTrailingDirectorySeparator github.com/microsoft/typescript-go/internal/tspath.HasTrailingDirectorySeparator
|
|
110
156
|
func HasTrailingDirectorySeparator(path string) bool
|
|
157
|
+
|
|
111
158
|
//go:linkname IsDeclarationFileName github.com/microsoft/typescript-go/internal/tspath.IsDeclarationFileName
|
|
112
159
|
func IsDeclarationFileName(fileName string) bool
|
|
160
|
+
|
|
113
161
|
//go:linkname IsDiskPathRoot github.com/microsoft/typescript-go/internal/tspath.IsDiskPathRoot
|
|
114
162
|
func IsDiskPathRoot(path string) bool
|
|
163
|
+
|
|
115
164
|
//go:linkname IsDynamicFileName github.com/microsoft/typescript-go/internal/tspath.IsDynamicFileName
|
|
116
165
|
func IsDynamicFileName(fileName string) bool
|
|
166
|
+
|
|
117
167
|
//go:linkname IsExternalModuleNameRelative github.com/microsoft/typescript-go/internal/tspath.IsExternalModuleNameRelative
|
|
118
168
|
func IsExternalModuleNameRelative(moduleName string) bool
|
|
169
|
+
|
|
119
170
|
//go:linkname IsRootedDiskPath github.com/microsoft/typescript-go/internal/tspath.IsRootedDiskPath
|
|
120
171
|
func IsRootedDiskPath(path string) bool
|
|
172
|
+
|
|
121
173
|
//go:linkname IsUrl github.com/microsoft/typescript-go/internal/tspath.IsUrl
|
|
122
174
|
func IsUrl(path string) bool
|
|
175
|
+
|
|
123
176
|
//go:linkname IsVolumeCharacter github.com/microsoft/typescript-go/internal/tspath.IsVolumeCharacter
|
|
124
177
|
func IsVolumeCharacter(char byte) bool
|
|
178
|
+
|
|
125
179
|
//go:linkname NormalizePath github.com/microsoft/typescript-go/internal/tspath.NormalizePath
|
|
126
180
|
func NormalizePath(path string) string
|
|
181
|
+
|
|
127
182
|
//go:linkname NormalizeSlashes github.com/microsoft/typescript-go/internal/tspath.NormalizeSlashes
|
|
128
183
|
func NormalizeSlashes(path string) string
|
|
184
|
+
|
|
129
185
|
type Path = tspath.Path
|
|
186
|
+
|
|
130
187
|
//go:linkname PathIsAbsolute github.com/microsoft/typescript-go/internal/tspath.PathIsAbsolute
|
|
131
188
|
func PathIsAbsolute(path string) bool
|
|
189
|
+
|
|
132
190
|
//go:linkname PathIsRelative github.com/microsoft/typescript-go/internal/tspath.PathIsRelative
|
|
133
191
|
func PathIsRelative(path string) bool
|
|
192
|
+
|
|
134
193
|
//go:linkname RemoveExtension github.com/microsoft/typescript-go/internal/tspath.RemoveExtension
|
|
135
194
|
func RemoveExtension(path string, extension string) string
|
|
195
|
+
|
|
136
196
|
//go:linkname RemoveFileExtension github.com/microsoft/typescript-go/internal/tspath.RemoveFileExtension
|
|
137
197
|
func RemoveFileExtension(path string) string
|
|
198
|
+
|
|
138
199
|
//go:linkname RemoveTrailingDirectorySeparator github.com/microsoft/typescript-go/internal/tspath.RemoveTrailingDirectorySeparator
|
|
139
200
|
func RemoveTrailingDirectorySeparator(path string) string
|
|
201
|
+
|
|
140
202
|
//go:linkname RemoveTrailingDirectorySeparators github.com/microsoft/typescript-go/internal/tspath.RemoveTrailingDirectorySeparators
|
|
141
203
|
func RemoveTrailingDirectorySeparators(path string) string
|
|
204
|
+
|
|
142
205
|
//go:linkname ResolvePath github.com/microsoft/typescript-go/internal/tspath.ResolvePath
|
|
143
206
|
func ResolvePath(path string, paths ...string) string
|
|
207
|
+
|
|
144
208
|
//go:linkname ResolveTripleslashReference github.com/microsoft/typescript-go/internal/tspath.ResolveTripleslashReference
|
|
145
209
|
func ResolveTripleslashReference(moduleName string, containingFile string) string
|
|
210
|
+
|
|
146
211
|
//go:linkname SplitVolumePath github.com/microsoft/typescript-go/internal/tspath.SplitVolumePath
|
|
147
212
|
func SplitVolumePath(path string) (volume string, rest string, ok bool)
|
|
213
|
+
|
|
148
214
|
//go:linkname StartsWithDirectory github.com/microsoft/typescript-go/internal/tspath.StartsWithDirectory
|
|
149
215
|
func StartsWithDirectory(fileName string, directoryName string, useCaseSensitiveFileNames bool) bool
|
|
216
|
+
|
|
150
217
|
var SupportedDeclarationExtensions = tspath.SupportedDeclarationExtensions
|
|
151
218
|
var SupportedJSExtensions = tspath.SupportedJSExtensions
|
|
152
219
|
var SupportedJSExtensionsFlat = tspath.SupportedJSExtensionsFlat
|
|
@@ -155,11 +222,15 @@ var SupportedTSExtensionsFlat = tspath.SupportedTSExtensionsFlat
|
|
|
155
222
|
var SupportedTSExtensionsWithJson = tspath.SupportedTSExtensionsWithJson
|
|
156
223
|
var SupportedTSExtensionsWithJsonFlat = tspath.SupportedTSExtensionsWithJsonFlat
|
|
157
224
|
var SupportedTSImplementationExtensions = tspath.SupportedTSImplementationExtensions
|
|
225
|
+
|
|
158
226
|
//go:linkname ToFileNameLowerCase github.com/microsoft/typescript-go/internal/tspath.ToFileNameLowerCase
|
|
159
227
|
func ToFileNameLowerCase(fileName string) string
|
|
228
|
+
|
|
160
229
|
//go:linkname ToPath github.com/microsoft/typescript-go/internal/tspath.ToPath
|
|
161
230
|
func ToPath(fileName string, basePath string, useCaseSensitiveFileNames bool) tspath.Path
|
|
231
|
+
|
|
162
232
|
//go:linkname TryExtractTSExtension github.com/microsoft/typescript-go/internal/tspath.TryExtractTSExtension
|
|
163
233
|
func TryExtractTSExtension(fileName string) string
|
|
234
|
+
|
|
164
235
|
//go:linkname TryGetExtensionFromPath github.com/microsoft/typescript-go/internal/tspath.TryGetExtensionFromPath
|
|
165
236
|
func TryGetExtensionFromPath(p string) string
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
// Code generated by packages/ttsc/tools/gen_shims. DO NOT EDIT.
|
|
3
2
|
|
|
4
3
|
package cachedvfs
|
|
@@ -8,5 +7,6 @@ import "github.com/microsoft/typescript-go/internal/vfs/cachedvfs"
|
|
|
8
7
|
import _ "unsafe"
|
|
9
8
|
|
|
10
9
|
type FS = cachedvfs.FS
|
|
10
|
+
|
|
11
11
|
//go:linkname From github.com/microsoft/typescript-go/internal/vfs/cachedvfs.From
|
|
12
12
|
func From(fs vfs.FS) *cachedvfs.FS
|
package/shim/vfs/osvfs/shim.go
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
// Code generated by packages/ttsc/tools/gen_shims. DO NOT EDIT.
|
|
3
2
|
|
|
4
3
|
package osvfs
|
|
@@ -9,5 +8,6 @@ import _ "unsafe"
|
|
|
9
8
|
|
|
10
9
|
//go:linkname FS github.com/microsoft/typescript-go/internal/vfs/osvfs.FS
|
|
11
10
|
func FS() vfs.FS
|
|
11
|
+
|
|
12
12
|
//go:linkname GetGlobalTypingsCacheLocation github.com/microsoft/typescript-go/internal/vfs/osvfs.GetGlobalTypingsCacheLocation
|
|
13
13
|
func GetGlobalTypingsCacheLocation() string
|
package/shim/vfs/shim.go
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
// Code generated by packages/ttsc/tools/gen_shims. DO NOT EDIT.
|
|
3
2
|
|
|
4
3
|
package vfs
|
|
@@ -7,13 +6,17 @@ import "github.com/microsoft/typescript-go/internal/vfs"
|
|
|
7
6
|
|
|
8
7
|
type DirEntry = vfs.DirEntry
|
|
9
8
|
type Entries = vfs.Entries
|
|
9
|
+
|
|
10
10
|
var ErrClosed = vfs.ErrClosed
|
|
11
11
|
var ErrExist = vfs.ErrExist
|
|
12
12
|
var ErrInvalid = vfs.ErrInvalid
|
|
13
13
|
var ErrNotExist = vfs.ErrNotExist
|
|
14
14
|
var ErrPermission = vfs.ErrPermission
|
|
15
|
+
|
|
15
16
|
type FS = vfs.FS
|
|
16
17
|
type FileInfo = vfs.FileInfo
|
|
18
|
+
|
|
17
19
|
var SkipAll = vfs.SkipAll
|
|
18
20
|
var SkipDir = vfs.SkipDir
|
|
21
|
+
|
|
19
22
|
type WalkDirFunc = vfs.WalkDirFunc
|
|
@@ -125,8 +125,10 @@ function readOutputDirectory(
|
|
|
125
125
|
return output;
|
|
126
126
|
}
|
|
127
127
|
for (const file of listFiles(directory)) {
|
|
128
|
-
output[keyOf(pathToKey(path.relative(directory, file)))] =
|
|
129
|
-
|
|
128
|
+
output[keyOf(pathToKey(path.relative(directory, file)))] = fs.readFileSync(
|
|
129
|
+
file,
|
|
130
|
+
"utf8",
|
|
131
|
+
);
|
|
130
132
|
}
|
|
131
133
|
return output;
|
|
132
134
|
}
|
|
@@ -166,7 +168,8 @@ function parseNativeCompileOutput(
|
|
|
166
168
|
};
|
|
167
169
|
} catch {
|
|
168
170
|
throw new Error(
|
|
169
|
-
(stderr || stdout).trim() ||
|
|
171
|
+
(stderr || stdout).trim() ||
|
|
172
|
+
"ttsc: native compiler host returned no output",
|
|
170
173
|
);
|
|
171
174
|
}
|
|
172
175
|
}
|
|
@@ -19,7 +19,8 @@ export function resolveEmittedJavaScript(options: {
|
|
|
19
19
|
|
|
20
20
|
let best: string | null = null;
|
|
21
21
|
let bestScore = 0;
|
|
22
|
-
for (const file of options.emittedFiles ??
|
|
22
|
+
for (const file of options.emittedFiles ??
|
|
23
|
+
listJavaScriptFiles(options.outDir)) {
|
|
23
24
|
if (!isJavaScriptOutput(file)) continue;
|
|
24
25
|
const score = sharedSourceStemSegments(file, options.sourceFile);
|
|
25
26
|
if (score > bestScore) {
|
|
@@ -99,9 +99,6 @@ export function runBuild(
|
|
|
99
99
|
const compilers = execution.nativePlugins.filter(
|
|
100
100
|
(plugin) => plugin.stage === "transform",
|
|
101
101
|
);
|
|
102
|
-
const outputs = execution.nativePlugins.filter(
|
|
103
|
-
(plugin) => plugin.stage === "output",
|
|
104
|
-
);
|
|
105
102
|
const checked = runNativeCheckPlugins(options, execution);
|
|
106
103
|
if (checked.status !== 0) {
|
|
107
104
|
return checked;
|
|
@@ -109,7 +106,7 @@ export function runBuild(
|
|
|
109
106
|
|
|
110
107
|
if (options.emit === false) {
|
|
111
108
|
if (compilers.length !== 0) {
|
|
112
|
-
|
|
109
|
+
assertCompilerHostCompatibility(compilers);
|
|
113
110
|
return appendBuildOutput(
|
|
114
111
|
checked,
|
|
115
112
|
buildWithNativeCompilerPlugins(options, execution, compilers),
|
|
@@ -123,7 +120,7 @@ export function runBuild(
|
|
|
123
120
|
|
|
124
121
|
let result: TtscBuildResult;
|
|
125
122
|
if (compilers.length !== 0) {
|
|
126
|
-
|
|
123
|
+
assertCompilerHostCompatibility(compilers);
|
|
127
124
|
result = appendBuildOutput(
|
|
128
125
|
checked,
|
|
129
126
|
buildWithNativeCompilerPlugins(options, execution, compilers),
|
|
@@ -140,25 +137,13 @@ export function runBuild(
|
|
|
140
137
|
}
|
|
141
138
|
}
|
|
142
139
|
const args = createTsgoBuildArgs(execution, options, {
|
|
143
|
-
listEmittedFiles:
|
|
144
|
-
outputs.length !== 0 || options.forceListEmittedFiles === true,
|
|
140
|
+
listEmittedFiles: options.forceListEmittedFiles === true,
|
|
145
141
|
});
|
|
146
142
|
const emitted = runTsgoBuild(execution, options, args);
|
|
147
143
|
result = appendBuildOutput(checked, emitted);
|
|
148
144
|
}
|
|
149
145
|
|
|
150
|
-
|
|
151
|
-
return result;
|
|
152
|
-
}
|
|
153
|
-
return appendBuildOutput(
|
|
154
|
-
result,
|
|
155
|
-
applyOutputPlugins(
|
|
156
|
-
options,
|
|
157
|
-
execution,
|
|
158
|
-
result.emittedFiles ?? [],
|
|
159
|
-
outputs,
|
|
160
|
-
),
|
|
161
|
-
);
|
|
146
|
+
return result;
|
|
162
147
|
}
|
|
163
148
|
|
|
164
149
|
if (options.emit !== false && options.skipDiagnosticsCheck !== true) {
|
|
@@ -332,30 +317,13 @@ function createNativeCheckArgs(
|
|
|
332
317
|
return args;
|
|
333
318
|
}
|
|
334
319
|
|
|
335
|
-
function createNativeOutputArgs(
|
|
336
|
-
execution: ReturnType<typeof resolveExecutionContext>,
|
|
337
|
-
options: TtscBuildOptions,
|
|
338
|
-
file: string,
|
|
339
|
-
): string[] {
|
|
340
|
-
const args = [
|
|
341
|
-
"output",
|
|
342
|
-
"--file=" + file,
|
|
343
|
-
"--tsconfig=" + execution.tsconfig,
|
|
344
|
-
"--plugins-json=" + serializeNativePlugins(execution.nativePlugins),
|
|
345
|
-
"--cwd=" + execution.projectRoot,
|
|
346
|
-
];
|
|
347
|
-
if (options.outDir) {
|
|
348
|
-
args.push("--outDir=" + path.resolve(execution.cwd, options.outDir));
|
|
349
|
-
}
|
|
350
|
-
return args;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
320
|
function serializeNativePlugins(
|
|
354
321
|
plugins: readonly ITtscLoadedNativePlugin[],
|
|
355
322
|
): string {
|
|
356
323
|
return JSON.stringify(
|
|
357
324
|
plugins.map((plugin) => ({
|
|
358
325
|
config: plugin.config,
|
|
326
|
+
hooks: plugin.hooks,
|
|
359
327
|
name: plugin.name,
|
|
360
328
|
stage: plugin.stage,
|
|
361
329
|
})),
|
|
@@ -390,48 +358,6 @@ function runNativeCheckPlugins(
|
|
|
390
358
|
return out;
|
|
391
359
|
}
|
|
392
360
|
|
|
393
|
-
function applyOutputPlugins(
|
|
394
|
-
options: TtscBuildOptions,
|
|
395
|
-
execution: ReturnType<typeof resolveExecutionContext>,
|
|
396
|
-
emittedFiles: readonly string[],
|
|
397
|
-
plugins: readonly ITtscLoadedNativePlugin[],
|
|
398
|
-
): TtscBuildResult {
|
|
399
|
-
let out: TtscBuildResult = {
|
|
400
|
-
diagnostics: [],
|
|
401
|
-
status: 0,
|
|
402
|
-
stdout: "",
|
|
403
|
-
stderr: "",
|
|
404
|
-
};
|
|
405
|
-
for (const plugin of plugins) {
|
|
406
|
-
for (const file of emittedFiles) {
|
|
407
|
-
if (!fs.existsSync(file)) {
|
|
408
|
-
continue;
|
|
409
|
-
}
|
|
410
|
-
const result = runNativeOutputPlugin(options, execution, plugin, file);
|
|
411
|
-
out = appendBuildOutput(out, result);
|
|
412
|
-
if (result.status !== 0) {
|
|
413
|
-
return out;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
return out;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
function runNativeOutputPlugin(
|
|
421
|
-
options: TtscBuildOptions,
|
|
422
|
-
execution: ReturnType<typeof resolveExecutionContext>,
|
|
423
|
-
plugin: ITtscLoadedNativePlugin,
|
|
424
|
-
file: string,
|
|
425
|
-
): TtscBuildResult {
|
|
426
|
-
return runNativePluginCommand(
|
|
427
|
-
plugin,
|
|
428
|
-
createNativeOutputArgs(execution, options, file),
|
|
429
|
-
options,
|
|
430
|
-
execution,
|
|
431
|
-
"ttsc.output",
|
|
432
|
-
);
|
|
433
|
-
}
|
|
434
|
-
|
|
435
361
|
function runNativePluginCommand(
|
|
436
362
|
plugin: ITtscLoadedNativePlugin,
|
|
437
363
|
args: readonly string[],
|
|
@@ -473,16 +399,59 @@ function appendBuildOutput(
|
|
|
473
399
|
});
|
|
474
400
|
}
|
|
475
401
|
|
|
476
|
-
function
|
|
402
|
+
function assertCompilerHostCompatibility(
|
|
477
403
|
plugins: readonly ITtscLoadedNativePlugin[],
|
|
478
404
|
): void {
|
|
479
405
|
const binaries = [...new Set(plugins.map((plugin) => plugin.binary))];
|
|
480
|
-
if (binaries.length
|
|
481
|
-
|
|
482
|
-
"ttsc: multiple compiler native backends cannot share one emit pass; " +
|
|
483
|
-
"use output-capability plugins for post-emit transforms",
|
|
484
|
-
);
|
|
406
|
+
if (binaries.length <= 1) {
|
|
407
|
+
return;
|
|
485
408
|
}
|
|
409
|
+
if (plugins.every(isFirstPartyUtilityTransformPlugin)) {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
throw new Error(
|
|
413
|
+
"ttsc: multiple compiler native backends cannot share one emit pass; " +
|
|
414
|
+
"compose transform hook libraries through one aggregate host",
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function isFirstPartyUtilityTransformPlugin(
|
|
419
|
+
plugin: ITtscLoadedNativePlugin,
|
|
420
|
+
): boolean {
|
|
421
|
+
if (plugin.stage !== "transform") return false;
|
|
422
|
+
if (!firstPartyUtilityPluginNames.has(plugin.name)) return false;
|
|
423
|
+
const manifest = readNearestPackageManifest(plugin.source);
|
|
424
|
+
return manifest?.name === plugin.name;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
const firstPartyUtilityPluginNames = new Set([
|
|
428
|
+
"@ttsc/banner",
|
|
429
|
+
"@ttsc/paths",
|
|
430
|
+
"@ttsc/strip",
|
|
431
|
+
]);
|
|
432
|
+
|
|
433
|
+
function readNearestPackageManifest(
|
|
434
|
+
source: string,
|
|
435
|
+
): { name?: unknown } | undefined {
|
|
436
|
+
try {
|
|
437
|
+
let current = fs.statSync(source).isDirectory()
|
|
438
|
+
? source
|
|
439
|
+
: path.dirname(source);
|
|
440
|
+
for (let i = 0; i < 4; i += 1) {
|
|
441
|
+
const manifest = path.join(current, "package.json");
|
|
442
|
+
if (fs.existsSync(manifest)) {
|
|
443
|
+
return JSON.parse(fs.readFileSync(manifest, "utf8")) as {
|
|
444
|
+
name?: unknown;
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
const parent = path.dirname(current);
|
|
448
|
+
if (parent === current) break;
|
|
449
|
+
current = parent;
|
|
450
|
+
}
|
|
451
|
+
} catch {
|
|
452
|
+
return undefined;
|
|
453
|
+
}
|
|
454
|
+
return undefined;
|
|
486
455
|
}
|
|
487
456
|
|
|
488
457
|
function resolveExecutionContext(
|
|
@@ -617,7 +586,10 @@ function parseDiagnosticLine(
|
|
|
617
586
|
};
|
|
618
587
|
}
|
|
619
588
|
|
|
620
|
-
function normalizeDiagnosticFile(
|
|
589
|
+
function normalizeDiagnosticFile(
|
|
590
|
+
file: string,
|
|
591
|
+
cwd: string | undefined,
|
|
592
|
+
): string {
|
|
621
593
|
if (path.isAbsolute(file) || cwd === undefined) {
|
|
622
594
|
return file;
|
|
623
595
|
}
|
|
@@ -118,7 +118,7 @@ function transformProjectWithPlugins(
|
|
|
118
118
|
if (transformers.length === 0) {
|
|
119
119
|
return transformProjectWithNativeHost(options, project);
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
assertTransformHostCompatibility(transformers);
|
|
122
122
|
|
|
123
123
|
const plugin = transformers[0]!;
|
|
124
124
|
const res = spawnNative(
|
|
@@ -218,21 +218,66 @@ function serializeNativePlugins(
|
|
|
218
218
|
return JSON.stringify(
|
|
219
219
|
plugins.map((plugin) => ({
|
|
220
220
|
config: plugin.config,
|
|
221
|
+
hooks: plugin.hooks,
|
|
221
222
|
name: plugin.name,
|
|
222
223
|
stage: plugin.stage,
|
|
223
224
|
})),
|
|
224
225
|
);
|
|
225
226
|
}
|
|
226
227
|
|
|
227
|
-
function
|
|
228
|
+
function assertTransformHostCompatibility(
|
|
228
229
|
plugins: readonly ITtscLoadedNativePlugin[],
|
|
229
230
|
): void {
|
|
230
231
|
const binaries = [...new Set(plugins.map((plugin) => plugin.binary))];
|
|
231
|
-
if (binaries.length
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
232
|
+
if (binaries.length <= 1) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (plugins.every(isFirstPartyUtilityTransformPlugin)) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
throw new Error(
|
|
239
|
+
"ttsc: multiple transform native backends cannot share one source-to-source pass; " +
|
|
240
|
+
"compose transform hook libraries through one aggregate host",
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function isFirstPartyUtilityTransformPlugin(
|
|
245
|
+
plugin: ITtscLoadedNativePlugin,
|
|
246
|
+
): boolean {
|
|
247
|
+
if (plugin.stage !== "transform") return false;
|
|
248
|
+
if (!firstPartyUtilityPluginNames.has(plugin.name)) return false;
|
|
249
|
+
const manifest = readNearestPackageManifest(plugin.source);
|
|
250
|
+
return manifest?.name === plugin.name;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const firstPartyUtilityPluginNames = new Set([
|
|
254
|
+
"@ttsc/banner",
|
|
255
|
+
"@ttsc/paths",
|
|
256
|
+
"@ttsc/strip",
|
|
257
|
+
]);
|
|
258
|
+
|
|
259
|
+
function readNearestPackageManifest(
|
|
260
|
+
source: string,
|
|
261
|
+
): { name?: unknown } | undefined {
|
|
262
|
+
try {
|
|
263
|
+
let current = fs.statSync(source).isDirectory()
|
|
264
|
+
? source
|
|
265
|
+
: path.dirname(source);
|
|
266
|
+
for (let i = 0; i < 4; i += 1) {
|
|
267
|
+
const manifest = path.join(current, "package.json");
|
|
268
|
+
if (fs.existsSync(manifest)) {
|
|
269
|
+
return JSON.parse(fs.readFileSync(manifest, "utf8")) as {
|
|
270
|
+
name?: unknown;
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
const parent = path.dirname(current);
|
|
274
|
+
if (parent === current) break;
|
|
275
|
+
current = parent;
|
|
276
|
+
}
|
|
277
|
+
} catch {
|
|
278
|
+
return undefined;
|
|
235
279
|
}
|
|
280
|
+
return undefined;
|
|
236
281
|
}
|
|
237
282
|
|
|
238
283
|
function appendBuildResult(
|
|
@@ -17,8 +17,7 @@ export function getCompilerVersionText(
|
|
|
17
17
|
});
|
|
18
18
|
if (res.error || res.status !== 0) {
|
|
19
19
|
throw new Error(
|
|
20
|
-
"ttsc.version: failed: " +
|
|
21
|
-
(outputText(res.stderr) || res.error?.message),
|
|
20
|
+
"ttsc.version: failed: " + (outputText(res.stderr) || res.error?.message),
|
|
22
21
|
);
|
|
23
22
|
}
|
|
24
23
|
return `ttsc ${readOwnPackageVersion()} (${outputText(res.stdout).trim()})`;
|
|
@@ -58,7 +58,8 @@ function createProjectContext(
|
|
|
58
58
|
const tsconfig = project.path;
|
|
59
59
|
const root = project.root;
|
|
60
60
|
const cacheDir =
|
|
61
|
-
options.cacheDir ??
|
|
61
|
+
options.cacheDir ??
|
|
62
|
+
path.join(root, "node_modules", ".cache", "ttsc", "ttsx");
|
|
62
63
|
const processDir = path.join(cacheDir, "project", PROCESS_CACHE_KEY);
|
|
63
64
|
const virtualRoot = path.join(processDir, "fs");
|
|
64
65
|
return {
|
|
@@ -81,7 +82,9 @@ function resolveRuntimeSourceRoot(
|
|
|
81
82
|
): string {
|
|
82
83
|
const rootDir = project.compilerOptions.rootDir;
|
|
83
84
|
if (typeof rootDir === "string") {
|
|
84
|
-
return path.isAbsolute(rootDir)
|
|
85
|
+
return path.isAbsolute(rootDir)
|
|
86
|
+
? rootDir
|
|
87
|
+
: path.resolve(project.root, rootDir);
|
|
85
88
|
}
|
|
86
89
|
return path.dirname(filename);
|
|
87
90
|
}
|
|
@@ -191,10 +194,7 @@ function collectLinkDirectories(projectRoot: string): string[] {
|
|
|
191
194
|
function isUnsafeVirtualParent(directory: string): boolean {
|
|
192
195
|
const resolved = path.resolve(directory);
|
|
193
196
|
const root = path.parse(resolved).root;
|
|
194
|
-
return (
|
|
195
|
-
resolved === root ||
|
|
196
|
-
resolved === path.resolve(os.tmpdir())
|
|
197
|
-
);
|
|
197
|
+
return resolved === root || resolved === path.resolve(os.tmpdir());
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
function virtualPath(root: string, absolute: string): string {
|