@sveltejs/vite-plugin-svelte 6.2.0 → 6.2.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 +6 -6
- package/src/plugins/configure.js +1 -34
- package/src/plugins/setup-optimizer.js +2 -2
- package/src/types/compile.d.ts +1 -1
- package/src/utils/log.js +5 -31
- package/src/utils/options.js +17 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/vite-plugin-svelte",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "dominikg",
|
|
6
6
|
"files": [
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"homepage": "https://github.com/sveltejs/vite-plugin-svelte#readme",
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@sveltejs/vite-plugin-svelte-inspector": "^5.0.0",
|
|
38
|
-
"debug": "^4.4.1",
|
|
39
38
|
"deepmerge": "^4.3.1",
|
|
40
|
-
"magic-string": "^0.30.
|
|
39
|
+
"magic-string": "^0.30.21",
|
|
40
|
+
"obug": "^2.1.0",
|
|
41
41
|
"vitefu": "^1.1.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/debug": "^4.1.12",
|
|
49
|
-
"sass": "^1.
|
|
50
|
-
"svelte": "^5.
|
|
51
|
-
"vite": "^7.
|
|
49
|
+
"sass": "^1.94.2",
|
|
50
|
+
"svelte": "^5.45.4",
|
|
51
|
+
"vite": "^7.2.6"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"check:publint": "publint --strict",
|
package/src/plugins/configure.js
CHANGED
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
} from '../utils/options.js';
|
|
13
13
|
import { buildIdFilter, buildIdParser } from '../utils/id.js';
|
|
14
14
|
import { createCompileSvelte } from '../utils/compile.js';
|
|
15
|
-
import { gte } from '../utils/svelte-version.js';
|
|
16
15
|
|
|
17
16
|
// @ts-ignore rolldownVersion
|
|
18
17
|
const { version: viteVersion, rolldownVersion } = vite;
|
|
@@ -25,7 +24,7 @@ const { version: viteVersion, rolldownVersion } = vite;
|
|
|
25
24
|
export function configure(api, inlineOptions) {
|
|
26
25
|
if (rolldownVersion) {
|
|
27
26
|
log.warn.once(
|
|
28
|
-
`!!! Support for
|
|
27
|
+
`!!! Support for vite 8 beta in vite-plugin-svelte is experimental (rolldown: ${rolldownVersion}, vite: ${viteVersion}) !!!
|
|
29
28
|
See https://github.com/sveltejs/vite-plugin-svelte/issues/1143 for a list of known issues and to report feedback.`.replace(
|
|
30
29
|
/\t+/g,
|
|
31
30
|
'\t'
|
|
@@ -59,39 +58,7 @@ export function configure(api, inlineOptions) {
|
|
|
59
58
|
preOptions = await preResolveOptions(inlineOptions, config, configEnv);
|
|
60
59
|
// extra vite config
|
|
61
60
|
const extraViteConfig = await buildExtraViteConfig(preOptions, config);
|
|
62
|
-
|
|
63
|
-
if (
|
|
64
|
-
rolldownVersion &&
|
|
65
|
-
configEnv.command === 'build' &&
|
|
66
|
-
gte(rolldownVersion, '1.0.0-beta.35') // inlineConst received a critical bugfix in 1.0.0-beta.35
|
|
67
|
-
) {
|
|
68
|
-
extraViteConfig.build ??= {};
|
|
69
|
-
// rename rollupOptions to rolldownOptions
|
|
70
|
-
//@ts-ignore rolldownOptions only exists in rolldown-vite
|
|
71
|
-
extraViteConfig.build.rolldownOptions = extraViteConfig.build.rollupOptions || {};
|
|
72
|
-
delete extraViteConfig.build.rollupOptions;
|
|
73
|
-
// read user config inlineConst value
|
|
74
|
-
const inlineConst =
|
|
75
|
-
//@ts-ignore optimization only exists in rolldown-vite
|
|
76
|
-
config.build?.rolldownOptions?.optimization?.inlineConst ??
|
|
77
|
-
//@ts-ignore optimization only exists in rolldown-vite
|
|
78
|
-
config.build?.rollupOptions?.optimization?.inlineConst;
|
|
79
|
-
|
|
80
|
-
if (inlineConst == null) {
|
|
81
|
-
// set inlineConst build optimization for esm-env
|
|
82
|
-
//@ts-ignore rolldownOptions only exists in rolldown-vite
|
|
83
|
-
extraViteConfig.build.rolldownOptions.optimization ??= {};
|
|
84
|
-
//@ts-ignore rolldownOptions only exists in rolldown-vite
|
|
85
|
-
extraViteConfig.build.rolldownOptions.optimization.inlineConst = true;
|
|
86
|
-
} else if (inlineConst === false) {
|
|
87
|
-
log.warn(
|
|
88
|
-
'Your rolldown config contains `optimization.inlineConst: false`. This can lead to increased bundle size and leaked server code in client build.'
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
61
|
log.debug('additional vite config', extraViteConfig, 'config');
|
|
94
|
-
|
|
95
62
|
return extraViteConfig;
|
|
96
63
|
}
|
|
97
64
|
},
|
|
@@ -43,7 +43,7 @@ export function setupOptimizer(api) {
|
|
|
43
43
|
// the added plugins are patched in configResolved below
|
|
44
44
|
if (rolldownVersion) {
|
|
45
45
|
//@ts-ignore rolldown types not finished
|
|
46
|
-
optimizeDeps.
|
|
46
|
+
optimizeDeps.rolldownOptions = {
|
|
47
47
|
plugins: [
|
|
48
48
|
placeholderRolldownOptimizerPlugin(optimizeSveltePluginName),
|
|
49
49
|
placeholderRolldownOptimizerPlugin(optimizeSvelteModulePluginName)
|
|
@@ -65,7 +65,7 @@ export function setupOptimizer(api) {
|
|
|
65
65
|
if (rolldownVersion) {
|
|
66
66
|
const plugins =
|
|
67
67
|
// @ts-expect-error not typed
|
|
68
|
-
optimizeDeps.
|
|
68
|
+
optimizeDeps.rolldownOptions?.plugins?.filter((p) =>
|
|
69
69
|
[optimizeSveltePluginName, optimizeSvelteModulePluginName].includes(p.name)
|
|
70
70
|
) ?? [];
|
|
71
71
|
for (const plugin of plugins) {
|
package/src/types/compile.d.ts
CHANGED
package/src/utils/log.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
|
|
3
|
+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
3
4
|
import { styleText } from 'node:util';
|
|
4
5
|
const cyan = (/** @type {string} */ txt) => styleText('cyan', txt);
|
|
5
6
|
const yellow = (/** @type {string} */ txt) => styleText('yellow', txt);
|
|
6
7
|
const red = (/** @type {string} */ txt) => styleText('red', txt);
|
|
7
8
|
|
|
8
|
-
import
|
|
9
|
+
import { createDebug, enabled } from 'obug';
|
|
9
10
|
|
|
10
11
|
/** @type {import('../types/log.d.ts').LogLevel[]} */
|
|
11
12
|
const levels = ['debug', 'info', 'warn', 'error', 'silent'];
|
|
@@ -13,7 +14,7 @@ const prefix = 'vite-plugin-svelte';
|
|
|
13
14
|
/** @type {Record<import('../types/log.d.ts').LogLevel, any>} */
|
|
14
15
|
const loggers = {
|
|
15
16
|
debug: {
|
|
16
|
-
log:
|
|
17
|
+
log: createDebug(`${prefix}`),
|
|
17
18
|
enabled: false,
|
|
18
19
|
isDebug: true
|
|
19
20
|
},
|
|
@@ -145,9 +146,7 @@ export function logCompilerWarnings(svelteRequest, warnings, options) {
|
|
|
145
146
|
let warn = isBuild ? warnBuild : warnDev;
|
|
146
147
|
/** @type {import('svelte/compiler').Warning[]} */
|
|
147
148
|
const handledByDefaultWarn = [];
|
|
148
|
-
const
|
|
149
|
-
const extra = buildExtraWarnings(warnings, isBuild);
|
|
150
|
-
const allWarnings = [...notIgnored, ...extra];
|
|
149
|
+
const allWarnings = warnings?.filter((w) => !ignoreCompilerWarning(w, isBuild, emitCss));
|
|
151
150
|
if (sendViaWS) {
|
|
152
151
|
const _warn = warn;
|
|
153
152
|
/** @type {(w: import('svelte/compiler').Warning) => void} */
|
|
@@ -202,31 +201,6 @@ function isNoScopableElementWarning(warning) {
|
|
|
202
201
|
return warning.code === 'css_unused_selector' && warning.message.includes('"*"');
|
|
203
202
|
}
|
|
204
203
|
|
|
205
|
-
/**
|
|
206
|
-
*
|
|
207
|
-
* @param {import('svelte/compiler').Warning[]} warnings
|
|
208
|
-
* @param {boolean} isBuild
|
|
209
|
-
* @returns {import('svelte/compiler').Warning[]}
|
|
210
|
-
*/
|
|
211
|
-
function buildExtraWarnings(warnings, isBuild) {
|
|
212
|
-
const extraWarnings = [];
|
|
213
|
-
if (!isBuild) {
|
|
214
|
-
const noScopableElementWarnings = warnings.filter((w) => isNoScopableElementWarning(w));
|
|
215
|
-
if (noScopableElementWarnings.length > 0) {
|
|
216
|
-
// in case there are multiple, use last one as that is the one caused by our *{} rule
|
|
217
|
-
const noScopableElementWarning =
|
|
218
|
-
noScopableElementWarnings[noScopableElementWarnings.length - 1];
|
|
219
|
-
extraWarnings.push({
|
|
220
|
-
...noScopableElementWarning,
|
|
221
|
-
code: 'vite-plugin-svelte-css-no-scopable-elements',
|
|
222
|
-
message:
|
|
223
|
-
"No scopable elements found in template. If you're using global styles in the style tag, you should move it into an external stylesheet file and import it in JS. See https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#where-should-i-put-my-global-styles."
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
return extraWarnings;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
204
|
/**
|
|
231
205
|
* @param {import('svelte/compiler').Warning} w
|
|
232
206
|
*/
|
|
@@ -278,5 +252,5 @@ export function buildExtendedLogMessage(w) {
|
|
|
278
252
|
* @returns {boolean}
|
|
279
253
|
*/
|
|
280
254
|
export function isDebugNamespaceEnabled(namespace) {
|
|
281
|
-
return
|
|
255
|
+
return enabled(`${prefix}:${namespace}`);
|
|
282
256
|
}
|
package/src/utils/options.js
CHANGED
|
@@ -6,7 +6,9 @@ const {
|
|
|
6
6
|
defaultClientConditions,
|
|
7
7
|
defaultServerConditions,
|
|
8
8
|
normalizePath,
|
|
9
|
-
searchForWorkspaceRoot
|
|
9
|
+
searchForWorkspaceRoot,
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
rolldownVersion
|
|
10
12
|
} = vite;
|
|
11
13
|
import { log } from './log.js';
|
|
12
14
|
import { loadSvelteConfig } from './load-svelte-config.js';
|
|
@@ -418,6 +420,20 @@ function validateViteConfig(extraViteConfig, config, options) {
|
|
|
418
420
|
);
|
|
419
421
|
}
|
|
420
422
|
}
|
|
423
|
+
if (rolldownVersion && isBuild) {
|
|
424
|
+
// read user config inlineConst value
|
|
425
|
+
const inlineConst =
|
|
426
|
+
//@ts-ignore optimization only exists in vite-8 beta
|
|
427
|
+
config.build?.rolldownOptions?.optimization?.inlineConst ??
|
|
428
|
+
//@ts-ignore optimization only exists in vite-8 beta
|
|
429
|
+
config.build?.rollupOptions?.optimization?.inlineConst;
|
|
430
|
+
|
|
431
|
+
if (inlineConst === false) {
|
|
432
|
+
log.warn(
|
|
433
|
+
'Your rolldown config contains `optimization.inlineConst: false`. This can lead to increased bundle size and leaked server code in client build.'
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
421
437
|
}
|
|
422
438
|
|
|
423
439
|
/**
|