Home / Function/ get_relative_path() — svelte Function Reference

get_relative_path() — svelte Function Reference

Architecture documentation for the get_relative_path() function in mapped_code.js from the svelte codebase.

Function javascript Compiler Migrator calls 1 called by 2

Entity Profile

Dependency Diagram

graph TD
  83e8a17c_7a83_f4d3_1629_6a92427d44f2["get_relative_path()"]
  d383a41d_5383_ee86_cab6_03bf1a2daf93["mapped_code.js"]
  83e8a17c_7a83_f4d3_1629_6a92427d44f2 -->|defined in| d383a41d_5383_ee86_cab6_03bf1a2daf93
  cbb1ee69_356b_2015_1118_b75b5cb5088f["merge_with_preprocessor_map()"]
  cbb1ee69_356b_2015_1118_b75b5cb5088f -->|calls| 83e8a17c_7a83_f4d3_1629_6a92427d44f2
  8164d272_5d30_264a_68d0_0339d7d146e1["get_source_name()"]
  8164d272_5d30_264a_68d0_0339d7d146e1 -->|calls| 83e8a17c_7a83_f4d3_1629_6a92427d44f2
  0b0d6cc0_5fd9_5ba4_3426_05a4a4d6e501["concat()"]
  83e8a17c_7a83_f4d3_1629_6a92427d44f2 -->|calls| 0b0d6cc0_5fd9_5ba4_3426_05a4a4d6e501
  style 83e8a17c_7a83_f4d3_1629_6a92427d44f2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/utils/mapped_code.js lines 423–437

function get_relative_path(from, to) {
	// Don't use node's utils here to ensure the compiler is usable in a browser environment
	const from_parts = from.split(/[/\\]/);
	const to_parts = to.split(/[/\\]/);
	from_parts.pop(); // get dirname
	while (from_parts[0] === to_parts[0]) {
		from_parts.shift();
		to_parts.shift();
	}
	if (from_parts.length) {
		let i = from_parts.length;
		while (i--) from_parts[i] = '..';
	}
	return from_parts.concat(to_parts).join('/');
}

Domain

Subdomains

Calls

Frequently Asked Questions

What does get_relative_path() do?
get_relative_path() is a function in the svelte codebase, defined in packages/svelte/src/compiler/utils/mapped_code.js.
Where is get_relative_path() defined?
get_relative_path() is defined in packages/svelte/src/compiler/utils/mapped_code.js at line 423.
What does get_relative_path() call?
get_relative_path() calls 1 function(s): concat.
What calls get_relative_path()?
get_relative_path() is called by 2 function(s): get_source_name, merge_with_preprocessor_map.

Analyze Your Own Codebase

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

Try Supermodel Free