import { Pinia, PiniaPlugin, setActivePinia, piniaSymbol } from './rootStore'
import { ref, App, markRaw, effectScope, isVue2, Ref } from 'vue-demi'
import { registerPiniaDevtools, devtoolsPlugin } from './devtools'
-import { IS_CLIENT } from './env'
+import { USE_DEVTOOLS } from './env'
import { StateTree, StoreGeneric } from './types'
/**
app.provide(piniaSymbol, pinia)
app.config.globalProperties.$pinia = pinia
/* istanbul ignore else */
- if (__DEV__ && IS_CLIENT) {
+ if (USE_DEVTOOLS) {
registerPiniaDevtools(app, pinia)
}
toBeInstalled.forEach((plugin) => _p.push(plugin))
})
// pinia devtools rely on dev only features so they cannot be forced unless
- // the dev build of Vue is used
- // We also don't need devtools in test mode or anywhere where Proxy isn't supported (like IE)
- if (__DEV__ && IS_CLIENT && !__TEST__ && typeof Proxy !== 'undefined') {
+ // the dev build of Vue is used. Avoid old browsers like IE11.
+ if (USE_DEVTOOLS && typeof Proxy !== 'undefined') {
pinia.use(devtoolsPlugin)
}
export const IS_CLIENT = typeof window !== 'undefined'
+
+/**
+ * Should we add the devtools plugins.
+ * - only if dev mode or forced through the prod devtools flag
+ * - not in test
+ * - only if window exists (could change in the future)
+ */
+export const USE_DEVTOOLS =
+ (__DEV__ || __FEATURE_PROD_DEVTOOLS__) && !__TEST__ && IS_CLIENT
import type { Plugin } from 'vue-demi'
import { registerPiniaDevtools } from './devtools'
-import { IS_CLIENT } from './env'
+import { IS_CLIENT, USE_DEVTOOLS } from './env'
import { Pinia, piniaSymbol, setActivePinia } from './rootStore'
/**
// this allows calling useStore() outside of a component setup after
// installing pinia's plugin
setActivePinia(pinia)
- if (__DEV__) {
- registerPiniaDevtools(pinia._a, pinia)
- }
+ }
+ if (USE_DEVTOOLS) {
+ registerPiniaDevtools(pinia._a, pinia)
}
} else if (!this.$pinia && options.parent && options.parent.$pinia) {
this.$pinia = options.parent.$pinia
(isBundlerESMBuild && !isRawESMBuild) || isNodeBuild
? `(process.env.NODE_ENV === 'test')`
: 'false',
+ __FEATURE_PROD_DEVTOOLS__: isBundlerESMBuild
+ ? `__VUE_PROD_DEVTOOLS__`
+ : 'false',
// If the build is expected to run directly in the browser (global / esm builds)
__BROWSER__: JSON.stringify(isRawESMBuild),
// is targeting bundlers?