oxc-project/oxc · error · OxcDiagnostic

This rule can't verify that `export *` only exports componen

Error message

This rule can't verify that `export *` only exports components.

What it means

Raised by react/only_export_components when a module contains an `export *` re-export. At the throw site React Fast Refresh cannot statically know whether the star-exported module only exports components, so any hot-reload boundary through this file is invalidated and Fast Refresh falls back to a full reload. export_all_components_diagnostic is emitted from analyze_exports for every ExportAllDeclaration found in the analyzed module.

Source

Thrown at crates/oxc_linter/src/rules/react/only_export_components.rs:17

use oxc_ast::{AstKind, ast::*};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_semantic::NodeId;
use oxc_span::{GetSpan, Span};
use rustc_hash::FxHashSet;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use crate::{
    context::LintContext,
    rule::{DefaultRuleConfig, Rule},
    utils::is_react_component_name,
};

fn export_all_components_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("This rule can't verify that `export *` only exports components.")
        .with_label(span)
}

fn named_export_components_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components.")
        .with_label(span)
}

fn anonymous_components_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn(
        "Fast refresh can't handle anonymous components. Add a name to your export.",
    )
    .with_label(span)
}

fn local_components_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Fast refresh only works when a file only exports components. Move your component(s) to a separate file.")
        .with_label(span)

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Replace `export *` with explicit named exports of components only.
  2. Split component and non-component exports into separate files.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/react/only_export_components.rs:17 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/15c6818fd7d1ec0f. Report an issue: GitHub.