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",
|
||||
"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": {
|
||||
|
@ -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": [
|
||||
|
@ -15,9 +15,9 @@
|
||||
"name": "VueRuntimeDOM",
|
||||
"formats": [
|
||||
"esm-bundler",
|
||||
"esm-browser",
|
||||
"cjs",
|
||||
"global",
|
||||
"esm"
|
||||
"global"
|
||||
],
|
||||
"dts": [
|
||||
"jsx.d.ts"
|
||||
|
@ -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'
|
||||
|
||||
|
@ -14,12 +14,6 @@
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/vuejs/vue-next.git"
|
||||
},
|
||||
"buildOptions": {
|
||||
"name": "VueRuntimeTest",
|
||||
"formats": [
|
||||
"global"
|
||||
]
|
||||
},
|
||||
"keywords": [
|
||||
"vue"
|
||||
],
|
||||
|
@ -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
|
||||
|
||||
|
@ -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": {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user