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.44 to 1.0.0-next.45

6

dist/index.d.ts

@@ -49,7 +49,9 @@ import { Plugin } from 'vite';

/**
* The options to be passed to the Svelte compiler
* The options to be passed to the Svelte compiler. A few options are set by default,
* including `dev` and `css`. However, some options are non-configurable, like
* `filename`, `format`, `generate`, and `cssHash` (in dev).
*
* @see https://svelte.dev/docs#svelte_compile
*/
compilerOptions?: CompileOptions;
compilerOptions?: Omit<CompileOptions, 'filename' | 'format' | 'generate'>;
/**

@@ -56,0 +58,0 @@ * Handles warning emitted from the Svelte compiler

@@ -283,3 +283,4 @@ var __defProp = Object.defineProperty;

filename,
generate: ssr ? "ssr" : "dom"
generate: ssr ? "ssr" : "dom",
format: "esm"
});

@@ -1087,6 +1088,3 @@ if (options.hot && options.emitCss) {

extensions: [".svelte"],
emitCss: true,
compilerOptions: {
format: "esm"
}
emitCss: true
};

@@ -1128,2 +1126,3 @@ const svelteConfig = await loadSvelteConfig(viteConfigWithResolvedRoot, inlineOptions);

const merged = mergeConfigs(defaultOptions, preResolveOptions2, extraOptions);
removeIgnoredOptions(merged);
addExtraPreprocessors(merged, viteConfig);

@@ -1177,2 +1176,16 @@ enforceOptionsForHmr(merged);

}
function removeIgnoredOptions(options) {
const ignoredCompilerOptions = ["generate", "format", "filename"];
if (options.hot && options.emitCss) {
ignoredCompilerOptions.push("cssHash");
}
const passedCompilerOptions = Object.keys(options.compilerOptions || {});
const passedIgnored = passedCompilerOptions.filter((o) => ignoredCompilerOptions.includes(o));
if (passedIgnored.length) {
log.warn(`The following Svelte compilerOptions are controlled by vite-plugin-svelte and essential to its functionality. User-specified values are ignored. Please remove them from your configuration: ${passedIgnored.join(", ")}`);
passedIgnored.forEach((ignored) => {
delete options.compilerOptions[ignored];
});
}
}
function resolveViteRoot(viteConfig) {

@@ -1549,3 +1562,3 @@ return normalizePath2(viteConfig.root ? path4.resolve(viteConfig.root) : process.cwd());

if (vps.api.options.kit && !inspectorOptions.appendTo) {
const out_dir = vps.api.options.kit.outDir || ".svelte-kit";
const out_dir = path8.basename(vps.api.options.kit.outDir || ".svelte-kit");
inspectorOptions.appendTo = `${out_dir}/runtime/client/start.js`;

@@ -1552,0 +1565,0 @@ }

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

@@ -48,3 +48,3 @@ "author": "dominikg",

"kleur": "^4.1.4",
"magic-string": "^0.26.1",
"magic-string": "^0.26.2",
"svelte-hmr": "^0.14.11"

@@ -66,7 +66,7 @@ },

"diff-match-patch": "^1.0.5",
"esbuild": "^0.14.38",
"rollup": "^2.72.1",
"esbuild": "^0.14.39",
"rollup": "^2.74.1",
"svelte": "^3.48.0",
"tsup": "^5.12.7",
"vite": "^2.9.8"
"tsup": "^5.12.8",
"vite": "^2.9.9"
},

@@ -73,0 +73,0 @@ "scripts": {

@@ -46,3 +46,3 @@ import { Plugin, normalizePath } from 'vite';

if (vps.api.options.kit && !inspectorOptions.appendTo) {
const out_dir = vps.api.options.kit.outDir || '.svelte-kit';
const out_dir = path.basename(vps.api.options.kit.outDir || '.svelte-kit');
inspectorOptions.appendTo = `${out_dir}/runtime/client/start.js`;

@@ -49,0 +49,0 @@ }

@@ -0,4 +1,8 @@

import { describe, it, expect } from 'vitest';
import { findRootSvelteDependencies, needsOptimization } from '../dependencies';
import * as path from 'path';
import { createRequire } from 'module';
import { fileURLToPath } from 'url';
const __dir = path.dirname(fileURLToPath(import.meta.url));
const e2eTestRoot = path.resolve(__dir, '../../../../../packages/e2e-tests');

@@ -14,5 +18,3 @@ describe('dependencies', () => {

it('should find nested svelte dependencies in packages/e2e-test/package-json-svelte-field', () => {
const deps = findRootSvelteDependencies(
path.resolve('packages/e2e-tests/package-json-svelte-field')
);
const deps = findRootSvelteDependencies(path.join(e2eTestRoot, 'package-json-svelte-field'));
expect(deps).toHaveLength(3);

@@ -33,3 +35,4 @@ const hybrid = deps.find((dep) => dep.name === 'e2e-test-dep-svelte-hybrid');

it('should optimize cjs deps only', () => {
const localRequire = createRequire(path.resolve('packages/e2e-tests/dependencies'));
const testDepsPath = path.join(e2eTestRoot, 'dependencies/package.json');
const localRequire = createRequire(testDepsPath);
expect(needsOptimization('e2e-test-dep-cjs-and-esm', localRequire)).toBe(false);

@@ -36,0 +39,0 @@ expect(needsOptimization('e2e-test-dep-cjs-only', localRequire)).toBe(true);

@@ -0,1 +1,2 @@

import { describe, it, expect } from 'vitest';
import { buildMagicString, buildSourceMap } from '../sourcemap';

@@ -2,0 +3,0 @@

@@ -24,3 +24,4 @@ import { CompileOptions, ResolvedOptions } from './options';

filename,
generate: ssr ? 'ssr' : 'dom'
generate: ssr ? 'ssr' : 'dom',
format: 'esm'
};

@@ -27,0 +28,0 @@ if (options.hot && options.emitCss) {

@@ -64,6 +64,3 @@ /* eslint-disable no-unused-vars */

extensions: ['.svelte'],
emitCss: true,
compilerOptions: {
format: 'esm'
}
emitCss: true
};

@@ -122,2 +119,3 @@ const svelteConfig = await loadSvelteConfig(viteConfigWithResolvedRoot, inlineOptions);

removeIgnoredOptions(merged);
addExtraPreprocessors(merged, viteConfig);

@@ -182,2 +180,22 @@ enforceOptionsForHmr(merged);

function removeIgnoredOptions(options: ResolvedOptions) {
const ignoredCompilerOptions = ['generate', 'format', 'filename'];
if (options.hot && options.emitCss) {
ignoredCompilerOptions.push('cssHash');
}
const passedCompilerOptions = Object.keys(options.compilerOptions || {});
const passedIgnored = passedCompilerOptions.filter((o) => ignoredCompilerOptions.includes(o));
if (passedIgnored.length) {
log.warn(
`The following Svelte compilerOptions are controlled by vite-plugin-svelte and essential to its functionality. User-specified values are ignored. Please remove them from your configuration: ${passedIgnored.join(
', '
)}`
);
passedIgnored.forEach((ignored) => {
// @ts-expect-error string access
delete options.compilerOptions[ignored];
});
}
}
// vite passes unresolved `root`option to config hook but we need the resolved value, so do it here

@@ -407,7 +425,9 @@ // https://github.com/sveltejs/vite-plugin-svelte/issues/113

/**
* The options to be passed to the Svelte compiler
* The options to be passed to the Svelte compiler. A few options are set by default,
* including `dev` and `css`. However, some options are non-configurable, like
* `filename`, `format`, `generate`, and `cssHash` (in dev).
*
* @see https://svelte.dev/docs#svelte_compile
*/
compilerOptions?: CompileOptions;
compilerOptions?: Omit<CompileOptions, 'filename' | 'format' | 'generate'>;

@@ -414,0 +434,0 @@ /**

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

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