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

Not usable via CDN #79

Open
kierans opened this issue Jan 17, 2022 · 4 comments · May be fixed by #80
Open

Not usable via CDN #79

kierans opened this issue Jan 17, 2022 · 4 comments · May be fixed by #80

Comments

@kierans
Copy link

kierans commented Jan 17, 2022

I have a Shopify site where I need to dynamically convert from a currency code to a symbol. However being in Shopify I can't use NPM modules.

I'm happy to do a PR for a webpack build so that this library can be used via a CDN.

@kierans kierans linked a pull request Jan 17, 2022 that will close this issue
@official-akshayjadhav
Copy link

is there any solution?

@kierans
Copy link
Author

kierans commented Jun 2, 2022

@official-akshayjadhav I used my webpack config to create a dist and added it to my Shopify site's assets as a JS file. Adding an include tag in the main template file saw the JS loaded which means I could use the module. However it would be better to have this module in a CDN.

@mreinstein
Copy link

you can use skypack, which will transform this nicely for you: https://cdn.skypack.dev/currency-symbol-map

example invocation:

<script type="module">
    import getSymbolFromCurrency from 'https://cdn.skypack.dev/currency-symbol-map'

    const s = getSymbolFromCurrency('USD')
</script>

@Daniel-FDS
Copy link

Daniel-FDS commented Nov 11, 2022

you can use skypack, which will transform this nicely for you: https://cdn.skypack.dev/currency-symbol-map

example invocation:

<script type="module">
    import getSymbolFromCurrency from 'https://cdn.skypack.dev/currency-symbol-map'

    const s = getSymbolFromCurrency('USD')
</script>

Perfect, thank you so much! I was able to get it working with this (although I implemented it a bit differently).

I had made a file called globalModules.js:

import getSymbolFromCurrency from "https://cdn.skypack.dev/currency-symbol-map";

const Get_Currency_Symbol = (code) => {
	return getSymbolFromCurrency(code);
};

export { Get_Currency_Symbol };

I then imported this into another JS file, which was loaded in the HTML with the type="module" attribute:

import { Get_Currency_Symbol } from "./globalModules.js";

Then you directly use the function Get_Currency_Symbol().

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

Successfully merging a pull request may close this issue.

4 participants