workflow: adjust esm-bundler build file name

This commit is contained in:
Evan You 2018-09-19 21:51:21 -04:00
parent 77d57813eb
commit 38109fe915
15 changed files with 43 additions and 67 deletions

View File

@ -3,7 +3,7 @@
"version": "3.0.0-alpha.1", "version": "3.0.0-alpha.1",
"description": "@vue/compiler-core", "description": "@vue/compiler-core",
"main": "index.js", "main": "index.js",
"module": "dist/compiler-core.esm.js", "module": "dist/compiler-core.esm-bundler.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
"repository": { "repository": {
"type": "git", "type": "git",
@ -18,4 +18,4 @@
"url": "https://github.com/vuejs/vue/issues" "url": "https://github.com/vuejs/vue/issues"
}, },
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/compiler-core#readme" "homepage": "https://github.com/vuejs/vue/tree/dev/packages/compiler-core#readme"
} }

View File

@ -3,7 +3,7 @@
"version": "3.0.0-alpha.1", "version": "3.0.0-alpha.1",
"description": "@vue/compiler-dom", "description": "@vue/compiler-dom",
"main": "index.js", "main": "index.js",
"module": "dist/compiler-dom.esm.js", "module": "dist/compiler-dom.esm-bundler.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
"repository": { "repository": {
"type": "git", "type": "git",
@ -18,4 +18,4 @@
"url": "https://github.com/vuejs/vue/issues" "url": "https://github.com/vuejs/vue/issues"
}, },
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/compiler-dom#readme" "homepage": "https://github.com/vuejs/vue/tree/dev/packages/compiler-dom#readme"
} }

View File

@ -3,7 +3,7 @@
"version": "3.0.0-alpha.1", "version": "3.0.0-alpha.1",
"description": "@vue/compiler-server", "description": "@vue/compiler-server",
"main": "index.js", "main": "index.js",
"module": "dist/compiler-server.esm.js", "module": "dist/compiler-server.esm-bundler.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
"repository": { "repository": {
"type": "git", "type": "git",
@ -18,4 +18,4 @@
"url": "https://github.com/vuejs/vue/issues" "url": "https://github.com/vuejs/vue/issues"
}, },
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/compiler-server#readme" "homepage": "https://github.com/vuejs/vue/tree/dev/packages/compiler-server#readme"
} }

View File

@ -3,7 +3,7 @@
"version": "3.0.0-alpha.1", "version": "3.0.0-alpha.1",
"description": "@vue/core", "description": "@vue/core",
"main": "index.js", "main": "index.js",
"module": "dist/core.esm.js", "module": "dist/core.esm-bundler.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -1283,7 +1283,7 @@ export function createRenderer(options: RendererOptions) {
// API ----------------------------------------------------------------------- // API -----------------------------------------------------------------------
function render(vnode: VNode | null, container: RenderNode) { function render(vnode: VNode | null, container: any) {
const prevVNode = container.vnode const prevVNode = container.vnode
if (vnode && vnode.el) { if (vnode && vnode.el) {
vnode = cloneVNode(vnode) vnode = cloneVNode(vnode)

View File

@ -22,7 +22,7 @@ type ElementType =
| typeof Portal | typeof Portal
export interface createElement { export interface createElement {
(tag: ElementType, data: any, children: any): VNode (tag: ElementType, data?: any, children?: any): VNode
c: typeof createComponentVNode c: typeof createComponentVNode
e: typeof createElementVNode e: typeof createElementVNode
t: typeof createTextVNode t: typeof createTextVNode
@ -30,7 +30,7 @@ export interface createElement {
p: typeof createPortal p: typeof createPortal
} }
export const h = ((tag: ElementType, data: any, children: any): VNode => { export const h = ((tag: ElementType, data?: any, children?: any): VNode => {
if (Array.isArray(data) || (data !== void 0 && typeof data !== 'object')) { if (Array.isArray(data) || (data !== void 0 && typeof data !== 'object')) {
children = data children = data
data = null data = null

View File

@ -4,23 +4,11 @@ export { cloneVNode, createPortal, createFragment } from './vdom'
export { createRenderer } from './createRenderer' export { createRenderer } from './createRenderer'
import { Component as InternalComponent, ComponentClass } from './component' import { Component as InternalComponent, ComponentClass } from './component'
// the public component constructor with proper type inference. // the public component constructor with proper type inference.
export const Component = InternalComponent as ComponentClass export const Component = InternalComponent as ComponentClass
// observer api // observer api
export { export * from '@vue/observer'
autorun,
stop,
observable,
immutable,
computed,
isObservable,
isImmutable,
markImmutable,
markNonReactive,
unwrap
} from '@vue/observer'
// flags & types // flags & types
export { FunctionalComponent } from './component' export { FunctionalComponent } from './component'

View File

@ -3,7 +3,7 @@
"version": "3.0.0-alpha.1", "version": "3.0.0-alpha.1",
"description": "@vue/observer", "description": "@vue/observer",
"main": "index.js", "main": "index.js",
"module": "dist/observer.esm.js", "module": "dist/observer.esm-bundler.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
"unpkg": "dist/observer.global.js", "unpkg": "dist/observer.global.js",
"repository": { "repository": {

View File

@ -3,7 +3,7 @@
"version": "3.0.0-alpha.1", "version": "3.0.0-alpha.1",
"description": "@vue/renderer-dom", "description": "@vue/renderer-dom",
"main": "index.js", "main": "index.js",
"module": "dist/renderer-dom.esm.js", "module": "dist/renderer-dom.esm-bundler.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
"unpkg": "dist/renderer-dom.global.js", "unpkg": "dist/renderer-dom.global.js",
"buildOptions": { "buildOptions": {

View File

@ -1,46 +1,23 @@
import { import { createRenderer, VNode } from '@vue/core'
h, import { queueJob } from '@vue/scheduler'
cloneVNode,
createPortal,
Component,
createRenderer
} from '@vue/core'
import { queueJob, nextTick } from '@vue/scheduler'
import { nodeOps } from './nodeOps' import { nodeOps } from './nodeOps'
import { patchData } from './patchData' import { patchData } from './patchData'
import { teardownVNode } from './teardownVNode' import { teardownVNode } from './teardownVNode'
const { render } = createRenderer({ const { render: _render } = createRenderer({
queueJob, queueJob,
nodeOps, nodeOps,
patchData, patchData,
teardownVNode teardownVNode
}) })
// important: inline the definition for nextTick type publicRender = (node: VNode | null, container: HTMLElement) => void
const publicNextTick = nextTick as (fn: Function) => Promise<void> export const render = _render as publicRender
export { // nextTick from scheduler
h, export { nextTick } from '@vue/scheduler'
cloneVNode,
createPortal,
Component,
render,
publicNextTick as nextTick
}
// also expose observer API // re-export everything from core
export { // h, Component, observer API, flags & types
autorun, export * from '@vue/core'
stop,
observable,
immutable,
computed,
isObservable,
isImmutable,
markImmutable,
markNonReactive,
unwrap
} from '@vue/core'

View File

@ -3,8 +3,10 @@
"version": "3.0.0-alpha.1", "version": "3.0.0-alpha.1",
"description": "@vue/renderer-server", "description": "@vue/renderer-server",
"main": "index.js", "main": "index.js",
"module": "dist/renderer-server.esm.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
"buildOptions": {
"formats": ["cjs"]
},
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/vuejs/vue.git" "url": "git+https://github.com/vuejs/vue.git"
@ -18,4 +20,4 @@
"url": "https://github.com/vuejs/vue/issues" "url": "https://github.com/vuejs/vue/issues"
}, },
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/renderer-server#readme" "homepage": "https://github.com/vuejs/vue/tree/dev/packages/renderer-server#readme"
} }

View File

@ -3,7 +3,7 @@
"version": "3.0.0-alpha.1", "version": "3.0.0-alpha.1",
"description": "@vue/scheduler", "description": "@vue/scheduler",
"main": "index.js", "main": "index.js",
"module": "dist/scheduler.esm.js", "module": "dist/scheduler.esm-bundler.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -18,7 +18,10 @@ const packageOptions = pkg.buildOptions || {}
// build aliases dynamically // build aliases dynamically
const aliasOptions = { resolve: ['.ts'] } const aliasOptions = { resolve: ['.ts'] }
fs.readdirSync(packagesDir).forEach(dir => { fs.readdirSync(packagesDir).forEach(dir => {
if (fs.statSync(path.resolve(packagesDir, dir)).isDirectory()) { if (
dir !== 'vue' &&
fs.statSync(path.resolve(packagesDir, dir)).isDirectory()
) {
aliasOptions[`@vue/${dir}`] = path.resolve(packagesDir, `${dir}/src/index`) aliasOptions[`@vue/${dir}`] = path.resolve(packagesDir, `${dir}/src/index`)
} }
}) })
@ -71,6 +74,7 @@ function createConfig(output, plugins = []) {
const isGlobalBuild = /\.global(\.prod)?\.js$/.test(output.file) const isGlobalBuild = /\.global(\.prod)?\.js$/.test(output.file)
const isBunlderESMBuild = /\.esm\.js$/.test(output.file) const isBunlderESMBuild = /\.esm\.js$/.test(output.file)
const isBrowserESMBuild = /esm-browser(\.prod)?\.js$/.test(output.file) const isBrowserESMBuild = /esm-browser(\.prod)?\.js$/.test(output.file)
const isCompat = /dist\/vue\./.test(output.file)
if (isGlobalBuild) { if (isGlobalBuild) {
output.name = packageOptions.name output.name = packageOptions.name
@ -100,7 +104,7 @@ function createConfig(output, plugins = []) {
plugins: [ plugins: [
tsPlugin, tsPlugin,
aliasPlugin, aliasPlugin,
createReplacePlugin(isProductionBuild, isBunlderESMBuild), createReplacePlugin(isProductionBuild, isBunlderESMBuild, isCompat),
...plugins ...plugins
], ],
output, output,
@ -112,7 +116,7 @@ function createConfig(output, plugins = []) {
} }
} }
function createReplacePlugin(isProduction, isBunlderESMBuild) { function createReplacePlugin(isProduction, isBunlderESMBuild, isCompat) {
return replace({ return replace({
__DEV__: isBunlderESMBuild __DEV__: isBunlderESMBuild
? // preserve to be handled by bundlers ? // preserve to be handled by bundlers
@ -120,7 +124,7 @@ function createReplacePlugin(isProduction, isBunlderESMBuild) {
: // hard coded dev/prod builds : // hard coded dev/prod builds
!isProduction, !isProduction,
// compatibility builds // compatibility builds
__COMPAT__: !!process.env.COMPAT __COMPAT__: !!packageOptions.compat
}) })
} }

View File

@ -21,7 +21,7 @@ files.forEach(shortName => {
version: baseVersion, version: baseVersion,
description: name, description: name,
main: 'index.js', main: 'index.js',
module: `dist/${shortName}.esm.js`, module: `dist/${shortName}.esm-bundler.js`,
typings: 'dist/index.d.ts', typings: 'dist/index.d.ts',
repository: { repository: {
type: 'git', type: 'git',

View File

@ -21,7 +21,12 @@
"paths": { "paths": {
"@vue/core": ["packages/core/src"], "@vue/core": ["packages/core/src"],
"@vue/observer": ["packages/observer/src"], "@vue/observer": ["packages/observer/src"],
"@vue/scheduler": ["packages/scheduler/src"] "@vue/scheduler": ["packages/scheduler/src"],
"@vue/renderer-dom": ["packages/renderer-dom/src"],
"@vue/renderer-server": ["packages/renderer-server/src"],
"@vue/compiler-core": ["packages/compiler-core/src"],
"@vue/compiler-dom": ["packages/compiler-dom/src"],
"@vue/compiler-server": ["packages/compiler-server/src"]
} }
}, },
"include": [ "include": [