Home / Function/ get_processor() — svelte Function Reference

get_processor() — svelte Function Reference

Architecture documentation for the get_processor() function in _config.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  07f6c784_05a6_9f38_e225_78ada73f0526["get_processor()"]
  9b44e71a_66ae_4baf_57a9_5cd698aa8602["_config.js"]
  07f6c784_05a6_9f38_e225_78ada73f0526 -->|defined in| 9b44e71a_66ae_4baf_57a9_5cd698aa8602
  style 07f6c784_05a6_9f38_e225_78ada73f0526 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/tests/sourcemaps/samples/attached-sourcemap/_config.js lines 16–46

function get_processor(tag_name, search, replace) {
	/** @type {Preprocessor} */
	const preprocessor = ({ content, filename = '' }) => {
		let code = content.slice();
		const ms = new MagicString(code);

		const idx = ms.original.indexOf(search);
		if (idx == -1) throw new Error('search not found in src');
		ms.overwrite(idx, idx + search.length, replace, { storeName: true });

		// change line + column
		const indent = Array.from({ length: indent_size }).join(' ');
		ms.prependLeft(idx, '\n' + indent);

		const map_opts = { source: path.basename(filename), hires: true, includeContent: false };
		const map = ms.generateMap(map_opts);
		const attach_line =
			tag_name == 'style' || comment_multi
				? `\n/*# sourceMappingURL=${map.toUrl()} */`
				: `\n//# sourceMappingURL=${map.toUrl()}`; // only in script
		code = ms.toString() + attach_line;

		indent_size += 2;
		if (tag_name == 'script') comment_multi = !comment_multi;
		return { code };
	};

	return {
		[tag_name]: preprocessor
	};
}

Domain

Subdomains

Frequently Asked Questions

What does get_processor() do?
get_processor() is a function in the svelte codebase, defined in packages/svelte/tests/sourcemaps/samples/attached-sourcemap/_config.js.
Where is get_processor() defined?
get_processor() is defined in packages/svelte/tests/sourcemaps/samples/attached-sourcemap/_config.js at line 16.

Analyze Your Own Codebase

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

Try Supermodel Free