@sveltejs/vite-plugin-svelte 4.0.0 → 4.0.2
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 +4 -4
- package/src/public.d.ts +3 -3
- package/src/utils/compile.js +3 -3
- package/src/utils/id.js +2 -10
- package/types/index.d.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/vite-plugin-svelte",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "dominikg",
|
|
6
6
|
"files": [
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/debug": "^4.1.12",
|
|
52
52
|
"esbuild": "^0.24.0",
|
|
53
|
-
"sass": "^1.
|
|
54
|
-
"svelte": "^5.
|
|
55
|
-
"vite": "^5.4.
|
|
53
|
+
"sass": "^1.81.0",
|
|
54
|
+
"svelte": "^5.2.0",
|
|
55
|
+
"vite": "^5.4.11"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"check:publint": "publint --strict",
|
package/src/public.d.ts
CHANGED
|
@@ -92,9 +92,9 @@ export interface PluginOptions {
|
|
|
92
92
|
* @example
|
|
93
93
|
* ```
|
|
94
94
|
* ({ filename, compileOptions }) => {
|
|
95
|
-
* // Dynamically set
|
|
96
|
-
* if (
|
|
97
|
-
* return {
|
|
95
|
+
* // Dynamically set runes mode per Svelte file
|
|
96
|
+
* if (forceRunesMode(filename) && !compileOptions.runes) {
|
|
97
|
+
* return { runes: true };
|
|
98
98
|
* }
|
|
99
99
|
* }
|
|
100
100
|
* ```
|
package/src/utils/compile.js
CHANGED
|
@@ -14,7 +14,7 @@ import { enhanceCompileError } from './error.js';
|
|
|
14
14
|
// which is closer to the other regexes in at least not falling into commented script
|
|
15
15
|
// but ideally would be shared exactly with svelte and other tools that use it
|
|
16
16
|
const scriptLangRE =
|
|
17
|
-
/<!--[^]*?-->|<script
|
|
17
|
+
/<!--[^]*?-->|<script\s+(?:[^>]*|(?:[^=>'"/]+=(?:"[^"]*"|'[^']*'|[^>\s]+)\s+)*)lang=(["'])?([^"' >]+)\1[^>]*>/g;
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* @returns {import('../types/compile.d.ts').CompileSvelte}
|
|
@@ -172,8 +172,8 @@ export function createCompileSvelte() {
|
|
|
172
172
|
|
|
173
173
|
let lang = 'js';
|
|
174
174
|
for (const match of code.matchAll(scriptLangRE)) {
|
|
175
|
-
if (match[
|
|
176
|
-
lang = match[
|
|
175
|
+
if (match[2]) {
|
|
176
|
+
lang = match[2];
|
|
177
177
|
break;
|
|
178
178
|
}
|
|
179
179
|
}
|
package/src/utils/id.js
CHANGED
|
@@ -8,15 +8,7 @@ import { DEFAULT_SVELTE_MODULE_EXT, DEFAULT_SVELTE_MODULE_INFIX } from './consta
|
|
|
8
8
|
const VITE_FS_PREFIX = '/@fs/';
|
|
9
9
|
const IS_WINDOWS = process.platform === 'win32';
|
|
10
10
|
|
|
11
|
-
const SUPPORTED_COMPILER_OPTIONS = [
|
|
12
|
-
'generate',
|
|
13
|
-
'dev',
|
|
14
|
-
'css',
|
|
15
|
-
'hydratable',
|
|
16
|
-
'customElement',
|
|
17
|
-
'immutable',
|
|
18
|
-
'enableSourcemap'
|
|
19
|
-
];
|
|
11
|
+
const SUPPORTED_COMPILER_OPTIONS = ['generate', 'dev', 'css', 'customElement', 'immutable'];
|
|
20
12
|
const TYPES_WITH_COMPILER_OPTIONS = ['style', 'script', 'all'];
|
|
21
13
|
|
|
22
14
|
/**
|
|
@@ -102,7 +94,7 @@ function parseRequestQuery(rawQuery) {
|
|
|
102
94
|
throw new Error(
|
|
103
95
|
`Invalid compilerOptions in query ${rawQuery}. CompilerOptions are only supported for raw or direct queries with type in "${TYPES_WITH_COMPILER_OPTIONS.join(
|
|
104
96
|
', '
|
|
105
|
-
)}" e.g. '?svelte&raw&type=script&compilerOptions={"generate":"
|
|
97
|
+
)}" e.g. '?svelte&raw&type=script&compilerOptions={"generate":"server","dev":false}`
|
|
106
98
|
);
|
|
107
99
|
}
|
|
108
100
|
try {
|
package/types/index.d.ts
CHANGED
|
@@ -92,9 +92,9 @@ declare module '@sveltejs/vite-plugin-svelte' {
|
|
|
92
92
|
* @example
|
|
93
93
|
* ```
|
|
94
94
|
* ({ filename, compileOptions }) => {
|
|
95
|
-
* // Dynamically set
|
|
96
|
-
* if (
|
|
97
|
-
* return {
|
|
95
|
+
* // Dynamically set runes mode per Svelte file
|
|
96
|
+
* if (forceRunesMode(filename) && !compileOptions.runes) {
|
|
97
|
+
* return { runes: true };
|
|
98
98
|
* }
|
|
99
99
|
* }
|
|
100
100
|
* ```
|