MCPcopy
hub / github.com/rollup/rollup / includeStatements

Method includeStatements

src/Graph.ts:166–214  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

164 }
165
166 private includeStatements(): void {
167 const entryModules = [...this.entryModules, ...this.implicitEntryModules];
168 for (const module of entryModules) {
169 markModuleAndImpureDependenciesAsExecuted(module);
170 }
171 if (this.options.treeshake) {
172 let treeshakingPass = 1;
173 this.newlyIncludedVariableInits.clear();
174 do {
175 timeStart(`treeshaking pass ${treeshakingPass}`, 3);
176 this.needsTreeshakingPass = false;
177 for (const module of this.modules) {
178 if (module.isExecuted) {
179 module.hasTreeShakingPassStarted = true;
180 if (module.info.moduleSideEffects === 'no-treeshake') {
181 module.includeAllInBundle();
182 } else {
183 module.include();
184 }
185 for (const entity of this.newlyIncludedVariableInits) {
186 this.newlyIncludedVariableInits.delete(entity);
187 entity.include(createInclusionContext(), false);
188 }
189 }
190 }
191 if (treeshakingPass === 1) {
192 // We only include exports after the first pass to avoid issues with
193 // the TDZ detection logic
194 for (const module of entryModules) {
195 if (module.preserveSignature !== false) {
196 module.includeAllExports();
197 this.needsTreeshakingPass = true;
198 }
199 }
200 }
201 timeEnd(`treeshaking pass ${treeshakingPass++}`, 3);
202 } while (this.needsTreeshakingPass);
203 } else {
204 for (const module of this.modules) module.includeAllInBundle();
205 }
206 for (const externalModule of this.externalModules) externalModule.warnUnusedImports();
207 for (const module of this.implicitEntryModules) {
208 for (const dependent of module.implicitlyLoadedAfter) {
209 if (!(dependent.info.isEntry || dependent.isIncluded())) {
210 error(logImplicitDependantIsNotIncluded(dependent));
211 }
212 }
213 }
214 }
215
216 private sortAndBindModules(): void {
217 const { orderedModules, cyclePaths } = analyseModuleExecution(this.entryModules);

Callers 1

buildMethod · 0.95

Calls 10

createInclusionContextFunction · 0.90
errorFunction · 0.90
includeAllInBundleMethod · 0.80
deleteMethod · 0.80
includeAllExportsMethod · 0.80
warnUnusedImportsMethod · 0.80
isIncludedMethod · 0.80
includeMethod · 0.65

Tested by

no test coverage detected