wip: isolatedModules + use rollup-plugin-esbuild
This commit is contained in:
parent
9381349f37
commit
124373db50
|
@ -56,6 +56,7 @@
|
||||||
"@babel/types": "^7.12.0",
|
"@babel/types": "^7.12.0",
|
||||||
"@esbuild-plugins/node-modules-polyfill": "^0.1.4",
|
"@esbuild-plugins/node-modules-polyfill": "^0.1.4",
|
||||||
"@microsoft/api-extractor": "~7.20.0",
|
"@microsoft/api-extractor": "~7.20.0",
|
||||||
|
"@rollup/plugin-alias": "^4.0.3",
|
||||||
"@rollup/plugin-commonjs": "^23.0.2",
|
"@rollup/plugin-commonjs": "^23.0.2",
|
||||||
"@rollup/plugin-json": "^5.0.1",
|
"@rollup/plugin-json": "^5.0.1",
|
||||||
"@rollup/plugin-node-resolve": "^15.0.1",
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
||||||
|
@ -88,6 +89,7 @@
|
||||||
"pug": "^3.0.1",
|
"pug": "^3.0.1",
|
||||||
"puppeteer": "^19.2.2",
|
"puppeteer": "^19.2.2",
|
||||||
"rollup": "~3.10.0",
|
"rollup": "~3.10.0",
|
||||||
|
"rollup-plugin-esbuild": "^5.0.0",
|
||||||
"rollup-plugin-node-builtins": "^2.1.2",
|
"rollup-plugin-node-builtins": "^2.1.2",
|
||||||
"rollup-plugin-node-globals": "^1.4.0",
|
"rollup-plugin-node-globals": "^1.4.0",
|
||||||
"rollup-plugin-polyfill-node": "^0.11.0",
|
"rollup-plugin-polyfill-node": "^0.11.0",
|
||||||
|
|
|
@ -2,31 +2,31 @@ export { baseCompile } from './compile'
|
||||||
|
|
||||||
// Also expose lower level APIs & types
|
// Also expose lower level APIs & types
|
||||||
export {
|
export {
|
||||||
CompilerOptions,
|
type CompilerOptions,
|
||||||
ParserOptions,
|
type ParserOptions,
|
||||||
TransformOptions,
|
type TransformOptions,
|
||||||
CodegenOptions,
|
type CodegenOptions,
|
||||||
HoistTransform,
|
type HoistTransform,
|
||||||
BindingMetadata,
|
type BindingMetadata,
|
||||||
BindingTypes
|
BindingTypes
|
||||||
} from './options'
|
} from './options'
|
||||||
export { baseParse, TextModes } from './parse'
|
export { baseParse, TextModes } from './parse'
|
||||||
export {
|
export {
|
||||||
transform,
|
transform,
|
||||||
TransformContext,
|
type TransformContext,
|
||||||
createTransformContext,
|
createTransformContext,
|
||||||
traverseNode,
|
traverseNode,
|
||||||
createStructuralDirectiveTransform,
|
createStructuralDirectiveTransform,
|
||||||
NodeTransform,
|
type NodeTransform,
|
||||||
StructuralDirectiveTransform,
|
type StructuralDirectiveTransform,
|
||||||
DirectiveTransform
|
type DirectiveTransform
|
||||||
} from './transform'
|
} from './transform'
|
||||||
export { generate, CodegenContext, CodegenResult } from './codegen'
|
export { generate, type CodegenContext, type CodegenResult } from './codegen'
|
||||||
export {
|
export {
|
||||||
ErrorCodes,
|
ErrorCodes,
|
||||||
CoreCompilerError,
|
createCompilerError,
|
||||||
CompilerError,
|
type CoreCompilerError,
|
||||||
createCompilerError
|
type CompilerError
|
||||||
} from './errors'
|
} from './errors'
|
||||||
|
|
||||||
export * from './ast'
|
export * from './ast'
|
||||||
|
@ -34,7 +34,7 @@ export * from './utils'
|
||||||
export * from './babelUtils'
|
export * from './babelUtils'
|
||||||
export * from './runtimeHelpers'
|
export * from './runtimeHelpers'
|
||||||
|
|
||||||
export { getBaseTransformPreset, TransformPreset } from './compile'
|
export { getBaseTransformPreset, type TransformPreset } from './compile'
|
||||||
export { transformModel } from './transforms/vModel'
|
export { transformModel } from './transforms/vModel'
|
||||||
export { transformOn } from './transforms/vOn'
|
export { transformOn } from './transforms/vOn'
|
||||||
export { transformBind } from './transforms/vBind'
|
export { transformBind } from './transforms/vBind'
|
||||||
|
@ -48,7 +48,7 @@ export {
|
||||||
} from './transforms/transformExpression'
|
} from './transforms/transformExpression'
|
||||||
export {
|
export {
|
||||||
buildSlots,
|
buildSlots,
|
||||||
SlotFnBuilder,
|
type SlotFnBuilder,
|
||||||
trackVForSlotScopes,
|
trackVForSlotScopes,
|
||||||
trackSlotScopes
|
trackSlotScopes
|
||||||
} from './transforms/vSlot'
|
} from './transforms/vSlot'
|
||||||
|
@ -57,7 +57,7 @@ export {
|
||||||
resolveComponentType,
|
resolveComponentType,
|
||||||
buildProps,
|
buildProps,
|
||||||
buildDirectiveArgs,
|
buildDirectiveArgs,
|
||||||
PropsExpression
|
type PropsExpression
|
||||||
} from './transforms/transformElement'
|
} from './transforms/transformElement'
|
||||||
export { processSlotOutlet } from './transforms/transformSlotOutlet'
|
export { processSlotOutlet } from './transforms/transformSlotOutlet'
|
||||||
export { getConstantType } from './transforms/hoistStatic'
|
export { getConstantType } from './transforms/hoistStatic'
|
||||||
|
|
|
@ -27,7 +27,7 @@ export {
|
||||||
} from '@vue/compiler-core'
|
} from '@vue/compiler-core'
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
export {
|
export type {
|
||||||
SFCParseOptions,
|
SFCParseOptions,
|
||||||
SFCParseResult,
|
SFCParseResult,
|
||||||
SFCDescriptor,
|
SFCDescriptor,
|
||||||
|
@ -36,19 +36,22 @@ export {
|
||||||
SFCScriptBlock,
|
SFCScriptBlock,
|
||||||
SFCStyleBlock
|
SFCStyleBlock
|
||||||
} from './parse'
|
} from './parse'
|
||||||
export {
|
export type {
|
||||||
TemplateCompiler,
|
TemplateCompiler,
|
||||||
SFCTemplateCompileOptions,
|
SFCTemplateCompileOptions,
|
||||||
SFCTemplateCompileResults
|
SFCTemplateCompileResults
|
||||||
} from './compileTemplate'
|
} from './compileTemplate'
|
||||||
export {
|
export type {
|
||||||
SFCStyleCompileOptions,
|
SFCStyleCompileOptions,
|
||||||
SFCAsyncStyleCompileOptions,
|
SFCAsyncStyleCompileOptions,
|
||||||
SFCStyleCompileResults
|
SFCStyleCompileResults
|
||||||
} from './compileStyle'
|
} from './compileStyle'
|
||||||
export { SFCScriptCompileOptions } from './compileScript'
|
export type { SFCScriptCompileOptions } from './compileScript'
|
||||||
export { AssetURLOptions, AssetURLTagConfig } from './templateTransformAssetUrl'
|
export type {
|
||||||
export {
|
AssetURLOptions,
|
||||||
|
AssetURLTagConfig
|
||||||
|
} from './templateTransformAssetUrl'
|
||||||
|
export type {
|
||||||
CompilerOptions,
|
CompilerOptions,
|
||||||
CompilerError,
|
CompilerError,
|
||||||
BindingMetadata
|
BindingMetadata
|
||||||
|
|
|
@ -8,14 +8,14 @@ export {
|
||||||
proxyRefs,
|
proxyRefs,
|
||||||
customRef,
|
customRef,
|
||||||
triggerRef,
|
triggerRef,
|
||||||
Ref,
|
type Ref,
|
||||||
ToRef,
|
type ToRef,
|
||||||
ToRefs,
|
type ToRefs,
|
||||||
UnwrapRef,
|
type UnwrapRef,
|
||||||
ShallowRef,
|
type ShallowRef,
|
||||||
ShallowUnwrapRef,
|
type ShallowUnwrapRef,
|
||||||
RefUnwrapBailTypes,
|
type RefUnwrapBailTypes,
|
||||||
CustomRefFactory
|
type CustomRefFactory
|
||||||
} from './ref'
|
} from './ref'
|
||||||
export {
|
export {
|
||||||
reactive,
|
reactive,
|
||||||
|
@ -28,19 +28,19 @@ export {
|
||||||
shallowReadonly,
|
shallowReadonly,
|
||||||
markRaw,
|
markRaw,
|
||||||
toRaw,
|
toRaw,
|
||||||
Raw,
|
|
||||||
ReactiveFlags,
|
ReactiveFlags,
|
||||||
DeepReadonly,
|
type Raw,
|
||||||
ShallowReactive,
|
type DeepReadonly,
|
||||||
UnwrapNestedRefs
|
type ShallowReactive,
|
||||||
|
type UnwrapNestedRefs
|
||||||
} from './reactive'
|
} from './reactive'
|
||||||
export {
|
export {
|
||||||
computed,
|
computed,
|
||||||
ComputedRef,
|
type ComputedRef,
|
||||||
WritableComputedRef,
|
type WritableComputedRef,
|
||||||
WritableComputedOptions,
|
type WritableComputedOptions,
|
||||||
ComputedGetter,
|
type ComputedGetter,
|
||||||
ComputedSetter
|
type ComputedSetter
|
||||||
} from './computed'
|
} from './computed'
|
||||||
export { deferredComputed } from './deferredComputed'
|
export { deferredComputed } from './deferredComputed'
|
||||||
export {
|
export {
|
||||||
|
@ -53,12 +53,12 @@ export {
|
||||||
resetTracking,
|
resetTracking,
|
||||||
ITERATE_KEY,
|
ITERATE_KEY,
|
||||||
ReactiveEffect,
|
ReactiveEffect,
|
||||||
ReactiveEffectRunner,
|
type ReactiveEffectRunner,
|
||||||
ReactiveEffectOptions,
|
type ReactiveEffectOptions,
|
||||||
EffectScheduler,
|
type EffectScheduler,
|
||||||
DebuggerOptions,
|
type DebuggerOptions,
|
||||||
DebuggerEvent,
|
type DebuggerEvent,
|
||||||
DebuggerEventExtraInfo
|
type DebuggerEventExtraInfo
|
||||||
} from './effect'
|
} from './effect'
|
||||||
export {
|
export {
|
||||||
effectScope,
|
effectScope,
|
||||||
|
|
|
@ -162,7 +162,7 @@ export type Component<
|
||||||
| ConcreteComponent<Props, RawBindings, D, C, M>
|
| ConcreteComponent<Props, RawBindings, D, C, M>
|
||||||
| ComponentPublicInstanceConstructor<Props>
|
| ComponentPublicInstanceConstructor<Props>
|
||||||
|
|
||||||
export { ComponentOptions }
|
export type { ComponentOptions }
|
||||||
|
|
||||||
type LifecycleHook<TFn = Function> = TFn[] | null
|
type LifecycleHook<TFn = Function> = TFn[] | null
|
||||||
|
|
||||||
|
|
|
@ -86,11 +86,11 @@ export { h } from './h'
|
||||||
// Advanced render function utilities
|
// Advanced render function utilities
|
||||||
export { createVNode, cloneVNode, mergeProps, isVNode } from './vnode'
|
export { createVNode, cloneVNode, mergeProps, isVNode } from './vnode'
|
||||||
// VNode types
|
// VNode types
|
||||||
export { Fragment, Text, Comment, Static, VNodeRef } from './vnode'
|
export { Fragment, Text, Comment, Static, type VNodeRef } from './vnode'
|
||||||
// Built-in components
|
// Built-in components
|
||||||
export { Teleport, TeleportProps } from './components/Teleport'
|
export { Teleport, type TeleportProps } from './components/Teleport'
|
||||||
export { Suspense, SuspenseProps } from './components/Suspense'
|
export { Suspense, type SuspenseProps } from './components/Suspense'
|
||||||
export { KeepAlive, KeepAliveProps } from './components/KeepAlive'
|
export { KeepAlive, type KeepAliveProps } from './components/KeepAlive'
|
||||||
export {
|
export {
|
||||||
BaseTransition,
|
BaseTransition,
|
||||||
BaseTransitionPropsValidators,
|
BaseTransitionPropsValidators,
|
||||||
|
@ -148,8 +148,8 @@ declare module '@vue/reactivity' {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export { TrackOpTypes, TriggerOpTypes } from '@vue/reactivity'
|
||||||
export {
|
export type {
|
||||||
Ref,
|
Ref,
|
||||||
ToRef,
|
ToRef,
|
||||||
ToRefs,
|
ToRefs,
|
||||||
|
@ -172,11 +172,9 @@ export {
|
||||||
DebuggerOptions,
|
DebuggerOptions,
|
||||||
DebuggerEvent,
|
DebuggerEvent,
|
||||||
DebuggerEventExtraInfo,
|
DebuggerEventExtraInfo,
|
||||||
TrackOpTypes,
|
|
||||||
TriggerOpTypes,
|
|
||||||
Raw
|
Raw
|
||||||
} from '@vue/reactivity'
|
} from '@vue/reactivity'
|
||||||
export {
|
export type {
|
||||||
WatchEffect,
|
WatchEffect,
|
||||||
WatchOptions,
|
WatchOptions,
|
||||||
WatchOptionsBase,
|
WatchOptionsBase,
|
||||||
|
@ -184,8 +182,8 @@ export {
|
||||||
WatchSource,
|
WatchSource,
|
||||||
WatchStopHandle
|
WatchStopHandle
|
||||||
} from './apiWatch'
|
} from './apiWatch'
|
||||||
export { InjectionKey } from './apiInject'
|
export type { InjectionKey } from './apiInject'
|
||||||
export {
|
export type {
|
||||||
App,
|
App,
|
||||||
AppConfig,
|
AppConfig,
|
||||||
AppContext,
|
AppContext,
|
||||||
|
@ -193,7 +191,7 @@ export {
|
||||||
CreateAppFunction,
|
CreateAppFunction,
|
||||||
OptionMergeFunction
|
OptionMergeFunction
|
||||||
} from './apiCreateApp'
|
} from './apiCreateApp'
|
||||||
export {
|
export type {
|
||||||
VNode,
|
VNode,
|
||||||
VNodeChild,
|
VNodeChild,
|
||||||
VNodeTypes,
|
VNodeTypes,
|
||||||
|
@ -201,7 +199,7 @@ export {
|
||||||
VNodeArrayChildren,
|
VNodeArrayChildren,
|
||||||
VNodeNormalizedChildren
|
VNodeNormalizedChildren
|
||||||
} from './vnode'
|
} from './vnode'
|
||||||
export {
|
export type {
|
||||||
Component,
|
Component,
|
||||||
ConcreteComponent,
|
ConcreteComponent,
|
||||||
FunctionalComponent,
|
FunctionalComponent,
|
||||||
|
@ -210,8 +208,8 @@ export {
|
||||||
ComponentCustomProps,
|
ComponentCustomProps,
|
||||||
AllowedComponentProps
|
AllowedComponentProps
|
||||||
} from './component'
|
} from './component'
|
||||||
export { DefineComponent } from './apiDefineComponent'
|
export type { DefineComponent } from './apiDefineComponent'
|
||||||
export {
|
export type {
|
||||||
ComponentOptions,
|
ComponentOptions,
|
||||||
ComponentOptionsMixin,
|
ComponentOptionsMixin,
|
||||||
ComponentOptionsWithoutProps,
|
ComponentOptionsWithoutProps,
|
||||||
|
@ -226,13 +224,13 @@ export {
|
||||||
RuntimeCompilerOptions,
|
RuntimeCompilerOptions,
|
||||||
ComponentInjectOptions
|
ComponentInjectOptions
|
||||||
} from './componentOptions'
|
} from './componentOptions'
|
||||||
export { EmitsOptions, ObjectEmitsOptions } from './componentEmits'
|
export type { EmitsOptions, ObjectEmitsOptions } from './componentEmits'
|
||||||
export {
|
export type {
|
||||||
ComponentPublicInstance,
|
ComponentPublicInstance,
|
||||||
ComponentCustomProperties,
|
ComponentCustomProperties,
|
||||||
CreateComponentPublicInstance
|
CreateComponentPublicInstance
|
||||||
} from './componentPublicInstance'
|
} from './componentPublicInstance'
|
||||||
export {
|
export type {
|
||||||
Renderer,
|
Renderer,
|
||||||
RendererNode,
|
RendererNode,
|
||||||
RendererElement,
|
RendererElement,
|
||||||
|
@ -240,9 +238,9 @@ export {
|
||||||
RendererOptions,
|
RendererOptions,
|
||||||
RootRenderFunction
|
RootRenderFunction
|
||||||
} from './renderer'
|
} from './renderer'
|
||||||
export { RootHydrateFunction } from './hydration'
|
export type { RootHydrateFunction } from './hydration'
|
||||||
export { Slot, Slots } from './componentSlots'
|
export type { Slot, Slots } from './componentSlots'
|
||||||
export {
|
export type {
|
||||||
Prop,
|
Prop,
|
||||||
PropType,
|
PropType,
|
||||||
ComponentPropsOptions,
|
ComponentPropsOptions,
|
||||||
|
@ -250,7 +248,7 @@ export {
|
||||||
ExtractPropTypes,
|
ExtractPropTypes,
|
||||||
ExtractDefaultPropTypes
|
ExtractDefaultPropTypes
|
||||||
} from './componentProps'
|
} from './componentProps'
|
||||||
export {
|
export type {
|
||||||
Directive,
|
Directive,
|
||||||
DirectiveBinding,
|
DirectiveBinding,
|
||||||
DirectiveHook,
|
DirectiveHook,
|
||||||
|
@ -258,13 +256,16 @@ export {
|
||||||
FunctionDirective,
|
FunctionDirective,
|
||||||
DirectiveArguments
|
DirectiveArguments
|
||||||
} from './directives'
|
} from './directives'
|
||||||
export { SuspenseBoundary } from './components/Suspense'
|
export type { SuspenseBoundary } from './components/Suspense'
|
||||||
export { TransitionState, TransitionHooks } from './components/BaseTransition'
|
export type {
|
||||||
export {
|
TransitionState,
|
||||||
|
TransitionHooks
|
||||||
|
} from './components/BaseTransition'
|
||||||
|
export type {
|
||||||
AsyncComponentOptions,
|
AsyncComponentOptions,
|
||||||
AsyncComponentLoader
|
AsyncComponentLoader
|
||||||
} from './apiAsyncComponent'
|
} from './apiAsyncComponent'
|
||||||
export { HMRRuntime } from './hmr'
|
export type { HMRRuntime } from './hmr'
|
||||||
|
|
||||||
// Internal API ----------------------------------------------------------------
|
// Internal API ----------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -336,8 +337,8 @@ export const ssrUtils = (__SSR__ ? _ssrUtils : null) as typeof _ssrUtils
|
||||||
// 2.x COMPAT ------------------------------------------------------------------
|
// 2.x COMPAT ------------------------------------------------------------------
|
||||||
|
|
||||||
export { DeprecationTypes } from './compat/compatConfig'
|
export { DeprecationTypes } from './compat/compatConfig'
|
||||||
export { CompatVue } from './compat/global'
|
export type { CompatVue } from './compat/global'
|
||||||
export { LegacyConfig } from './compat/globalConfig'
|
export type { LegacyConfig } from './compat/globalConfig'
|
||||||
|
|
||||||
import { warnDeprecation } from './compat/compatConfig'
|
import { warnDeprecation } from './compat/compatConfig'
|
||||||
import { createCompatVue } from './compat/global'
|
import { createCompatVue } from './compat/global'
|
||||||
|
|
|
@ -207,7 +207,7 @@ export {
|
||||||
defineCustomElement,
|
defineCustomElement,
|
||||||
defineSSRCustomElement,
|
defineSSRCustomElement,
|
||||||
VueElement,
|
VueElement,
|
||||||
VueElementConstructor
|
type VueElementConstructor
|
||||||
} from './apiCustomElement'
|
} from './apiCustomElement'
|
||||||
|
|
||||||
// SFC CSS utilities
|
// SFC CSS utilities
|
||||||
|
@ -215,10 +215,10 @@ export { useCssModule } from './helpers/useCssModule'
|
||||||
export { useCssVars } from './helpers/useCssVars'
|
export { useCssVars } from './helpers/useCssVars'
|
||||||
|
|
||||||
// DOM-only components
|
// DOM-only components
|
||||||
export { Transition, TransitionProps } from './components/Transition'
|
export { Transition, type TransitionProps } from './components/Transition'
|
||||||
export {
|
export {
|
||||||
TransitionGroup,
|
TransitionGroup,
|
||||||
TransitionGroupProps
|
type TransitionGroupProps
|
||||||
} from './components/TransitionGroup'
|
} from './components/TransitionGroup'
|
||||||
|
|
||||||
// **Internal** DOM-only runtime directive helpers
|
// **Internal** DOM-only runtime directive helpers
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { hyphenate, isArray } from '@vue/shared'
|
import { hyphenate, isArray } from '@vue/shared'
|
||||||
import {
|
import {
|
||||||
|
ErrorCodes,
|
||||||
ComponentInternalInstance,
|
ComponentInternalInstance,
|
||||||
callWithAsyncErrorHandling
|
callWithAsyncErrorHandling
|
||||||
} from '@vue/runtime-core'
|
} from '@vue/runtime-core'
|
||||||
import { ErrorCodes } from 'packages/runtime-core/src/errorHandling'
|
|
||||||
|
|
||||||
interface Invoker extends EventListener {
|
interface Invoker extends EventListener {
|
||||||
value: EventValue
|
value: EventValue
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { initDirectivesForSSR } from 'vue'
|
||||||
initDirectivesForSSR()
|
initDirectivesForSSR()
|
||||||
|
|
||||||
// public
|
// public
|
||||||
export { SSRContext } from './render'
|
export type { SSRContext } from './render'
|
||||||
export { renderToString } from './renderToString'
|
export { renderToString } from './renderToString'
|
||||||
export {
|
export {
|
||||||
renderToSimpleStream,
|
renderToSimpleStream,
|
||||||
|
@ -10,7 +10,7 @@ export {
|
||||||
pipeToNodeWritable,
|
pipeToNodeWritable,
|
||||||
renderToWebStream,
|
renderToWebStream,
|
||||||
pipeToWebWritable,
|
pipeToWebWritable,
|
||||||
SimpleReadable,
|
type SimpleReadable,
|
||||||
// deprecated
|
// deprecated
|
||||||
renderToStream
|
renderToStream
|
||||||
} from './renderToStream'
|
} from './renderToStream'
|
||||||
|
|
|
@ -7,6 +7,7 @@ importers:
|
||||||
'@babel/types': ^7.12.0
|
'@babel/types': ^7.12.0
|
||||||
'@esbuild-plugins/node-modules-polyfill': ^0.1.4
|
'@esbuild-plugins/node-modules-polyfill': ^0.1.4
|
||||||
'@microsoft/api-extractor': ~7.20.0
|
'@microsoft/api-extractor': ~7.20.0
|
||||||
|
'@rollup/plugin-alias': ^4.0.3
|
||||||
'@rollup/plugin-commonjs': ^23.0.2
|
'@rollup/plugin-commonjs': ^23.0.2
|
||||||
'@rollup/plugin-json': ^5.0.1
|
'@rollup/plugin-json': ^5.0.1
|
||||||
'@rollup/plugin-node-resolve': ^15.0.1
|
'@rollup/plugin-node-resolve': ^15.0.1
|
||||||
|
@ -39,6 +40,7 @@ importers:
|
||||||
pug: ^3.0.1
|
pug: ^3.0.1
|
||||||
puppeteer: ^19.2.2
|
puppeteer: ^19.2.2
|
||||||
rollup: ~3.10.0
|
rollup: ~3.10.0
|
||||||
|
rollup-plugin-esbuild: ^5.0.0
|
||||||
rollup-plugin-node-builtins: ^2.1.2
|
rollup-plugin-node-builtins: ^2.1.2
|
||||||
rollup-plugin-node-globals: ^1.4.0
|
rollup-plugin-node-globals: ^1.4.0
|
||||||
rollup-plugin-polyfill-node: ^0.11.0
|
rollup-plugin-polyfill-node: ^0.11.0
|
||||||
|
@ -57,6 +59,7 @@ importers:
|
||||||
'@babel/types': 7.16.0
|
'@babel/types': 7.16.0
|
||||||
'@esbuild-plugins/node-modules-polyfill': 0.1.4_esbuild@0.17.4
|
'@esbuild-plugins/node-modules-polyfill': 0.1.4_esbuild@0.17.4
|
||||||
'@microsoft/api-extractor': 7.20.1
|
'@microsoft/api-extractor': 7.20.1
|
||||||
|
'@rollup/plugin-alias': 4.0.3_rollup@3.10.0
|
||||||
'@rollup/plugin-commonjs': 23.0.2_rollup@3.10.0
|
'@rollup/plugin-commonjs': 23.0.2_rollup@3.10.0
|
||||||
'@rollup/plugin-json': 5.0.1_rollup@3.10.0
|
'@rollup/plugin-json': 5.0.1_rollup@3.10.0
|
||||||
'@rollup/plugin-node-resolve': 15.0.1_rollup@3.10.0
|
'@rollup/plugin-node-resolve': 15.0.1_rollup@3.10.0
|
||||||
|
@ -89,6 +92,7 @@ importers:
|
||||||
pug: 3.0.2
|
pug: 3.0.2
|
||||||
puppeteer: 19.2.2
|
puppeteer: 19.2.2
|
||||||
rollup: 3.10.0
|
rollup: 3.10.0
|
||||||
|
rollup-plugin-esbuild: 5.0.0_ejjt5bxqy7rglzzuwkobwucgry
|
||||||
rollup-plugin-node-builtins: 2.1.2
|
rollup-plugin-node-builtins: 2.1.2
|
||||||
rollup-plugin-node-globals: 1.4.0
|
rollup-plugin-node-globals: 1.4.0
|
||||||
rollup-plugin-polyfill-node: 0.11.0_rollup@3.10.0
|
rollup-plugin-polyfill-node: 0.11.0_rollup@3.10.0
|
||||||
|
@ -337,7 +341,7 @@ packages:
|
||||||
'@babel/traverse': 7.16.3
|
'@babel/traverse': 7.16.3
|
||||||
'@babel/types': 7.16.0
|
'@babel/types': 7.16.0
|
||||||
convert-source-map: 1.8.0
|
convert-source-map: 1.8.0
|
||||||
debug: 4.3.3
|
debug: 4.3.4
|
||||||
gensync: 1.0.0-beta.2
|
gensync: 1.0.0-beta.2
|
||||||
json5: 2.2.0
|
json5: 2.2.0
|
||||||
semver: 6.3.0
|
semver: 6.3.0
|
||||||
|
@ -524,7 +528,7 @@ packages:
|
||||||
'@babel/helper-split-export-declaration': 7.16.0
|
'@babel/helper-split-export-declaration': 7.16.0
|
||||||
'@babel/parser': 7.16.4
|
'@babel/parser': 7.16.4
|
||||||
'@babel/types': 7.16.0
|
'@babel/types': 7.16.0
|
||||||
debug: 4.3.3
|
debug: 4.3.4
|
||||||
globals: 11.12.0
|
globals: 11.12.0
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
@ -1082,6 +1086,19 @@ packages:
|
||||||
fastq: 1.13.0
|
fastq: 1.13.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/@rollup/plugin-alias/4.0.3_rollup@3.10.0:
|
||||||
|
resolution: {integrity: sha512-ZuDWE1q4PQDhvm/zc5Prun8sBpLJy41DMptYrS6MhAy9s9kL/doN1613BWfEchGVfKxzliJ3BjbOPizXX38DbQ==}
|
||||||
|
engines: {node: '>=14.0.0'}
|
||||||
|
peerDependencies:
|
||||||
|
rollup: ^1.20.0||^2.0.0||^3.0.0
|
||||||
|
peerDependenciesMeta:
|
||||||
|
rollup:
|
||||||
|
optional: true
|
||||||
|
dependencies:
|
||||||
|
rollup: 3.10.0
|
||||||
|
slash: 4.0.0
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@rollup/plugin-commonjs/23.0.2_rollup@3.10.0:
|
/@rollup/plugin-commonjs/23.0.2_rollup@3.10.0:
|
||||||
resolution: {integrity: sha512-e9ThuiRf93YlVxc4qNIurvv+Hp9dnD+4PjOqQs5vAYfcZ3+AXSrcdzXnVjWxcGQOa6KGJFcRZyUI3ktWLavFjg==}
|
resolution: {integrity: sha512-e9ThuiRf93YlVxc4qNIurvv+Hp9dnD+4PjOqQs5vAYfcZ3+AXSrcdzXnVjWxcGQOa6KGJFcRZyUI3ktWLavFjg==}
|
||||||
engines: {node: '>=14.0.0'}
|
engines: {node: '>=14.0.0'}
|
||||||
|
@ -2750,6 +2767,10 @@ packages:
|
||||||
unbox-primitive: 1.0.1
|
unbox-primitive: 1.0.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/es-module-lexer/1.1.0:
|
||||||
|
resolution: {integrity: sha512-fJg+1tiyEeS8figV+fPcPpm8WqJEflG3yPU0NOm5xMvrNkuiy7HzX/Ljng4Y0hAoiw4/3hQTCFYw+ub8+a2pRA==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/es-to-primitive/1.2.1:
|
/es-to-primitive/1.2.1:
|
||||||
resolution: {integrity: sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==}
|
resolution: {integrity: sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
|
@ -3933,6 +3954,11 @@ packages:
|
||||||
resolution: {integrity: sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA==}
|
resolution: {integrity: sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/joycon/3.1.1:
|
||||||
|
resolution: {integrity: sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==}
|
||||||
|
engines: {node: '>=10'}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/js-stringify/1.0.2:
|
/js-stringify/1.0.2:
|
||||||
resolution: {integrity: sha512-rtS5ATOo2Q5k1G+DADISilDA6lv79zIiwFd6CcjuIxGKLFm5C+RLImRscVap9k55i+MOZwgliw+NejvkLuGD5g==}
|
resolution: {integrity: sha512-rtS5ATOo2Q5k1G+DADISilDA6lv79zIiwFd6CcjuIxGKLFm5C+RLImRscVap9k55i+MOZwgliw+NejvkLuGD5g==}
|
||||||
dev: true
|
dev: true
|
||||||
|
@ -5490,6 +5516,24 @@ packages:
|
||||||
inherits: 2.0.4
|
inherits: 2.0.4
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/rollup-plugin-esbuild/5.0.0_ejjt5bxqy7rglzzuwkobwucgry:
|
||||||
|
resolution: {integrity: sha512-1cRIOHAPh8WQgdQQyyvFdeOdxuiyk+zB5zJ5+YOwrZP4cJ0MT3Fs48pQxrZeyZHcn+klFherytILVfE4aYrneg==}
|
||||||
|
engines: {node: '>=14.18.0', npm: '>=8.0.0'}
|
||||||
|
peerDependencies:
|
||||||
|
esbuild: '>=0.10.1'
|
||||||
|
rollup: ^1.20.0 || ^2.0.0 || ^3.0.0
|
||||||
|
dependencies:
|
||||||
|
'@rollup/pluginutils': 5.0.2_rollup@3.10.0
|
||||||
|
debug: 4.3.4
|
||||||
|
es-module-lexer: 1.1.0
|
||||||
|
esbuild: 0.17.4
|
||||||
|
joycon: 3.1.1
|
||||||
|
jsonc-parser: 3.2.0
|
||||||
|
rollup: 3.10.0
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- supports-color
|
||||||
|
dev: true
|
||||||
|
|
||||||
/rollup-plugin-inject/3.0.2:
|
/rollup-plugin-inject/3.0.2:
|
||||||
resolution: {integrity: sha512-ptg9PQwzs3orn4jkgXJ74bfs5vYz1NCZlSQMBUA0wKcGp5i5pA1AO3fOUEte8enhGUC+iapTCzEWw2jEFFUO/w==}
|
resolution: {integrity: sha512-ptg9PQwzs3orn4jkgXJ74bfs5vYz1NCZlSQMBUA0wKcGp5i5pA1AO3fOUEte8enhGUC+iapTCzEWw2jEFFUO/w==}
|
||||||
deprecated: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.
|
deprecated: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.
|
||||||
|
@ -5736,6 +5780,11 @@ packages:
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/slash/4.0.0:
|
||||||
|
resolution: {integrity: sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==}
|
||||||
|
engines: {node: '>=12'}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/slice-ansi/3.0.0:
|
/slice-ansi/3.0.0:
|
||||||
resolution: {integrity: sha512-pSyv7bSTC7ig9Dcgbw9AuRNUb5k5V6oDudjZoMBSr13qpLBG7tB+zgCkARjq7xIUgdz5P1Qe8u+rSGdouOOIyQ==}
|
resolution: {integrity: sha512-pSyv7bSTC7ig9Dcgbw9AuRNUb5k5V6oDudjZoMBSr13qpLBG7tB+zgCkARjq7xIUgdz5P1Qe8u+rSGdouOOIyQ==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// @ts-check
|
// @ts-check
|
||||||
import { createRequire } from 'module'
|
import { createRequire } from 'node:module'
|
||||||
import { fileURLToPath } from 'url'
|
import { fileURLToPath } from 'node:url'
|
||||||
import path from 'path'
|
import path from 'node:path'
|
||||||
import ts from 'rollup-plugin-typescript2'
|
import { readdirSync } from 'node:fs'
|
||||||
import replace from '@rollup/plugin-replace'
|
import replace from '@rollup/plugin-replace'
|
||||||
import json from '@rollup/plugin-json'
|
import json from '@rollup/plugin-json'
|
||||||
import chalk from 'chalk'
|
import chalk from 'chalk'
|
||||||
|
@ -10,6 +10,8 @@ import commonJS from '@rollup/plugin-commonjs'
|
||||||
import polyfillNode from 'rollup-plugin-polyfill-node'
|
import polyfillNode from 'rollup-plugin-polyfill-node'
|
||||||
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
||||||
import terser from '@rollup/plugin-terser'
|
import terser from '@rollup/plugin-terser'
|
||||||
|
import esbuild from 'rollup-plugin-esbuild'
|
||||||
|
import alias from '@rollup/plugin-alias'
|
||||||
|
|
||||||
if (!process.env.TARGET) {
|
if (!process.env.TARGET) {
|
||||||
throw new Error('TARGET package must be specified via --environment flag.')
|
throw new Error('TARGET package must be specified via --environment flag.')
|
||||||
|
@ -114,23 +116,37 @@ function createConfig(format, output, plugins = []) {
|
||||||
output.name = packageOptions.name
|
output.name = packageOptions.name
|
||||||
}
|
}
|
||||||
|
|
||||||
const shouldEmitDeclarations =
|
// package aliases
|
||||||
pkg.types && process.env.TYPES != null && !hasTSChecked
|
// TODO reuse between rollup and vitest
|
||||||
|
const resolveEntryForPkg = p =>
|
||||||
const tsPlugin = ts({
|
path.resolve(
|
||||||
check: process.env.NODE_ENV === 'production' && !hasTSChecked,
|
fileURLToPath(import.meta.url),
|
||||||
tsconfig: path.resolve(__dirname, 'tsconfig.json'),
|
`../packages/${p}/src/index.ts`
|
||||||
cacheRoot: path.resolve(__dirname, 'node_modules/.rts2_cache'),
|
)
|
||||||
tsconfigOverride: {
|
const dirs = readdirSync(new URL('./packages', import.meta.url))
|
||||||
compilerOptions: {
|
const entries = {
|
||||||
target: isServerRenderer || isNodeBuild ? 'es2019' : 'es2015',
|
vue: resolveEntryForPkg('vue'),
|
||||||
sourceMap: output.sourcemap,
|
'vue/compiler-sfc': resolveEntryForPkg('compiler-sfc'),
|
||||||
declaration: shouldEmitDeclarations,
|
'vue/server-renderer': resolveEntryForPkg('server-renderer'),
|
||||||
declarationMap: shouldEmitDeclarations
|
'@vue/compat': resolveEntryForPkg('vue-compat')
|
||||||
},
|
|
||||||
exclude: ['**/__tests__', 'test-dts']
|
|
||||||
}
|
}
|
||||||
|
for (const dir of dirs) {
|
||||||
|
const key = `@vue/${dir}`
|
||||||
|
if (dir !== 'vue' && !(key in entries)) {
|
||||||
|
entries[key] = resolveEntryForPkg(dir)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const aliasPlugin = alias({
|
||||||
|
entries
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const tsPlugin = esbuild({
|
||||||
|
tsconfig: path.resolve(__dirname, 'tsconfig.json'),
|
||||||
|
sourceMap: output.sourcemap,
|
||||||
|
minify: false,
|
||||||
|
target: isServerRenderer || isNodeBuild ? 'es2019' : 'es2015'
|
||||||
|
})
|
||||||
|
|
||||||
// we only need to check TS and generate declarations once for each build.
|
// we only need to check TS and generate declarations once for each build.
|
||||||
// it also seems to run into weird issues when checking multiple times
|
// it also seems to run into weird issues when checking multiple times
|
||||||
// during a single build.
|
// during a single build.
|
||||||
|
@ -211,6 +227,7 @@ function createConfig(format, output, plugins = []) {
|
||||||
json({
|
json({
|
||||||
namedExports: false
|
namedExports: false
|
||||||
}),
|
}),
|
||||||
|
aliasPlugin,
|
||||||
tsPlugin,
|
tsPlugin,
|
||||||
createReplacePlugin(
|
createReplacePlugin(
|
||||||
isProductionBuild,
|
isProductionBuild,
|
||||||
|
@ -239,7 +256,15 @@ function createConfig(format, output, plugins = []) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createReplacePlugin(
|
function createReplacePlugin(...args) {
|
||||||
|
return replace({
|
||||||
|
// @ts-ignore
|
||||||
|
values: createReplacements(...args),
|
||||||
|
preventAssignment: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function createReplacements(
|
||||||
isProduction,
|
isProduction,
|
||||||
isBundlerESMBuild,
|
isBundlerESMBuild,
|
||||||
isBrowserESMBuild,
|
isBrowserESMBuild,
|
||||||
|
@ -256,9 +281,9 @@ function createReplacePlugin(
|
||||||
? // preserve to be handled by bundlers
|
? // preserve to be handled by bundlers
|
||||||
`(process.env.NODE_ENV !== 'production')`
|
`(process.env.NODE_ENV !== 'production')`
|
||||||
: // hard coded dev/prod builds
|
: // hard coded dev/prod builds
|
||||||
!isProduction,
|
String(!isProduction),
|
||||||
// this is only used during Vue's internal tests
|
// this is only used during Vue's internal tests
|
||||||
__TEST__: false,
|
__TEST__: `false`,
|
||||||
// If the build is expected to run directly in the browser (global / esm builds)
|
// If the build is expected to run directly in the browser (global / esm builds)
|
||||||
__BROWSER__: isBrowserBuild,
|
__BROWSER__: isBrowserBuild,
|
||||||
__GLOBAL__: isGlobalBuild,
|
__GLOBAL__: isGlobalBuild,
|
||||||
|
@ -282,11 +307,11 @@ function createReplacePlugin(
|
||||||
__COMPAT__: isCompatBuild,
|
__COMPAT__: isCompatBuild,
|
||||||
|
|
||||||
// feature flags
|
// feature flags
|
||||||
__FEATURE_SUSPENSE__: true,
|
__FEATURE_SUSPENSE__: `true`,
|
||||||
__FEATURE_OPTIONS_API__: isBundlerESMBuild ? `__VUE_OPTIONS_API__` : true,
|
__FEATURE_OPTIONS_API__: isBundlerESMBuild ? `__VUE_OPTIONS_API__` : `true`,
|
||||||
__FEATURE_PROD_DEVTOOLS__: isBundlerESMBuild
|
__FEATURE_PROD_DEVTOOLS__: isBundlerESMBuild
|
||||||
? `__VUE_PROD_DEVTOOLS__`
|
? `__VUE_PROD_DEVTOOLS__`
|
||||||
: false,
|
: `false`,
|
||||||
...(isProduction && isBrowserBuild
|
...(isProduction && isBrowserBuild
|
||||||
? {
|
? {
|
||||||
'context.onError(': `/*#__PURE__*/ context.onError(`,
|
'context.onError(': `/*#__PURE__*/ context.onError(`,
|
||||||
|
@ -297,17 +322,13 @@ function createReplacePlugin(
|
||||||
: {})
|
: {})
|
||||||
}
|
}
|
||||||
// allow inline overrides like
|
// allow inline overrides like
|
||||||
//__RUNTIME_COMPILE__=true yarn build runtime-core
|
//__RUNTIME_COMPILE__=true pnpm build runtime-core
|
||||||
Object.keys(replacements).forEach(key => {
|
Object.keys(replacements).forEach(key => {
|
||||||
if (key in process.env) {
|
if (key in process.env) {
|
||||||
replacements[key] = process.env[key]
|
replacements[key] = process.env[key]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return replace({
|
return replacements
|
||||||
// @ts-ignore
|
|
||||||
values: replacements,
|
|
||||||
preventAssignment: true
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createProductionConfig(format) {
|
function createProductionConfig(format) {
|
||||||
|
|
|
@ -0,0 +1,379 @@
|
||||||
|
// @ts-check
|
||||||
|
import { createRequire } from 'module'
|
||||||
|
import { fileURLToPath } from 'url'
|
||||||
|
import path from 'path'
|
||||||
|
import ts from 'rollup-plugin-typescript2'
|
||||||
|
import replace from '@rollup/plugin-replace'
|
||||||
|
import json from '@rollup/plugin-json'
|
||||||
|
import chalk from 'chalk'
|
||||||
|
import commonJS from '@rollup/plugin-commonjs'
|
||||||
|
import polyfillNode from 'rollup-plugin-polyfill-node'
|
||||||
|
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
||||||
|
import terser from '@rollup/plugin-terser'
|
||||||
|
|
||||||
|
if (!process.env.TARGET) {
|
||||||
|
throw new Error('TARGET package must be specified via --environment flag.')
|
||||||
|
}
|
||||||
|
|
||||||
|
const require = createRequire(import.meta.url)
|
||||||
|
const __dirname = fileURLToPath(new URL('.', import.meta.url))
|
||||||
|
|
||||||
|
const masterVersion = require('./package.json').version
|
||||||
|
const consolidatePkg = require('@vue/consolidate/package.json')
|
||||||
|
|
||||||
|
const packagesDir = path.resolve(__dirname, 'packages')
|
||||||
|
const packageDir = path.resolve(packagesDir, process.env.TARGET)
|
||||||
|
|
||||||
|
const resolve = p => path.resolve(packageDir, p)
|
||||||
|
const pkg = require(resolve(`package.json`))
|
||||||
|
const packageOptions = pkg.buildOptions || {}
|
||||||
|
const name = packageOptions.filename || path.basename(packageDir)
|
||||||
|
|
||||||
|
// ensure TS checks only once for each build
|
||||||
|
let hasTSChecked = false
|
||||||
|
|
||||||
|
const outputConfigs = {
|
||||||
|
'esm-bundler': {
|
||||||
|
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`
|
||||||
|
},
|
||||||
|
global: {
|
||||||
|
file: resolve(`dist/${name}.global.js`),
|
||||||
|
format: `iife`
|
||||||
|
},
|
||||||
|
// 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'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultFormats = ['esm-bundler', 'cjs']
|
||||||
|
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(format, outputConfigs[format]))
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV === 'production') {
|
||||||
|
packageFormats.forEach(format => {
|
||||||
|
if (packageOptions.prod === false) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (format === 'cjs') {
|
||||||
|
packageConfigs.push(createProductionConfig(format))
|
||||||
|
}
|
||||||
|
if (/^(global|esm-browser)(-runtime)?/.test(format)) {
|
||||||
|
packageConfigs.push(createMinifiedConfig(format))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default packageConfigs
|
||||||
|
|
||||||
|
function createConfig(format, output, plugins = []) {
|
||||||
|
if (!output) {
|
||||||
|
console.log(chalk.yellow(`invalid format: "${format}"`))
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
const isProductionBuild =
|
||||||
|
process.env.__DEV__ === 'false' || /\.prod\.js$/.test(output.file)
|
||||||
|
const isBundlerESMBuild = /esm-bundler/.test(format)
|
||||||
|
const isBrowserESMBuild = /esm-browser/.test(format)
|
||||||
|
const isServerRenderer = name === 'server-renderer'
|
||||||
|
const isNodeBuild = format === 'cjs'
|
||||||
|
const isGlobalBuild = /global/.test(format)
|
||||||
|
const isCompatPackage = pkg.name === '@vue/compat'
|
||||||
|
const isCompatBuild = !!packageOptions.compat
|
||||||
|
|
||||||
|
output.exports = isCompatPackage ? 'auto' : 'named'
|
||||||
|
output.esModule = true
|
||||||
|
output.sourcemap = !!process.env.SOURCE_MAP
|
||||||
|
output.externalLiveBindings = false
|
||||||
|
|
||||||
|
if (isGlobalBuild) {
|
||||||
|
output.name = packageOptions.name
|
||||||
|
}
|
||||||
|
|
||||||
|
const shouldEmitDeclarations =
|
||||||
|
pkg.types && process.env.TYPES != null && !hasTSChecked
|
||||||
|
|
||||||
|
const tsPlugin = ts({
|
||||||
|
check: process.env.NODE_ENV === 'production' && !hasTSChecked,
|
||||||
|
tsconfig: path.resolve(__dirname, 'tsconfig.json'),
|
||||||
|
cacheRoot: path.resolve(__dirname, 'node_modules/.rts2_cache'),
|
||||||
|
tsconfigOverride: {
|
||||||
|
compilerOptions: {
|
||||||
|
target: isServerRenderer || isNodeBuild ? 'es2019' : 'es2015',
|
||||||
|
sourceMap: output.sourcemap,
|
||||||
|
declaration: shouldEmitDeclarations,
|
||||||
|
declarationMap: shouldEmitDeclarations
|
||||||
|
},
|
||||||
|
exclude: ['**/__tests__', 'test-dts']
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// we only need to check TS and generate declarations once for each build.
|
||||||
|
// it also seems to run into weird issues when checking multiple times
|
||||||
|
// during a single build.
|
||||||
|
hasTSChecked = true
|
||||||
|
|
||||||
|
let entryFile = /runtime$/.test(format) ? `src/runtime.ts` : `src/index.ts`
|
||||||
|
|
||||||
|
// the compat build needs both default AND named exports. This will cause
|
||||||
|
// Rollup to complain for non-ESM targets, so we use separate entries for
|
||||||
|
// esm vs. non-esm builds.
|
||||||
|
if (isCompatPackage && (isBrowserESMBuild || isBundlerESMBuild)) {
|
||||||
|
entryFile = /runtime$/.test(format)
|
||||||
|
? `src/esm-runtime.ts`
|
||||||
|
: `src/esm-index.ts`
|
||||||
|
}
|
||||||
|
|
||||||
|
let external = []
|
||||||
|
const treeShakenDeps = ['source-map', '@babel/parser', 'estree-walker']
|
||||||
|
|
||||||
|
if (isGlobalBuild || isBrowserESMBuild || isCompatPackage) {
|
||||||
|
if (!packageOptions.enableNonBrowserBranches) {
|
||||||
|
// normal browser builds - non-browser only imports are tree-shaken,
|
||||||
|
// they are only listed here to suppress warnings.
|
||||||
|
external = treeShakenDeps
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Node / esm-bundler builds.
|
||||||
|
// externalize all direct deps unless it's the compat build.
|
||||||
|
external = [
|
||||||
|
...Object.keys(pkg.dependencies || {}),
|
||||||
|
...Object.keys(pkg.peerDependencies || {}),
|
||||||
|
// for @vue/compiler-sfc / server-renderer
|
||||||
|
...['path', 'url', 'stream'],
|
||||||
|
// somehow these throw warnings for runtime-* package builds
|
||||||
|
...treeShakenDeps
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// we are bundling forked consolidate.js in compiler-sfc which dynamically
|
||||||
|
// requires a ton of template engines which should be ignored.
|
||||||
|
let cjsIgnores = []
|
||||||
|
if (pkg.name === '@vue/compiler-sfc') {
|
||||||
|
cjsIgnores = [
|
||||||
|
...Object.keys(consolidatePkg.devDependencies),
|
||||||
|
'vm',
|
||||||
|
'crypto',
|
||||||
|
'react-dom/server',
|
||||||
|
'teacup/lib/express',
|
||||||
|
'arc-templates/dist/es5',
|
||||||
|
'then-pug',
|
||||||
|
'then-jade'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
const nodePlugins =
|
||||||
|
(format === 'cjs' && Object.keys(pkg.devDependencies || {}).length) ||
|
||||||
|
packageOptions.enableNonBrowserBranches
|
||||||
|
? [
|
||||||
|
commonJS({
|
||||||
|
sourceMap: false,
|
||||||
|
ignore: cjsIgnores
|
||||||
|
}),
|
||||||
|
...(format === 'cjs' ? [] : [polyfillNode()]),
|
||||||
|
nodeResolve()
|
||||||
|
]
|
||||||
|
: []
|
||||||
|
|
||||||
|
if (format === 'cjs') {
|
||||||
|
nodePlugins.push(cjsReExportsPatchPlugin())
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
input: resolve(entryFile),
|
||||||
|
// Global and Browser ESM builds inlines everything so that they can be
|
||||||
|
// used alone.
|
||||||
|
external,
|
||||||
|
plugins: [
|
||||||
|
json({
|
||||||
|
namedExports: false
|
||||||
|
}),
|
||||||
|
tsPlugin,
|
||||||
|
createReplacePlugin(
|
||||||
|
isProductionBuild,
|
||||||
|
isBundlerESMBuild,
|
||||||
|
isBrowserESMBuild,
|
||||||
|
// isBrowserBuild?
|
||||||
|
(isGlobalBuild || isBrowserESMBuild || isBundlerESMBuild) &&
|
||||||
|
!packageOptions.enableNonBrowserBranches,
|
||||||
|
isGlobalBuild,
|
||||||
|
isNodeBuild,
|
||||||
|
isCompatBuild,
|
||||||
|
isServerRenderer
|
||||||
|
),
|
||||||
|
...nodePlugins,
|
||||||
|
...plugins
|
||||||
|
],
|
||||||
|
output,
|
||||||
|
onwarn: (msg, warn) => {
|
||||||
|
if (!/Circular/.test(msg)) {
|
||||||
|
warn(msg)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
treeshake: {
|
||||||
|
moduleSideEffects: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createReplacePlugin(
|
||||||
|
isProduction,
|
||||||
|
isBundlerESMBuild,
|
||||||
|
isBrowserESMBuild,
|
||||||
|
isBrowserBuild,
|
||||||
|
isGlobalBuild,
|
||||||
|
isNodeBuild,
|
||||||
|
isCompatBuild,
|
||||||
|
isServerRenderer
|
||||||
|
) {
|
||||||
|
const replacements = {
|
||||||
|
__COMMIT__: `"${process.env.COMMIT}"`,
|
||||||
|
__VERSION__: `"${masterVersion}"`,
|
||||||
|
__DEV__: isBundlerESMBuild
|
||||||
|
? // preserve to be handled by bundlers
|
||||||
|
`(process.env.NODE_ENV !== 'production')`
|
||||||
|
: // hard coded dev/prod builds
|
||||||
|
!isProduction,
|
||||||
|
// this is only used during Vue's internal tests
|
||||||
|
__TEST__: false,
|
||||||
|
// If the build is expected to run directly in the browser (global / esm builds)
|
||||||
|
__BROWSER__: isBrowserBuild,
|
||||||
|
__GLOBAL__: isGlobalBuild,
|
||||||
|
__ESM_BUNDLER__: isBundlerESMBuild,
|
||||||
|
__ESM_BROWSER__: isBrowserESMBuild,
|
||||||
|
// is targeting Node (SSR)?
|
||||||
|
__NODE_JS__: isNodeBuild,
|
||||||
|
// need SSR-specific branches?
|
||||||
|
__SSR__: isNodeBuild || isBundlerESMBuild || isServerRenderer,
|
||||||
|
|
||||||
|
// for compiler-sfc browser build inlined deps
|
||||||
|
...(isBrowserESMBuild
|
||||||
|
? {
|
||||||
|
'process.env': '({})',
|
||||||
|
'process.platform': '""',
|
||||||
|
'process.stdout': 'null'
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
|
||||||
|
// 2.x compat build
|
||||||
|
__COMPAT__: isCompatBuild,
|
||||||
|
|
||||||
|
// feature flags
|
||||||
|
__FEATURE_SUSPENSE__: true,
|
||||||
|
__FEATURE_OPTIONS_API__: isBundlerESMBuild ? `__VUE_OPTIONS_API__` : true,
|
||||||
|
__FEATURE_PROD_DEVTOOLS__: isBundlerESMBuild
|
||||||
|
? `__VUE_PROD_DEVTOOLS__`
|
||||||
|
: false,
|
||||||
|
...(isProduction && isBrowserBuild
|
||||||
|
? {
|
||||||
|
'context.onError(': `/*#__PURE__*/ context.onError(`,
|
||||||
|
'emitError(': `/*#__PURE__*/ emitError(`,
|
||||||
|
'createCompilerError(': `/*#__PURE__*/ createCompilerError(`,
|
||||||
|
'createDOMCompilerError(': `/*#__PURE__*/ createDOMCompilerError(`
|
||||||
|
}
|
||||||
|
: {})
|
||||||
|
}
|
||||||
|
// allow inline overrides like
|
||||||
|
//__RUNTIME_COMPILE__=true yarn build runtime-core
|
||||||
|
Object.keys(replacements).forEach(key => {
|
||||||
|
if (key in process.env) {
|
||||||
|
replacements[key] = process.env[key]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return replace({
|
||||||
|
// @ts-ignore
|
||||||
|
values: replacements,
|
||||||
|
preventAssignment: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function createProductionConfig(format) {
|
||||||
|
return createConfig(format, {
|
||||||
|
file: resolve(`dist/${name}.${format}.prod.js`),
|
||||||
|
format: outputConfigs[format].format
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function createMinifiedConfig(format) {
|
||||||
|
return createConfig(
|
||||||
|
format,
|
||||||
|
{
|
||||||
|
file: outputConfigs[format].file.replace(/\.js$/, '.prod.js'),
|
||||||
|
format: outputConfigs[format].format
|
||||||
|
},
|
||||||
|
[
|
||||||
|
terser({
|
||||||
|
module: /^esm/.test(format),
|
||||||
|
compress: {
|
||||||
|
ecma: 2015,
|
||||||
|
pure_getters: true
|
||||||
|
},
|
||||||
|
safari10: true
|
||||||
|
})
|
||||||
|
]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// temporary patch for https://github.com/nodejs/cjs-module-lexer/issues/79
|
||||||
|
//
|
||||||
|
// When importing a cjs module from esm, Node.js uses cjs-module-lexer to
|
||||||
|
// detect * re-exports from other packages. However, the detection logic is
|
||||||
|
// fragile and breaks when Rollup generates different code for the re-exports.
|
||||||
|
// We were locked on an old version of Rollup because of this.
|
||||||
|
//
|
||||||
|
// The latest versions of Node ships an updated version of cjs-module-lexer that
|
||||||
|
// has fixed https://github.com/nodejs/cjs-module-lexer/issues/38, however we
|
||||||
|
// still need to support older versions of Node that does not have the latest
|
||||||
|
// version of cjs-module-lexer (Node < 14.18)
|
||||||
|
//
|
||||||
|
// At the same time, we want to upgrade to Rollup 3 so we are not forever locked
|
||||||
|
// on an old version of Rollup.
|
||||||
|
//
|
||||||
|
// What this patch does:
|
||||||
|
// 1. Rewrite the for...in loop to Object.keys() so cjs-module-lexer can find it
|
||||||
|
// The for...in loop is only used when output.externalLiveBindings is set to
|
||||||
|
// false, and we do want to set it to false to avoid perf costs during SSR.
|
||||||
|
// 2. Also remove exports.hasOwnProperty check, which breaks the detection in
|
||||||
|
// Node.js versions that
|
||||||
|
//
|
||||||
|
// TODO in the future, we should no longer rely on this if we inline all deps
|
||||||
|
// in the main `vue` package.
|
||||||
|
function cjsReExportsPatchPlugin() {
|
||||||
|
const matcher =
|
||||||
|
/for \(var k in (\w+)\) {(\s+if \(k !== 'default') && !exports.hasOwnProperty\(k\)(\) exports\[k\] = (?:\w+)\[k\];\s+)}/
|
||||||
|
return {
|
||||||
|
name: 'patch-cjs-re-exports',
|
||||||
|
renderChunk(code, _, options) {
|
||||||
|
if (matcher.test(code)) {
|
||||||
|
return code.replace(matcher, (_, r1, r2, r3) => {
|
||||||
|
return `Object.keys(${r1}).forEach(function(k) {${r2}${r3}});`
|
||||||
|
})
|
||||||
|
} else if (options.file.endsWith('packages/vue/dist/vue.cjs.js')) {
|
||||||
|
// make sure we don't accidentally miss the rewrite in case Rollup
|
||||||
|
// changes the output again.
|
||||||
|
throw new Error('cjs build re-exports rewrite failed.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,7 @@
|
||||||
"noUnusedLocals": true,
|
"noUnusedLocals": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
|
"isolatedModules": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"removeComments": false,
|
"removeComments": false,
|
||||||
"jsx": "preserve",
|
"jsx": "preserve",
|
||||||
|
|
Loading…
Reference in New Issue