@volar/typescript
Advanced tools
Comparing version 2.4.0-alpha.13 to 2.4.0-alpha.14
@@ -7,5 +7,5 @@ import type * as ts from 'typescript'; | ||
}; | ||
export declare function runTsc(tscPath: string, extensionsOrOptions: string[] | { | ||
supportedExtensions: string[]; | ||
extensionsToRemove: string[]; | ||
export declare function runTsc(tscPath: string, options: string[] | { | ||
extraSupportedExtensions: string[]; | ||
extraExtensionsToRemove: string[]; | ||
}, _getLanguagePlugins: typeof getLanguagePlugins): void; |
@@ -8,3 +8,3 @@ "use strict"; | ||
exports.getLanguagePlugins = getLanguagePlugins; | ||
function runTsc(tscPath, extensionsOrOptions, _getLanguagePlugins) { | ||
function runTsc(tscPath, options, _getLanguagePlugins) { | ||
exports.getLanguagePlugins = _getLanguagePlugins; | ||
@@ -16,15 +16,34 @@ const proxyApiPath = require.resolve('../node/proxyCreateProgram'); | ||
let tsc = readFileSync(...args); | ||
const supportedExtensions = Array.isArray(extensionsOrOptions) ? extensionsOrOptions : extensionsOrOptions.supportedExtensions; | ||
const extensionsToRemove = Array.isArray(extensionsOrOptions) ? [] : extensionsOrOptions.extensionsToRemove; | ||
// add allow extensions | ||
if (supportedExtensions.length) { | ||
const extsText = supportedExtensions.map(ext => `"${ext}"`).join(', '); | ||
tsc = replace(tsc, /supportedTSExtensions = .*(?=;)/, s => s + `.concat([[${extsText}]])`); | ||
tsc = replace(tsc, /supportedJSExtensions = .*(?=;)/, s => s + `.concat([[${extsText}]])`); | ||
tsc = replace(tsc, /allSupportedExtensions = .*(?=;)/, s => s + `.concat([[${extsText}]])`); | ||
let extraSupportedExtensions; | ||
let extraExtensionsToRemove; | ||
if (Array.isArray(options)) { | ||
extraSupportedExtensions = options; | ||
extraExtensionsToRemove = []; | ||
} | ||
if (extensionsToRemove.length) { | ||
const extsText = extensionsToRemove.map(ext => `"${ext}"`).join(', '); | ||
else { | ||
extraSupportedExtensions = options.extraSupportedExtensions; | ||
extraExtensionsToRemove = options.extraExtensionsToRemove; | ||
} | ||
const needPatchExtenstions = extraSupportedExtensions.filter(ext => !extraExtensionsToRemove.includes(ext)); | ||
// Add allow extensions | ||
if (extraSupportedExtensions.length) { | ||
const extsText = extraSupportedExtensions.map(ext => `"${ext}"`).join(', '); | ||
tsc = replace(tsc, /supportedTSExtensions = .*(?=;)/, s => s + `.map((group, i) => i === 0 ? group.splice(0, 0, ${extsText}) && group : group)`); | ||
tsc = replace(tsc, /supportedJSExtensions = .*(?=;)/, s => s + `.map((group, i) => i === 0 ? group.splice(0, 0, ${extsText}) && group : group)`); | ||
tsc = replace(tsc, /allSupportedExtensions = .*(?=;)/, s => s + `.map((group, i) => i === 0 ? group.splice(0, 0, ${extsText}) && group : group)`); | ||
} | ||
// Use to emit basename.xxx to basename.d.ts instead of basename.xxx.d.ts | ||
if (extraExtensionsToRemove.length) { | ||
const extsText = extraExtensionsToRemove.map(ext => `"${ext}"`).join(', '); | ||
tsc = replace(tsc, /extensionsToRemove = .*(?=;)/, s => s + `.concat([${extsText}])`); | ||
} | ||
// Support for basename.xxx to basename.xxx.d.ts | ||
if (needPatchExtenstions.length) { | ||
const extsText = needPatchExtenstions.map(ext => `"${ext}"`).join(', '); | ||
tsc = replace(tsc, /function changeExtension\(/, s => `function changeExtension(path, newExtension) { | ||
return [${extsText}].some(ext => path.endsWith(ext)) | ||
? path + newExtension | ||
: _changeExtension(path, newExtension) | ||
}\n` + s.replace('changeExtension', '_changeExtension')); | ||
} | ||
// proxy createProgram | ||
@@ -31,0 +50,0 @@ tsc = replace(tsc, /function createProgram\(.+\) {/, s => `var createProgram = require(${JSON.stringify(proxyApiPath)}).proxyCreateProgram(` |
{ | ||
"name": "@volar/typescript", | ||
"version": "2.4.0-alpha.13", | ||
"version": "2.4.0-alpha.14", | ||
"license": "MIT", | ||
@@ -15,3 +15,3 @@ "files": [ | ||
"dependencies": { | ||
"@volar/language-core": "2.4.0-alpha.13", | ||
"@volar/language-core": "2.4.0-alpha.14", | ||
"path-browserify": "^1.0.1", | ||
@@ -23,5 +23,5 @@ "vscode-uri": "^3.0.8" | ||
"@types/path-browserify": "latest", | ||
"@volar/language-service": "2.4.0-alpha.13" | ||
"@volar/language-service": "2.4.0-alpha.14" | ||
}, | ||
"gitHead": "5f6d5d8ec51a5dda702d071c283e9133254cae97" | ||
"gitHead": "fc61afbf59f54fd6e92776a8569d6ce591e9b9d5" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
201825
4295
+ Added@volar/language-core@2.4.0-alpha.14(transitive)
+ Added@volar/source-map@2.4.0-alpha.14(transitive)
- Removed@volar/language-core@2.4.0-alpha.13(transitive)
- Removed@volar/source-map@2.4.0-alpha.13(transitive)