]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
feat: production tip
authorEvan You <yyx990803@gmail.com>
Wed, 4 Sep 2019 00:51:42 +0000 (20:51 -0400)
committerEvan You <yyx990803@gmail.com>
Wed, 4 Sep 2019 00:51:42 +0000 (20:51 -0400)
packages/global.d.ts
packages/vue/src/index.ts
rollup.config.js

index f82292626ed2a56e4a2707ba3355185065a495e4..60adb6451c692eaea1ea0e83c8987edc275876cd 100644 (file)
@@ -1,4 +1,7 @@
 // Global compile-time constants
 declare var __DEV__: boolean
-declare var __COMPAT__: boolean
 declare var __JSDOM__: boolean
+
+// Feature flags
+declare var __FEATURE_OPTIONS__: boolean
+declare var __FEATURE_PRODUCTION_TIP__: boolean
index d9dd498d849597676509377bdc890cc726721465..e7bc46d216e04e84399adbffee18975c817ca475 100644 (file)
@@ -1,3 +1,10 @@
 // TODO this package will be the "full-build" that includes both the runtime
 // and the compiler
 export * from '@vue/runtime-dom'
+
+if (__FEATURE_PRODUCTION_TIP__) {
+  console[console.info ? 'info' : 'log'](
+    `You are running a development build of Vue.\n` +
+      `Make sure to use the production build (*.prod.js) when deploying for production.`
+  )
+}
index 0c9bc1d12c6e764695790abe8ce841ffbccd6ef4..3f530bbcaf321eb56c44ee3ba21086e95d5d327a 100644 (file)
@@ -75,7 +75,6 @@ function createConfig(output, plugins = []) {
   const isGlobalBuild = /\.global(\.prod)?\.js$/.test(output.file)
   const isBunlderESMBuild = /\.esm\.js$/.test(output.file)
   const isBrowserESMBuild = /esm-browser(\.prod)?\.js$/.test(output.file)
-  const isCompat = /dist\/vue\./.test(output.file)
 
   if (isGlobalBuild) {
     output.name = packageOptions.name
@@ -112,7 +111,11 @@ function createConfig(output, plugins = []) {
     plugins: [
       tsPlugin,
       aliasPlugin,
-      createReplacePlugin(isProductionBuild, isBunlderESMBuild, isCompat),
+      createReplacePlugin(
+        isProductionBuild,
+        isBunlderESMBuild,
+        isGlobalBuild || isBrowserESMBuild
+      ),
       ...plugins
     ],
     output,
@@ -124,15 +127,19 @@ function createConfig(output, plugins = []) {
   }
 }
 
-function createReplacePlugin(isProduction, isBunlderESMBuild, isCompat) {
+function createReplacePlugin(isProduction, isBunlderESMBuild, isBrowserBuild) {
   return replace({
     __DEV__: isBunlderESMBuild
       ? // preserve to be handled by bundlers
         `process.env.NODE_ENV !== 'production'`
       : // hard coded dev/prod builds
         !isProduction,
-    // compatibility builds
-    __COMPAT__: !!packageOptions.compat,
+    // show production tip?
+    // should only do this for dev AND browser-targeting builds.
+    __FEATURE_PRODUCTION_TIP__: !isProduction && isBrowserBuild,
+    // support options?
+    // the lean build drops options related code with buildOptions.lean: true
+    __FEATURE_OPTIONS__: !packageOptions.lean,
     // this is only used during tests
     __JSDOM__: false
   })