MCPcopy
hub / github.com/meteor/meteor / mainModule

Method mainModule

tools/isobuild/package-api.js:338–382  ·  view source on GitHub ↗
(path, arch, fileOptions = {})

Source from the content-addressed store, hash-verified

336 }
337
338 mainModule(path, arch, fileOptions = {}) {
339 arch = toArchArray(arch);
340
341 const errors = [];
342
343 forAllMatchingArchs(arch, a => {
344 const filesForArch = this.files[a];
345 const source = {
346 relPath: pathRelative(".", path),
347 fileOptions: {
348 ...fileOptions,
349 mainModule: true
350 }
351 };
352
353 const oldMain = filesForArch.main;
354 if (oldMain) {
355 // It's not an error to call api.mainModule multiple times, but
356 // the last call takes precedence over the earlier calls.
357 oldMain.fileOptions.mainModule = false;
358
359 if (! _.has(oldMain.fileOptions, "lazy")) {
360 // If the laziness of the old main module was not explicitly
361 // specified, then it would have been implicitly eager just
362 // because it was the main module. Since we are revoking its
363 // status as main module now, we should also explicitly revoke
364 // the eagerness that came with that status.
365 oldMain.fileOptions.lazy = true;
366 }
367 }
368
369 if (filesForArch.sources.some(old => source.relPath === old.relPath)) {
370 errors.push(`Duplicate api.mainModule: ${path}`);
371 }
372
373 filesForArch.main = source;
374 filesForArch.sources.push(source);
375
376 this._forbidExportWithLazyMain(a);
377 });
378
379 errors.forEach(error => {
380 buildmessage.error(error, { useMyCaller: 1 });
381 });
382 }
383
384 _forbidExportWithLazyMain(arch) {
385 const filesForArch = this.files[arch];

Callers 15

package.jsFile · 0.80
package.jsFile · 0.80
package.jsFile · 0.80
package.jsFile · 0.80
package.jsFile · 0.80
package.jsFile · 0.80
package.jsFile · 0.80
package.jsFile · 0.80
package.jsFile · 0.80
package.jsFile · 0.80
package.jsFile · 0.80
package.jsFile · 0.80

Calls 7

toArchArrayFunction · 0.85
forAllMatchingArchsFunction · 0.85
pathRelativeFunction · 0.85
hasMethod · 0.45
forEachMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected