tools/isobuild/import-scanner.js
// Called by this.resolver when a module identifier cannot be resolved.
Called by this.resolver when a module identifier cannot be resolved.
Called by this . resolver when a module identifier cannot be resolved .
_onMissing(parentFile, id, forDynamicImport = false) {
    const isApp = ! this.name;
    const absParentPath = pathJoin(
      this.sourceRoot,
      parentFile.sourcePath,
    );
    if (isApp &&
        Resolver.isNative(id) &&
        this.isWeb()) {
      const stubId = Resolver.getNativeStubId(id);
      if (isString(stubId) && stubId !== id) {
        const info = parentFile.deps[id];
        info.helpers = info.helpers || {};
        info.helpers[stubId] = forDynamicImport;
        return this._resolve(parentFile, stubId, forDynamicImport);
      }
    }
    const info = {
      packageName: this.name,
      parentPath: absParentPath,
      bundleArch: this.bundleArch,
      possiblySpurious: false,
      dynamic: false,
      parentWasDynamic: forDynamicImport,
    };
    if (parentFile &&
        parentFile.deps &&
        has(parentFile.deps, id)) {
      const importInfo = parentFile.deps[id];
      info.possiblySpurious = importInfo.possiblySpurious;
      info.dynamic = importInfo.dynamic;
    }
    if (parentFile) {
      const missing =
        parentFile.missingModules ||
        Object.create(null);
      missing[id] = info;
      parentFile.missingModules = missing;
    }
    ImportScanner.mergeMissing(
      this.allMissingModules,
      { [id]: [info] }
    );
  }
_onMissing ( parentFile , id , forDynamicImport = false ) { const isApp = ! this . name ; const absParentPath = pathJoin ( this . sourceRoot , parentFile . sourcePath , ) ; if ( isApp && Resolver . isNative ( id ) && this . isWeb ( ) ) { const stubId = Resolver . getNativeStubId ( id ) ; if ( isString ( stubId ) && stubId !== id ) { const info = parentFile . deps [ id ] ; info . helpers = info . helpers || { } ; info . helpers [ stubId ] = forDynamicImport ; return this . _resolve ( parentFile , stubId , forDynamicImport ) ; } } const info = { packageName : this . name , parentPath : absParentPath , bundleArch : this . bundleArch , possiblySpurious : false , dynamic : false , parentWasDynamic : forDynamicImport , } ; if ( parentFile && parentFile . deps && has ( parentFile . deps , id ) ) { const importInfo = parentFile . deps [ id ] ; info . possiblySpurious = importInfo . possiblySpurious ; info . dynamic = importInfo . dynamic ; } if ( parentFile ) { const missing = parentFile . missingModules || Object . create ( null ) ; missing [ id ] = info ; parentFile . missingModules = missing ; } ImportScanner . mergeMissing ( this . allMissingModules , { [ id ] : [ info ] } ) ; }
Called by this.resolver when a module identifier cannot be resolved.
Called by this . resolver when a module identifier cannot be resolved .
// To ensure the native module can be evaluated at runtime, register // a dependency on meteor-node-stubs/deps/<id>.js. // Although not explicitly imported, any stubs associated with // this native import should be recorded as implicit "helpers." // When we later attempt to resolve this id in the application's // node_modules directory or in other packages, we need to remember // if the parent module was imported dynamically, since that makes // this import effectively dynamic, even if the parent module // imported the given id with a static import or require. // Remember that this property only indicates whether or not the // parent module used a dynamic import(...) to import this module. // Even if info.dynamic is false (because the parent module used a // static import or require for this import), this module may still // be effectively dynamic if the parent was imported dynamically, as // indicated by info.parentWasDynamic. // If the imported identifier is neither absolute nor relative, but // top-level, then it might be satisfied by a package installed in // the top-level node_modules directory, and we should record the // missing dependency so that we can include it in the app bundle.