I would like to refactor some very large JavaScript project into smaller files. However, using modules fails when trying to run the main file in the SpiderMonkey JavaScript shell:
<code>user@host:~/git/project$ ../jsshell-81_0_1/js main.js
smash.js:1:0 SyntaxError: import declarations may only appear at top level of a module:
smash.js:1:0 import utilities from './utils.js'
smash.js:1:0 ^
</code>
<code>user@host:~/git/project$ ../jsshell-81_0_1/js main.js
smash.js:1:0 SyntaxError: import declarations may only appear at top level of a module:
smash.js:1:0 import utilities from './utils.js'
smash.js:1:0 ^
</code>
user@host:~/git/project$ ../jsshell-81_0_1/js main.js
smash.js:1:0 SyntaxError: import declarations may only appear at top level of a module:
smash.js:1:0 import utilities from './utils.js'
smash.js:1:0 ^
I think the issue is that I would need to import the main file in the HTML file as module but that’s not possible when using the SpiderMonkey JavaScript shell (and that’s not changeable as my development host is headless).
Is there any other way to solve this?