Repository: parcel-bundler/parcel
File: packages/packagers/js/src/ScopeHoistingPackager.js (JavaScript)

Code before:
            );
          }
        }

        external.set(imported, renamed);
        if (local !== '*' && replacements) {
          let replacement = renamed;
          if (property === '*') {
            replacement = renamed;
          } else if (property === 'default') {
            replacement = `($parcel$interopDefault(${renamed}))`;
            this.usedHelpers.add('$parcel$interopDefault');
          } else if (property) {
            replacement = this.getPropertyAccess(renamed, property);
          }
          replacements.set(local, replacement);
        }
      }
    }
  }

  isWrapped(resolved: Asset, parentAsset: Asset): boolean {
    if (resolved.meta.isConstantModule) {
      invariant(
        this.bundle.hasAsset(resolved),
        `Constant module ${path.relative(
          this.options.projectRoot,
          resolved.filePath,
        )} referenced from ${path.relative(
          this.options.projectRoot,
          parentAsset.filePath,
        )} not found in bundle ${this.bundle.name}`,
      );
      return false;
    }
    return (
      (!this.bundle.hasAsset(resolved) && !this.externalAssets.has(resolved)) ||
      (this.wrappedAssets.has(resolved.id) && resolved !== parentAsset)
    );
  }

  getSymbolResolution(
    parentAsset: Asset,
    resolved: Asset,
    imported: string,
    dep?: Dependency,
    replacements?: Map<string, string>,
  ): string {
    let {
      asset: resolvedAsset,
      exportSymbol,

Review comment (suggestion):
This is probably fine as it only runs for constant modules, however I'd normally favour a `if(){throw err}` here as it means we only generate the error message when it's going to be thrown. 

Code after:
            );
          }
        }

        external.set(imported, renamed);
        if (local !== '*' && replacements) {
          let replacement = renamed;
          if (property === '*') {
            replacement = renamed;
          } else if (property === 'default') {
            replacement = `($parcel$interopDefault(${renamed}))`;
            this.usedHelpers.add('$parcel$interopDefault');
          } else if (property) {
            replacement = this.getPropertyAccess(renamed, property);
          }
          replacements.set(local, replacement);
        }
      }
    }
  }

  isWrapped(resolved: Asset, parentAsset: Asset): boolean {
    if (resolved.meta.isConstantModule) {
      if (!this.bundle.hasAsset(resolved)) {
        throw new AssertionError({
          message: `Constant module ${path.relative(
            this.options.projectRoot,
            resolved.filePath,
          )} referenced from ${path.relative(
            this.options.projectRoot,
            parentAsset.filePath,
          )} not found in bundle ${this.bundle.name}`,
        });
      }
      return false;
    }
    return (
      (!this.bundle.hasAsset(resolved) && !this.externalAssets.has(resolved)) ||
      (this.wrappedAssets.has(resolved.id) && resolved !== parentAsset)
    );
  }

  getSymbolResolution(
    parentAsset: Asset,
    resolved: Asset,
    imported: string,
    dep?: Dependency,
    replacements?: Map<string, string>,
  ): string {
    let {
      asset: resolvedAsset,