I am having trouble splitting code across multiple files using transcrypt (version 3.6.95). As a basic example, I have the following files in the same directory:
index.htm
<html>
<head>
<meta charset="utf-8">
<title>Transcrypt test</title>
</head>
<body>
<div id="box"></div>
<button onclick="myscript.set_box_content()">Set box content</button>
</body>
<script src="__javascript__/myscript.js"></script>
</html>
mymodule.py
def helloworld():
return "Hello world!"
myscript.py
from mymodule import helloworld
def set_box_content():
document.getElementById("box").innerHTML = helloworld()
I then run
python -m transcrypt -n mymodule.py
python -m transcrypt -n myscript.py
Which runs without error and generates mymodule.js, mymodule.mod.js, myscript.js and myscript.mod.js in the directory __javascript__.
When I open index.htm in Firefox 58 and open the console it says 'TypeError: module is undefined'. I have tried adding <script src="__javascript__/mymodule.js"></script>
to the HTML but this does not help. I read through this part of the transcrypt documentation, but the -u
switch does not appear in the list of available commands when I type python -m transcrypt -h
.