MCPcopy
hub / github.com/meteor/meteor / _getEntryModule

Method _getEntryModule

tools/project-context.js:1744–1797  ·  view source on GitHub ↗
(
    arch,
    entryModulesByArch,
  )

Source from the content-addressed store, hash-verified

1742 }
1743
1744 _getEntryModule(
1745 arch,
1746 entryModulesByArch,
1747 ) {
1748 const entryMatch = archinfo.mostSpecificMatch(
1749 arch, Object.keys(entryModulesByArch));
1750
1751 if (entryMatch) {
1752 const entryModule = entryModulesByArch[entryMatch];
1753
1754 if (entryModule === false) {
1755 // If meteor.{main,test}Module.{client,server,...} === false, no
1756 // modules will be loaded eagerly on the client or server. This is
1757 // useful if you have an app with no special app/{client,server}
1758 // directory structure and you want to specify an entry point for
1759 // just the client (or just the server), without accidentally
1760 // loading everything on the other architecture. Instead of
1761 // omitting the entry module for the other architecture, simply
1762 // set it to false.
1763 return entryModule;
1764 }
1765
1766 if (! this._resolversByArch[arch]) {
1767 this._resolversByArch[arch] = new Resolver({
1768 sourceRoot: this.appDirectory,
1769 targetArch: arch,
1770 });
1771 }
1772
1773 // Use a Resolver to allow the mainModule strings to omit .js or
1774 // .json file extensions, and to enable resolving directories
1775 // containing package.json or index.js files.
1776 const res = this._resolversByArch[arch].resolve(
1777 // Only relative paths are allowed (not top-level packages).
1778 "./" + files.pathNormalize(entryModule),
1779 this.packageJsonPath
1780 );
1781
1782 if (res && typeof res === "object") {
1783 return files.pathRelative(this.appDirectory, res.path);
1784 }
1785
1786 buildmessage.error(
1787 `Could not resolve meteor.mainModule ${
1788 JSON.stringify(entryModule)
1789 } in ${
1790 files.pathRelative(
1791 this.appDirectory,
1792 this.packageJsonPath
1793 )
1794 } (${arch})`
1795 );
1796 }
1797 }
1798}

Callers 2

getMainModuleMethod · 0.95
getTestModuleMethod · 0.95

Calls 2

resolveMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected