Home / File/ _config.js — svelte Source File

_config.js — svelte Source File

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

File javascript BuildSystem QualityControl 3 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  b8ab85a8_e1a7_641f_cd15_c4b65ad4053a["_config.js"]
  032186a9_8a8b_b603_4335_6ade22d767cb["test.ts"]
  b8ab85a8_e1a7_641f_cd15_c4b65ad4053a --> 032186a9_8a8b_b603_4335_6ade22d767cb
  6bc9684c_1a71_1bdf_8ee4_8d5d204604b3["magic-string"]
  b8ab85a8_e1a7_641f_cd15_c4b65ad4053a --> 6bc9684c_1a71_1bdf_8ee4_8d5d204604b3
  f8929fbd_6327_2bb8_f43b_31a3db2e4d74["node:path"]
  b8ab85a8_e1a7_641f_cd15_c4b65ad4053a --> f8929fbd_6327_2bb8_f43b_31a3db2e4d74
  style b8ab85a8_e1a7_641f_cd15_c4b65ad4053a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import MagicString, { Bundle } from 'magic-string';
import * as path from 'node:path';
import { test } from '../../test';

/**
 * @param {Bundle} bundle
 * @param {string} filename
 * @param {string} source
 */
function add(bundle, filename, source) {
	bundle.addSource({
		filename,
		content: new MagicString(source),
		// @ts-ignore TODO
		separator: '\n'
		//separator: '' // ERROR. probably a bug in magic-string
	});
}

/**
 * @param {Bundle} bundle
 * @param {string} filename
 */
function result(bundle, filename) {
	return {
		code: bundle.toString(),
		map: bundle.generateMap({
			file: filename,
			includeContent: false,
			hires: true // required for remapping
		})
	};
}

const FOO = 'var answer = 42; // foo.js\n';
const BAR = 'console.log(answer); // bar.js\n';
const FOO2 = 'var answer2 = 84; // foo2.js\n';
const BAR2 = 'console.log(answer2); // bar2.js\n';

export default test({
	js_map_sources: [
		'../../input.svelte',
		'../../foo.js',
		'../../bar.js',
		'../../foo2.js',
		'../../bar2.js'
	],
	preprocess: [
		{
			script: ({ content, filename = '' }) => {
				const bundle = new Bundle();

				add(bundle, path.basename(filename), content);
				add(bundle, 'foo.js', FOO);
				add(bundle, 'bar.js', BAR);

				return result(bundle, path.basename(filename));
			}
		},
		{
			script: ({ content, filename = '' }) => {
				const bundle = new Bundle();

				add(bundle, path.basename(filename), content);
				add(bundle, 'foo2.js', FOO2);
				add(bundle, 'bar2.js', BAR2);

				return result(bundle, path.basename(filename));
			}
		}
	],
	client: [
		{
			code: FOO,
			str: 'answer'
		},
		{
			code: BAR,
			str: 'answer',
			idxGenerated: 1
		},
		{
			code: FOO2,
			str: 'answer2'
		},
		{
			code: BAR2,
			str: 'answer2',
			idxGenerated: 1
		}
	]
});

Domain

Subdomains

Functions

Dependencies

Frequently Asked Questions

What does _config.js do?
_config.js is a source file in the svelte codebase, written in javascript. It belongs to the BuildSystem domain, QualityControl subdomain.
What functions are defined in _config.js?
_config.js defines 2 function(s): add, result.
What does _config.js depend on?
_config.js imports 3 module(s): magic-string, node:path, test.ts.
Where is _config.js in the architecture?
_config.js is located at packages/svelte/tests/sourcemaps/samples/sourcemap-sources/_config.js (domain: BuildSystem, subdomain: QualityControl, directory: packages/svelte/tests/sourcemaps/samples/sourcemap-sources).

Analyze Your Own Codebase

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

Try Supermodel Free