analyze_module() — svelte Function Reference
Architecture documentation for the analyze_module() function in index.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 05334dc2_42b5_e2cb_fe55_aa3f6a2de9df["analyze_module()"] 4aa8a188_84d4_0274_ed83_cac0ab1d3572["index.js"] 05334dc2_42b5_e2cb_fe55_aa3f6a2de9df -->|defined in| 4aa8a188_84d4_0274_ed83_cac0ab1d3572 39054977_bbc9_e3d5_4935_6918741df7be["compileModule()"] 39054977_bbc9_e3d5_4935_6918741df7be -->|calls| 05334dc2_42b5_e2cb_fe55_aa3f6a2de9df 3c435eeb_8c73_85a6_1db6_39a90111f42e["set_source()"] 05334dc2_42b5_e2cb_fe55_aa3f6a2de9df -->|calls| 3c435eeb_8c73_85a6_1db6_39a90111f42e f47134ed_b840_afa5_bf63_d93768eb2045["parse()"] 05334dc2_42b5_e2cb_fe55_aa3f6a2de9df -->|calls| f47134ed_b840_afa5_bf63_d93768eb2045 c531899f_2ddc_b054_bfe1_2cfdfd2b1c7f["create_scopes()"] 05334dc2_42b5_e2cb_fe55_aa3f6a2de9df -->|calls| c531899f_2ddc_b054_bfe1_2cfdfd2b1c7f 14aee6bc_58b8_9da9_3853_23ecd1ef30fe["global_reference_invalid()"] 05334dc2_42b5_e2cb_fe55_aa3f6a2de9df -->|calls| 14aee6bc_58b8_9da9_3853_23ecd1ef30fe 627dc2f8_4dbc_5bb1_8f54_cee503e17098["get()"] 05334dc2_42b5_e2cb_fe55_aa3f6a2de9df -->|calls| 627dc2f8_4dbc_5bb1_8f54_cee503e17098 96840921_f43d_a26b_1d2e_cd28c0fd6d73["is_rune()"] 05334dc2_42b5_e2cb_fe55_aa3f6a2de9df -->|calls| 96840921_f43d_a26b_1d2e_cd28c0fd6d73 184f48cb_76c9_9db4_9fd7_3c5e91a5b286["store_invalid_subscription_module()"] 05334dc2_42b5_e2cb_fe55_aa3f6a2de9df -->|calls| 184f48cb_76c9_9db4_9fd7_3c5e91a5b286 784480d0_767d_ac40_b03e_ae8ddcc82684["Set()"] 05334dc2_42b5_e2cb_fe55_aa3f6a2de9df -->|calls| 784480d0_767d_ac40_b03e_ae8ddcc82684 235c8d25_76a1_8477_bb76_fbb408b6a46d["adjust()"] 05334dc2_42b5_e2cb_fe55_aa3f6a2de9df -->|calls| 235c8d25_76a1_8477_bb76_fbb408b6a46d style 05334dc2_42b5_e2cb_fe55_aa3f6a2de9df fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/compiler/phases/2-analyze/index.js lines 256–322
export function analyze_module(source, options) {
/** @type {AST.JSComment[]} */
const comments = [];
state.set_source(source);
const ast = parse(source, comments, false, false);
const { scope, scopes, has_await } = create_scopes(ast, new ScopeRoot(), false, null);
for (const [name, references] of scope.references) {
if (name[0] !== '$' || RESERVED.includes(name)) continue;
if (name === '$' || name[1] === '$') {
e.global_reference_invalid(references[0].node, name);
}
const binding = scope.get(name.slice(1));
if (binding !== null && !is_rune(name)) {
e.store_invalid_subscription_module(references[0].node);
}
}
/** @type {Analysis} */
const analysis = {
module: { ast, scope, scopes, has_await },
name: options.filename,
accessors: false,
runes: true,
immutable: true,
tracing: false,
async_deriveds: new Set(),
comments,
classes: new Map(),
pickled_awaits: new Set()
};
state.adjust({
dev: options.dev,
rootDir: options.rootDir,
runes: true
});
walk(
/** @type {ESTree.Node} */ (ast),
{
scope,
scopes,
analysis: /** @type {ComponentAnalysis} */ (analysis),
state_fields: new Map(),
// TODO the following are not needed for modules, but we have to pass them in order to avoid type error,
// and reducing the type would result in a lot of tedious type casts elsewhere - find a good solution one day
ast_type: /** @type {any} */ (null),
component_slots: /** @type {Set<string>} */ (new Set()),
expression: null,
function_depth: 0,
has_props_rune: false,
options: /** @type {ValidatedCompileOptions} */ (options),
fragment: null,
parent_element: null,
reactive_statement: null,
derived_function_depth: -1
},
visitors
);
return analysis;
}
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does analyze_module() do?
analyze_module() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/2-analyze/index.js.
Where is analyze_module() defined?
analyze_module() is defined in packages/svelte/src/compiler/phases/2-analyze/index.js at line 256.
What does analyze_module() call?
analyze_module() calls 9 function(s): Set, adjust, create_scopes, get, global_reference_invalid, is_rune, parse, set_source, and 1 more.
What calls analyze_module()?
analyze_module() is called by 1 function(s): compileModule.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free