@sveltejs/vite-plugin-svelte
Advanced tools
Comparing version 2.0.0-beta.0 to 2.0.0-beta.1
{ | ||
"name": "@sveltejs/vite-plugin-svelte", | ||
"version": "2.0.0-beta.0", | ||
"version": "2.0.0-beta.1", | ||
"license": "MIT", | ||
@@ -48,12 +48,12 @@ "author": "dominikg", | ||
"peerDependencies": { | ||
"svelte": "^3.44.0", | ||
"vite": "^4.0.0-beta.1" | ||
"svelte": "^3.54.0", | ||
"vite": "^4.0.0-beta.5" | ||
}, | ||
"devDependencies": { | ||
"@types/debug": "^4.1.7", | ||
"esbuild": "^0.15.18", | ||
"esbuild": "^0.16.1", | ||
"rollup": "^2.79.1", | ||
"svelte": "^3.53.1", | ||
"svelte": "^3.54.0", | ||
"tsup": "^6.5.0", | ||
"vite": "^4.0.0-beta.1" | ||
"vite": "^4.0.0-beta.5" | ||
}, | ||
@@ -60,0 +60,0 @@ "scripts": { |
@@ -21,3 +21,2 @@ import fs from 'fs'; | ||
import { resolveViaPackageJsonSvelte } from './utils/resolve'; | ||
import { PartialResolvedId } from 'rollup'; | ||
import { toRollupError } from './utils/error'; | ||
@@ -51,5 +50,3 @@ import { saveSvelteMetadata } from './utils/optimizer'; | ||
let compileSvelte: CompileSvelte; | ||
/* eslint-enable no-unused-vars */ | ||
let resolvedSvelteSSR: Promise<PartialResolvedId | null>; | ||
const api: PluginAPI = {}; | ||
@@ -141,20 +138,2 @@ const plugins: Plugin[] = [ | ||
if (ssr && importee === 'svelte') { | ||
if (!resolvedSvelteSSR) { | ||
resolvedSvelteSSR = this.resolve('svelte/ssr', undefined, { skipSelf: true }).then( | ||
(svelteSSR) => { | ||
log.debug('resolved svelte to svelte/ssr'); | ||
return svelteSSR; | ||
}, | ||
(err) => { | ||
log.debug( | ||
'failed to resolve svelte to svelte/ssr. Update svelte to a version that exports it', | ||
err | ||
); | ||
return null; // returning null here leads to svelte getting resolved regularly | ||
} | ||
); | ||
} | ||
return resolvedSvelteSSR; | ||
} | ||
//@ts-expect-error scan | ||
@@ -161,0 +140,0 @@ const scan = !!opts?.scan; // scanner phase of optimizeDeps |
@@ -8,3 +8,2 @@ import { readFileSync } from 'fs'; | ||
import { toESBuildError } from './error'; | ||
import { atLeastSvelte } from './svelte-version'; | ||
import { StatCollection } from './vite-plugin-svelte-stats'; | ||
@@ -14,3 +13,2 @@ | ||
type EsbuildPlugin = NonNullable<EsbuildOptions['plugins']>[number]; | ||
const isCssString = atLeastSvelte('3.53.0'); | ||
@@ -58,3 +56,4 @@ export const facadeEsbuildSveltePluginName = 'vite-plugin-svelte:facade'; | ||
if (css !== 'none') { | ||
css = isCssString ? 'injected' : true; | ||
// TODO ideally we'd be able to externalize prebundled styles too, but for now always put them in the js | ||
css = 'injected'; | ||
} | ||
@@ -61,0 +60,0 @@ const compileOptions: CompileOptions = { |
@@ -33,9 +33,6 @@ /* eslint-disable no-unused-vars */ | ||
} from 'vitefu'; | ||
import { atLeastSvelte } from './svelte-version'; | ||
import { isCommonDepWithoutSvelteField } from './dependencies'; | ||
import { VitePluginSvelteStats } from './vite-plugin-svelte-stats'; | ||
// svelte 3.53.0 changed compilerOptions.css from boolean to string | boolen, use string when available | ||
const cssAsString = atLeastSvelte('3.53.0'); | ||
const allowedPluginOptions = new Set([ | ||
@@ -186,7 +183,3 @@ 'include', | ||
): ResolvedOptions { | ||
const css = cssAsString | ||
? preResolveOptions.emitCss | ||
? 'external' | ||
: 'injected' | ||
: !preResolveOptions.emitCss; | ||
const css = preResolveOptions.emitCss ? 'external' : 'injected'; | ||
const defaultOptions: Partial<Options> = { | ||
@@ -196,3 +189,3 @@ hot: viteConfig.isProduction | ||
: { | ||
injectCss: css === true || css === 'injected', | ||
injectCss: css === 'injected', | ||
partialAccept: !!viteConfig.experimental?.hmrPartialAccept | ||
@@ -241,3 +234,3 @@ }, | ||
if (css === true || css === 'injected') { | ||
const forcedCss = cssAsString ? 'external' : false; | ||
const forcedCss = 'external'; | ||
log.warn( | ||
@@ -261,3 +254,3 @@ `hmr and emitCss are enabled but compilerOptions.css is ${css}, forcing it to ${forcedCss}` | ||
if (!(css === true || css === 'injected')) { | ||
const forcedCss = cssAsString ? 'injected' : true; | ||
const forcedCss = 'injected'; | ||
log.warn( | ||
@@ -264,0 +257,0 @@ `hmr with emitCss disabled requires compilerOptions.css to be enabled, forcing it to ${forcedCss}` |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
362994
5705