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",
|
||||
"description": "vue",
|
||||
"main": "index.js",
|
||||
"module": "dist/vue.esm-bundler.js",
|
||||
"module": "dist/vue.runtime.esm-bundler.js",
|
||||
"files": [
|
||||
"index.js",
|
||||
"dist"
|
||||
@ -14,6 +14,7 @@
|
||||
"name": "Vue",
|
||||
"formats": [
|
||||
"esm-bundler",
|
||||
"esm-bundler-runtime",
|
||||
"cjs",
|
||||
"global",
|
||||
"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.
|
||||
import { compile, CompilerOptions, CompilerError } from '@vue/compiler-dom'
|
||||
import { registerRuntimeCompiler, RenderFunction, warn } from '@vue/runtime-dom'
|
||||
@ -61,9 +61,4 @@ registerRuntimeCompiler(compileToFunction)
|
||||
export { compileToFunction as compile }
|
||||
export * from '@vue/runtime-dom'
|
||||
|
||||
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.`
|
||||
)
|
||||
}
|
||||
import './devCheck'
|
||||
|
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
|
||||
let hasTSChecked = false
|
||||
|
||||
const configs = {
|
||||
const outputConfigs = {
|
||||
'esm-bundler': {
|
||||
file: resolve(`dist/${name}.esm-bundler.js`),
|
||||
format: `es`
|
||||
},
|
||||
// main "vue" package only
|
||||
'esm-bundler-runtime': {
|
||||
file: resolve(`dist/${name}.runtime.esm-bundler.js`),
|
||||
format: `es`
|
||||
},
|
||||
cjs: {
|
||||
file: resolve(`dist/${name}.cjs.js`),
|
||||
format: `cjs`
|
||||
@ -47,7 +52,7 @@ const inlineFormats = process.env.FORMATS && process.env.FORMATS.split(',')
|
||||
const packageFormats = inlineFormats || packageOptions.formats || defaultFormats
|
||||
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') {
|
||||
packageFormats.forEach(format => {
|
||||
@ -62,14 +67,14 @@ if (process.env.NODE_ENV === 'production') {
|
||||
|
||||
export default packageConfigs
|
||||
|
||||
function createConfig(output, plugins = []) {
|
||||
function createConfig(format, output, plugins = []) {
|
||||
output.externalLiveBindings = false
|
||||
|
||||
const isProductionBuild =
|
||||
process.env.__DEV__ === 'false' || /\.prod\.js$/.test(output.file)
|
||||
const isGlobalBuild = /\.global(\.prod)?\.js$/.test(output.file)
|
||||
const isBundlerESMBuild = /\.esm-bundler\.js$/.test(output.file)
|
||||
const isRawESMBuild = /esm(\.prod)?\.js$/.test(output.file)
|
||||
const isGlobalBuild = format === 'global'
|
||||
const isRawESMBuild = format === 'esm'
|
||||
const isBundlerESMBuild = /esm-bundler/.test(format)
|
||||
const isRuntimeCompileBuild = /vue\./.test(output.file)
|
||||
|
||||
if (isGlobalBuild) {
|
||||
@ -98,8 +103,11 @@ function createConfig(output, plugins = []) {
|
||||
// during a single build.
|
||||
hasTSChecked = true
|
||||
|
||||
const entryFile =
|
||||
format === 'esm-bundler-runtime' ? `src/runtime.ts` : `src/index.ts`
|
||||
|
||||
return {
|
||||
input: resolve(`src/index.ts`),
|
||||
input: resolve(entryFile),
|
||||
// Global and Browser ESM builds inlines everything so that they can be
|
||||
// used alone.
|
||||
external:
|
||||
@ -167,18 +175,19 @@ function createReplacePlugin(
|
||||
}
|
||||
|
||||
function createProductionConfig(format) {
|
||||
return createConfig({
|
||||
return createConfig(format, {
|
||||
file: resolve(`dist/${name}.${format}.prod.js`),
|
||||
format: configs[format].format
|
||||
format: outputConfigs[format].format
|
||||
})
|
||||
}
|
||||
|
||||
function createMinifiedConfig(format) {
|
||||
const { terser } = require('rollup-plugin-terser')
|
||||
return createConfig(
|
||||
format,
|
||||
{
|
||||
file: resolve(`dist/${name}.${format}.prod.js`),
|
||||
format: configs[format].format
|
||||
format: outputConfigs[format].format
|
||||
},
|
||||
[
|
||||
terser({
|
||||
|
Loading…
Reference in New Issue
Block a user