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

How do you import/use external libraries? #19

Closed
dblock opened this issue May 15, 2021 · 3 comments
Closed

How do you import/use external libraries? #19

dblock opened this issue May 15, 2021 · 3 comments

Comments

@dblock
Copy link
Contributor

dblock commented May 15, 2021

What's the right way to import and use something like https://github.com/kazuhikoarase/qrcode-generator (or https://github.com/1w2w3y/qrcode-generator-ts) into this?

@Gaweph
Copy link
Owner

Gaweph commented May 16, 2021

  1. Add script tag to your index.html
    <script src="https://cdnjs.cloudflare.com/ajax/libs/qrcode-generator/1.4.4/qrcode.min.js"></script>

  2. Add the typings to your project
    npm install -D qrcode-generator --save

  3. Add an import line in your global.d.ts file
    import qrcode = require('qrcode-generator');

Note: I have updated the tsconfig.json file to include "moduleResolution": "node" (you can get the latest version of this repository or update this file on your own version)

The method outlined above means you can add the script tag to your html and get everything working without anything fancy like webpack etc... keeping it simple (pure js and html).

Let me know if you get stuck.

@Gaweph Gaweph closed this as completed May 17, 2021
@dblock
Copy link
Contributor Author

dblock commented May 26, 2021

This worked (https://github.com/dblock/p5qr), thank you. Maybe it could be a section in the README? I can queue it up for myself.

@Gaweph
Copy link
Owner

Gaweph commented May 26, 2021

Brilliant. Good idea. Happy to include this in the readme.

rodigu added a commit to rodigu/EntiTS that referenced this issue Jun 22, 2023
rodigu added a commit to rodigu/EntiTS that referenced this issue Jun 22, 2023
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

2 participants