import { Pinia, PiniaPlugin, setActivePinia, piniaSymbol } from './rootStore'
import { ref, App, markRaw, effectScope, isVue2, Ref } from 'vue-demi'
import { registerPiniaDevtools, devtoolsPlugin } from './devtools'
-import { USE_DEVTOOLS } from './env'
import { StateTree, StoreGeneric } from './types'
/**
app.provide(piniaSymbol, pinia)
app.config.globalProperties.$pinia = pinia
/* istanbul ignore else */
- if (USE_DEVTOOLS) {
+ 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. Avoid old browsers like IE11.
- if (USE_DEVTOOLS && typeof Proxy !== 'undefined') {
+ if (__USE_DEVTOOLS__ && typeof Proxy !== 'undefined') {
pinia.use(devtoolsPlugin)
}
* - only if dev mode or forced through the prod devtools flag
* - not in test
* - only if window exists (could change in the future)
+ * NOTE: Moved to a build time replacement
*/
-export const USE_DEVTOOLS =
- (__DEV__ || __FEATURE_PROD_DEVTOOLS__) && !__TEST__ && IS_CLIENT
+// export const USE_DEVTOOLS =
+// (__DEV__ || __FEATURE_PROD_DEVTOOLS__) && !__TEST__ && IS_CLIENT
// Global compile-time constants
declare var __DEV__: boolean
+declare var __USE_DEVTOOLS__: boolean
declare var __TEST__: boolean
declare var __FEATURE_PROD_DEVTOOLS__: boolean
declare var __BROWSER__: boolean
import type { Plugin } from 'vue-demi'
import { registerPiniaDevtools } from './devtools'
-import { IS_CLIENT, USE_DEVTOOLS } from './env'
+import { IS_CLIENT } from './env'
import { Pinia, piniaSymbol, setActivePinia } from './rootStore'
/**
// installing pinia's plugin
setActivePinia(pinia)
}
- if (USE_DEVTOOLS) {
+ if (__USE_DEVTOOLS__) {
registerPiniaDevtools(pinia._a, pinia)
}
} else if (!this.$pinia && options.parent && options.parent.$pinia) {
isGlobalBuild,
isNodeBuild
) {
+ const __DEV__ =
+ (isBundlerESMBuild && !isRawESMBuild) || (isNodeBuild && !isProduction)
+ ? // preserve to be handled by bundlers
+ `(process.env.NODE_ENV !== 'production')`
+ : // hard coded dev/prod builds
+ JSON.stringify(!isProduction)
+ const __FEATURE_PROD_DEVTOOLS__ = isBundlerESMBuild
+ ? `(typeof __VUE_PROD_DEVTOOLS__ !== 'undefined' && __VUE_PROD_DEVTOOLS__)`
+ : 'false'
+
+ const __TEST__ =
+ (isBundlerESMBuild && !isRawESMBuild) || isNodeBuild
+ ? `(process.env.NODE_ENV === 'test')`
+ : 'false'
+
const replacements = {
__COMMIT__: `"${process.env.COMMIT}"`,
__VERSION__: `"${pkg.version}"`,
- __DEV__:
- (isBundlerESMBuild && !isRawESMBuild) || (isNodeBuild && !isProduction)
- ? // preserve to be handled by bundlers
- `(process.env.NODE_ENV !== 'production')`
- : // hard coded dev/prod builds
- JSON.stringify(!isProduction),
+ __DEV__,
// this is only used during tests
- __TEST__:
- (isBundlerESMBuild && !isRawESMBuild) || isNodeBuild
- ? `(process.env.NODE_ENV === 'test')`
- : 'false',
- __FEATURE_PROD_DEVTOOLS__: isBundlerESMBuild
- ? `(typeof __VUE_PROD_DEVTOOLS__ !== 'undefined' && __VUE_PROD_DEVTOOLS__)`
- : 'false',
+ __TEST__,
+ __FEATURE_PROD_DEVTOOLS__,
+ __USE_DEVTOOLS__: `((${__DEV__} || ${__FEATURE_PROD_DEVTOOLS__}) && !${__TEST__} && typeof window !== 'undefined')`,
// If the build is expected to run directly in the browser (global / esm builds)
__BROWSER__: JSON.stringify(isRawESMBuild),
// is targeting bundlers?
export default defineConfig({
define: {
__DEV__: true,
+ __USE_DEVTOOLS__: false,
__TEST__: true,
__BROWSER__: true,
},