]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
workflow: rename umd build to global
authorEvan You <yyx990803@gmail.com>
Wed, 19 Sep 2018 16:46:55 +0000 (12:46 -0400)
committerEvan You <yyx990803@gmail.com>
Wed, 19 Sep 2018 16:46:55 +0000 (12:46 -0400)
packages/observer/README.md
packages/observer/package.json
packages/renderer-dom/package.json
rollup.config.js
scripts/dev.js

index 4e42994421611f4f3d049804d7e72c4eb935a380..0fd7a6c50a7ac8b9d91db21393b27f464019376c 100644 (file)
@@ -1,3 +1,3 @@
 # @vue/observer
 
-> This package is inlined into UMD & Browser ESM builds of user-facing renderers (e.g. `@vue/renderer-dom`), but also published as a package that can be used standalone. The standalone build should not be used alongside a pre-bundled build of a user-facing renderer, as they will have different internal storage for reactivity connections. A user-facing renderer should re-export all APIs from this package.
+> This package is inlined into Global & Browser ESM builds of user-facing renderers (e.g. `@vue/renderer-dom`), but also published as a package that can be used standalone. The standalone build should not be used alongside a pre-bundled build of a user-facing renderer, as they will have different internal storage for reactivity connections. A user-facing renderer should re-export all APIs from this package.
index 81bccff66976b04161d749ae61692abf49378743..d5fa3f5e6ea262ef2e7eab88f183190932d02b74 100644 (file)
@@ -5,14 +5,14 @@
   "main": "index.js",
   "module": "dist/observer.esm.js",
   "typings": "dist/index.d.ts",
-  "unpkg": "dist/observer.umd.js",
+  "unpkg": "dist/observer.global.js",
   "repository": {
     "type": "git",
     "url": "git+https://github.com/vuejs/vue.git"
   },
   "buildOptions": {
     "name": "VueObserver",
-    "formats": ["esm", "cjs", "umd", "esm-browser"]
+    "formats": ["esm", "cjs", "global", "esm-browser"]
   },
   "keywords": [
     "vue"
index 17b55aafd82ecdd8113119def824f1a9909b4738..a379956b7d6d75bd009025536dc9b0224a30f43e 100644 (file)
@@ -5,10 +5,10 @@
   "main": "index.js",
   "module": "dist/renderer-dom.esm.js",
   "typings": "dist/index.d.ts",
-  "unpkg": "dist/renderer-dom.umd.js",
+  "unpkg": "dist/renderer-dom.global.js",
   "buildOptions": {
-    "name": "Vue",
-    "formats": ["esm", "cjs", "umd", "esm-browser"]
+    "name": "VueDOMRenderer",
+    "formats": ["esm", "cjs", "global", "esm-browser"]
   },
   "repository": {
     "type": "git",
index 320edf5f5afd6be9b36a6e99d6cd46af425a9d20..99d8e5ce8f989a3cb6c5210864f92c3b6b947e6d 100644 (file)
@@ -29,16 +29,16 @@ let hasTSChecked = false
 
 const configs = {
   esm: {
-    file: resolve(`dist/${name}.esm.js`),
+    file: resolve(`dist/${name}.esm-bundler.js`),
     format: `es`
   },
   cjs: {
     file: resolve(`dist/${name}.cjs.js`),
     format: `cjs`
   },
-  umd: {
-    file: resolve(`dist/${name}.umd.js`),
-    format: `umd`
+  global: {
+    file: resolve(`dist/${name}.global.js`),
+    format: `iife`
   },
   'esm-browser': {
     file: resolve(`dist/${name}.esm-browser.js`),
@@ -49,14 +49,16 @@ const configs = {
 const defaultFormats = ['esm', 'cjs']
 const inlineFromats = process.env.FORMATS && process.env.FORMATS.split(',')
 const packageFormats = inlineFromats || packageOptions.formats || defaultFormats
-const packageConfigs = packageFormats.map(format => createConfig(configs[format]))
+const packageConfigs = packageFormats.map(format =>
+  createConfig(configs[format])
+)
 
 if (process.env.NODE_ENV === 'production') {
   packageFormats.forEach(format => {
     if (format === 'cjs') {
       packageConfigs.push(createProductionConfig(format))
     }
-    if (format === 'umd' || format === 'esm-browser') {
+    if (format === 'global' || format === 'esm-browser') {
       packageConfigs.push(createMinifiedConfig(format))
     }
   })
@@ -66,11 +68,11 @@ module.exports = packageConfigs
 
 function createConfig(output, plugins = []) {
   const isProductionBuild = /\.prod\.js$/.test(output.file)
-  const isUMDBuild = /\.umd(\.prod)?\.js$/.test(output.file)
+  const isGlobalBuild = /\.global(\.prod)?\.js$/.test(output.file)
   const isBunlderESMBuild = /\.esm\.js$/.test(output.file)
   const isBrowserESMBuild = /esm-browser(\.prod)?\.js$/.test(output.file)
 
-  if (isUMDBuild) {
+  if (isGlobalBuild) {
     output.name = packageOptions.name
   }
 
@@ -91,11 +93,10 @@ function createConfig(output, plugins = []) {
 
   return {
     input: resolve(`src/index.ts`),
-    // UMD and Browser ESM builds inlines everything so that they can be
+    // Global and Browser ESM builds inlines everything so that they can be
     // used alone.
-    external: isUMDBuild || isBrowserESMBuild
-      ? []
-      : Object.keys(aliasOptions),
+    external:
+      isGlobalBuild || isBrowserESMBuild ? [] : Object.keys(aliasOptions),
     plugins: [
       tsPlugin,
       aliasPlugin,
@@ -114,10 +115,10 @@ function createConfig(output, plugins = []) {
 function createReplacePlugin(isProduction, isBunlderESMBuild) {
   return replace({
     __DEV__: isBunlderESMBuild
-      // preserve to be handled by bundlers
-      ? `process.env.NODE_ENV !== 'production'`
-      // hard coded dev/prod builds
-      : !isProduction,
+      // preserve to be handled by bundlers
+        `process.env.NODE_ENV !== 'production'`
+      // hard coded dev/prod builds
+        !isProduction,
     // compatibility builds
     __COMPAT__: !!process.env.COMPAT
   })
@@ -126,21 +127,20 @@ function createReplacePlugin(isProduction, isBunlderESMBuild) {
 function createProductionConfig(format) {
   return createConfig({
     file: resolve(`dist/${name}.${format}.prod.js`),
-    format: /^esm/.test(format) ? 'es' : format
+    format: configs[format].format
   })
 }
 
 function createMinifiedConfig(format) {
   const { terser } = require('rollup-plugin-terser')
-  const isESM = /^esm/.test(format)
   return createConfig(
     {
       file: resolve(`dist/${name}.${format}.prod.js`),
-      format: isESM ? 'es' : format
+      format: configs[format].format
     },
     [
       terser({
-        module: isESM
+        module: /^esm/.test(format)
       })
     ]
   )
index c0879361fa8aecd05efe9b1ab9c0b2106661ceb8..887cdfa3a9d9274c08a15703d93d6bf78b498905 100644 (file)
@@ -2,7 +2,7 @@
 Run Rollup in watch mode for development.
 
 To specific the package to watch, simply pass its name and the desired build
-formats to watch (defaults to "umd"):
+formats to watch (defaults to "global"):
 
 ```
 # name supports fuzzy match. will watch all packages with name containing "dom"
@@ -22,7 +22,7 @@ const formats = args.formats || args.f
 
 execa(
   'rollup',
-  ['-wc', '--environment', `TARGET:${target},FORMATS:${formats || 'umd'}`],
+  ['-wc', '--environment', `TARGET:${target},FORMATS:${formats || 'global'}`],
   {
     stdio: 'inherit'
   }