typescript-svelte-plugin 0.3.37 → 0.3.39
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/src/config-manager.d.ts +2 -0
- package/dist/src/config-manager.js +7 -0
- package/dist/src/index.js +23 -12
- package/dist/src/language-service/inlay-hints.js +3 -2
- package/dist/src/language-service/sveltekit.js +2 -1
- package/dist/src/module-loader.d.ts +3 -1
- package/dist/src/module-loader.js +9 -2
- package/dist/src/project-svelte-files.d.ts +1 -0
- package/dist/src/project-svelte-files.js +11 -9
- package/dist/src/svelte-snapshots.d.ts +5 -1
- package/dist/src/svelte-snapshots.js +8 -2
- package/dist/src/svelte-sys.d.ts +1 -1
- package/dist/src/utils.d.ts +4 -1
- package/dist/src/utils.js +49 -4
- package/package.json +3 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export interface Configuration {
|
|
2
|
+
global?: boolean;
|
|
2
3
|
enable: boolean;
|
|
3
4
|
/** Skip the Svelte detection and assume this is a Svelte project */
|
|
4
5
|
assumeIsSvelteProject: boolean;
|
|
@@ -7,6 +8,7 @@ export declare class ConfigManager {
|
|
|
7
8
|
private emitter;
|
|
8
9
|
private config;
|
|
9
10
|
onConfigurationChanged(listener: (config: Configuration) => void): void;
|
|
11
|
+
removeConfigurationChangeListener(listener: (config: Configuration) => void): void;
|
|
10
12
|
isConfigChanged(config: Configuration): boolean;
|
|
11
13
|
updateConfigFromPluginConfig(config: Configuration): void;
|
|
12
14
|
getConfig(): Configuration;
|
|
@@ -14,11 +14,18 @@ class ConfigManager {
|
|
|
14
14
|
onConfigurationChanged(listener) {
|
|
15
15
|
this.emitter.on(configurationEventName, listener);
|
|
16
16
|
}
|
|
17
|
+
removeConfigurationChangeListener(listener) {
|
|
18
|
+
this.emitter.off(configurationEventName, listener);
|
|
19
|
+
}
|
|
17
20
|
isConfigChanged(config) {
|
|
18
21
|
// right now we only care about enable
|
|
19
22
|
return config.enable !== this.config.enable;
|
|
20
23
|
}
|
|
21
24
|
updateConfigFromPluginConfig(config) {
|
|
25
|
+
// TODO this doesn't work because TS will resolve/load files already before we get the config request,
|
|
26
|
+
// which leads to TS files that use Svelte files getting all kinds of type errors
|
|
27
|
+
// const shouldWaitForConfigRequest = config.global == true;
|
|
28
|
+
// const enable = config.enable ?? !shouldWaitForConfigRequest;
|
|
22
29
|
this.config = {
|
|
23
30
|
...this.config,
|
|
24
31
|
...config
|
package/dist/src/index.js
CHANGED
|
@@ -10,10 +10,11 @@ const utils_1 = require("./utils");
|
|
|
10
10
|
function init(modules) {
|
|
11
11
|
const configManager = new config_manager_1.ConfigManager();
|
|
12
12
|
let resolvedSvelteTsxFiles;
|
|
13
|
+
const isSvelteProjectCache = new Map();
|
|
13
14
|
function create(info) {
|
|
14
15
|
const logger = new logger_1.Logger(info.project.projectService.logger);
|
|
15
16
|
if (!info.config?.assumeIsSvelteProject &&
|
|
16
|
-
!
|
|
17
|
+
!isSvelteProjectWithCache(info.project)) {
|
|
17
18
|
logger.log('Detected that this is not a Svelte project, abort patching TypeScript');
|
|
18
19
|
return info.languageService;
|
|
19
20
|
}
|
|
@@ -47,7 +48,7 @@ function init(modules) {
|
|
|
47
48
|
if (snapshot) {
|
|
48
49
|
const originalText = snapshot.getText(0, snapshot.getLength());
|
|
49
50
|
const startIdx = originalText.indexOf(`declare module '*.svelte' {`);
|
|
50
|
-
const endIdx = originalText.indexOf(
|
|
51
|
+
const endIdx = originalText.indexOf(`\n}`, startIdx + 1) + 2;
|
|
51
52
|
return modules.typescript.ScriptSnapshot.fromString(originalText.substring(0, startIdx) +
|
|
52
53
|
' '.repeat(endIdx - startIdx) +
|
|
53
54
|
originalText.substring(endIdx));
|
|
@@ -87,12 +88,12 @@ function init(modules) {
|
|
|
87
88
|
const svelteOptions = parsedCommandLine?.raw?.svelteOptions || { namespace: 'svelteHTML' };
|
|
88
89
|
logger.log('svelteOptions:', svelteOptions);
|
|
89
90
|
logger.debug(parsedCommandLine?.wildcardDirectories);
|
|
90
|
-
const snapshotManager = new svelte_snapshots_1.SvelteSnapshotManager(modules.typescript, info.project.projectService, svelteOptions, logger, configManager);
|
|
91
|
+
const snapshotManager = new svelte_snapshots_1.SvelteSnapshotManager(modules.typescript, info.project.projectService, svelteOptions, logger, configManager, (0, utils_1.importSvelteCompiler)((0, utils_1.getProjectDirectory)(info.project)));
|
|
91
92
|
const projectSvelteFilesManager = parsedCommandLine
|
|
92
93
|
? new project_svelte_files_1.ProjectSvelteFilesManager(modules.typescript, info.project, info.serverHost, snapshotManager, logger, parsedCommandLine, configManager)
|
|
93
94
|
: undefined;
|
|
94
|
-
(0, module_loader_1.patchModuleLoader)(logger, snapshotManager, modules.typescript, info.languageServiceHost, info.project, configManager);
|
|
95
|
-
|
|
95
|
+
const moduleLoaderDisposable = (0, module_loader_1.patchModuleLoader)(logger, snapshotManager, modules.typescript, info.languageServiceHost, info.project, configManager);
|
|
96
|
+
const updateProjectWhenConfigChanges = () => {
|
|
96
97
|
// enabling/disabling the plugin means TS has to recompute stuff
|
|
97
98
|
// don't clear semantic cache here
|
|
98
99
|
// typescript now expected the program updates to be completely in their control
|
|
@@ -103,16 +104,21 @@ function init(modules) {
|
|
|
103
104
|
if (projectSvelteFilesManager) {
|
|
104
105
|
info.project.updateGraph();
|
|
105
106
|
}
|
|
107
|
+
};
|
|
108
|
+
configManager.onConfigurationChanged(updateProjectWhenConfigChanges);
|
|
109
|
+
return (0, language_service_1.decorateLanguageService)(info.languageService, snapshotManager, logger, configManager, info, modules.typescript, () => {
|
|
110
|
+
projectSvelteFilesManager?.dispose();
|
|
111
|
+
configManager.removeConfigurationChangeListener(updateProjectWhenConfigChanges);
|
|
112
|
+
moduleLoaderDisposable.dispose();
|
|
106
113
|
});
|
|
107
|
-
return (0, language_service_1.decorateLanguageService)(info.languageService, snapshotManager, logger, configManager, info, modules.typescript, () => projectSvelteFilesManager?.dispose());
|
|
108
114
|
}
|
|
109
115
|
function getExternalFiles(project) {
|
|
110
|
-
if (!
|
|
116
|
+
if (!isSvelteProjectWithCache(project) || !configManager.getConfig().enable) {
|
|
111
117
|
return [];
|
|
112
118
|
}
|
|
113
|
-
const configFilePath =
|
|
119
|
+
const configFilePath = (0, utils_1.getProjectDirectory)(project);
|
|
114
120
|
// Needed so the ambient definitions are known inside the tsx files
|
|
115
|
-
const svelteTsxFiles = resolveSvelteTsxFiles(
|
|
121
|
+
const svelteTsxFiles = resolveSvelteTsxFiles(configFilePath);
|
|
116
122
|
if (!configFilePath) {
|
|
117
123
|
svelteTsxFiles.forEach((file) => {
|
|
118
124
|
openSvelteTsxFileForInferredProject(project, file);
|
|
@@ -145,9 +151,14 @@ function init(modules) {
|
|
|
145
151
|
resolvedSvelteTsxFiles = svelteTsxFiles;
|
|
146
152
|
return svelteTsxFiles;
|
|
147
153
|
}
|
|
148
|
-
function
|
|
149
|
-
|
|
150
|
-
|
|
154
|
+
function isSvelteProjectWithCache(project) {
|
|
155
|
+
const cached = isSvelteProjectCache.get(project.getProjectName());
|
|
156
|
+
if (cached !== undefined) {
|
|
157
|
+
return cached;
|
|
158
|
+
}
|
|
159
|
+
const result = !!(0, utils_1.isSvelteProject)(project);
|
|
160
|
+
isSvelteProjectCache.set(project.getProjectName(), result);
|
|
161
|
+
return result;
|
|
151
162
|
}
|
|
152
163
|
function onConfigurationChanged(config) {
|
|
153
164
|
if (configManager.isConfigChanged(config)) {
|
|
@@ -10,10 +10,11 @@ function decorateInlayHints(ls, info, ts, logger) {
|
|
|
10
10
|
return provideInlayHints(fileName, span, preferences);
|
|
11
11
|
}
|
|
12
12
|
const { languageService, toVirtualPos, toOriginalPos } = result;
|
|
13
|
+
const start = toVirtualPos(span.start);
|
|
13
14
|
return languageService
|
|
14
15
|
.provideInlayHints(fileName, {
|
|
15
|
-
start
|
|
16
|
-
length: span.length
|
|
16
|
+
start,
|
|
17
|
+
length: toVirtualPos(span.start + span.length) - start
|
|
17
18
|
}, preferences)
|
|
18
19
|
.map((hint) => ({
|
|
19
20
|
...hint,
|
|
@@ -488,7 +488,8 @@ function getProxiedLanguageService(info, ts, logger) {
|
|
|
488
488
|
if (cachedProxiedLanguageService !== undefined) {
|
|
489
489
|
return cachedProxiedLanguageService ?? undefined;
|
|
490
490
|
}
|
|
491
|
-
|
|
491
|
+
const projectDirectory = (0, utils_1.getProjectDirectory)(info.project);
|
|
492
|
+
if (projectDirectory && !(0, utils_1.hasNodeModule)(projectDirectory, '@sveltejs/kit')) {
|
|
492
493
|
// Not a SvelteKit project, do nothing
|
|
493
494
|
cache.set(info, null);
|
|
494
495
|
return;
|
|
@@ -18,4 +18,6 @@ declare module 'typescript/lib/tsserverlibrary' {
|
|
|
18
18
|
* so it assumes it's a normal typescript file and searches for files like `../Component.svelte.ts`, which is wrong.
|
|
19
19
|
* In order to fix this, we need to wrap typescript's module resolution and reroute all `.svelte.ts` file lookups to .svelte.
|
|
20
20
|
*/
|
|
21
|
-
export declare function patchModuleLoader(logger: Logger, snapshotManager: SvelteSnapshotManager, typescript: typeof ts, lsHost: ts.LanguageServiceHost, project: ts.server.Project, configManager: ConfigManager):
|
|
21
|
+
export declare function patchModuleLoader(logger: Logger, snapshotManager: SvelteSnapshotManager, typescript: typeof ts, lsHost: ts.LanguageServiceHost, project: ts.server.Project, configManager: ConfigManager): {
|
|
22
|
+
dispose: () => void;
|
|
23
|
+
};
|
|
@@ -73,9 +73,16 @@ function patchModuleLoader(logger, snapshotManager, typescript, lsHost, project,
|
|
|
73
73
|
moduleCache.delete(info.fileName);
|
|
74
74
|
return origRemoveFile(info, fileExists, detachFromProject);
|
|
75
75
|
};
|
|
76
|
-
|
|
76
|
+
const onConfigChanged = () => {
|
|
77
77
|
moduleCache.clear();
|
|
78
|
-
}
|
|
78
|
+
};
|
|
79
|
+
configManager.onConfigurationChanged(onConfigChanged);
|
|
80
|
+
return {
|
|
81
|
+
dispose() {
|
|
82
|
+
configManager.removeConfigurationChangeListener(onConfigChanged);
|
|
83
|
+
moduleCache.clear();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
79
86
|
function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, compilerOptions, containingSourceFile) {
|
|
80
87
|
logger.debug('Resolving modules names for ' + containingFile);
|
|
81
88
|
// Try resolving all module names with the original method first.
|
|
@@ -13,6 +13,7 @@ export declare class ProjectSvelteFilesManager {
|
|
|
13
13
|
private readonly snapshotManager;
|
|
14
14
|
private readonly logger;
|
|
15
15
|
private parsedCommandLine;
|
|
16
|
+
private readonly configManager;
|
|
16
17
|
private projectFileToOriginalCasing;
|
|
17
18
|
private directoryWatchers;
|
|
18
19
|
private static instances;
|
|
@@ -13,13 +13,22 @@ class ProjectSvelteFilesManager {
|
|
|
13
13
|
this.snapshotManager = snapshotManager;
|
|
14
14
|
this.logger = logger;
|
|
15
15
|
this.parsedCommandLine = parsedCommandLine;
|
|
16
|
+
this.configManager = configManager;
|
|
16
17
|
this.projectFileToOriginalCasing = new Map();
|
|
17
18
|
this.directoryWatchers = new Set();
|
|
19
|
+
this.onConfigChanged = (config) => {
|
|
20
|
+
this.disposeWatchers();
|
|
21
|
+
this.clearProjectFile();
|
|
22
|
+
if (config.enable) {
|
|
23
|
+
this.setupWatchers();
|
|
24
|
+
this.updateProjectSvelteFiles();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
18
27
|
if (configManager.getConfig().enable) {
|
|
19
28
|
this.setupWatchers();
|
|
20
29
|
this.updateProjectSvelteFiles();
|
|
21
30
|
}
|
|
22
|
-
configManager.onConfigurationChanged(this.onConfigChanged
|
|
31
|
+
configManager.onConfigurationChanged(this.onConfigChanged);
|
|
23
32
|
ProjectSvelteFilesManager.instances.set(project.getProjectName(), this);
|
|
24
33
|
}
|
|
25
34
|
updateProjectConfig(serviceHost) {
|
|
@@ -109,14 +118,6 @@ class ProjectSvelteFilesManager {
|
|
|
109
118
|
.readDirectory(this.project.getCurrentDirectory() || process.cwd(), ['.svelte'], exclude, include)
|
|
110
119
|
.map(this.typescript.server.toNormalizedPath);
|
|
111
120
|
}
|
|
112
|
-
onConfigChanged(config) {
|
|
113
|
-
this.disposeWatchers();
|
|
114
|
-
this.clearProjectFile();
|
|
115
|
-
if (config.enable) {
|
|
116
|
-
this.setupWatchers();
|
|
117
|
-
this.updateProjectSvelteFiles();
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
121
|
removeFileFromProject(file, exists = true) {
|
|
121
122
|
const info = this.project.getScriptInfo(file);
|
|
122
123
|
if (info) {
|
|
@@ -137,6 +138,7 @@ class ProjectSvelteFilesManager {
|
|
|
137
138
|
// because TypeScript already does that when the project is closed
|
|
138
139
|
// - and because the project is closed, `project.removeFile` will result in an error
|
|
139
140
|
this.projectFileToOriginalCasing.clear();
|
|
141
|
+
this.configManager.removeConfigurationChangeListener(this.onConfigChanged);
|
|
140
142
|
ProjectSvelteFilesManager.instances.delete(this.project.getProjectName());
|
|
141
143
|
}
|
|
142
144
|
}
|
|
@@ -43,10 +43,14 @@ export declare class SvelteSnapshotManager {
|
|
|
43
43
|
private svelteOptions;
|
|
44
44
|
private logger;
|
|
45
45
|
private configManager;
|
|
46
|
+
/** undefined if no node_modules with Svelte next to tsconfig.json */
|
|
47
|
+
private svelteCompiler;
|
|
46
48
|
private snapshots;
|
|
47
49
|
constructor(typescript: typeof ts, projectService: ts.server.ProjectService, svelteOptions: {
|
|
48
50
|
namespace: string;
|
|
49
|
-
}, logger: Logger, configManager: ConfigManager
|
|
51
|
+
}, logger: Logger, configManager: ConfigManager,
|
|
52
|
+
/** undefined if no node_modules with Svelte next to tsconfig.json */
|
|
53
|
+
svelteCompiler: typeof import('svelte/compiler') | undefined);
|
|
50
54
|
get(fileName: string): SvelteSnapshot | undefined;
|
|
51
55
|
create(fileName: string): SvelteSnapshot | undefined;
|
|
52
56
|
private patchProjectServiceReadFile;
|
|
@@ -220,12 +220,15 @@ class SvelteSnapshot {
|
|
|
220
220
|
}
|
|
221
221
|
exports.SvelteSnapshot = SvelteSnapshot;
|
|
222
222
|
class SvelteSnapshotManager {
|
|
223
|
-
constructor(typescript, projectService, svelteOptions, logger, configManager
|
|
223
|
+
constructor(typescript, projectService, svelteOptions, logger, configManager,
|
|
224
|
+
/** undefined if no node_modules with Svelte next to tsconfig.json */
|
|
225
|
+
svelteCompiler) {
|
|
224
226
|
this.typescript = typescript;
|
|
225
227
|
this.projectService = projectService;
|
|
226
228
|
this.svelteOptions = svelteOptions;
|
|
227
229
|
this.logger = logger;
|
|
228
230
|
this.configManager = configManager;
|
|
231
|
+
this.svelteCompiler = svelteCompiler;
|
|
229
232
|
this.snapshots = new Map();
|
|
230
233
|
this.patchProjectServiceReadFile();
|
|
231
234
|
}
|
|
@@ -311,7 +314,10 @@ class SvelteSnapshotManager {
|
|
|
311
314
|
filename: path.split('/').pop(),
|
|
312
315
|
isTsFile,
|
|
313
316
|
mode: 'ts',
|
|
314
|
-
typingsNamespace: this.svelteOptions.namespace
|
|
317
|
+
typingsNamespace: this.svelteOptions.namespace,
|
|
318
|
+
// Don't search for compiler from current path - could be a different one from which we have loaded the svelte2tsx globals
|
|
319
|
+
parse: this.svelteCompiler?.parse,
|
|
320
|
+
version: this.svelteCompiler?.VERSION
|
|
315
321
|
});
|
|
316
322
|
code = result.code;
|
|
317
323
|
mapper = new source_mapper_1.SourceMapper(result.map.mappings);
|
package/dist/src/svelte-sys.d.ts
CHANGED
package/dist/src/utils.d.ts
CHANGED
|
@@ -43,5 +43,8 @@ export declare function isGeneratedSvelteComponentName(className: string): boole
|
|
|
43
43
|
export declare function offsetOfGeneratedComponentExport(snapshot: SvelteSnapshot): number;
|
|
44
44
|
export declare function gatherDescendants<T extends ts.Node>(node: ts.Node, predicate: NodeTypePredicate<T>, dest?: T[]): T[];
|
|
45
45
|
export declare function findIdentifier(ts: _ts, node: ts.Node): ts.Identifier | undefined;
|
|
46
|
-
export declare function
|
|
46
|
+
export declare function getProjectDirectory(project: ts.server.Project): string | undefined;
|
|
47
|
+
export declare function hasNodeModule(startPath: string, module: string): string | boolean;
|
|
48
|
+
export declare function isSvelteProject(project: ts.server.Project): string | boolean;
|
|
49
|
+
export declare function importSvelteCompiler(fromPath: string | undefined): typeof import('svelte/compiler') | undefined;
|
|
47
50
|
export {};
|
package/dist/src/utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasNodeModule = exports.findIdentifier = exports.gatherDescendants = exports.offsetOfGeneratedComponentExport = exports.isGeneratedSvelteComponentName = exports.isTopLevelExport = exports.findNodeAtPosition = exports.findNodeAtSpan = exports.get$storeOffsetOf$storeDeclaration = exports.isStoreVariableIn$storeDeclaration = exports.getConfigPathForProject = exports.replaceDeep = exports.isNoTextSpanInGeneratedCode = exports.isInGeneratedCode = exports.isNotNullOrUndefined = exports.ensureRealSvelteFilePath = exports.toRealSvelteFilePath = exports.isVirtualSvelteFilePath = exports.isSvelteFilePath = void 0;
|
|
3
|
+
exports.importSvelteCompiler = exports.isSvelteProject = exports.hasNodeModule = exports.getProjectDirectory = exports.findIdentifier = exports.gatherDescendants = exports.offsetOfGeneratedComponentExport = exports.isGeneratedSvelteComponentName = exports.isTopLevelExport = exports.findNodeAtPosition = exports.findNodeAtSpan = exports.get$storeOffsetOf$storeDeclaration = exports.isStoreVariableIn$storeDeclaration = exports.getConfigPathForProject = exports.replaceDeep = exports.isNoTextSpanInGeneratedCode = exports.isInGeneratedCode = exports.isNotNullOrUndefined = exports.ensureRealSvelteFilePath = exports.toRealSvelteFilePath = exports.isVirtualSvelteFilePath = exports.isSvelteFilePath = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
4
5
|
function isSvelteFilePath(filePath) {
|
|
5
6
|
return filePath.endsWith('.svelte');
|
|
6
7
|
}
|
|
@@ -187,10 +188,18 @@ function findIdentifier(ts, node) {
|
|
|
187
188
|
}
|
|
188
189
|
}
|
|
189
190
|
exports.findIdentifier = findIdentifier;
|
|
190
|
-
function
|
|
191
|
+
function getProjectDirectory(project) {
|
|
192
|
+
const compilerOptions = project.getCompilerOptions();
|
|
193
|
+
if (typeof compilerOptions.configFilePath === 'string') {
|
|
194
|
+
return (0, path_1.dirname)(compilerOptions.configFilePath);
|
|
195
|
+
}
|
|
196
|
+
const packageJsonPath = (0, path_1.join)(project.getCurrentDirectory(), 'package.json');
|
|
197
|
+
return project.fileExists(packageJsonPath) ? project.getCurrentDirectory() : undefined;
|
|
198
|
+
}
|
|
199
|
+
exports.getProjectDirectory = getProjectDirectory;
|
|
200
|
+
function hasNodeModule(startPath, module) {
|
|
191
201
|
try {
|
|
192
|
-
const hasModule =
|
|
193
|
-
require.resolve(module, { paths: [compilerOptions.configFilePath] });
|
|
202
|
+
const hasModule = require.resolve(module, { paths: [startPath] });
|
|
194
203
|
return hasModule;
|
|
195
204
|
}
|
|
196
205
|
catch (e) {
|
|
@@ -200,4 +209,40 @@ function hasNodeModule(compilerOptions, module) {
|
|
|
200
209
|
}
|
|
201
210
|
}
|
|
202
211
|
exports.hasNodeModule = hasNodeModule;
|
|
212
|
+
function isSvelteProject(project) {
|
|
213
|
+
const projectDirectory = getProjectDirectory(project);
|
|
214
|
+
if (projectDirectory) {
|
|
215
|
+
return hasNodeModule(projectDirectory, 'svelte');
|
|
216
|
+
}
|
|
217
|
+
const packageJsons = project
|
|
218
|
+
.readDirectory(project.getCurrentDirectory(), ['.json'], ['node_modules', 'dist', 'build'], ['**/package.json'],
|
|
219
|
+
// assuming structure like packages/projectName
|
|
220
|
+
3)
|
|
221
|
+
// in case some other plugin patched readDirectory in a weird way
|
|
222
|
+
.filter((file) => file.endsWith('package.json') && !hasConfigInConjunction(file, project));
|
|
223
|
+
return packageJsons.some((packageJsonPath) => hasNodeModule((0, path_1.dirname)(packageJsonPath), 'svelte'));
|
|
224
|
+
}
|
|
225
|
+
exports.isSvelteProject = isSvelteProject;
|
|
226
|
+
function hasConfigInConjunction(packageJsonPath, project) {
|
|
227
|
+
const dir = (0, path_1.dirname)(packageJsonPath);
|
|
228
|
+
return (project.fileExists((0, path_1.join)(dir, 'tsconfig.json')) ||
|
|
229
|
+
project.fileExists((0, path_1.join)(dir, 'jsconfig.json')));
|
|
230
|
+
}
|
|
231
|
+
function importSvelteCompiler(fromPath) {
|
|
232
|
+
if (!fromPath)
|
|
233
|
+
return undefined;
|
|
234
|
+
try {
|
|
235
|
+
const sveltePath = require.resolve('svelte/compiler', { paths: [fromPath] });
|
|
236
|
+
const compiler = require(sveltePath);
|
|
237
|
+
if (compiler.VERSION.split('.')[0] === '3') {
|
|
238
|
+
// use built-in version for Svelte 3
|
|
239
|
+
return undefined;
|
|
240
|
+
}
|
|
241
|
+
return compiler;
|
|
242
|
+
}
|
|
243
|
+
catch (e) {
|
|
244
|
+
// ignore
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
exports.importSvelteCompiler = importSvelteCompiler;
|
|
203
248
|
//# sourceMappingURL=utils.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typescript-svelte-plugin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.39",
|
|
4
4
|
"description": "A TypeScript Plugin providing Svelte intellisense",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@types/node": "^16.0.0",
|
|
16
|
-
"typescript": "^5.
|
|
16
|
+
"typescript": "^5.4.5",
|
|
17
|
+
"svelte": "^3.57.0"
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
19
20
|
"@jridgewell/sourcemap-codec": "^1.4.14",
|