Transcrypt
Transcrypt copied to clipboard
__pragma__('js') bug?
In trying to use an ES6 style JavaScript import rather than the Node require()
function, the js
pragma fails if the import module name is more than 5 characters long.
So this transpiles as expected:
__pragma__('js','''import * as test from 'abcde';''')
But this fails:
__pragma__('js','''import * as test from 'abcdef';''')
giving this error:
Error while compiling (offending file last):
File 'scratch_3', line 0, namely:
Import error, can't find any of:
/home/jennasys/.config/JetBrains/PyCharm2020.3/scratches/c.py
/home/jennasys/.config/JetBrains/PyCharm2020.3/scratches/c.js
/home/data/Python/Transcrypt/pymui/venv/lib/python3.7/site-packages/transcrypt/modules/c.py
/home/data/Python/Transcrypt/pymui/venv/lib/python3.7/site-packages/transcrypt/modules/c.js
/home/data/Python/Transcrypt/pymui/venv/bin/c.py
/home/data/Python/Transcrypt/pymui/venv/bin/c.js
/usr/lib/python3.7/c.py
/usr/lib/python3.7/c.js
/usr/lib/python3.7/lib-dynload/c.py
/usr/lib/python3.7/lib-dynload/c.js
/home/data/Python/Transcrypt/pymui/venv/lib/python3.7/site-packages/c.py
/home/data/Python/Transcrypt/pymui/venv/lib/python3.7/site-packages/c.js
/home/data/Python/Transcrypt/pymui/venv/lib/python3.7/site-packages/setuptools-40.8.0-py3.7.egg/c.py
/home/data/Python/Transcrypt/pymui/venv/lib/python3.7/site-packages/setuptools-40.8.0-py3.7.egg/c.js
/home/data/Python/Transcrypt/pymui/venv/lib/python3.7/site-packages/pip-19.0.3-py3.7.egg/c.py
/home/data/Python/Transcrypt/pymui/venv/lib/python3.7/site-packages/pip-19.0.3-py3.7.egg/c.js
Aborted
In the error, the "filename" it looks for is the name of the import module with the first 2 and last 3 characters removed. So similar to the above example, this:
__pragma__('js','''import * as test from 'abcdefghijk';''')
gives an error of:
Error while compiling (offending file last):
File 'scratch_3', line 0, namely:
Import error, can't find any of:
/home/jennasys/.config/JetBrains/PyCharm2020.3/scratches/cdefgh.py
/home/jennasys/.config/JetBrains/PyCharm2020.3/scratches/cdefgh.js
...
Update: It looks like the JavaScript file containing the ES6 import is actually being generated correctly and the compile error occurs at some point after that happens.