utsuboco / r3f-perf

Easily monitor your ThreeJS performances.
https://codesandbox.io/s/perlin-cubes-r3f-perf-wtp9t?file=/src/App.js
MIT License
624 stars 24 forks source link

Difficult to import production version of component into Typescript project #10

Closed joshuaellis closed 3 years ago

joshuaellis commented 3 years ago

Importing the component to show in production as shown in the readme poses a lot of difficulties in Typescript, would it be better perhaps to maybe be able to flag an .env variable instead? The use case being, we're doing a lot of exploration into models, complex scenes etc. and seeing how it performs in production is really valuable.

RenaudRohlinger commented 3 years ago

@joshuaellis if you got any quick workaround for that it would be welcome otherwise I'm seriously thinking of just removing the dev/prod condition and let the developer manage it.

joshuaellis commented 3 years ago

I think having it remove from prod is a great idea. I think its useful to have a simpler override. Would this work?:

if (process.env.NODE_ENV === 'development' || process.env.R3F_PERF_SHOW_IN_PROD) {
  module.exports = require('./r3f-perf.cjs.development.js')
} else {
  module.exports = require('./r3f-perf.cjs.production.min.js')
}

That's taken from dist/index

joshuaellis commented 3 years ago

That way in my env file i can set:

R3F_PERF_SHOW_IN_PROD=true
RenaudRohlinger commented 3 years ago

@joshuaellis v.0.79.0 released. It adds process.env.R3F_PERF_SHOW_IN_PROD.