Skip to content

Add named import syntax for ESM imports#16

Open
marcoroth wants to merge 1 commit intomtgrosser:masterfrom
marcoroth:named-imports
Open

Add named import syntax for ESM imports#16
marcoroth wants to merge 1 commit intomtgrosser:masterfrom
marcoroth:named-imports

Conversation

@marcoroth
Copy link

@marcoroth marcoroth commented Feb 18, 2026

In modern JavaScript it's quite common to use the named import syntax over importing the default export from a package or importing the whole package using the star alias imports.

This pull request adds support for the named import syntax for ESM modules.

The following JavaScript import:

import { v4 } from 'uuid'

Can now be represented as the following in Nodo::Core:

class Example < Nodo::Core
  import :v4, from: 'uuid'
  function :generate, "() => v4()"
end

I chose this syntax with the from kwarg, but if you prefer a different syntax for this please let me know 🙌🏼

@marcoroth
Copy link
Author

marcoroth commented Feb 18, 2026

I kept this pull request simple as this is mostly a convenience thing, but I have also been thinking about the following for multiple imports and import aliasing:

import [:v4, :v1], from: 'uuid'
# => import { v4, v1 } from 'uuid'

import { v4: :generateUuid }, from: 'uuid'
# => import { v4 as generateUuid } from 'uuid'

Happy to open a separate pull request for this, or add it to this one if you like this functionality as well! 🙌🏼

@mtgrosser mtgrosser self-assigned this Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants