@marko/type-check 1.0.7 → 1.1.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/dist/cli.js +40 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -45,6 +45,8 @@ var currentDirectory = import_tsserverlibrary.default.sys.getCurrentDirectory();
|
|
|
45
45
|
var getCanonicalFileName = import_tsserverlibrary.default.sys.useCaseSensitiveFileNames ? (fileName) => fileName : (fileName) => fileName.toLowerCase();
|
|
46
46
|
var fsPathReg = /^(?:[./\\]|[A-Z]:)/i;
|
|
47
47
|
var modulePartsReg = /^((?:@(?:[^/]+)\/)?(?:[^/]+))(.*)$/;
|
|
48
|
+
var isRemapExtensionReg = /\.ts$/;
|
|
49
|
+
var skipRemapExtensionsReg = /\.(?:[cm]?jsx?|json|marko|css|less|sass|scss|styl|stylus|pcss|postcss|sss|a?png|jpe?g|jfif|pipeg|pjp|gif|svg|ico|web[pm]|avif|mp4|ogg|mp3|wav|flac|aac|opus|woff2?|eot|[ot]tf|webmanifest|pdf|txt)$/;
|
|
48
50
|
var extractCache = /* @__PURE__ */ new WeakMap();
|
|
49
51
|
var requiredTSCompilerOptions = {
|
|
50
52
|
allowJs: true,
|
|
@@ -87,6 +89,43 @@ function run(opts) {
|
|
|
87
89
|
getCanonicalFileName,
|
|
88
90
|
options
|
|
89
91
|
);
|
|
92
|
+
const getJSFileIfTSExists = (source, importer) => compilerHost.fileExists(import_path.default.join(importer, "..", `${source}.ts`)) && `${source}.js`;
|
|
93
|
+
const customTransformers = {
|
|
94
|
+
after: [
|
|
95
|
+
(ctx) => (sourceFile) => {
|
|
96
|
+
return import_tsserverlibrary.default.visitNode(sourceFile, visit);
|
|
97
|
+
function visit(node) {
|
|
98
|
+
if (import_tsserverlibrary.default.isSourceFile(node)) {
|
|
99
|
+
return import_tsserverlibrary.default.visitEachChild(node, visit, ctx);
|
|
100
|
+
}
|
|
101
|
+
if ((import_tsserverlibrary.default.isImportDeclaration(node) || import_tsserverlibrary.default.isExportDeclaration(node)) && node.moduleSpecifier && import_tsserverlibrary.default.isStringLiteral(node.moduleSpecifier)) {
|
|
102
|
+
const value = node.moduleSpecifier.text;
|
|
103
|
+
if (value[0] === "." && !skipRemapExtensionsReg.test(value)) {
|
|
104
|
+
const { fileName } = sourceFile;
|
|
105
|
+
const remap = isRemapExtensionReg.test(value) ? `${value.slice(0, -2)}js` : getJSFileIfTSExists(value, fileName) || getJSFileIfTSExists(`${value}/index`, fileName);
|
|
106
|
+
if (remap) {
|
|
107
|
+
return import_tsserverlibrary.default.isImportDeclaration(node) ? ctx.factory.updateImportDeclaration(
|
|
108
|
+
node,
|
|
109
|
+
node.modifiers,
|
|
110
|
+
node.importClause,
|
|
111
|
+
ctx.factory.createStringLiteral(remap),
|
|
112
|
+
node.attributes
|
|
113
|
+
) : ctx.factory.updateExportDeclaration(
|
|
114
|
+
node,
|
|
115
|
+
node.modifiers,
|
|
116
|
+
node.isTypeOnly,
|
|
117
|
+
node.exportClause,
|
|
118
|
+
ctx.factory.createStringLiteral(remap),
|
|
119
|
+
node.attributes
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return node;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
};
|
|
90
129
|
const { readDirectory = import_tsserverlibrary.default.sys.readDirectory } = compilerHost;
|
|
91
130
|
compilerHost.readDirectory = (path3, extensions, exclude, include, depth) => readDirectory(
|
|
92
131
|
path3,
|
|
@@ -224,7 +263,7 @@ function run(opts) {
|
|
|
224
263
|
);
|
|
225
264
|
const program = builderProgram.getProgram();
|
|
226
265
|
const builderEmit = builderProgram.emit.bind(builderProgram);
|
|
227
|
-
builderProgram.emit = (targetSourceFile, _writeFile, cancellationToken, emitOnlyDtsFiles
|
|
266
|
+
builderProgram.emit = (targetSourceFile, _writeFile, cancellationToken, emitOnlyDtsFiles) => {
|
|
228
267
|
let writeFile = _writeFile;
|
|
229
268
|
if (_writeFile) {
|
|
230
269
|
const typeChecker = program.getTypeChecker();
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/type-check",
|
|
3
3
|
"description": "A CLI to type check Marko projects",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.1",
|
|
5
5
|
"bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@babel/code-frame": "^7.23.5",
|
|
8
|
-
"@marko/language-tools": "^2.
|
|
8
|
+
"@marko/language-tools": "^2.2.0",
|
|
9
9
|
"arg": "^5.0.2",
|
|
10
10
|
"kleur": "^4.1.5",
|
|
11
11
|
"strip-json-comments": "^3.1.1",
|