typescript-svelte-plugin 0.3.28 → 0.3.30
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.
|
@@ -5,6 +5,7 @@ export declare class ConfigManager {
|
|
|
5
5
|
private emitter;
|
|
6
6
|
private config;
|
|
7
7
|
onConfigurationChanged(listener: (config: Configuration) => void): void;
|
|
8
|
+
isConfigChanged(config: Configuration): boolean;
|
|
8
9
|
updateConfigFromPluginConfig(config: Configuration): void;
|
|
9
10
|
getConfig(): Configuration;
|
|
10
11
|
}
|
|
@@ -13,6 +13,10 @@ class ConfigManager {
|
|
|
13
13
|
onConfigurationChanged(listener) {
|
|
14
14
|
this.emitter.on(configurationEventName, listener);
|
|
15
15
|
}
|
|
16
|
+
isConfigChanged(config) {
|
|
17
|
+
// right now we only care about enable
|
|
18
|
+
return config.enable !== this.config.enable;
|
|
19
|
+
}
|
|
16
20
|
updateConfigFromPluginConfig(config) {
|
|
17
21
|
this.config = {
|
|
18
22
|
...this.config,
|
package/dist/src/index.js
CHANGED
|
@@ -93,7 +93,9 @@ function init(modules) {
|
|
|
93
93
|
(0, module_loader_1.patchModuleLoader)(logger, snapshotManager, modules.typescript, info.languageServiceHost, info.project, configManager);
|
|
94
94
|
configManager.onConfigurationChanged(() => {
|
|
95
95
|
// enabling/disabling the plugin means TS has to recompute stuff
|
|
96
|
-
|
|
96
|
+
// don't clear semantic cache here
|
|
97
|
+
// typescript now expected the program updates to be completely in their control
|
|
98
|
+
// doing so will result in a crash
|
|
97
99
|
info.project.markAsDirty();
|
|
98
100
|
// updateGraph checks for new root files
|
|
99
101
|
// if there's no tsconfig there isn't root files to check
|
|
@@ -125,9 +127,20 @@ function init(modules) {
|
|
|
125
127
|
const svelteTsPath = (0, path_1.dirname)(require.resolve('svelte2tsx'));
|
|
126
128
|
const sveltePath = require.resolve('svelte/compiler', configFilePath ? { paths: [configFilePath] } : undefined);
|
|
127
129
|
const VERSION = require(sveltePath).VERSION;
|
|
128
|
-
const
|
|
130
|
+
const isSvelte3 = VERSION.split('.')[0] === '3';
|
|
131
|
+
const svelteHtmlDeclaration = isSvelte3
|
|
132
|
+
? undefined
|
|
133
|
+
: (0, path_1.join)((0, path_1.dirname)(sveltePath), 'svelte-html.d.ts');
|
|
134
|
+
const svelteHtmlFallbackIfNotExist = svelteHtmlDeclaration && modules.typescript.sys.fileExists(svelteHtmlDeclaration)
|
|
135
|
+
? svelteHtmlDeclaration
|
|
136
|
+
: './svelte-jsx-v4.d.ts';
|
|
137
|
+
const svelteTsxFiles = (isSvelte3
|
|
129
138
|
? ['./svelte-shims.d.ts', './svelte-jsx.d.ts', './svelte-native-jsx.d.ts']
|
|
130
|
-
: [
|
|
139
|
+
: [
|
|
140
|
+
'./svelte-shims-v4.d.ts',
|
|
141
|
+
svelteHtmlFallbackIfNotExist,
|
|
142
|
+
'./svelte-native-jsx.d.ts'
|
|
143
|
+
]).map((f) => modules.typescript.sys.resolvePath((0, path_1.resolve)(svelteTsPath, f)));
|
|
131
144
|
resolvedSvelteTsxFiles = svelteTsxFiles;
|
|
132
145
|
return svelteTsxFiles;
|
|
133
146
|
}
|
|
@@ -136,7 +149,9 @@ function init(modules) {
|
|
|
136
149
|
return (0, utils_1.hasNodeModule)(compilerOptions, 'svelte');
|
|
137
150
|
}
|
|
138
151
|
function onConfigurationChanged(config) {
|
|
139
|
-
configManager.
|
|
152
|
+
if (configManager.isConfigChanged(config)) {
|
|
153
|
+
configManager.updateConfigFromPluginConfig(config);
|
|
154
|
+
}
|
|
140
155
|
}
|
|
141
156
|
/**
|
|
142
157
|
* TypeScript doesn't load the external files in projects without a config file. So we load it by ourselves.
|