Transcrypt icon indicating copy to clipboard operation
Transcrypt copied to clipboard

How to access a javscript library whose name includes '-'?

Open warrenchopin opened this issue 8 months ago • 1 comments

Hi,

I am trying to integrate a Javascript library whose name is 'babylon-htmlmesh'. As you can see, the name of the library includes '-' character. I found that Transcrypt mistranslated it adding a space character to both sides of '-' character.

python .py file:

api = __pragma__('js',
    '{}',
    'babylon-htmlmesh;'
)

Transcrypted .js file:

export var api = babylon - htmlmesh;

Note that '-' became ' - ' after Transcrypted above. Because of the added spaces, Javascript raises an error.

How can I access a javscript library whose name includes '-' in Transcrypt?

Thanks in advance.

warrenchopin avatar Jul 24 '25 14:07 warrenchopin

I found a way:

api = __pragma__('js',
    '{}',
    #'babylon-htmlmesh;' # CAUTION: '-' is Transcrypted to ' - ' raising an error in Javacript
    'window["babylon-htmlmesh"];'
)

warrenchopin avatar Jul 24 '25 15:07 warrenchopin