_config.js — svelte Source File
Architecture documentation for _config.js, a javascript file in the svelte codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR cd8a45ab_4236_5f51_36bb_5a4a0f57c0da["_config.js"] 032186a9_8a8b_b603_4335_6ade22d767cb["test.ts"] cd8a45ab_4236_5f51_36bb_5a4a0f57c0da --> 032186a9_8a8b_b603_4335_6ade22d767cb 740dc682_957b_322a_475e_aac0e8ee02bc["helpers.js"] cd8a45ab_4236_5f51_36bb_5a4a0f57c0da --> 740dc682_957b_322a_475e_aac0e8ee02bc f63dfb1f_0f71_c394_6a93_89f93b04f5eb["magic_string_preprocessor_result"] cd8a45ab_4236_5f51_36bb_5a4a0f57c0da --> f63dfb1f_0f71_c394_6a93_89f93b04f5eb 7f99a384_e0e9_ba03_93cc_da62552bcef7["magic_string_replace_all"] cd8a45ab_4236_5f51_36bb_5a4a0f57c0da --> 7f99a384_e0e9_ba03_93cc_da62552bcef7 6bc9684c_1a71_1bdf_8ee4_8d5d204604b3["magic-string"] cd8a45ab_4236_5f51_36bb_5a4a0f57c0da --> 6bc9684c_1a71_1bdf_8ee4_8d5d204604b3 d7ae4515_c954_5459_c5db_feb8d3ba09d3["trace-mapping"] cd8a45ab_4236_5f51_36bb_5a4a0f57c0da --> d7ae4515_c954_5459_c5db_feb8d3ba09d3 5415ae33_acc7_39bf_2a56_bf3800623713["locate-character"] cd8a45ab_4236_5f51_36bb_5a4a0f57c0da --> 5415ae33_acc7_39bf_2a56_bf3800623713 style cd8a45ab_4236_5f51_36bb_5a4a0f57c0da fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/** @import { Location } from 'locate-character' */
import MagicString from 'magic-string';
import { TraceMap, originalPositionFor } from '@jridgewell/trace-mapping';
import { test } from '../../test';
import { magic_string_preprocessor_result, magic_string_replace_all } from '../../helpers.js';
import { getLocator } from 'locate-character';
export default test({
compileOptions: {
dev: true,
css: 'injected'
},
preprocess: [
{
style: ({ content, filename = '' }) => {
const src = new MagicString(content);
magic_string_replace_all(src, '--replace-me-once', '\n --done-replace-once');
magic_string_replace_all(src, '--replace-me-twice', '\n--almost-done-replace-twice');
return magic_string_preprocessor_result(filename, src);
}
},
{
style: ({ content, filename = '' }) => {
const src = new MagicString(content);
magic_string_replace_all(src, '--almost-done-replace-twice', '\n --done-replace-twice');
return magic_string_preprocessor_result(filename, src);
}
}
],
async test({ assert, code_client }) {
// Check that the css source map embedded in the js is accurate
const match = code_client.match(
/code: '(.*?)(?:\\n\/\*# sourceMappingURL=data:(.*?);charset=(.*?);base64,(.*?) \*\/)?'/
);
assert.ok(match);
const [css, mime_type, encoding, css_map_base64] = /** @type {RegExpMatchArray} */ (
match
).slice(1);
assert.equal(mime_type, 'application/json');
assert.equal(encoding, 'utf-8');
const css_map_json = Buffer.from(css_map_base64, 'base64').toString();
const map = new TraceMap(css_map_json);
const sourcefile = '../../input.svelte';
const locate = getLocator(
css.replace(/\\r/g, '\r').replace(/\\n/g, '\n').replace(/\\t/g, '\t'),
{ offsetLine: 1 }
);
/** @type {const} */ ([
['--keep-me: blue', null, 13, 2],
['--done-replace-once: red', '--replace-me-once', 7, 2],
['--done-replace-twice: green', '--replace-me-twice', 10, 2]
]).forEach(([content, name, line, column]) => {
assert.deepEqual(
originalPositionFor(map, /** @type {Location} */ (locate(content))),
{
source: sourcefile,
name,
line,
column
},
`failed to locate "${content}" from "${sourcefile}"`
);
});
}
});
Domain
Subdomains
Functions
Dependencies
- helpers.js
- locate-character
- magic-string
- magic_string_preprocessor_result
- magic_string_replace_all
- test.ts
- trace-mapping
Source
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, MessageProcessor subdomain.
What functions are defined in _config.js?
_config.js defines 1 function(s): default.test.
What does _config.js depend on?
_config.js imports 7 module(s): helpers.js, locate-character, magic-string, magic_string_preprocessor_result, magic_string_replace_all, test.ts, trace-mapping.
Where is _config.js in the architecture?
_config.js is located at packages/svelte/tests/sourcemaps/samples/css-injected-map/_config.js (domain: BuildSystem, subdomain: MessageProcessor, directory: packages/svelte/tests/sourcemaps/samples/css-injected-map).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free