Import Order
There are two main cases:
- Undefined execution order of imports, see this comment
- Only one execution order of imports, see this comment
Many would call both of the above code smells. The first one has a simple workaround in Hugo. Define the import order in its own script and make sure it gets passed early to ESBuild, e.g. by putting it in a script goup with a name that comes early in the alphabet.
{{< script resource="entrypoints-workaround.js" id="__aardwark" >}}
Removing the shortcode reference above makes the JS fail.
import './lib2.js';
import './lib1.js';
console.log('entrypoints-workaround.js');
Note that the workaround does not make this case work, but that also seem to be a problem in other bundlers (e.g. Rollup).