MCPcopy
hub / github.com/meteor/meteor / scanFile

Method scanFile

tools/isobuild/import-scanner.ts:1056–1149  ·  view source on GitHub ↗
(file: File, forDynamicImport = false)

Source from the content-addressed store, hash-verified

1054 }
1055
1056 private scanFile(file: File, forDynamicImport = false) {
1057 if (file.imported === "static") {
1058 // If we've already scanned this file non-dynamically, then we don't
1059 // need to scan it again.
1060 return;
1061 }
1062
1063 if (forDynamicImport &&
1064 file.imported === Status.DYNAMIC) {
1065 // If we've already scanned this file dynamically, then we don't
1066 // need to scan it dynamically again.
1067 return;
1068 }
1069
1070 // Set file.imported to a truthy value (either "dynamic" or true).
1071 setImportedStatus(file, forDynamicImport ? Status.DYNAMIC : Status.STATIC);
1072
1073 if (file.reportPendingErrors &&
1074 file.reportPendingErrors() > 0) {
1075 file.hasErrors = true;
1076 // Any errors reported to InputFile#error were saved but not
1077 // reported at compilation time. Now that we know the file has been
1078 // imported, it's time to report those errors.
1079 return;
1080 }
1081
1082 try {
1083 file.deps = file.deps || this.findImportedModuleIdentifiers(file);
1084 } catch (e) {
1085 if (e.$ParseError) {
1086 (buildmessage as any).error(e.message, {
1087 file: file.sourcePath,
1088 line: e.loc.line,
1089 column: e.loc.column,
1090 });
1091 return;
1092 }
1093 throw e;
1094 }
1095
1096 each(file.deps, (info: ImportInfo, id: string) => {
1097 // Asynchronous module fetching only really makes sense in the
1098 // browser (even though it works equally well on the server), so
1099 // it's better if forDynamicImport never becomes true on the server.
1100 const dynamic = this.isWebBrowser() &&
1101 (forDynamicImport ||
1102 info.parentWasDynamic ||
1103 info.dynamic);
1104
1105 const resolved = this.resolve(file, id, dynamic);
1106 const absImportedPath = resolved && resolved !== "missing" && resolved.path;
1107 if (! absImportedPath) {
1108 return;
1109 }
1110
1111 let depFile = this.getFile(absImportedPath);
1112 if (depFile) {
1113 // We should never have stored a fake file in this.outputFiles, so

Callers 2

scanImportsMethod · 0.95
scanMissingModulesMethod · 0.95

Calls 10

isWebBrowserMethod · 0.95
resolveMethod · 0.95
getFileMethod · 0.95
readPackageJsonMethod · 0.95
readDepFileMethod · 0.95
addFileMethod · 0.95
setImportedStatusFunction · 0.85
reportPendingErrorsMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected