@sveltejs/vite-plugin-svelte 2.4.4 → 2.4.6

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": "2.4.4",
3
+ "version": "2.4.6",
4
4
  "license": "MIT",
5
5
  "author": "dominikg",
6
6
  "files": [
@@ -34,13 +34,13 @@
34
34
  },
35
35
  "homepage": "https://github.com/sveltejs/vite-plugin-svelte#readme",
36
36
  "dependencies": {
37
+ "@sveltejs/vite-plugin-svelte-inspector": "^1.0.4",
37
38
  "debug": "^4.3.4",
38
39
  "deepmerge": "^4.3.1",
39
40
  "kleur": "^4.1.5",
40
- "magic-string": "^0.30.2",
41
+ "magic-string": "^0.30.3",
41
42
  "svelte-hmr": "^0.15.3",
42
- "vitefu": "^0.2.4",
43
- "@sveltejs/vite-plugin-svelte-inspector": "^1.0.3"
43
+ "vitefu": "^0.2.4"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "svelte": "^3.54.0 || ^4.0.0",
@@ -48,9 +48,9 @@
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/debug": "^4.1.8",
51
- "esbuild": "^0.18.17",
52
- "svelte": "^4.1.2",
53
- "vite": "^4.4.8"
51
+ "esbuild": "^0.19.3",
52
+ "svelte": "^4.2.0",
53
+ "vite": "^4.4.9"
54
54
  },
55
55
  "scripts": {
56
56
  "check:publint": "publint --strict",
package/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import fs from 'fs';
1
+ import fs from 'node:fs';
2
2
  import { version as viteVersion } from 'vite';
3
3
 
4
4
  import { svelteInspector } from '@sveltejs/vite-plugin-svelte-inspector';
@@ -19,7 +19,7 @@ export interface Compiled {
19
19
  css: Code;
20
20
  ast: any; // TODO type
21
21
  warnings: any[]; // TODO type
22
- vars: {
22
+ vars: Array<{
23
23
  name: string;
24
24
  export_name: string;
25
25
  injected: boolean;
@@ -29,7 +29,7 @@ export interface Compiled {
29
29
  referenced: boolean;
30
30
  writable: boolean;
31
31
  referenced_from_script: boolean;
32
- }[];
32
+ }>;
33
33
  stats: {
34
34
  timings: {
35
35
  total: number;
@@ -1,5 +1,5 @@
1
- import path from 'path';
2
- import fs from 'fs/promises';
1
+ import path from 'node:path';
2
+ import fs from 'node:fs/promises';
3
3
  import { findDepPkgJsonPath } from 'vitefu';
4
4
 
5
5
  /**
@@ -30,8 +30,9 @@ export async function resolveDependencyData(dep, parent) {
30
30
  const COMMON_DEPENDENCIES_WITHOUT_SVELTE_FIELD = [
31
31
  '@lukeed/uuid',
32
32
  '@playwright/test',
33
- '@sveltejs/vite-plugin-svelte',
34
33
  '@sveltejs/kit',
34
+ '@sveltejs/package',
35
+ '@sveltejs/vite-plugin-svelte',
35
36
  'autoprefixer',
36
37
  'cookie',
37
38
  'dotenv',
@@ -43,6 +44,7 @@ const COMMON_DEPENDENCIES_WITHOUT_SVELTE_FIELD = [
43
44
  'postcss',
44
45
  'prettier',
45
46
  'svelte',
47
+ 'svelte2tsx',
46
48
  'svelte-check',
47
49
  'svelte-hmr',
48
50
  'svelte-preprocess',
@@ -1,4 +1,4 @@
1
- import { readFileSync } from 'fs';
1
+ import { readFileSync } from 'node:fs';
2
2
  import { compile, preprocess } from 'svelte/compiler';
3
3
  import { log } from './log.js';
4
4
  import { toESBuildError } from './error.js';
@@ -24,7 +24,7 @@ export function esbuildSveltePlugin(options) {
24
24
  if (build.initialOptions.plugins?.some((v) => v.name === 'vite:dep-scan')) return;
25
25
 
26
26
  const svelteExtensions = (options.extensions ?? ['.svelte']).map((ext) => ext.slice(1));
27
- const svelteFilter = new RegExp(`\\.(` + svelteExtensions.join('|') + `)(\\?.*)?$`);
27
+ const svelteFilter = new RegExp('\\.(' + svelteExtensions.join('|') + ')(\\?.*)?$');
28
28
  /** @type {import('../types/vite-plugin-svelte-stats.d.ts').StatCollection | undefined} */
29
29
  let statsCollection;
30
30
  build.onStart(() => {
@@ -106,5 +106,7 @@ async function compileSvelte(options, { filename, code }, statsCollection) {
106
106
  if (endStat) {
107
107
  endStat();
108
108
  }
109
- return compiled.js.code + '//# sourceMappingURL=' + compiled.js.map.toUrl();
109
+ return compiled.js.map
110
+ ? compiled.js.code + '//# sourceMappingURL=' + compiled.js.map.toUrl()
111
+ : compiled.js.code;
110
112
  }
package/src/utils/hash.js CHANGED
@@ -1,4 +1,4 @@
1
- import * as crypto from 'crypto';
1
+ import * as crypto from 'node:crypto';
2
2
 
3
3
  const hashes = Object.create(null);
4
4
 
package/src/utils/id.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createFilter, normalizePath } from 'vite';
2
- import * as fs from 'fs';
2
+ import * as fs from 'node:fs';
3
3
  import { log } from './log.js';
4
4
 
5
5
  const VITE_FS_PREFIX = '/@fs/';
@@ -21,7 +21,7 @@ const TYPES_WITH_COMPILER_OPTIONS = ['style', 'script', 'all'];
21
21
  * @returns {{ filename: string, rawQuery: string }}
22
22
  */
23
23
  function splitId(id) {
24
- const parts = id.split(`?`, 2);
24
+ const parts = id.split('?', 2);
25
25
  const filename = parts[0];
26
26
  const rawQuery = parts[1];
27
27
  return { filename, rawQuery };
@@ -1,4 +1,4 @@
1
- import fs from 'fs';
1
+ import fs from 'node:fs';
2
2
  import { toRollupError } from './error.js';
3
3
  import { log } from './log.js';
4
4
 
@@ -126,7 +126,7 @@ function toRawExports(object) {
126
126
  .map(([key, value]) => `export const ${key}=${JSON.stringify(value)}`)
127
127
  .join('\n') + '\n';
128
128
  if (Object.prototype.hasOwnProperty.call(object, 'code')) {
129
- exports += `export default code\n`;
129
+ exports += 'export default code\n';
130
130
  }
131
131
  return exports;
132
132
  }
@@ -1,7 +1,7 @@
1
- import { createRequire } from 'module';
2
- import path from 'path';
3
- import fs from 'fs';
4
- import { pathToFileURL } from 'url';
1
+ import { createRequire } from 'node:module';
2
+ import path from 'node:path';
3
+ import fs from 'node:fs';
4
+ import { pathToFileURL } from 'node:url';
5
5
  import { log } from './log.js';
6
6
 
7
7
  // used to require cjs config in esm.
package/src/utils/log.js CHANGED
@@ -204,7 +204,8 @@ function buildExtraWarnings(warnings, isBuild) {
204
204
  extraWarnings.push({
205
205
  ...noScopableElementWarning,
206
206
  code: 'vite-plugin-svelte-css-no-scopable-elements',
207
- message: `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.`
207
+ message:
208
+ "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."
208
209
  });
209
210
  }
210
211
  }
@@ -1,5 +1,5 @@
1
- import { promises as fs } from 'fs';
2
- import path from 'path';
1
+ import { promises as fs } from 'node:fs';
2
+ import path from 'node:path';
3
3
 
4
4
  // List of options that changes the prebundling result
5
5
  /** @type {(keyof import('../types/options.d.ts').ResolvedOptions)[]} */
@@ -10,7 +10,7 @@ import {
10
10
  VITE_RESOLVE_MAIN_FIELDS
11
11
  } from './constants.js';
12
12
 
13
- import path from 'path';
13
+ import path from 'node:path';
14
14
  import { esbuildSveltePlugin, facadeEsbuildSveltePluginName } from './esbuild.js';
15
15
  import { addExtraPreprocessors } from './preprocess.js';
16
16
  import deepmerge from 'deepmerge';
@@ -1,6 +1,6 @@
1
1
  import MagicString from 'magic-string';
2
2
  import { log } from './log.js';
3
- import path from 'path';
3
+ import path from 'node:path';
4
4
 
5
5
  /**
6
6
  * this appends a *{} rule to component styles to force the svelte compiler to add style classes to all nodes
@@ -1,5 +1,5 @@
1
- import path from 'path';
2
- import { builtinModules } from 'module';
1
+ import path from 'node:path';
2
+ import { builtinModules } from 'node:module';
3
3
  import { resolveDependencyData, isCommonDepWithoutSvelteField } from './dependencies.js';
4
4
  import { normalizePath } from 'vite';
5
5
 
@@ -1,4 +1,4 @@
1
- import path from 'path';
1
+ import path from 'node:path';
2
2
 
3
3
  const IS_WINDOWS = process.platform === 'win32';
4
4
 
@@ -1,5 +1,5 @@
1
- import { readFileSync } from 'fs';
2
- import { dirname } from 'path';
1
+ import { readFileSync } from 'node:fs';
2
+ import { dirname } from 'node:path';
3
3
  import { findClosestPkgJsonPath } from 'vitefu';
4
4
  import { normalizePath } from 'vite';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { log } from './log.js';
2
- import { performance } from 'perf_hooks';
2
+ import { performance } from 'node:perf_hooks';
3
3
  import { normalizePath } from 'vite';
4
4
 
5
5
  /** @type {import('../types/vite-plugin-svelte-stats.d.ts').CollectionOptions} */
@@ -1,7 +1,7 @@
1
- import fs from 'fs';
1
+ import fs from 'node:fs';
2
2
  import { log } from './log.js';
3
3
  import { knownSvelteConfigNames } from './load-svelte-config.js';
4
- import path from 'path';
4
+ import path from 'node:path';
5
5
 
6
6
  /**
7
7
  * @param {import('../types/options.d.ts').ResolvedOptions} options