@sveltejs/vite-plugin-svelte 6.2.0 → 6.2.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": "6.2.0",
3
+ "version": "6.2.1",
4
4
  "license": "MIT",
5
5
  "author": "dominikg",
6
6
  "files": [
@@ -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;
@@ -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
  },
package/src/utils/log.js CHANGED
@@ -1,5 +1,6 @@
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);
@@ -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 notIgnored = warnings?.filter((w) => !ignoreCompilerWarning(w, isBuild, emitCss));
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
  */
@@ -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 rolldown-vite
427
+ config.build?.rolldownOptions?.optimization?.inlineConst ??
428
+ //@ts-ignore optimization only exists in rolldown-vite
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
  /**