Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tomyo opened this issue Jun 19, 2023 · 1 comment
Open

Comments

@tomyo
Copy link

tomyo commented Jun 19, 2023

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 tomyo changed the title Can't import as ES module Can't import as ES module: SyntaxError: ambiguous indirect export: tns Jun 19, 2023
@tomyo
Copy link
Author

tomyo commented Jun 19, 2023

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant