build: expose compiler-sfc and server-renderer under main vue package + optimize package size
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import LRU from 'lru-cache'
|
||||
|
||||
export function createCache<T>(size = 500) {
|
||||
return __GLOBAL__ || __ESM_BROWSER__
|
||||
? new Map<string, T>()
|
||||
: (new (require('lru-cache'))(size) as Map<string, T>)
|
||||
: (new LRU(size) as any as Map<string, T>)
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
} from './stylePreprocessors'
|
||||
import { RawSourceMap } from 'source-map'
|
||||
import { cssVarsPlugin } from './cssVars'
|
||||
import postcssModules from 'postcss-modules'
|
||||
|
||||
export interface SFCStyleCompileOptions {
|
||||
source: string
|
||||
@@ -47,7 +48,7 @@ export interface CSSModulesOptions {
|
||||
hashPrefix?: string
|
||||
localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly'
|
||||
exportGlobals?: boolean
|
||||
globalModulePaths?: string[]
|
||||
globalModulePaths?: RegExp[]
|
||||
}
|
||||
|
||||
export interface SFCAsyncStyleCompileOptions extends SFCStyleCompileOptions {
|
||||
@@ -131,7 +132,7 @@ export function doCompileStyle(
|
||||
)
|
||||
}
|
||||
plugins.push(
|
||||
require('postcss-modules')({
|
||||
postcssModules({
|
||||
...modulesOptions,
|
||||
getJSON: (_cssFileName: string, json: Record<string, string>) => {
|
||||
cssModules = json
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
import { generateCodeFrame, isObject } from '@vue/shared'
|
||||
import * as CompilerDOM from '@vue/compiler-dom'
|
||||
import * as CompilerSSR from '@vue/compiler-ssr'
|
||||
import consolidate from 'consolidate'
|
||||
import consolidate from '@vue/consolidate'
|
||||
import { warnOnce } from './warn'
|
||||
import { genCssVarsFromList } from './cssVars'
|
||||
|
||||
@@ -121,7 +121,7 @@ export function compileTemplate(
|
||||
? preprocessCustomRequire(preprocessLang)
|
||||
: __ESM_BROWSER__
|
||||
? undefined
|
||||
: require('consolidate')[preprocessLang as keyof typeof consolidate]
|
||||
: consolidate[preprocessLang as keyof typeof consolidate]
|
||||
: false
|
||||
if (preprocessor) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user