]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
build: adjust build formats
authorEvan You <yyx990803@gmail.com>
Sun, 19 Apr 2020 22:42:07 +0000 (18:42 -0400)
committerEvan You <yyx990803@gmail.com>
Sun, 19 Apr 2020 22:43:21 +0000 (18:43 -0400)
- Rename `esm` to `esm-browser`
- Add runtime-only build for `esm-browser`
- Add default CDN alias for jsdelivr

packages/compiler-dom/package.json
packages/reactivity/package.json
packages/runtime-dom/package.json
packages/runtime-test/README.md
packages/runtime-test/package.json
packages/vue/README.md
packages/vue/package.json
rollup.config.js

index 615c506ee6b8a46f309d20ba0024965318b87a1b..cce6b86b8943ca712e96666eda644bbe581f34c3 100644 (file)
@@ -6,6 +6,7 @@
   "module": "dist/compiler-dom.esm-bundler.js",
   "types": "dist/compiler-dom.d.ts",
   "unpkg": "dist/compiler-dom/global.js",
+  "jsdelivr": "dist/compiler-dom/global.js",
   "files": [
     "index.js",
     "dist"
@@ -15,9 +16,9 @@
     "name": "VueCompilerDOM",
     "formats": [
       "esm-bundler",
+      "esm-browser",
       "cjs",
-      "global",
-      "esm"
+      "global"
     ]
   },
   "repository": {
index 4e3ca165d8a7ce6874681b44a7e9c643f6010a3b..6a33fed69df5e220665786cb7a4581e3cf19326f 100644 (file)
@@ -6,6 +6,7 @@
   "module": "dist/reactivity.esm-bundler.js",
   "types": "dist/reactivity.d.ts",
   "unpkg": "dist/reactivity.global.js",
+  "jsdelivr": "dist/reactivity.global.js",
   "files": [
     "index.js",
     "dist"
@@ -19,9 +20,9 @@
     "name": "VueReactivity",
     "formats": [
       "esm-bundler",
+      "esm-browser",
       "cjs",
-      "global",
-      "esm"
+      "global"
     ]
   },
   "keywords": [
index 477cbf2b94864643e1c59a2a369f7c83abb1d196..8b9a0e20066623c7e0742cf95f58e850c5a35a0b 100644 (file)
@@ -15,9 +15,9 @@
     "name": "VueRuntimeDOM",
     "formats": [
       "esm-bundler",
+      "esm-browser",
       "cjs",
-      "global",
-      "esm"
+      "global"
     ],
     "dts": [
       "jsx.d.ts"
index 66cbb62dbd200bfedef19d026a4ec2cba6c56deb..6d6ba8298226c23a61eed1de94ddc85fbd2f85e2 100644 (file)
@@ -1,5 +1,9 @@
 # @vue/runtime-test
 
+This is for Vue's own internal tests only - it ensures logic tested using this package is DOM-agnostic, and it runs faster than JSDOM.
+
+It can also be used as a reference for implementing a custom renderer.
+
 ``` js
 import { h, render, nodeOps, dumpOps } from '@vue/runtime-test'
 
index 082a662a93e4e91d59850d14e894c2b3de590cd9..df69ceb6f84dc377044d7bcf839d0f51031d4a11 100644 (file)
     "type": "git",
     "url": "git+https://github.com/vuejs/vue-next.git"
   },
-  "buildOptions": {
-    "name": "VueRuntimeTest",
-    "formats": [
-      "global"
-    ]
-  },
   "keywords": [
     "vue"
   ],
index d2911f7de02dbcdf78a0a1364d0832dc87720404..e37aad3e081f4e37e7164b248e9f0cf976117a96 100644 (file)
@@ -6,27 +6,30 @@
 
 - **`vue(.runtime).global(.prod).js`**:
   - For direct use via `<script src="...">` in the browser. Exposes the `Vue` global.
-  - Note: global builds are not [UMD](https://github.com/umdjs/umd) builds.  They are built as [IIFEs](https://developer.mozilla.org/en-US/docs/Glossary/IIFE) and is only meant for direct use via `<script src>`.
-  - **`vue.global.js`**: the "full" build that supports compiling templates on the fly.
-  - **`vue.runtime.global.js`**: runtime only, does not include runtime template compilation support. Use this if you are not using a bundler, but somehow pre-compiling your template.
+  - Note that global builds are not [UMD](https://github.com/umdjs/umd) builds.  They are built as [IIFEs](https://developer.mozilla.org/en-US/docs/Glossary/IIFE) and is only meant for direct use via `<script src="...">`.
+  - In-browser template compilation:
+    - **`vue.global.js`** is the "full" build that includes both the compiler and the runtime so it supports compiling templates on the fly.
+    - **`vue.runtime.global.js`** contains only the runtime and requires templates to be pre-compiled during a build step.
+  - Inlines all Vue core internal packages - i.e. it's a single file with no dependencies on other files. This means you **must** import everything from this file and this file only to ensure you are getting the same instance of code.
+  - Contains hard-coded prod/dev branches, and the prod build is pre-minified. Use the `*.prod.js` files for production.
 
-- **`vue.esm(.prod).js`**:
-  - For usage via native ES modules imports (in browser via `<script type="module">`, or via Node.js native ES modules support in the future)
-  - Inlines all dependencies - i.e. it's a single ES module with no imports from other files
-    - this means you **must** import everything from this file and this file only to ensure you are getting the same instance of code.
-  - Hard-coded prod/dev branches, and the prod build is pre-minified (you will need to use different files for dev/prod)
+- **`vue(.runtime).esm-browser(.prod).js`**:
+  - For usage via native ES modules imports (in browser via `<script type="module">`.
+  - Shares the same runtime compilation, dependency inlining and hard-coded prod/dev behavior with the global build.
 
 ### With a Bundler
 
 - **`vue(.runtime).esm-bundler.js`**:
+
   - For use with bundlers like `webpack`, `rollup` and `parcel`.
   - Leaves prod/dev branches with `process.env.NODE_ENV` guards (must be replaced by bundler)
   - Does not ship minified builds (to be done together with the rest of the code after bundling)
-  - imports dependencies (e.g. `@vue/runtime-core`, `@vue/runtime-compiler`)
-    - imported dependencies are also `esm-bundler` builds and will in turn import their dependencies (e.g. `@vue/runtime-core` imports `@vue/reactivity`)
-    - this means you **can** install/import these deps individually without ending up with different instances of these dependencies.
-  - **`vue.runtime.esm-bundler.js`**: runtime only, does not include runtime template compilation support. **This is the default entry for bundlers (via `module` field in `package.json`)** because when using a bundler templates are typically pre-compiled (e.g. in `*.vue` files).
-  - **`vue.esm-bundler.js`**: includes the runtime compiler. Use this if you are using a bundler but still want runtime template compilation (e.g. in-DOM templates or templates via inline JavaScript strings).
+  - Imports dependencies (e.g. `@vue/runtime-core`, `@vue/runtime-compiler`)
+    - Imported dependencies are also `esm-bundler` builds and will in turn import their dependencies (e.g. `@vue/runtime-core` imports `@vue/reactivity`)
+    - This means you **can** install/import these deps individually without ending up with different instances of these dependencies, but you must make sure they all resolve to the same version.
+  - In-browser template compilation:
+    - **`vue.runtime.esm-bundler.js` (default)** is runtime only, and requires all templates to be pre-compiled. This is the default entry for bundlers (via `module` field in `package.json`) because when using a bundler templates are typically pre-compiled (e.g. in `*.vue` files).
+    - **`vue.esm-bundler.js`**: includes the runtime compiler. Use this if you are using a bundler but still want runtime template compilation (e.g. in-DOM templates or templates via inline JavaScript strings). You will need to configure your bundler to alias `vue` to this file.
 
 ### For Server-Side Rendering
 
index 369a93c12d83e558b4b1a4a46195225935d75ee1..9247a9fa7c047641b8aa46ca9f35e05d947d5e6d 100644 (file)
@@ -6,6 +6,7 @@
   "module": "dist/vue.runtime.esm-bundler.js",
   "types": "dist/vue.d.ts",
   "unpkg": "dist/vue.global.js",
+  "jsdelivr": "dist/vue.global.js",
   "sideEffects": false,
   "files": [
     "index.js",
@@ -19,7 +20,8 @@
       "cjs",
       "global",
       "global-runtime",
-      "esm"
+      "esm-browser",
+      "esm-browser-runtime"
     ]
   },
   "repository": {
index 2176401efb8221e9a1c20cefbb75e96c9b9d4f29..cfa8b1ce6f78d684620ce6e46d5fb685d6f29380 100644 (file)
@@ -23,6 +23,10 @@ const outputConfigs = {
     file: resolve(`dist/${name}.esm-bundler.js`),
     format: `es`
   },
+  'esm-browser': {
+    file: resolve(`dist/${name}.esm-browser.js`),
+    format: `es`
+  },
   cjs: {
     file: resolve(`dist/${name}.cjs.js`),
     format: `cjs`
@@ -31,15 +35,16 @@ const outputConfigs = {
     file: resolve(`dist/${name}.global.js`),
     format: `iife`
   },
-  esm: {
-    file: resolve(`dist/${name}.esm.js`),
-    format: `es`
-  },
-  // main "vue" package only
+
+  // runtime-only builds, for main "vue" package only
   'esm-bundler-runtime': {
     file: resolve(`dist/${name}.runtime.esm-bundler.js`),
     format: `es`
   },
+  'esm-browser-runtime': {
+    file: resolve(`dist/${name}.runtime.esm-browser.js`),
+    format: 'es'
+  },
   'global-runtime': {
     file: resolve(`dist/${name}.runtime.global.js`),
     format: 'iife'
@@ -58,7 +63,7 @@ if (process.env.NODE_ENV === 'production') {
     if (format === 'cjs' && packageOptions.prod !== false) {
       packageConfigs.push(createProductionConfig(format))
     }
-    if (/global/.test(format) || format === 'esm') {
+    if (/^(global|esm-browser)(-runtime)?/.test(format)) {
       packageConfigs.push(createMinifiedConfig(format))
     }
   })
@@ -77,10 +82,10 @@ function createConfig(format, output, plugins = []) {
 
   const isProductionBuild =
     process.env.__DEV__ === 'false' || /\.prod\.js$/.test(output.file)
-  const isGlobalBuild = /global/.test(format)
-  const isRawESMBuild = format === 'esm'
-  const isNodeBuild = format === 'cjs'
   const isBundlerESMBuild = /esm-bundler/.test(format)
+  const isBrowserESMBuild = /esm-browser/.test(format)
+  const isNodeBuild = format === 'cjs'
+  const isGlobalBuild = /global/.test(format)
 
   if (isGlobalBuild) {
     output.name = packageOptions.name
@@ -109,7 +114,7 @@ function createConfig(format, output, plugins = []) {
   const entryFile = /runtime$/.test(format) ? `src/runtime.ts` : `src/index.ts`
 
   const external =
-    isGlobalBuild || isRawESMBuild
+    isGlobalBuild || isBrowserESMBuild
       ? []
       : [
           ...Object.keys(pkg.dependencies || {}),
@@ -137,7 +142,7 @@ function createConfig(format, output, plugins = []) {
         isProductionBuild,
         isBundlerESMBuild,
         // isBrowserBuild?
-        (isGlobalBuild || isRawESMBuild || isBundlerESMBuild) &&
+        (isGlobalBuild || isBrowserESMBuild || isBundlerESMBuild) &&
           !packageOptions.enableNonBrowserBranches,
         isGlobalBuild,
         isNodeBuild