ganlanyuan/tiny-slider

Can't import as ES module: `SyntaxError: ambiguous indirect export: tns`

tomyo opened this issue · 1 comments

tomyo commented

Issue description:
Following the docs, if I include the js file from the cdn (I downloaded that file from https://cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.9.4/min/tiny-slider.js), and then try to import it in a module as:

<script type="module">
    import { tns } from "/assets/vendor/tiny-slider/tiny-slider.js";

</script>

I get this error in browser:

SyntaxError: ambiguous indirect export: tns

I see in the source that there's no export, just a global variable tns defined.

Am I importing it wrong or using the wrong file?

Thanks.

P.S.: I don't use a bundler, so npm install is not an option for me.

P.S.2: cdn link for js file in readme is for version 2.9.2.

Tiny-slider version: 2.9.4
Browser name && version: firefox 114
OS name && version: linux

tomyo commented

I modified the first line of the minified script from the cnd, from:

var tns = (function () {...})()

to

export const tns = (function () {...})()

And now the import seems to work from a module.

I'll leave the issue open since I consider this as something to be fixed / improved. ES imports are the modern way to include stuff from other scripts.

Thanks!