@sveltejs/vite-plugin-svelte 3.0.0 → 3.0.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/vite-plugin-svelte",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "dominikg",
|
|
6
6
|
"files": [
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/debug": "^4.1.12",
|
|
53
|
-
"esbuild": "^0.19.
|
|
53
|
+
"esbuild": "^0.19.7",
|
|
54
54
|
"sass": "^1.69.5",
|
|
55
|
-
"svelte": "^4.2.
|
|
56
|
-
"vite": "^5.0.
|
|
55
|
+
"svelte": "^4.2.7",
|
|
56
|
+
"vite": "^5.0.2"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"check:publint": "publint --strict",
|
package/src/handle-hot-update.js
CHANGED
|
@@ -104,8 +104,10 @@ function jsChanged(prev, next, filename) {
|
|
|
104
104
|
}
|
|
105
105
|
const isLooseEqual = isCodeEqual(normalizeJsCode(prevJs), normalizeJsCode(nextJs));
|
|
106
106
|
if (!isStrictEqual && isLooseEqual) {
|
|
107
|
-
log.
|
|
108
|
-
`ignoring compiler output js change for ${filename} as it is equal to previous output after normalization
|
|
107
|
+
log.debug(
|
|
108
|
+
`ignoring compiler output js change for ${filename} as it is equal to previous output after normalization`,
|
|
109
|
+
undefined,
|
|
110
|
+
'hmr'
|
|
109
111
|
);
|
|
110
112
|
}
|
|
111
113
|
return !isLooseEqual;
|
package/src/preprocess.js
CHANGED
|
@@ -10,7 +10,7 @@ const supportedScriptLangs = ['ts'];
|
|
|
10
10
|
export const lang_sep = '.vite-preprocess';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* @param {import('./public.d.ts').VitePreprocessOptions} opts
|
|
13
|
+
* @param {import('./public.d.ts').VitePreprocessOptions} [opts]
|
|
14
14
|
* @returns {import('svelte/compiler').PreprocessorGroup}
|
|
15
15
|
*/
|
|
16
16
|
export function vitePreprocess(opts) {
|
package/src/utils/compile.js
CHANGED
|
@@ -12,7 +12,11 @@ import { mapToRelative } from './sourcemaps.js';
|
|
|
12
12
|
import { enhanceCompileError } from './error.js';
|
|
13
13
|
import { isSvelte5 } from './svelte-version.js';
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
// TODO this is a patched version of https://github.com/sveltejs/vite-plugin-svelte/pull/796/files#diff-3bce0b33034aad4b35ca094893671f7e7ddf4d27254ae7b9b0f912027a001b15R10
|
|
16
|
+
// which is closer to the other regexes in at least not falling into commented script
|
|
17
|
+
// but ideally would be shared exactly with svelte and other tools that use it
|
|
18
|
+
const scriptLangRE =
|
|
19
|
+
/<!--[^]*?-->|<script (?:[^>]*|(?:[^=>'"/]+=(?:"[^"]*"|'[^']*'|[^>\s]+)\s+)*)lang=["']?([^"' >]+)["']?[^>]*>/;
|
|
16
20
|
|
|
17
21
|
/**
|
|
18
22
|
* @param {Function} [makeHot]
|
package/src/utils/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isSvelte5 } from './svelte-version.js';
|
|
2
2
|
|
|
3
|
-
export const VITE_RESOLVE_MAIN_FIELDS = ['module', 'jsnext:main', 'jsnext'];
|
|
3
|
+
export const VITE_RESOLVE_MAIN_FIELDS = ['browser', 'module', 'jsnext:main', 'jsnext'];
|
|
4
4
|
|
|
5
5
|
export const SVELTE_RESOLVE_MAIN_FIELDS = ['svelte'];
|
|
6
6
|
|
package/src/utils/error.js
CHANGED
|
@@ -114,8 +114,9 @@ export function enhanceCompileError(err, originalCode, preprocessors) {
|
|
|
114
114
|
|
|
115
115
|
// Handle incorrect TypeScript usage
|
|
116
116
|
if (err.code === 'parse-error') {
|
|
117
|
-
// Reference from Svelte: https://github.com/sveltejs/svelte/blob/
|
|
118
|
-
const scriptRe =
|
|
117
|
+
// Reference from Svelte: https://github.com/sveltejs/svelte/blob/9926347ad9dbdd0f3324d5538e25dcb7f5e442f8/packages/svelte/src/compiler/preprocess/index.js#L259
|
|
118
|
+
const scriptRe =
|
|
119
|
+
/<!--[^]*?-->|<script((?:\s+[^=>'"/]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"/]+)*\s*)(?:\/>|>([\S\s]*?)<\/script>)/g;
|
|
119
120
|
const errIndex = err.pos ?? -1;
|
|
120
121
|
|
|
121
122
|
let m;
|
|
@@ -142,7 +143,9 @@ export function enhanceCompileError(err, originalCode, preprocessors) {
|
|
|
142
143
|
|
|
143
144
|
// Handle incorrect CSS preprocessor usage
|
|
144
145
|
if (err.code === 'css-syntax-error') {
|
|
145
|
-
|
|
146
|
+
// Reference from Svelte: https://github.com/sveltejs/svelte/blob/9926347ad9dbdd0f3324d5538e25dcb7f5e442f8/packages/svelte/src/compiler/preprocess/index.js#L257
|
|
147
|
+
const styleRe =
|
|
148
|
+
/<!--[^]*?-->|<style((?:\s+[^=>'"/]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"/]+)*\s*)(?:\/>|>([\S\s]*?)<\/style>)/g;
|
|
146
149
|
|
|
147
150
|
let m;
|
|
148
151
|
while ((m = styleRe.exec(originalCode))) {
|
|
@@ -25,8 +25,8 @@ async function dynamicImportDefault(filePath, timestamp) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* @param {import('vite').UserConfig} viteConfig
|
|
29
|
-
* @param {Partial<import('../public.d.ts').Options>} inlineOptions
|
|
28
|
+
* @param {import('vite').UserConfig} [viteConfig]
|
|
29
|
+
* @param {Partial<import('../public.d.ts').Options>} [inlineOptions]
|
|
30
30
|
* @returns {Promise<Partial<import('../public.d.ts').SvelteConfig> | undefined>}
|
|
31
31
|
*/
|
|
32
32
|
export async function loadSvelteConfig(viteConfig, inlineOptions) {
|
package/types/index.d.ts
CHANGED
|
@@ -190,8 +190,8 @@ declare module '@sveltejs/vite-plugin-svelte' {
|
|
|
190
190
|
style?: boolean | InlineConfig | ResolvedConfig;
|
|
191
191
|
}
|
|
192
192
|
export function svelte(inlineOptions?: Partial<Options> | undefined): import('vite').Plugin[];
|
|
193
|
-
export function vitePreprocess(opts
|
|
194
|
-
export function loadSvelteConfig(viteConfig
|
|
193
|
+
export function vitePreprocess(opts?: VitePreprocessOptions | undefined): import('svelte/compiler').PreprocessorGroup;
|
|
194
|
+
export function loadSvelteConfig(viteConfig?: import("vite").UserConfig | undefined, inlineOptions?: Partial<Options> | undefined): Promise<Partial<SvelteConfig> | undefined>;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
//# sourceMappingURL=index.d.ts.map
|