@rsvelte/vite-plugin-svelte 0.2.0 → 0.3.0

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,8 +1,8 @@
1
1
  {
2
2
  "name": "@rsvelte/vite-plugin-svelte",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "license": "MIT",
5
- "author": "baseballyama",
5
+ "author": "dominikg",
6
6
  "files": [
7
7
  "src",
8
8
  "types"
@@ -15,11 +15,6 @@
15
15
  "default": "./src/index.js"
16
16
  }
17
17
  },
18
- "scripts": {
19
- "check:publint": "publint --strict",
20
- "check:types": "tsc --noEmit",
21
- "generate:types": "dts-buddy -m \"@rsvelte/vite-plugin-svelte:src/public.d.ts\""
22
- },
23
18
  "engines": {
24
19
  "node": "^20.19 || ^22.12 || >=24"
25
20
  },
@@ -39,12 +34,13 @@
39
34
  },
40
35
  "homepage": "https://github.com/baseballyama/vite-plugin-svelte#readme",
41
36
  "dependencies": {
42
- "@rsvelte/compiler": ">=0.1.0",
37
+ "@rsvelte/vite-plugin-svelte-native": ">=0.1.0",
43
38
  "@sveltejs/vite-plugin-svelte-inspector": "^5.0.0",
44
39
  "deepmerge": "^4.3.1",
45
40
  "magic-string": "^0.30.21",
46
41
  "obug": "^2.1.0",
47
- "vitefu": "^1.1.1"
42
+ "vitefu": "^1.1.1",
43
+ "@rsvelte/compiler": ">=0.3.0"
48
44
  },
49
45
  "peerDependencies": {
50
46
  "svelte": "^5.0.0",
@@ -55,5 +51,10 @@
55
51
  "sass": "^1.94.2",
56
52
  "svelte": "^5.45.4",
57
53
  "vite": "^7.2.6"
54
+ },
55
+ "scripts": {
56
+ "check:publint": "publint --strict",
57
+ "check:types": "tsc --noEmit",
58
+ "generate:types": "dts-buddy -m \"@rsvelte/vite-plugin-svelte:src/public.d.ts\""
58
59
  }
59
- }
60
+ }
@@ -1,5 +1,5 @@
1
1
  import { buildModuleIdFilter, buildModuleIdParser } from '../utils/id.js';
2
- import * as svelteCompiler from '@rsvelte/compiler';
2
+ import * as svelteCompiler from '@rsvelte/vite-plugin-svelte-native';
3
3
  import { log, logCompilerWarnings } from '../utils/log.js';
4
4
  import { toRollupError } from '../utils/error.js';
5
5
  import { isSvelteWithAsync } from '../utils/svelte-version.js';
@@ -19,7 +19,7 @@ export function compileModule(api) {
19
19
  let idParser;
20
20
 
21
21
  /**
22
- * @type {import('@rsvelte/compiler').ModuleCompileOptions}
22
+ * @type {import('@rsvelte/vite-plugin-svelte-native').ModuleCompileOptions}
23
23
  */
24
24
  let staticModuleCompileOptions;
25
25
 
@@ -42,7 +42,7 @@ export function compileModule(api) {
42
42
  return;
43
43
  }
44
44
  const filename = moduleRequest.filename;
45
- /** @type {import('@rsvelte/compiler').CompileOptions} */
45
+ /** @type {import('@rsvelte/vite-plugin-svelte-native').CompileOptions} */
46
46
  const compileOptions = {
47
47
  ...staticModuleCompileOptions,
48
48
  dev: !this.environment.config.isProduction,
@@ -96,11 +96,11 @@ export function compileModule(api) {
96
96
 
97
97
  /**
98
98
  *
99
- * @param {import('@rsvelte/compiler').CompileOptions} compilerOptions
100
- * @return {import('@rsvelte/compiler').ModuleCompileOptions}
99
+ * @param {import('@rsvelte/vite-plugin-svelte-native').CompileOptions} compilerOptions
100
+ * @return {import('@rsvelte/vite-plugin-svelte-native').ModuleCompileOptions}
101
101
  */
102
102
  function filterNonModuleCompilerOptions(compilerOptions) {
103
- /** @type {Array<keyof import('@rsvelte/compiler').ModuleCompileOptions>} */
103
+ /** @type {Array<keyof import('@rsvelte/vite-plugin-svelte-native').ModuleCompileOptions>} */
104
104
  const knownModuleCompileOptionNames = ['dev', 'generate', 'filename', 'rootDir', 'warningFilter'];
105
105
  if (isSvelteWithAsync) {
106
106
  knownModuleCompileOptionNames.push('experimental');
@@ -108,7 +108,7 @@ function filterNonModuleCompilerOptions(compilerOptions) {
108
108
  // not typed but this is temporary until svelte itself ignores CompileOptions passed to compileModule
109
109
  const experimentalModuleCompilerOptionNames = ['async'];
110
110
 
111
- /** @type {import('@rsvelte/compiler').ModuleCompileOptions} */
111
+ /** @type {import('@rsvelte/vite-plugin-svelte-native').ModuleCompileOptions} */
112
112
  const filtered = filterByPropNames(compilerOptions, knownModuleCompileOptionNames);
113
113
  if (filtered.experimental) {
114
114
  filtered.experimental = filterByPropNames(
@@ -1,6 +1,6 @@
1
1
  import { toRollupError } from '../utils/error.js';
2
2
  import { mapToRelative } from '../utils/sourcemaps.js';
3
- import * as svelte from '@rsvelte/compiler';
3
+ import * as svelte from '@rsvelte/vite-plugin-svelte-native';
4
4
  import { log } from '../utils/log.js';
5
5
  import { arraify } from '../utils/options.js';
6
6
  import fs from 'node:fs';
@@ -94,7 +94,7 @@ export function preprocess(api) {
94
94
  * @returns {import('../types/compile.d.ts').PreprocessSvelte}
95
95
  */
96
96
  function createPreprocessSvelte(options, resolvedConfig) {
97
- /** @type {Array<import('@rsvelte/compiler').PreprocessorGroup>} */
97
+ /** @type {Array<import('@rsvelte/vite-plugin-svelte-native').PreprocessorGroup>} */
98
98
  const preprocessors = arraify(options.preprocess);
99
99
 
100
100
  for (const preprocessor of preprocessors) {
@@ -1,7 +1,7 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { readFileSync } from 'node:fs';
4
- import * as svelte from '@rsvelte/compiler';
4
+ import * as svelte from '@rsvelte/vite-plugin-svelte-native';
5
5
  import { log } from '../utils/log.js';
6
6
  import { toESBuildError, toRollupError } from '../utils/error.js';
7
7
  import { safeBase64Hash } from '../utils/hash.js';
@@ -190,7 +190,7 @@ async function compileSvelte(options, { filename, code }, statsCollection) {
190
190
  // TODO ideally we'd be able to externalize prebundled styles too, but for now always put them in the js
191
191
  css = 'injected';
192
192
  }
193
- /** @type {import('@rsvelte/compiler').CompileOptions} */
193
+ /** @type {import('@rsvelte/vite-plugin-svelte-native').CompileOptions} */
194
194
  const compileOptions = {
195
195
  dev: true, // default to dev: true because prebundling is only used in dev
196
196
  ...options.compilerOptions,
package/src/preprocess.js CHANGED
@@ -21,10 +21,10 @@ export const lang_sep = '.vite-preprocess';
21
21
 
22
22
  /**
23
23
  * @param {import('./public.d.ts').VitePreprocessOptions} [opts]
24
- * @returns {import('@rsvelte/compiler').PreprocessorGroup}
24
+ * @returns {import('@rsvelte/vite-plugin-svelte-native').PreprocessorGroup}
25
25
  */
26
26
  export function vitePreprocess(opts) {
27
- /** @type {import('@rsvelte/compiler').PreprocessorGroup} */
27
+ /** @type {import('@rsvelte/vite-plugin-svelte-native').PreprocessorGroup} */
28
28
  const preprocessor = { name: 'vite-preprocess' };
29
29
  if (opts?.script === true) {
30
30
  preprocessor.script = rolldownVersion ? viteScriptOxc().script : viteScript().script;
@@ -37,7 +37,7 @@ export function vitePreprocess(opts) {
37
37
  }
38
38
 
39
39
  /**
40
- * @returns {{ script: import('@rsvelte/compiler').Preprocessor }}
40
+ * @returns {{ script: import('@rsvelte/vite-plugin-svelte-native').Preprocessor }}
41
41
  */
42
42
  function viteScript() {
43
43
  return {
@@ -67,7 +67,7 @@ function viteScript() {
67
67
  }
68
68
 
69
69
  /**
70
- * @returns {{ script: import('@rsvelte/compiler').Preprocessor }}
70
+ * @returns {{ script: import('@rsvelte/vite-plugin-svelte-native').Preprocessor }}
71
71
  */
72
72
  function viteScriptOxc() {
73
73
  return {
@@ -101,12 +101,12 @@ function viteScriptOxc() {
101
101
 
102
102
  /**
103
103
  * @param {import('vite').ResolvedConfig | import('vite').InlineConfig} config
104
- * @returns {{ style: import('@rsvelte/compiler').Preprocessor }}
104
+ * @returns {{ style: import('@rsvelte/vite-plugin-svelte-native').Preprocessor }}
105
105
  */
106
106
  function viteStyle(config = {}) {
107
107
  /** @type {Promise<CssTransform> | CssTransform} */
108
108
  let cssTransform;
109
- /** @type {import('@rsvelte/compiler').Preprocessor} */
109
+ /** @type {import('@rsvelte/vite-plugin-svelte-native').Preprocessor} */
110
110
  const style = async ({ attributes, content, filename = '' }) => {
111
111
  const ext = attributes.lang ? `.${attributes.lang}` : '.css';
112
112
  if (attributes.lang && !isCSSRequest(ext)) return;
@@ -132,7 +132,7 @@ function viteStyle(config = {}) {
132
132
  }
133
133
 
134
134
  /**
135
- * @param {import('@rsvelte/compiler').Preprocessor} style
135
+ * @param {import('@rsvelte/vite-plugin-svelte-native').Preprocessor} style
136
136
  * @param {import('vite').ResolvedConfig | import('vite').InlineConfig} config
137
137
  * @returns {Promise<CssTransform>}
138
138
  */
package/src/public.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { InlineConfig, ResolvedConfig } from 'vite';
2
- import type { CompileOptions, Warning, PreprocessorGroup } from '@rsvelte/compiler';
2
+ import type { CompileOptions, Warning, PreprocessorGroup } from '@rsvelte/vite-plugin-svelte-native';
3
3
  import type { Options as InspectorOptions } from '@sveltejs/vite-plugin-svelte-inspector';
4
4
 
5
5
  export type Options = Omit<SvelteConfig, 'vitePlugin'> & PluginOptionsInline;
@@ -1,4 +1,4 @@
1
- import type { Processed, CompileResult } from '@rsvelte/compiler';
1
+ import type { Processed, CompileResult } from '@rsvelte/vite-plugin-svelte-native';
2
2
  import type { SvelteRequest } from './id.d.ts';
3
3
  import type { ResolvedOptions } from './options.d.ts';
4
4
  import type { CustomPluginOptionsVite, Rollup } from 'vite';
@@ -1,4 +1,4 @@
1
- import type { Warning } from '@rsvelte/compiler';
1
+ import type { Warning } from '@rsvelte/vite-plugin-svelte-native';
2
2
 
3
3
  export interface LogFn extends SimpleLogFn {
4
4
  (message: string, payload?: unknown, namespace?: string): void;
@@ -1,4 +1,4 @@
1
- import type { CompileOptions } from '@rsvelte/compiler';
1
+ import type { CompileOptions } from '@rsvelte/vite-plugin-svelte-native';
2
2
  import type { ViteDevServer } from 'vite';
3
3
  // eslint-disable-next-line n/no-missing-import
4
4
  import { VitePluginSvelteStats } from '../utils/vite-plugin-svelte-stats.js';
@@ -1,4 +1,4 @@
1
- import * as svelte from '@rsvelte/compiler';
1
+ import * as svelte from '@rsvelte/vite-plugin-svelte-native';
2
2
  import { safeBase64Hash } from './hash.js';
3
3
  import { log } from './log.js';
4
4
 
@@ -21,7 +21,7 @@ export function createCompileSvelte() {
21
21
  return async function compileSvelte(svelteRequest, code, options, sourcemap) {
22
22
  const { filename, normalizedFilename, cssId, ssr, raw } = svelteRequest;
23
23
  const { emitCss = true } = options;
24
- /** @type {import('@rsvelte/compiler').Warning[]} */
24
+ /** @type {import('@rsvelte/vite-plugin-svelte-native').Warning[]} */
25
25
  const warnings = [];
26
26
 
27
27
  if (options.stats) {
@@ -49,7 +49,7 @@ export function createCompileSvelte() {
49
49
  }
50
50
  }
51
51
 
52
- /** @type {import('@rsvelte/compiler').CompileOptions} */
52
+ /** @type {import('@rsvelte/vite-plugin-svelte-native').CompileOptions} */
53
53
  const compileOptions = {
54
54
  ...options.compilerOptions,
55
55
  filename,
@@ -90,7 +90,7 @@ export function createCompileSvelte() {
90
90
  finalCompileOptions.sourcemap = sourcemap;
91
91
  }
92
92
  const endStat = stats?.start(filename);
93
- /** @type {import('@rsvelte/compiler').CompileResult} */
93
+ /** @type {import('@rsvelte/vite-plugin-svelte-native').CompileResult} */
94
94
  let compiled;
95
95
  try {
96
96
  compiled = svelte.compile(finalCode, { ...finalCompileOptions, filename });
@@ -2,7 +2,7 @@ import { buildExtendedLogMessage } from './log.js';
2
2
 
3
3
  /**
4
4
  * convert an error thrown by svelte.compile to a RollupError so that vite displays it in a user friendly way
5
- * @param {import('@rsvelte/compiler').Warning & Error & {frame?: string}} error a svelte compiler error, which is a mix of Warning and an error
5
+ * @param {import('@rsvelte/vite-plugin-svelte-native').Warning & Error & {frame?: string}} error a svelte compiler error, which is a mix of Warning and an error
6
6
  * @param {import('../types/options.d.ts').ResolvedOptions} options
7
7
  * @returns {import('vite').Rollup.RollupError} the converted error
8
8
  */
@@ -29,7 +29,7 @@ export function toRollupError(error, options) {
29
29
 
30
30
  /**
31
31
  * convert an error thrown by svelte.compile to an esbuild PartialMessage
32
- * @param {import('@rsvelte/compiler').Warning & Error & {frame?: string}} error a svelte compiler error, which is a mix of Warning and an error
32
+ * @param {import('@rsvelte/vite-plugin-svelte-native').Warning & Error & {frame?: string}} error a svelte compiler error, which is a mix of Warning and an error
33
33
  * @param {import('../types/options.d.ts').ResolvedOptions} options
34
34
  * @returns {any} the converted error as esbuild PartialMessage
35
35
  *
@@ -114,7 +114,7 @@ function couldBeFixedByCssPreprocessor(code) {
114
114
  }
115
115
 
116
116
  /**
117
- * @param {import('@rsvelte/compiler').Warning & Error} err a svelte compiler error, which is a mix of Warning and an error
117
+ * @param {import('@rsvelte/vite-plugin-svelte-native').Warning & Error} err a svelte compiler error, which is a mix of Warning and an error
118
118
  * @param {string} originalCode
119
119
  * @param {import('../public.d.ts').Options['preprocess']} [preprocessors]
120
120
  */
package/src/utils/log.js CHANGED
@@ -137,19 +137,19 @@ export const log = {
137
137
 
138
138
  /**
139
139
  * @param {import('../types/id.d.ts').SvelteRequest | import('../types/id.d.ts').SvelteModuleRequest} svelteRequest
140
- * @param {import('@rsvelte/compiler').Warning[]} warnings
140
+ * @param {import('@rsvelte/vite-plugin-svelte-native').Warning[]} warnings
141
141
  * @param {import('../types/options.d.ts').ResolvedOptions} options
142
142
  */
143
143
  export function logCompilerWarnings(svelteRequest, warnings, options) {
144
144
  const { emitCss, onwarn, isBuild } = options;
145
145
  const sendViaWS = !isBuild && options.experimental?.sendWarningsToBrowser;
146
146
  let warn = isBuild ? warnBuild : warnDev;
147
- /** @type {import('@rsvelte/compiler').Warning[]} */
147
+ /** @type {import('@rsvelte/vite-plugin-svelte-native').Warning[]} */
148
148
  const handledByDefaultWarn = [];
149
149
  const allWarnings = warnings?.filter((w) => !ignoreCompilerWarning(w, isBuild, emitCss));
150
150
  if (sendViaWS) {
151
151
  const _warn = warn;
152
- /** @type {(w: import('@rsvelte/compiler').Warning) => void} */
152
+ /** @type {(w: import('@rsvelte/vite-plugin-svelte-native').Warning) => void} */
153
153
  warn = (w) => {
154
154
  handledByDefaultWarn.push(w);
155
155
  _warn(w);
@@ -179,7 +179,7 @@ export function logCompilerWarnings(svelteRequest, warnings, options) {
179
179
  }
180
180
 
181
181
  /**
182
- * @param {import('@rsvelte/compiler').Warning} warning
182
+ * @param {import('@rsvelte/vite-plugin-svelte-native').Warning} warning
183
183
  * @param {boolean} isBuild
184
184
  * @param {boolean} [emitCss]
185
185
  * @returns {boolean}
@@ -193,7 +193,7 @@ function ignoreCompilerWarning(warning, isBuild, emitCss) {
193
193
 
194
194
  /**
195
195
  *
196
- * @param {import('@rsvelte/compiler').Warning} warning
196
+ * @param {import('@rsvelte/vite-plugin-svelte-native').Warning} warning
197
197
  * @returns {boolean}
198
198
  */
199
199
  function isNoScopableElementWarning(warning) {
@@ -202,7 +202,7 @@ function isNoScopableElementWarning(warning) {
202
202
  }
203
203
 
204
204
  /**
205
- * @param {import('@rsvelte/compiler').Warning} w
205
+ * @param {import('@rsvelte/vite-plugin-svelte-native').Warning} w
206
206
  */
207
207
  function warnDev(w) {
208
208
  if (w.filename?.includes('node_modules')) {
@@ -215,7 +215,7 @@ function warnDev(w) {
215
215
  }
216
216
 
217
217
  /**
218
- * @param {import('@rsvelte/compiler').Warning & {frame?: string}} w
218
+ * @param {import('@rsvelte/vite-plugin-svelte-native').Warning & {frame?: string}} w
219
219
  */
220
220
  function warnBuild(w) {
221
221
  if (w.filename?.includes('node_modules')) {
@@ -228,7 +228,7 @@ function warnBuild(w) {
228
228
  }
229
229
 
230
230
  /**
231
- * @param {import('@rsvelte/compiler').Warning} w
231
+ * @param {import('@rsvelte/vite-plugin-svelte-native').Warning} w
232
232
  */
233
233
  export function buildExtendedLogMessage(w) {
234
234
  const parts = [];
@@ -5,14 +5,14 @@ import { LINK_TRANSFORM_WITH_PLUGIN } from './constants.js';
5
5
  * @param {import('../types/options.d.ts').ResolvedOptions} options
6
6
  * @param {import('vite').ResolvedConfig} config
7
7
  * @returns {{
8
- * prependPreprocessors: import('@rsvelte/compiler').PreprocessorGroup[],
9
- * appendPreprocessors: import('@rsvelte/compiler').PreprocessorGroup[]
8
+ * prependPreprocessors: import('@rsvelte/vite-plugin-svelte-native').PreprocessorGroup[],
9
+ * appendPreprocessors: import('@rsvelte/vite-plugin-svelte-native').PreprocessorGroup[]
10
10
  * }}
11
11
  */
12
12
  function buildExtraPreprocessors(options, config) {
13
- /** @type {import('@rsvelte/compiler').PreprocessorGroup[]} */
13
+ /** @type {import('@rsvelte/vite-plugin-svelte-native').PreprocessorGroup[]} */
14
14
  const prependPreprocessors = [];
15
- /** @type {import('@rsvelte/compiler').PreprocessorGroup[]} */
15
+ /** @type {import('@rsvelte/vite-plugin-svelte-native').PreprocessorGroup[]} */
16
16
  const appendPreprocessors = [];
17
17
 
18
18
  /** @type {import('vite').Plugin[]} */
@@ -1,4 +1,4 @@
1
- import { VERSION } from '@rsvelte/compiler';
1
+ import { VERSION } from '@rsvelte/vite-plugin-svelte-native';
2
2
 
3
3
  /**
4
4
  * @type {boolean}