Gaweph / p5-typescript-starter

Base starter project using p5js and typescript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do you import/use external libraries?

dblock opened this issue · comments

  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.

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.

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