Only import it in dev mode
tcoopman opened this issue · 4 comments
tcoopman commented
What would your strategy be to only include this in development builds?
Something like doesn't work because import
only works on toplevel.
if (NODE_ENV !== 'production') {
import 'expose?Perf!react-addons-perf';
}
crysislinux commented
Do you mind using require instead?
if (NODE_ENV !== 'production') {
require('expose?Perf!react-addons-perf');
}
tcoopman commented
@crysislinux Yeah, I know that works, I was mostly wondering if there is an alternative
jfsiii commented
@tcoopman import
favors static analysis over flexibility and doesn't support dynamic imports.
IIUC, you should use System.import
for this. See systemjs
and es6-module-loader
for more info, but I believe you could do something like:
if (NODE_ENV !== 'production') {
System.import('react-addons-perf').then(Perf => window.Perf = Perf)
}