Socket
Socket
Sign inDemoInstall

@sveltejs/vite-plugin-svelte

Package Overview
Dependencies
Maintainers
4
Versions
107
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sveltejs/vite-plugin-svelte - npm Package Compare versions

Comparing version 1.0.0-next.15 to 1.0.0-next.16

51

dist/index.js

@@ -506,2 +506,3 @@ var __create = Object.create;

"svelte/motion",
"svelte/ssr",
"svelte/store",

@@ -628,19 +629,24 @@ "svelte/transition",

function buildExtraViteConfig(options, config) {
var _a, _b, _c, _d;
const allSvelteImports = [...SVELTE_IMPORTS, ...SVELTE_HMR_IMPORTS];
const excludeFromOptimize = allSvelteImports.filter((x) => {
var _a2, _b2;
return !((_b2 = (_a2 = config.optimizeDeps) == null ? void 0 : _a2.include) == null ? void 0 : _b2.includes(x));
});
var _a, _b, _c, _d, _e, _f;
const include = [];
const exclude = ["svelte-hmr"];
const isSvelteExcluded = (_b = (_a = config.optimizeDeps) == null ? void 0 : _a.exclude) == null ? void 0 : _b.includes("svelte");
if (!isSvelteExcluded) {
log.debug(`adding bare svelte packages to optimizeDeps.include: ${SVELTE_IMPORTS.join(", ")} `);
include.push(...SVELTE_IMPORTS);
} else {
log.debug('"svelte" is excluded in optimizeDeps.exclude, skipped adding it to include.');
}
const extraViteConfig = {
optimizeDeps: {
exclude: excludeFromOptimize
include,
exclude
},
resolve: {
mainFields: [...SVELTE_RESOLVE_MAIN_FIELDS],
dedupe: allSvelteImports
dedupe: [...SVELTE_IMPORTS, ...SVELTE_HMR_IMPORTS]
}
};
if (options.isBuild && ((_a = config.build) == null ? void 0 : _a.ssr)) {
if (!((_c = (_b = config.ssr) == null ? void 0 : _b.external) == null ? void 0 : _c.includes("svelte"))) {
if (options.isBuild && ((_c = config.build) == null ? void 0 : _c.ssr)) {
if (!((_e = (_d = config.ssr) == null ? void 0 : _d.external) == null ? void 0 : _e.includes("svelte"))) {
extraViteConfig.ssr = {

@@ -651,3 +657,3 @@ noExternal: ["svelte"]

}
if ((_d = options.experimental) == null ? void 0 : _d.useVitePreprocess) {
if ((_f = options.experimental) == null ? void 0 : _f.useVitePreprocess) {
extraViteConfig.esbuild = {

@@ -790,3 +796,3 @@ tsconfigRaw: {

};
const listeners = {
const listenerCollection = {
add: [],

@@ -797,13 +803,18 @@ change: [emitChangeEventOnDependants],

if (svelteConfigFile) {
listeners.change.push(restartOnConfigChange);
listeners.unlink.push(restartOnConfigChange);
listenerCollection.change.push(restartOnConfigChange);
listenerCollection.unlink.push(restartOnConfigChange);
} else {
listeners.add.push(restartOnConfigAdd);
listenerCollection.add.push(restartOnConfigAdd);
}
Object.entries(listeners).forEach(([evt, listeners2]) => {
if (listeners2.length > 0) {
watcher.on(evt, (filename) => listeners2.forEach((listener) => listener(filename)));
Object.entries(listenerCollection).forEach(([evt, listeners]) => {
if (listeners.length > 0) {
watcher.on(evt, (filename) => listeners.forEach((listener) => listener(filename)));
}
});
}
function ensureWatchedFile(watcher, file, root) {
if (file && !file.startsWith(root + "/") && !file.includes("\0") && fs3.existsSync(file)) {
watcher.add(path3.resolve(file));
}
}

@@ -1160,3 +1171,5 @@ // src/utils/resolve.ts

if (((_a = compileData.dependencies) == null ? void 0 : _a.length) && options.server) {
compileData.dependencies.forEach((d) => this.addWatchFile(d));
compileData.dependencies.forEach((d) => {
ensureWatchedFile(options.server.watcher, d, options.root);
});
}

@@ -1163,0 +1176,0 @@ log.debug(`transform returns compiled js for ${filename}`);

{
"name": "@sveltejs/vite-plugin-svelte",
"version": "1.0.0-next.15",
"version": "1.0.0-next.16",
"license": "MIT",

@@ -24,7 +24,2 @@ "author": "dominikg",

},
"scripts": {
"dev": "pnpm run build:ci -- --watch src",
"build:ci": "rimraf dist && tsup-node src/index.ts --format esm,cjs --no-splitting",
"build": "pnpm run build:ci -- --dts --sourcemap"
},
"engines": {

@@ -69,8 +64,13 @@ "node": "^12.20 || ^14.13.1 || >= 16"

"diff-match-patch": "^1.0.5",
"esbuild": "^0.12.16",
"rollup": "^2.55.0",
"svelte": "^3.41.0",
"tsup": "^4.12.5",
"esbuild": "^0.12.18",
"rollup": "^2.56.0",
"svelte": "^3.42.1",
"tsup": "^4.13.1",
"vite": "^2.4.4"
},
"scripts": {
"dev": "pnpm run build:ci -- --watch src",
"build:ci": "rimraf dist && tsup-node src/index.ts --format esm,cjs --no-splitting",
"build": "pnpm run build:ci -- --dts --sourcemap"
}
}
}

@@ -16,3 +16,3 @@ import fs from 'fs';

import { setupWatchers } from './utils/watch';
import { ensureWatchedFile, setupWatchers } from './utils/watch';
import { resolveViaPackageJsonSvelte } from './utils/resolve';

@@ -168,3 +168,5 @@ import { addExtraPreprocessors } from './utils/preprocess';

if (compileData.dependencies?.length && options.server) {
compileData.dependencies.forEach((d) => this.addWatchFile(d));
compileData.dependencies.forEach((d) => {
ensureWatchedFile(options.server!.watcher, d, options.root);
});
}

@@ -171,0 +173,0 @@ log.debug(`transform returns compiled js for ${filename}`);

@@ -10,2 +10,3 @@ const VITE_RESOLVE_MAIN_FIELDS = ['module', 'jsnext:main', 'jsnext'];

'svelte/motion',
'svelte/ssr',
'svelte/store',

@@ -12,0 +13,0 @@ 'svelte/transition',

@@ -182,16 +182,20 @@ /* eslint-disable no-unused-vars */

): Partial<UserConfig> {
const allSvelteImports = [...SVELTE_IMPORTS, ...SVELTE_HMR_IMPORTS];
// exclude svelte imports from optimization unless explicitly included
const excludeFromOptimize = allSvelteImports.filter(
(x) => !config.optimizeDeps?.include?.includes(x)
);
// include svelte imports for optimization unless explicitly excluded
const include: string[] = [];
const exclude: string[] = ['svelte-hmr'];
const isSvelteExcluded = config.optimizeDeps?.exclude?.includes('svelte');
if (!isSvelteExcluded) {
log.debug(`adding bare svelte packages to optimizeDeps.include: ${SVELTE_IMPORTS.join(', ')} `);
include.push(...SVELTE_IMPORTS);
} else {
log.debug('"svelte" is excluded in optimizeDeps.exclude, skipped adding it to include.');
}
const extraViteConfig: Partial<UserConfig> = {
optimizeDeps: {
exclude: excludeFromOptimize
include,
exclude
},
resolve: {
mainFields: [...SVELTE_RESOLVE_MAIN_FIELDS],
dedupe: allSvelteImports
dedupe: [...SVELTE_IMPORTS, ...SVELTE_HMR_IMPORTS]
}

@@ -198,0 +202,0 @@ // this option is still awaiting a PR in vite to be supported

@@ -8,2 +8,3 @@ import { VitePluginSvelteCache } from './vite-plugin-svelte-cache';

import path from 'path';
import { FSWatcher } from 'vite';

@@ -75,4 +76,4 @@ export function setupWatchers(

// collection of watcher listeners by event
const listeners = {
add: [],
const listenerCollection = {
add: [] as Array<Function>,
change: [emitChangeEventOnDependants],

@@ -82,10 +83,9 @@ unlink: [removeUnlinkedFromCache, emitChangeEventOnDependants]

if (svelteConfigFile) {
listeners.change.push(restartOnConfigChange);
listeners.unlink.push(restartOnConfigChange);
listenerCollection.change.push(restartOnConfigChange);
listenerCollection.unlink.push(restartOnConfigChange);
} else {
// @ts-ignore
listeners.add.push(restartOnConfigAdd);
listenerCollection.add.push(restartOnConfigAdd);
}
Object.entries(listeners).forEach(([evt, listeners]) => {
Object.entries(listenerCollection).forEach(([evt, listeners]) => {
if (listeners.length > 0) {

@@ -96,1 +96,15 @@ watcher.on(evt, (filename) => listeners.forEach((listener) => listener(filename)));

}
// taken from vite utils
export function ensureWatchedFile(watcher: FSWatcher, file: string | null, root: string): void {
if (
file &&
// only need to watch if out of root
!file.startsWith(root + '/') &&
// some rollup plugins use null bytes for private resolved Ids
!file.includes('\0') &&
fs.existsSync(file)
) {
// resolve file to normalized system path
watcher.add(path.resolve(file));
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc