Class: JsxRosetta::IR::ModuleImport

Inherits:
Data
  • Object
show all
Includes:
Node
Defined in:
lib/jsx_rosetta/ir/types.rb

Overview

A top-level ‘import` declaration. Captured at lowering time so the ExpressionTranslator can recognize use-site references and bail out to a TODO instead of emitting a bare snake_case identifier that NameErrors at render time.

name : String — the local binding name (the side the source uses

to reference the imported value). For `import { foo as bar }`
this is "bar"; for `import * as styles` this is "styles";
for `import Default` this is "Default".

source : String — the module specifier verbatim

(e.g. "./styles.module.css", "@apollo/client", "react").
Lets backends apply per-source policy later (e.g. always
strip `*.module.css` references).

kind : Symbol — :default | :named | :namespace. imported_name : String? — original exported name from the source module.

For `import { ChevronRight as CR } from "lucide-react"`,
`name` is `"CR"` and `imported_name` is `"ChevronRight"`.
nil for default / namespace imports where there's no
distinct exported name. Backends that look up vendored
data by canonical name (icons) need the imported name;
most callers want the local binding.

Instance Attribute Summary collapse

Instance Attribute Details

#imported_nameObject (readonly)

Returns the value of attribute imported_name

Returns:

  • (Object)

    the current value of imported_name



140
141
142
# File 'lib/jsx_rosetta/ir/types.rb', line 140

def imported_name
  @imported_name
end

#kindObject (readonly)

Returns the value of attribute kind

Returns:

  • (Object)

    the current value of kind



140
141
142
# File 'lib/jsx_rosetta/ir/types.rb', line 140

def kind
  @kind
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



140
141
142
# File 'lib/jsx_rosetta/ir/types.rb', line 140

def name
  @name
end

#sourceObject (readonly)

Returns the value of attribute source

Returns:

  • (Object)

    the current value of source



140
141
142
# File 'lib/jsx_rosetta/ir/types.rb', line 140

def source
  @source
end