Home / File/ index.js — svelte Source File

index.js — svelte Source File

Architecture documentation for index.js, a javascript file in the svelte codebase. 8 imports, 3 dependents.

File javascript Compiler Analyzer 8 imports 3 dependents 13 functions

Entity Profile

Dependency Diagram

graph LR
  194b07ed_c18e_6587_618d_b4b4d02442e0["index.js"]
  2a0e126c_5670_329c_f4f4_86feb8413563["css.js"]
  194b07ed_c18e_6587_618d_b4b4d02442e0 --> 2a0e126c_5670_329c_f4f4_86feb8413563
  aee1cb4d_8fc3_fbc4_d431_00510040685f["is_keyframes_node"]
  194b07ed_c18e_6587_618d_b4b4d02442e0 --> aee1cb4d_8fc3_fbc4_d431_00510040685f
  3f22fc17_0616_dd51_19f2_61263301f664["remove_css_prefix"]
  194b07ed_c18e_6587_618d_b4b4d02442e0 --> 3f22fc17_0616_dd51_19f2_61263301f664
  d383a41d_5383_ee86_cab6_03bf1a2daf93["mapped_code.js"]
  194b07ed_c18e_6587_618d_b4b4d02442e0 --> d383a41d_5383_ee86_cab6_03bf1a2daf93
  cbb1ee69_356b_2015_1118_b75b5cb5088f["merge_with_preprocessor_map"]
  194b07ed_c18e_6587_618d_b4b4d02442e0 --> cbb1ee69_356b_2015_1118_b75b5cb5088f
  62f818c8_e890_17ed_5ec1_92f953d4a7a6["state.js"]
  194b07ed_c18e_6587_618d_b4b4d02442e0 --> 62f818c8_e890_17ed_5ec1_92f953d4a7a6
  6bc9684c_1a71_1bdf_8ee4_8d5d204604b3["magic-string"]
  194b07ed_c18e_6587_618d_b4b4d02442e0 --> 6bc9684c_1a71_1bdf_8ee4_8d5d204604b3
  c49ac9f8_b355_57a2_8d10_b5fd945c6144["zimmerframe"]
  194b07ed_c18e_6587_618d_b4b4d02442e0 --> c49ac9f8_b355_57a2_8d10_b5fd945c6144
  7665e008_f37d_b860_a594_f2539a66af4e["transform-client.js"]
  7665e008_f37d_b860_a594_f2539a66af4e --> 194b07ed_c18e_6587_618d_b4b4d02442e0
  f1cb032f_d7a0_6877_cebc_2e5f4505e958["index.js"]
  f1cb032f_d7a0_6877_cebc_2e5f4505e958 --> 194b07ed_c18e_6587_618d_b4b4d02442e0
  86cf8685_38fa_3a1c_9b81_21c452968289["transform-server.js"]
  86cf8685_38fa_3a1c_9b81_21c452968289 --> 194b07ed_c18e_6587_618d_b4b4d02442e0
  style 194b07ed_c18e_6587_618d_b4b4d02442e0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/** @import { Visitors } from 'zimmerframe' */
/** @import { AST, ValidatedCompileOptions } from '#compiler' */
/** @import { ComponentAnalysis } from '../../types.js' */
import MagicString from 'magic-string';
import { walk } from 'zimmerframe';
import { is_keyframes_node, regex_css_name_boundary, remove_css_prefix } from '../../css.js';
import { merge_with_preprocessor_map } from '../../../utils/mapped_code.js';
import { dev } from '../../../state.js';

/**
 * @typedef {{
 *   code: MagicString;
 *   hash: string;
 *   minify: boolean;
 *   selector: string;
 *   keyframes: string[];
 *   specificity: {
 *     bumped: boolean
 *   }
 * }} State
 */

/**
 *
 * @param {string} source
 * @param {ComponentAnalysis} analysis
 * @param {ValidatedCompileOptions} options
 */
export function render_stylesheet(source, analysis, options) {
	const code = new MagicString(source);

	/** @type {State} */
	const state = {
		code,
		hash: analysis.css.hash,
		minify: analysis.inject_styles && !options.dev,
		selector: `.${analysis.css.hash}`,
		keyframes: analysis.css.keyframes,
		specificity: {
			bumped: false
		}
	};

	const ast = /** @type {AST.CSS.StyleSheet} */ (analysis.css.ast);

	walk(/** @type {AST.CSS.Node} */ (ast), state, visitors);

	code.remove(0, ast.content.start);
	code.remove(/** @type {number} */ (ast.content.end), source.length);
	if (state.minify) {
		remove_preceding_whitespace(ast.content.end, state);
	}

	const css = {
		code: code.toString(),
		map: code.generateMap({
			// include source content; makes it easier/more robust looking up the source map code
			includeContent: true,
			// generateMap takes care of calculating source relative to file
			source: options.filename,
// ... (420 more lines)

Domain

Subdomains

Frequently Asked Questions

What does index.js do?
index.js is a source file in the svelte codebase, written in javascript. It belongs to the Compiler domain, Analyzer subdomain.
What functions are defined in index.js?
index.js defines 13 function(s): escape_comment_close, is_empty, is_in_global_block, is_used, remove_global_pseudo_class, remove_preceding_whitespace, render_stylesheet, visitors.Atrule, visitors.ComplexSelector, visitors.Declaration, and 3 more.
What does index.js depend on?
index.js imports 8 module(s): css.js, is_keyframes_node, magic-string, mapped_code.js, merge_with_preprocessor_map, remove_css_prefix, state.js, zimmerframe.
What files import index.js?
index.js is imported by 3 file(s): index.js, transform-client.js, transform-server.js.
Where is index.js in the architecture?
index.js is located at packages/svelte/src/compiler/phases/3-transform/css/index.js (domain: Compiler, subdomain: Analyzer, directory: packages/svelte/src/compiler/phases/3-transform/css).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free