Home / File/ index.js — svelte Source File

index.js — svelte Source File

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

File javascript Compiler Transformer 23 imports 33 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  cab41022_1b55_3b7a_06c6_b90763bbea47["index.js"]
  67d7170b_725b_33cc_868d_fad6ed435252["index.js"]
  cab41022_1b55_3b7a_06c6_b90763bbea47 --> 67d7170b_725b_33cc_868d_fad6ed435252
  6d2356f8_1610_44a9_5698_878d5092688f["parse"]
  cab41022_1b55_3b7a_06c6_b90763bbea47 --> 6d2356f8_1610_44a9_5698_878d5092688f
  206889ff_1f9f_b6c1_d530_059d001e1cf4["element.js"]
  cab41022_1b55_3b7a_06c6_b90763bbea47 --> 206889ff_1f9f_b6c1_d530_059d001e1cf4
  4aa8a188_84d4_0274_ed83_cac0ab1d3572["index.js"]
  cab41022_1b55_3b7a_06c6_b90763bbea47 --> 4aa8a188_84d4_0274_ed83_cac0ab1d3572
  78a6ba9a_5003_f569_a638_76e4f1977809["analyze_component"]
  cab41022_1b55_3b7a_06c6_b90763bbea47 --> 78a6ba9a_5003_f569_a638_76e4f1977809
  ee93d8a6_6fde_b1c1_e15b_3a4da5326305["scope.js"]
  cab41022_1b55_3b7a_06c6_b90763bbea47 --> ee93d8a6_6fde_b1c1_e15b_3a4da5326305
  bed91719_d047_2256_e199_ee875d5f49b9["get_rune"]
  cab41022_1b55_3b7a_06c6_b90763bbea47 --> bed91719_d047_2256_e199_ee875d5f49b9
  62f818c8_e890_17ed_5ec1_92f953d4a7a6["state.js"]
  cab41022_1b55_3b7a_06c6_b90763bbea47 --> 62f818c8_e890_17ed_5ec1_92f953d4a7a6
  e7276e70_1452_b660_f65a_7accd86f2a27["reset"]
  cab41022_1b55_3b7a_06c6_b90763bbea47 --> e7276e70_1452_b660_f65a_7accd86f2a27
  0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c["ast.js"]
  cab41022_1b55_3b7a_06c6_b90763bbea47 --> 0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c
  c12e0147_3f27_cf17_5878_e54ffdc328d5["extract_identifiers"]
  cab41022_1b55_3b7a_06c6_b90763bbea47 --> c12e0147_3f27_cf17_5878_e54ffdc328d5
  f37fcfdb_9d8e_8c81_7fc8_e49a289d52bc["extract_all_identifiers_from_expression"]
  cab41022_1b55_3b7a_06c6_b90763bbea47 --> f37fcfdb_9d8e_8c81_7fc8_e49a289d52bc
  653284b2_68fd_eee3_0064_918a4c065d4a["is_text_attribute"]
  cab41022_1b55_3b7a_06c6_b90763bbea47 --> 653284b2_68fd_eee3_0064_918a4c065d4a
  d1869e84_a713_3c60_3aae_40e1a6b78424["extract_svelte_ignore.js"]
  cab41022_1b55_3b7a_06c6_b90763bbea47 --> d1869e84_a713_3c60_3aae_40e1a6b78424
  style cab41022_1b55_3b7a_06c6_b90763bbea47 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/** @import { VariableDeclarator, Node, Identifier, AssignmentExpression, LabeledStatement, ExpressionStatement } from 'estree' */
/** @import { Visitors } from 'zimmerframe' */
/** @import { ComponentAnalysis } from '../phases/types.js' */
/** @import { Scope } from '../phases/scope.js' */
/** @import { AST, Binding, ValidatedCompileOptions } from '#compiler' */
import MagicString from 'magic-string';
import { walk } from 'zimmerframe';
import { parse } from '../phases/1-parse/index.js';
import { regex_valid_component_name } from '../phases/1-parse/state/element.js';
import { analyze_component } from '../phases/2-analyze/index.js';
import { get_rune } from '../phases/scope.js';
import { reset, UNKNOWN_FILENAME } from '../state.js';
import {
	extract_identifiers,
	extract_all_identifiers_from_expression,
	is_text_attribute
} from '../utils/ast.js';
import { migrate_svelte_ignore } from '../utils/extract_svelte_ignore.js';
import { validate_component_options } from '../validate-options.js';
import { is_reserved, is_svg, is_void } from '../../utils.js';
import { regex_is_valid_identifier } from '../phases/patterns.js';

const regex_style_tags = /(<style[^>]+>)([\S\s]*?)(<\/style>)/g;
const style_placeholder = '/*$$__STYLE_CONTENT__$$*/';

let has_migration_task = false;

class MigrationError extends Error {
	/**
	 * @param {string} msg
	 */
	constructor(msg) {
		super(msg);
	}
}

/**
 *
 * @param {State} state
 */
function migrate_css(state) {
	if (!state.analysis.css.ast?.start) return;
	const css_contents = state.str
		.snip(state.analysis.css.ast.start, /** @type {number} */ (state.analysis.css.ast?.end))
		.toString();
	let code = css_contents;
	let starting = 0;

	// since we already blank css we can't work directly on `state.str` so we will create a copy that we can update
	const str = new MagicString(code);
	while (code) {
		if (
			code.startsWith(':has') ||
			code.startsWith(':is') ||
			code.startsWith(':where') ||
			code.startsWith(':not')
		) {
			let start = code.indexOf('(') + 1;
			let is_global = false;

// ... (1937 more lines)

Domain

Subdomains

Classes

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, Transformer subdomain.
What functions are defined in index.js?
index.js defines 33 function(s): extract_type_and_comment, find_closing_parenthesis, get_node_range, guess_indent, handle_events, handle_identifier, instance_script.BreakStatement, instance_script.ExportNamedDeclaration, instance_script.Identifier, instance_script.ImportDeclaration, and 23 more.
What does index.js depend on?
index.js imports 23 module(s): analyze_component, ast.js, element.js, extract_all_identifiers_from_expression, extract_identifiers, extract_svelte_ignore.js, get_rune, index.js, and 15 more.
Where is index.js in the architecture?
index.js is located at packages/svelte/src/compiler/migrate/index.js (domain: Compiler, subdomain: Transformer, directory: packages/svelte/src/compiler/migrate).

Analyze Your Own Codebase

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

Try Supermodel Free