@sveltejs/vite-plugin-svelte
Advanced tools
Comparing version 3.0.0-next.1 to 3.0.0-next.2
{ | ||
"name": "@sveltejs/vite-plugin-svelte", | ||
"version": "3.0.0-next.1", | ||
"version": "3.0.0-next.2", | ||
"license": "MIT", | ||
"author": "dominikg", | ||
"files": [ | ||
"src" | ||
"src", | ||
"types" | ||
], | ||
"type": "module", | ||
"types": "src/index.d.ts", | ||
"types": "types/index.d.ts", | ||
"exports": { | ||
".": { | ||
"types": "./src/index.d.ts", | ||
"import": "./src/index.js" | ||
}, | ||
"./package.json": "./package.json" | ||
"import": { | ||
"types": "./types/index.d.ts", | ||
"default": "./src/index.js" | ||
} | ||
} | ||
}, | ||
@@ -50,11 +52,13 @@ "engines": { | ||
"devDependencies": { | ||
"@types/debug": "^4.1.9", | ||
"esbuild": "^0.19.4", | ||
"svelte": "^4.2.1", | ||
"vite": "^5.0.0-beta.7" | ||
"@types/debug": "^4.1.10", | ||
"esbuild": "^0.19.5", | ||
"sass": "^1.69.5", | ||
"svelte": "^4.2.2", | ||
"vite": "^5.0.0-beta.12" | ||
}, | ||
"scripts": { | ||
"check:publint": "publint --strict", | ||
"check:types": "tsc --noEmit" | ||
"check:types": "tsc --noEmit", | ||
"generate:types": "dts-buddy -m \"@sveltejs/vite-plugin-svelte:src/public.d.ts\"" | ||
} | ||
} |
@@ -23,3 +23,6 @@ import fs from 'node:fs'; | ||
/** @type {import('./index.d.ts').svelte} */ | ||
/** | ||
* @param {Partial<import('./public.d.ts').Options>} [inlineOptions] | ||
* @returns {import('vite').Plugin[]} | ||
*/ | ||
export function svelte(inlineOptions) { | ||
@@ -26,0 +29,0 @@ if (process.env.DEBUG != null) { |
@@ -12,5 +12,8 @@ import { isCSSRequest, preprocessCSS, resolveConfig, transformWithEsbuild } from 'vite'; | ||
/** @type {import('./index.d.ts').vitePreprocess} */ | ||
/** | ||
* @param {import('./public.d.ts').VitePreprocessOptions} opts | ||
* @returns {import('svelte/compiler').PreprocessorGroup} | ||
*/ | ||
export function vitePreprocess(opts) { | ||
/** @type {import('svelte/types/compiler/preprocess').PreprocessorGroup} */ | ||
/** @type {import('svelte/compiler').PreprocessorGroup} */ | ||
const preprocessor = { name: 'vite-preprocess' }; | ||
@@ -28,3 +31,3 @@ if (opts?.script !== false) { | ||
/** | ||
* @returns {{ script: import('svelte/types/compiler/preprocess').Preprocessor }} | ||
* @returns {{ script: import('svelte/compiler').Preprocessor }} | ||
*/ | ||
@@ -60,3 +63,3 @@ function viteScript() { | ||
* @param {import('vite').ResolvedConfig | import('vite').InlineConfig} config | ||
* @returns {{ style: import('svelte/types/compiler/preprocess').Preprocessor }} | ||
* @returns {{ style: import('svelte/compiler').Preprocessor }} | ||
*/ | ||
@@ -66,3 +69,3 @@ function viteStyle(config = {}) { | ||
let transform; | ||
/** @type {import('svelte/types/compiler/preprocess').Preprocessor} */ | ||
/** @type {import('svelte/compiler').Preprocessor} */ | ||
const style = async ({ attributes, content, filename = '' }) => { | ||
@@ -69,0 +72,0 @@ const ext = attributes.lang ? `.${attributes.lang}` : '.css'; |
@@ -1,2 +0,2 @@ | ||
import type { Processed } from 'svelte/types/compiler/preprocess'; | ||
import type { Processed, CompileResult } from 'svelte/compiler'; | ||
import type { SvelteRequest } from './id.d.ts'; | ||
@@ -17,25 +17,2 @@ import type { ResolvedOptions } from './options.d.ts'; | ||
export interface Compiled { | ||
js: Code; | ||
css: Code; | ||
ast: any; // TODO type | ||
warnings: any[]; // TODO type | ||
vars: Array<{ | ||
name: string; | ||
export_name: string; | ||
injected: boolean; | ||
module: boolean; | ||
mutated: boolean; | ||
reassigned: boolean; | ||
referenced: boolean; | ||
writable: boolean; | ||
referenced_from_script: boolean; | ||
}>; | ||
stats: { | ||
timings: { | ||
total: number; | ||
}; | ||
}; | ||
} | ||
export interface CompileData { | ||
@@ -45,3 +22,3 @@ filename: string; | ||
lang: string; | ||
compiled: Compiled; | ||
compiled: CompileResult; | ||
ssr: boolean | undefined; | ||
@@ -48,0 +25,0 @@ dependencies: string[]; |
@@ -1,2 +0,2 @@ | ||
import type { Warning } from '../index.d.ts'; | ||
import type { Warning } from 'svelte/types/compiler/interfaces'; | ||
@@ -3,0 +3,0 @@ export interface LogFn extends SimpleLogFn { |
import type { CompileOptions } from 'svelte/types/compiler/interfaces'; | ||
import type { ViteDevServer } from 'vite'; | ||
import { VitePluginSvelteStats } from '../utils/vite-plugin-svelte-stats.js'; | ||
import type { Options } from '../index.d.ts'; | ||
import type { Options } from '../public.d.ts'; | ||
@@ -6,0 +6,0 @@ export interface PreResolvedOptions extends Options { |
@@ -57,3 +57,3 @@ import { compile, preprocess, walk } from 'svelte/compiler'; | ||
} | ||
/** @type {import('../index.d.ts').CompileOptions} */ | ||
/** @type {import('svelte/compiler').CompileOptions} */ | ||
const compileOptions = { | ||
@@ -60,0 +60,0 @@ ...options.compilerOptions, |
@@ -107,3 +107,3 @@ import { buildExtendedLogMessage } from './log.js'; | ||
* @param {string} originalCode | ||
* @param {import('../index.js').Arrayable<import('svelte/types/compiler/preprocess').PreprocessorGroup>} [preprocessors] | ||
* @param {import('../public.d.ts').Options['preprocess']} [preprocessors] | ||
*/ | ||
@@ -110,0 +110,0 @@ export function enhanceCompileError(err, originalCode, preprocessors) { |
@@ -62,3 +62,3 @@ import { readFileSync } from 'node:fs'; | ||
} | ||
/** @type {import('../index.d.ts').CompileOptions} */ | ||
/** @type {import('svelte/compiler').CompileOptions} */ | ||
const compileOptions = { | ||
@@ -65,0 +65,0 @@ ...options.compilerOptions, |
@@ -162,4 +162,4 @@ import { createFilter, normalizePath } from 'vite'; | ||
/** | ||
* @param {import('../index.d.ts').Arrayable<string> | undefined} include | ||
* @param {import('../index.d.ts').Arrayable<string> | undefined} exclude | ||
* @param {import('../public.d.ts').Options['include'] | undefined} include | ||
* @param {import('../public.d.ts').Options['exclude'] | undefined} exclude | ||
* @param {string[]} extensions | ||
@@ -166,0 +166,0 @@ * @returns {(filename: string) => boolean} |
@@ -19,12 +19,15 @@ import { createRequire } from 'node:module'; | ||
// hide dynamic import from ts transform to prevent it turning into a require | ||
// see https://github.com/microsoft/TypeScript/issues/43329#issuecomment-811606238 | ||
// also use timestamp query to avoid caching on reload | ||
const dynamicImportDefault = new Function( | ||
'path', | ||
'timestamp', | ||
'return import(path + "?t=" + timestamp).then(m => m.default)' | ||
); | ||
/** | ||
* @param {string} filePath | ||
* @param {number} timestamp | ||
*/ | ||
async function dynamicImportDefault(filePath, timestamp) { | ||
return await import(filePath + '?t=' + timestamp).then((m) => m.default); | ||
} | ||
/** @type {import('../index.d.ts').loadSvelteConfig} */ | ||
/** | ||
* @param {import('vite').UserConfig} viteConfig | ||
* @param {Partial<import('../public.d.ts').Options>} inlineOptions | ||
* @returns {Promise<Partial<import('../public.d.ts').SvelteConfig> | undefined>} | ||
*/ | ||
export async function loadSvelteConfig(viteConfig, inlineOptions) { | ||
@@ -91,3 +94,3 @@ if (inlineOptions?.configFile === false) { | ||
* @param {import('vite').UserConfig | undefined} viteConfig | ||
* @param {Partial<import('../index.d.ts').Options> | undefined} inlineOptions | ||
* @param {Partial<import('../public.d.ts').Options> | undefined} inlineOptions | ||
* @returns {string | undefined} | ||
@@ -94,0 +97,0 @@ */ |
@@ -48,3 +48,3 @@ /* eslint-disable no-unused-vars */ | ||
/** | ||
* @param {Partial<import('../index.d.ts').Options>} [inlineOptions] | ||
* @param {Partial<import('../public.d.ts').Options>} [inlineOptions] | ||
*/ | ||
@@ -61,4 +61,4 @@ export function validateInlineOptions(inlineOptions) { | ||
/** | ||
* @param {Partial<import('../index.d.ts').SvelteOptions>} [config] | ||
* @returns {Partial<import('../index.d.ts').Options> | undefined} | ||
* @param {Partial<import('../public.d.ts').SvelteConfig>} [config] | ||
* @returns {Partial<import('../public.d.ts').Options> | undefined} | ||
*/ | ||
@@ -113,3 +113,3 @@ function convertPluginOptions(config) { | ||
} | ||
/** @type {import('../index.d.ts').Options} */ | ||
/** @type {import('../public.d.ts').Options} */ | ||
const result = { | ||
@@ -127,3 +127,3 @@ ...config, | ||
* used in config phase, merges the default options, svelte config, and inline options | ||
* @param {Partial<import('../index.d.ts').Options> | undefined} inlineOptions | ||
* @param {Partial<import('../public.d.ts').Options> | undefined} inlineOptions | ||
* @param {import('vite').UserConfig} viteUserConfig | ||
@@ -198,3 +198,3 @@ * @param {import('vite').ConfigEnv} viteEnv | ||
const css = preResolveOptions.emitCss ? 'external' : 'injected'; | ||
/** @type {Partial<import('../index.d.ts').Options>} */ | ||
/** @type {Partial<import('../public.d.ts').Options>} */ | ||
const defaultOptions = { | ||
@@ -201,0 +201,0 @@ hot: viteConfig.isProduction |
@@ -12,3 +12,3 @@ import MagicString from 'magic-string'; | ||
* | ||
* @returns {import('svelte/types/compiler/preprocess').PreprocessorGroup} | ||
* @returns {import('svelte/compiler').PreprocessorGroup} | ||
*/ | ||
@@ -36,10 +36,10 @@ export function createInjectScopeEverythingRulePreprocessorGroup() { | ||
* @returns {{ | ||
* prependPreprocessors: import('svelte/types/compiler/preprocess').PreprocessorGroup[], | ||
* appendPreprocessors: import('svelte/types/compiler/preprocess').PreprocessorGroup[] | ||
* prependPreprocessors: import('svelte/compiler').PreprocessorGroup[], | ||
* appendPreprocessors: import('svelte/compiler').PreprocessorGroup[] | ||
* }} | ||
*/ | ||
function buildExtraPreprocessors(options, config) { | ||
/** @type {import('svelte/types/compiler/preprocess').PreprocessorGroup[]} */ | ||
/** @type {import('svelte/compiler').PreprocessorGroup[]} */ | ||
const prependPreprocessors = []; | ||
/** @type {import('svelte/types/compiler/preprocess').PreprocessorGroup[]} */ | ||
/** @type {import('svelte/compiler').PreprocessorGroup[]} */ | ||
const appendPreprocessors = []; | ||
@@ -46,0 +46,0 @@ |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
119219
33
3571
5
0
5