@volar/vue-language-core
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -9,14 +9,4 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
var _a, _b; | ||
patchResolveModuleNames(ts, vueCompilerOptions); | ||
const vueLanguagePlugin = (0, plugins_1.getDefaultVueLanguagePlugins)(ts, compilerOptions, vueCompilerOptions); | ||
// from https://github.com/johnsoncodehk/volar/pull/1543 | ||
if (!(ts.__VLS_pitched_resolveModuleNames)) { | ||
ts.__VLS_pitched_resolveModuleNames = true; | ||
const resolveModuleNames = ts.resolveModuleName; | ||
ts.resolveModuleName = (...args) => { | ||
if (args[6] === ts.ModuleKind.ESNext && vueCompilerOptions.extensions.some(ext => args[0].endsWith(ext))) { | ||
args[6] = ts.ModuleKind.CommonJS; | ||
} | ||
return resolveModuleNames(...args); | ||
}; | ||
} | ||
const sharedTypesSnapshot = ts.ScriptSnapshot.fromString(localTypes.getTypesCode(vueCompilerOptions.target, vueCompilerOptions)); | ||
@@ -92,2 +82,20 @@ const languageModule = { | ||
exports.createLanguageModules = createLanguageModules; | ||
function patchResolveModuleNames(ts, vueCompilerOptions) { | ||
try { | ||
// from https://github.com/johnsoncodehk/volar/pull/1543 | ||
if (!(ts.__vuePatchResolveModuleNames)) { | ||
ts.__vuePatchResolveModuleNames = true; | ||
const resolveModuleNames = ts.resolveModuleName; | ||
ts.resolveModuleName = (...args) => { | ||
if (args[6] === ts.ModuleKind.ESNext && vueCompilerOptions.extensions.some(ext => args[0].endsWith(ext))) { | ||
args[6] = ts.ModuleKind.CommonJS; | ||
} | ||
return resolveModuleNames(...args); | ||
}; | ||
} | ||
} | ||
catch (e) { | ||
console.warn('[volar] patchResolveModuleNames failed', e); | ||
} | ||
} | ||
//# sourceMappingURL=languageModule.js.map |
@@ -51,6 +51,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
if ((_a = content.raw.vueCompilerOptions) === null || _a === void 0 ? void 0 : _a.plugins) { | ||
content.raw.vueCompilerOptions.plugins = content.raw.vueCompilerOptions.plugins.map((pluginPath) => { | ||
const pluginPaths = content.raw.vueCompilerOptions.plugins; | ||
const plugins = pluginPaths | ||
.map((pluginPath) => { | ||
try { | ||
pluginPath = resolvePath(pluginPath); | ||
return require(pluginPath); | ||
const resolvedPath = resolvePath(pluginPath); | ||
if (resolvedPath) { | ||
return require(resolvedPath); | ||
} | ||
} | ||
@@ -60,11 +64,18 @@ catch (error) { | ||
} | ||
}); | ||
}) | ||
.filter((plugin) => !!plugin); | ||
content.raw.vueCompilerOptions.plugins = plugins; | ||
} | ||
const vueOptions = Object.assign(Object.assign({}, extendsVueOptions), content.raw.vueCompilerOptions); | ||
vueOptions.hooks = (_b = vueOptions.hooks) === null || _b === void 0 ? void 0 : _b.map(resolvePath); | ||
vueOptions.experimentalAdditionalLanguageModules = (_c = vueOptions.experimentalAdditionalLanguageModules) === null || _c === void 0 ? void 0 : _c.map(resolvePath); | ||
vueOptions.hooks = (_b = vueOptions.hooks) === null || _b === void 0 ? void 0 : _b.map(resolvePath).filter((hook) => !!hook); | ||
vueOptions.experimentalAdditionalLanguageModules = (_c = vueOptions.experimentalAdditionalLanguageModules) === null || _c === void 0 ? void 0 : _c.map(resolvePath).filter((module) => !!module); | ||
return Object.assign(Object.assign({}, content), { vueOptions }); | ||
function resolvePath(scriptPath) { | ||
try { | ||
scriptPath = require.resolve(scriptPath, { paths: [folder] }); | ||
if (require === null || require === void 0 ? void 0 : require.resolve) { | ||
scriptPath = require.resolve(scriptPath, { paths: [folder] }); | ||
} | ||
else { | ||
console.log('failed to resolve path:', scriptPath, 'require.resolve is not supported in web'); | ||
} | ||
} | ||
@@ -74,3 +85,3 @@ catch (error) { | ||
} | ||
return scriptPath; | ||
return; | ||
} | ||
@@ -77,0 +88,0 @@ } |
{ | ||
"name": "@volar/vue-language-core", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"main": "out/index.js", | ||
@@ -12,8 +12,8 @@ "license": "MIT", | ||
"type": "git", | ||
"url": "https://github.com/johnsoncodehk/volar.git", | ||
"url": "https://github.com/vuejs/language-tools.git", | ||
"directory": "packages/vue-language-core" | ||
}, | ||
"dependencies": { | ||
"@volar/language-core": "1.3.0-alpha.0", | ||
"@volar/source-map": "1.3.0-alpha.0", | ||
"@volar/language-core": "1.3.0-alpha.2", | ||
"@volar/source-map": "1.3.0-alpha.2", | ||
"@vue/compiler-dom": "^3.2.47", | ||
@@ -30,3 +30,3 @@ "@vue/compiler-sfc": "^3.2.47", | ||
}, | ||
"gitHead": "a709aab55a05921de35863d7f66f76b682720504" | ||
"gitHead": "b984fa45fbdb96606abf0d211c76b78f0948139e" | ||
} |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
225196
4787
6
+ Added@volar/language-core@1.3.0-alpha.2(transitive)
+ Added@volar/source-map@1.3.0-alpha.2(transitive)
- Removed@volar/language-core@1.3.0-alpha.0(transitive)
- Removed@volar/source-map@1.3.0-alpha.0(transitive)