build: export runtime-only build for bundlers by default in main vue package
This commit is contained in:
parent
9550302df4
commit
5cf7523787
@ -3,7 +3,7 @@
|
|||||||
"version": "3.0.0-alpha.0",
|
"version": "3.0.0-alpha.0",
|
||||||
"description": "vue",
|
"description": "vue",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "dist/vue.esm-bundler.js",
|
"module": "dist/vue.runtime.esm-bundler.js",
|
||||||
"files": [
|
"files": [
|
||||||
"index.js",
|
"index.js",
|
||||||
"dist"
|
"dist"
|
||||||
@ -14,6 +14,7 @@
|
|||||||
"name": "Vue",
|
"name": "Vue",
|
||||||
"formats": [
|
"formats": [
|
||||||
"esm-bundler",
|
"esm-bundler",
|
||||||
|
"esm-bundler-runtime",
|
||||||
"cjs",
|
"cjs",
|
||||||
"global",
|
"global",
|
||||||
"esm"
|
"esm"
|
||||||
|
6
packages/vue/src/devCheck.ts
Normal file
6
packages/vue/src/devCheck.ts
Normal file
@ -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.`
|
||||||
|
)
|
||||||
|
}
|
@ -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.
|
// and the compiler, and supports on-the-fly compilation of the template option.
|
||||||
import { compile, CompilerOptions, CompilerError } from '@vue/compiler-dom'
|
import { compile, CompilerOptions, CompilerError } from '@vue/compiler-dom'
|
||||||
import { registerRuntimeCompiler, RenderFunction, warn } from '@vue/runtime-dom'
|
import { registerRuntimeCompiler, RenderFunction, warn } from '@vue/runtime-dom'
|
||||||
@ -61,9 +61,4 @@ registerRuntimeCompiler(compileToFunction)
|
|||||||
export { compileToFunction as compile }
|
export { compileToFunction as compile }
|
||||||
export * from '@vue/runtime-dom'
|
export * from '@vue/runtime-dom'
|
||||||
|
|
||||||
if (__BROWSER__ && __DEV__) {
|
import './devCheck'
|
||||||
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.`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
6
packages/vue/src/runtime.ts
Normal file
6
packages/vue/src/runtime.ts
Normal file
@ -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'
|
@ -23,11 +23,16 @@ const knownExternals = fs.readdirSync(packagesDir).filter(p => {
|
|||||||
// ensure TS checks only once for each build
|
// ensure TS checks only once for each build
|
||||||
let hasTSChecked = false
|
let hasTSChecked = false
|
||||||
|
|
||||||
const configs = {
|
const outputConfigs = {
|
||||||
'esm-bundler': {
|
'esm-bundler': {
|
||||||
file: resolve(`dist/${name}.esm-bundler.js`),
|
file: resolve(`dist/${name}.esm-bundler.js`),
|
||||||
format: `es`
|
format: `es`
|
||||||
},
|
},
|
||||||
|
// main "vue" package only
|
||||||
|
'esm-bundler-runtime': {
|
||||||
|
file: resolve(`dist/${name}.runtime.esm-bundler.js`),
|
||||||
|
format: `es`
|
||||||
|
},
|
||||||
cjs: {
|
cjs: {
|
||||||
file: resolve(`dist/${name}.cjs.js`),
|
file: resolve(`dist/${name}.cjs.js`),
|
||||||
format: `cjs`
|
format: `cjs`
|
||||||
@ -47,7 +52,7 @@ const inlineFormats = process.env.FORMATS && process.env.FORMATS.split(',')
|
|||||||
const packageFormats = inlineFormats || packageOptions.formats || defaultFormats
|
const packageFormats = inlineFormats || packageOptions.formats || defaultFormats
|
||||||
const packageConfigs = process.env.PROD_ONLY
|
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') {
|
if (process.env.NODE_ENV === 'production') {
|
||||||
packageFormats.forEach(format => {
|
packageFormats.forEach(format => {
|
||||||
@ -62,14 +67,14 @@ if (process.env.NODE_ENV === 'production') {
|
|||||||
|
|
||||||
export default packageConfigs
|
export default packageConfigs
|
||||||
|
|
||||||
function createConfig(output, plugins = []) {
|
function createConfig(format, output, plugins = []) {
|
||||||
output.externalLiveBindings = false
|
output.externalLiveBindings = false
|
||||||
|
|
||||||
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(\.prod)?\.js$/.test(output.file)
|
const isGlobalBuild = format === 'global'
|
||||||
const isBundlerESMBuild = /\.esm-bundler\.js$/.test(output.file)
|
const isRawESMBuild = format === 'esm'
|
||||||
const isRawESMBuild = /esm(\.prod)?\.js$/.test(output.file)
|
const isBundlerESMBuild = /esm-bundler/.test(format)
|
||||||
const isRuntimeCompileBuild = /vue\./.test(output.file)
|
const isRuntimeCompileBuild = /vue\./.test(output.file)
|
||||||
|
|
||||||
if (isGlobalBuild) {
|
if (isGlobalBuild) {
|
||||||
@ -98,8 +103,11 @@ function createConfig(output, plugins = []) {
|
|||||||
// during a single build.
|
// during a single build.
|
||||||
hasTSChecked = true
|
hasTSChecked = true
|
||||||
|
|
||||||
|
const entryFile =
|
||||||
|
format === 'esm-bundler-runtime' ? `src/runtime.ts` : `src/index.ts`
|
||||||
|
|
||||||
return {
|
return {
|
||||||
input: resolve(`src/index.ts`),
|
input: resolve(entryFile),
|
||||||
// Global 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.
|
// used alone.
|
||||||
external:
|
external:
|
||||||
@ -167,18 +175,19 @@ function createReplacePlugin(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createProductionConfig(format) {
|
function createProductionConfig(format) {
|
||||||
return createConfig({
|
return createConfig(format, {
|
||||||
file: resolve(`dist/${name}.${format}.prod.js`),
|
file: resolve(`dist/${name}.${format}.prod.js`),
|
||||||
format: configs[format].format
|
format: outputConfigs[format].format
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function createMinifiedConfig(format) {
|
function createMinifiedConfig(format) {
|
||||||
const { terser } = require('rollup-plugin-terser')
|
const { terser } = require('rollup-plugin-terser')
|
||||||
return createConfig(
|
return createConfig(
|
||||||
|
format,
|
||||||
{
|
{
|
||||||
file: resolve(`dist/${name}.${format}.prod.js`),
|
file: resolve(`dist/${name}.${format}.prod.js`),
|
||||||
format: configs[format].format
|
format: outputConfigs[format].format
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
terser({
|
terser({
|
||||||
|
Loading…
Reference in New Issue
Block a user