build: expose compiler-sfc and server-renderer under main vue package + optimize package size

This commit is contained in:
Evan You
2021-09-21 10:26:08 -04:00
parent a42a14d3bc
commit 471f66a1f6
18 changed files with 76 additions and 60 deletions

View File

@@ -33,28 +33,27 @@
"homepage": "https://github.com/vuejs/vue-next/tree/master/packages/compiler-sfc#readme",
"dependencies": {
"@babel/parser": "^7.15.0",
"@types/estree": "^0.0.48",
"@vue/compiler-core": "3.2.12",
"@vue/compiler-dom": "3.2.12",
"@vue/compiler-ssr": "3.2.12",
"@vue/ref-transform": "3.2.12",
"@vue/shared": "3.2.12",
"consolidate": "^0.16.0",
"estree-walker": "^2.0.2",
"hash-sum": "^2.0.0",
"lru-cache": "^5.1.1",
"magic-string": "^0.25.7",
"merge-source-map": "^1.1.0",
"postcss": "^8.1.10",
"postcss-modules": "^4.0.0",
"postcss-selector-parser": "^6.0.4",
"source-map": "^0.6.1"
"source-map": "^0.6.1",
"postcss": "^8.1.10"
},
"devDependencies": {
"@types/estree": "^0.0.48",
"@babel/types": "^7.15.0",
"@types/consolidate": "^0.14.0",
"@types/lru-cache": "^5.1.0",
"pug": "^3.0.1",
"sass": "^1.26.9"
"sass": "^1.26.9",
"@vue/consolidate": "^0.17.2",
"hash-sum": "^2.0.0",
"lru-cache": "^5.1.1",
"merge-source-map": "^1.1.0",
"postcss-modules": "^4.0.0",
"postcss-selector-parser": "^6.0.4"
}
}

View File

@@ -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>)
}

View File

@@ -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

View File

@@ -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 {