build: adjust build formats
- Rename `esm` to `esm-browser` - Add runtime-only build for `esm-browser` - Add default CDN alias for jsdelivr
This commit is contained in:
parent
a51b052672
commit
218e6e1667
@ -6,6 +6,7 @@
|
|||||||
"module": "dist/compiler-dom.esm-bundler.js",
|
"module": "dist/compiler-dom.esm-bundler.js",
|
||||||
"types": "dist/compiler-dom.d.ts",
|
"types": "dist/compiler-dom.d.ts",
|
||||||
"unpkg": "dist/compiler-dom/global.js",
|
"unpkg": "dist/compiler-dom/global.js",
|
||||||
|
"jsdelivr": "dist/compiler-dom/global.js",
|
||||||
"files": [
|
"files": [
|
||||||
"index.js",
|
"index.js",
|
||||||
"dist"
|
"dist"
|
||||||
@ -15,9 +16,9 @@
|
|||||||
"name": "VueCompilerDOM",
|
"name": "VueCompilerDOM",
|
||||||
"formats": [
|
"formats": [
|
||||||
"esm-bundler",
|
"esm-bundler",
|
||||||
|
"esm-browser",
|
||||||
"cjs",
|
"cjs",
|
||||||
"global",
|
"global"
|
||||||
"esm"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
"module": "dist/reactivity.esm-bundler.js",
|
"module": "dist/reactivity.esm-bundler.js",
|
||||||
"types": "dist/reactivity.d.ts",
|
"types": "dist/reactivity.d.ts",
|
||||||
"unpkg": "dist/reactivity.global.js",
|
"unpkg": "dist/reactivity.global.js",
|
||||||
|
"jsdelivr": "dist/reactivity.global.js",
|
||||||
"files": [
|
"files": [
|
||||||
"index.js",
|
"index.js",
|
||||||
"dist"
|
"dist"
|
||||||
@ -19,9 +20,9 @@
|
|||||||
"name": "VueReactivity",
|
"name": "VueReactivity",
|
||||||
"formats": [
|
"formats": [
|
||||||
"esm-bundler",
|
"esm-bundler",
|
||||||
|
"esm-browser",
|
||||||
"cjs",
|
"cjs",
|
||||||
"global",
|
"global"
|
||||||
"esm"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
"name": "VueRuntimeDOM",
|
"name": "VueRuntimeDOM",
|
||||||
"formats": [
|
"formats": [
|
||||||
"esm-bundler",
|
"esm-bundler",
|
||||||
|
"esm-browser",
|
||||||
"cjs",
|
"cjs",
|
||||||
"global",
|
"global"
|
||||||
"esm"
|
|
||||||
],
|
],
|
||||||
"dts": [
|
"dts": [
|
||||||
"jsx.d.ts"
|
"jsx.d.ts"
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
# @vue/runtime-test
|
# @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
|
``` js
|
||||||
import { h, render, nodeOps, dumpOps } from '@vue/runtime-test'
|
import { h, render, nodeOps, dumpOps } from '@vue/runtime-test'
|
||||||
|
|
||||||
|
@ -14,12 +14,6 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/vuejs/vue-next.git"
|
"url": "git+https://github.com/vuejs/vue-next.git"
|
||||||
},
|
},
|
||||||
"buildOptions": {
|
|
||||||
"name": "VueRuntimeTest",
|
|
||||||
"formats": [
|
|
||||||
"global"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"vue"
|
"vue"
|
||||||
],
|
],
|
||||||
|
@ -6,27 +6,30 @@
|
|||||||
|
|
||||||
- **`vue(.runtime).global(.prod).js`**:
|
- **`vue(.runtime).global(.prod).js`**:
|
||||||
- For direct use via `<script src="...">` in the browser. Exposes the `Vue` global.
|
- 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>`.
|
- 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="...">`.
|
||||||
- **`vue.global.js`**: the "full" build that supports compiling templates on the fly.
|
- In-browser template compilation:
|
||||||
- **`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.
|
- **`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`**:
|
- **`vue(.runtime).esm-browser(.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)
|
- For usage via native ES modules imports (in browser via `<script type="module">`.
|
||||||
- Inlines all dependencies - i.e. it's a single ES module with no imports from other files
|
- Shares the same runtime compilation, dependency inlining and hard-coded prod/dev behavior with the global build.
|
||||||
- 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)
|
|
||||||
|
|
||||||
### With a Bundler
|
### With a Bundler
|
||||||
|
|
||||||
- **`vue(.runtime).esm-bundler.js`**:
|
- **`vue(.runtime).esm-bundler.js`**:
|
||||||
|
|
||||||
- For use with bundlers like `webpack`, `rollup` and `parcel`.
|
- For use with bundlers like `webpack`, `rollup` and `parcel`.
|
||||||
- Leaves prod/dev branches with `process.env.NODE_ENV` guards (must be replaced by bundler)
|
- 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)
|
- 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`)
|
- 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`)
|
- 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.
|
- 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.
|
||||||
- **`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).
|
- In-browser template compilation:
|
||||||
- **`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).
|
- **`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
|
### For Server-Side Rendering
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
"module": "dist/vue.runtime.esm-bundler.js",
|
"module": "dist/vue.runtime.esm-bundler.js",
|
||||||
"types": "dist/vue.d.ts",
|
"types": "dist/vue.d.ts",
|
||||||
"unpkg": "dist/vue.global.js",
|
"unpkg": "dist/vue.global.js",
|
||||||
|
"jsdelivr": "dist/vue.global.js",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
"files": [
|
"files": [
|
||||||
"index.js",
|
"index.js",
|
||||||
@ -19,7 +20,8 @@
|
|||||||
"cjs",
|
"cjs",
|
||||||
"global",
|
"global",
|
||||||
"global-runtime",
|
"global-runtime",
|
||||||
"esm"
|
"esm-browser",
|
||||||
|
"esm-browser-runtime"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -23,6 +23,10 @@ const outputConfigs = {
|
|||||||
file: resolve(`dist/${name}.esm-bundler.js`),
|
file: resolve(`dist/${name}.esm-bundler.js`),
|
||||||
format: `es`
|
format: `es`
|
||||||
},
|
},
|
||||||
|
'esm-browser': {
|
||||||
|
file: resolve(`dist/${name}.esm-browser.js`),
|
||||||
|
format: `es`
|
||||||
|
},
|
||||||
cjs: {
|
cjs: {
|
||||||
file: resolve(`dist/${name}.cjs.js`),
|
file: resolve(`dist/${name}.cjs.js`),
|
||||||
format: `cjs`
|
format: `cjs`
|
||||||
@ -31,15 +35,16 @@ const outputConfigs = {
|
|||||||
file: resolve(`dist/${name}.global.js`),
|
file: resolve(`dist/${name}.global.js`),
|
||||||
format: `iife`
|
format: `iife`
|
||||||
},
|
},
|
||||||
esm: {
|
|
||||||
file: resolve(`dist/${name}.esm.js`),
|
// runtime-only builds, for main "vue" package only
|
||||||
format: `es`
|
|
||||||
},
|
|
||||||
// main "vue" package only
|
|
||||||
'esm-bundler-runtime': {
|
'esm-bundler-runtime': {
|
||||||
file: resolve(`dist/${name}.runtime.esm-bundler.js`),
|
file: resolve(`dist/${name}.runtime.esm-bundler.js`),
|
||||||
format: `es`
|
format: `es`
|
||||||
},
|
},
|
||||||
|
'esm-browser-runtime': {
|
||||||
|
file: resolve(`dist/${name}.runtime.esm-browser.js`),
|
||||||
|
format: 'es'
|
||||||
|
},
|
||||||
'global-runtime': {
|
'global-runtime': {
|
||||||
file: resolve(`dist/${name}.runtime.global.js`),
|
file: resolve(`dist/${name}.runtime.global.js`),
|
||||||
format: 'iife'
|
format: 'iife'
|
||||||
@ -58,7 +63,7 @@ if (process.env.NODE_ENV === 'production') {
|
|||||||
if (format === 'cjs' && packageOptions.prod !== false) {
|
if (format === 'cjs' && packageOptions.prod !== false) {
|
||||||
packageConfigs.push(createProductionConfig(format))
|
packageConfigs.push(createProductionConfig(format))
|
||||||
}
|
}
|
||||||
if (/global/.test(format) || format === 'esm') {
|
if (/^(global|esm-browser)(-runtime)?/.test(format)) {
|
||||||
packageConfigs.push(createMinifiedConfig(format))
|
packageConfigs.push(createMinifiedConfig(format))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -77,10 +82,10 @@ function createConfig(format, output, plugins = []) {
|
|||||||
|
|
||||||
const isProductionBuild =
|
const isProductionBuild =
|
||||||
process.env.__DEV__ === 'false' || /\.prod\.js$/.test(output.file)
|
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 isBundlerESMBuild = /esm-bundler/.test(format)
|
||||||
|
const isBrowserESMBuild = /esm-browser/.test(format)
|
||||||
|
const isNodeBuild = format === 'cjs'
|
||||||
|
const isGlobalBuild = /global/.test(format)
|
||||||
|
|
||||||
if (isGlobalBuild) {
|
if (isGlobalBuild) {
|
||||||
output.name = packageOptions.name
|
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 entryFile = /runtime$/.test(format) ? `src/runtime.ts` : `src/index.ts`
|
||||||
|
|
||||||
const external =
|
const external =
|
||||||
isGlobalBuild || isRawESMBuild
|
isGlobalBuild || isBrowserESMBuild
|
||||||
? []
|
? []
|
||||||
: [
|
: [
|
||||||
...Object.keys(pkg.dependencies || {}),
|
...Object.keys(pkg.dependencies || {}),
|
||||||
@ -137,7 +142,7 @@ function createConfig(format, output, plugins = []) {
|
|||||||
isProductionBuild,
|
isProductionBuild,
|
||||||
isBundlerESMBuild,
|
isBundlerESMBuild,
|
||||||
// isBrowserBuild?
|
// isBrowserBuild?
|
||||||
(isGlobalBuild || isRawESMBuild || isBundlerESMBuild) &&
|
(isGlobalBuild || isBrowserESMBuild || isBundlerESMBuild) &&
|
||||||
!packageOptions.enableNonBrowserBranches,
|
!packageOptions.enableNonBrowserBranches,
|
||||||
isGlobalBuild,
|
isGlobalBuild,
|
||||||
isNodeBuild
|
isNodeBuild
|
||||||
|
Loading…
Reference in New Issue
Block a user