Closed ysulyma closed 4 years ago
i think umd would be too much trouble imo, and not sure if it's worth it. where do you need umd?
Maybe I don't, and I'm just misunderstanding how to use the package. Currently my code looks like
// main.ts
import * as React from "react";
import * as THREE from "three";
import {Canvas} from "react-three-fiber";
/* do awesome things */
This is bundled using Typescript+Webpack; I am getting React, ReactDOM, and THREE as global variables from a CDN, and would like to know how to do the same with this library.
// webpack.config.js
externals: {
"react": "React",
"react-dom": "ReactDOM",
"react-three-fiber": "????????", // what do I put here?
"three": "THREE"
},
<!-- libraries -->
<script src="https://unpkg.com/react@16.13.1/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@16.13.1/umd/react-dom.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/92/three.min.js"></script>
<!-- how do I include react-three-fiber here? -->
<!-- my code -->
<script src="bundle.js"></script>
you could fork this project and add umd to the rollup config. then test it. if it works, commit your changes and make a pull request, i'll accept it. myself, i wouldn't know what to do tbh, the last time i have used script tags, that must've been 6 years ago.
For anyone looking for a solution, you can do try something like what I have here https://github.com/z3t0/react-xr-bundle
I am using systemjs specifically, but if you set it to umd it also works.
Can a UMD build of this library be provided? I want to load react-three-fiber from a CDN rather than bundling it in to my project. I see some CJS builds are available, but I need UMD.
Specifically, I want it to use the existing
React
,ReactDOM
,THREE
global variables from the browser, but package all other dependencies (@babel/*, react-reconciler, scheduler, tiny-emitter, react-promise-suspense, react-use-measure, @juggle/resize-observer, react-merge-refs) on its own.