File tree Expand file tree Collapse file tree 4 files changed +0
-326
lines changed
packages/vite-plugin-svelte/src Expand file tree Collapse file tree 4 files changed +0
-326
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
- import path from 'node:path' ;
2
- import fs from 'node:fs/promises' ;
3
- import { findDepPkgJsonPath } from 'vitefu' ;
4
-
5
- /**
6
- * @typedef {{
7
- * dir: string;
8
- * pkg: Record<string, any>;
9
- * }} DependencyData
10
- */
11
-
12
- /**
13
- * @param {string } dep
14
- * @param {string } parent
15
- * @returns {Promise<DependencyData | undefined> }
16
- */
17
- export async function resolveDependencyData ( dep , parent ) {
18
- const depDataPath = await findDepPkgJsonPath ( dep , parent ) ;
19
- if ( ! depDataPath ) return undefined ;
20
- try {
21
- return {
22
- dir : path . dirname ( depDataPath ) ,
23
- pkg : JSON . parse ( await fs . readFile ( depDataPath , 'utf-8' ) )
24
- } ;
25
- } catch {
26
- return undefined ;
27
- }
28
- }
29
-
30
1
const COMMON_DEPENDENCIES_WITHOUT_SVELTE_FIELD = [
31
2
'@lukeed/uuid' ,
32
3
'@playwright/test' ,
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
- import MagicString from 'magic-string' ;
2
1
import { log } from './log.js' ;
3
- import path from 'node:path' ;
4
2
import { normalizePath } from 'vite' ;
5
3
6
- /**
7
- * this appends a *{} rule to component styles to force the svelte compiler to add style classes to all nodes
8
- * That means adding/removing class rules from <style> node won't trigger js updates as the scope classes are not changed
9
- *
10
- * only used during dev with enabled css hmr
11
- *
12
- * @returns {import('svelte/compiler').PreprocessorGroup }
13
- */
14
- export function createInjectScopeEverythingRulePreprocessorGroup ( ) {
15
- return {
16
- name : 'inject-scope-everything-rule' ,
17
- style ( { content, filename } ) {
18
- const s = new MagicString ( content ) ;
19
- s . append ( ' *{}' ) ;
20
- return {
21
- code : s . toString ( ) ,
22
- map : s . generateDecodedMap ( {
23
- source : filename ? path . basename ( filename ) : undefined ,
24
- hires : true
25
- } )
26
- } ;
27
- }
28
- } ;
29
- }
30
-
31
4
/**
32
5
* @param {import('../types/options.d.ts').ResolvedOptions } options
33
6
* @param {import('vite').ResolvedConfig } config
You can’t perform that action at this time.
0 commit comments