p5.domimporting like this is fine in standard js
import * as p5 from 'p5';
import 'p5/lib/addons/p5.dom';
but in typescript it seems to return an error
p5.dom.js?6a73:3225 Uncaught ReferenceError: p5 is not defined
at eval (p5.dom.js?6a73:3225)
at Object.../node_modules/p5/lib/addons/p5.dom.js (vendors~app.bundle.js:827)
at __webpack_require__ (bundle.js:783)
at fn (bundle.js:151)
at eval (p5Sketch.js?e190:1)
at Module../app/components/VideoShader/p5Sketch.js (app.bundle.js:58)
at __webpack_require__ (bundle.js:783)
at fn (bundle.js:151)
at Module.eval (index.tsx:4)
at eval (index.tsx:113)
the p5.dom module declaration seems to import the right reference on line 3
import * as p5 from '../../index';
and the index.d.ts is importing the reference on line 9
/// <reference path="./lib/addons/p5.dom.d.ts" />
UPDATE: SOLVED
I found the same issue reported in the p5-types repo
https://github.com/p5-types/p5.ts/issues/2
@Zalastax clear my doubts with an example project you can find here: link
In particular at this line
import 'script-loader!p5/lib/addons/p5.dom.min.js'
@Zalastax is using a custom webpack loader that made my day: https://www.npmjs.com/package/script-loader
The required synthax is clear as you can see: just add a script-loader! prefix before the import path
Most helpful comment
UPDATE: SOLVED
I found the same issue reported in the p5-types repo
https://github.com/p5-types/p5.ts/issues/2
@Zalastax clear my doubts with an example project you can find here: link
In particular at this line
@Zalastax is using a custom webpack loader that made my day: https://www.npmjs.com/package/script-loader
The required synthax is clear as you can see: just add a
script-loader!prefix before the import path