]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
build: export runtime-only build for bundlers by default in main vue package
authorEvan You <yyx990803@gmail.com>
Tue, 17 Dec 2019 23:24:01 +0000 (18:24 -0500)
committerEvan You <yyx990803@gmail.com>
Tue, 17 Dec 2019 23:24:01 +0000 (18:24 -0500)
packages/vue/package.json
packages/vue/src/devCheck.ts [new file with mode: 0644]
packages/vue/src/index.ts
packages/vue/src/runtime.ts [new file with mode: 0644]
rollup.config.js

index f17ccfd6be789a7d0333823557ae4c9442fccf49..0b66f0a05ff146c14934b47bd80075825407500c 100644 (file)
@@ -3,7 +3,7 @@
   "version": "3.0.0-alpha.0",
   "description": "vue",
   "main": "index.js",
-  "module": "dist/vue.esm-bundler.js",
+  "module": "dist/vue.runtime.esm-bundler.js",
   "files": [
     "index.js",
     "dist"
@@ -14,6 +14,7 @@
     "name": "Vue",
     "formats": [
       "esm-bundler",
+      "esm-bundler-runtime",
       "cjs",
       "global",
       "esm"
diff --git a/packages/vue/src/devCheck.ts b/packages/vue/src/devCheck.ts
new file mode 100644 (file)
index 0000000..10bd99f
--- /dev/null
@@ -0,0 +1,6 @@
+if (__BROWSER__ && __DEV__) {
+  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 e40ec89e5dbbb7bf9496be46899e568a75a9a002..f79b76960eaf2126956d78697a10df9f4ddb9fce 100644 (file)
@@ -1,4 +1,4 @@
-// This package is the "full-build" that includes both the runtime
+// This entry is the "full-build" that includes both the runtime
 // and the compiler, and supports on-the-fly compilation of the template option.
 import { compile, CompilerOptions, CompilerError } from '@vue/compiler-dom'
 import { registerRuntimeCompiler, RenderFunction, warn } from '@vue/runtime-dom'
@@ -61,9 +61,4 @@ registerRuntimeCompiler(compileToFunction)
 export { compileToFunction as compile }
 export * from '@vue/runtime-dom'
 
-if (__BROWSER__ && __DEV__) {
-  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.`
-  )
-}
+import './devCheck'
diff --git a/packages/vue/src/runtime.ts b/packages/vue/src/runtime.ts
new file mode 100644 (file)
index 0000000..b6bbe50
--- /dev/null
@@ -0,0 +1,6 @@
+// This entry exports the runtime only, and is built as
+// `dist/vue.esm-bundler.js` which is used by default for bundlers.
+
+export * from '@vue/runtime-dom'
+
+import './devCheck'
index b2a66d14bc57e46187957a091b50a1ad99112afc..75ec6ad5466a6fedde9c0980c62e77a1b0a52279 100644 (file)
@@ -23,11 +23,16 @@ const knownExternals = fs.readdirSync(packagesDir).filter(p => {
 // ensure TS checks only once for each build
 let hasTSChecked = false
 
-const configs = {
+const outputConfigs = {
   'esm-bundler': {
     file: resolve(`dist/${name}.esm-bundler.js`),
     format: `es`
   },
+  // main "vue" package only
+  'esm-bundler-runtime': {
+    file: resolve(`dist/${name}.runtime.esm-bundler.js`),
+    format: `es`
+  },
   cjs: {
     file: resolve(`dist/${name}.cjs.js`),
     format: `cjs`
@@ -47,7 +52,7 @@ const inlineFormats = process.env.FORMATS && process.env.FORMATS.split(',')
 const packageFormats = inlineFormats || packageOptions.formats || defaultFormats
 const packageConfigs = process.env.PROD_ONLY
   ? []
-  : packageFormats.map(format => createConfig(configs[format]))
+  : packageFormats.map(format => createConfig(format, outputConfigs[format]))
 
 if (process.env.NODE_ENV === 'production') {
   packageFormats.forEach(format => {
@@ -62,14 +67,14 @@ if (process.env.NODE_ENV === 'production') {
 
 export default packageConfigs
 
-function createConfig(output, plugins = []) {
+function createConfig(format, output, plugins = []) {
   output.externalLiveBindings = false
 
   const isProductionBuild =
     process.env.__DEV__ === 'false' || /\.prod\.js$/.test(output.file)
-  const isGlobalBuild = /\.global(\.prod)?\.js$/.test(output.file)
-  const isBundlerESMBuild = /\.esm-bundler\.js$/.test(output.file)
-  const isRawESMBuild = /esm(\.prod)?\.js$/.test(output.file)
+  const isGlobalBuild = format === 'global'
+  const isRawESMBuild = format === 'esm'
+  const isBundlerESMBuild = /esm-bundler/.test(format)
   const isRuntimeCompileBuild = /vue\./.test(output.file)
 
   if (isGlobalBuild) {
@@ -98,8 +103,11 @@ function createConfig(output, plugins = []) {
   // during a single build.
   hasTSChecked = true
 
+  const entryFile =
+    format === 'esm-bundler-runtime' ? `src/runtime.ts` : `src/index.ts`
+
   return {
-    input: resolve(`src/index.ts`),
+    input: resolve(entryFile),
     // Global and Browser ESM builds inlines everything so that they can be
     // used alone.
     external:
@@ -167,18 +175,19 @@ function createReplacePlugin(
 }
 
 function createProductionConfig(format) {
-  return createConfig({
+  return createConfig(format, {
     file: resolve(`dist/${name}.${format}.prod.js`),
-    format: configs[format].format
+    format: outputConfigs[format].format
   })
 }
 
 function createMinifiedConfig(format) {
   const { terser } = require('rollup-plugin-terser')
   return createConfig(
+    format,
     {
       file: resolve(`dist/${name}.${format}.prod.js`),
-      format: configs[format].format
+      format: outputConfigs[format].format
     },
     [
       terser({