Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commit 3285740

Browse files
committed
feat: Use runtime helper package instead of inline generated code
1 parent c2d0a7c commit 3285740

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@
4444
],
4545
"dependencies": {
4646
"@babel/runtime": "^7.0.0-beta.46",
47-
"@vue/component-compiler": "^3.4.4",
47+
"@vue/component-compiler": "^3.6",
4848
"@vue/component-compiler-utils": "^2.1.0",
4949
"debug": "^2.6.0",
5050
"hash-sum": "^1.0.2",
5151
"querystring": "^0.2.0",
52-
"rollup-pluginutils": "^2.0.1"
52+
"rollup-pluginutils": "^2.0.1",
53+
"vue-runtime-helpers": "^0.2.0"
5354
},
5455
"devDependencies": {
5556
"@babel/core": "^7.0.0-beta.46",

src/index.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ export default function VuePlugin(opts: VuePluginOptions = {}): Plugin {
115115
d(`Build environment: ${isProduction ? 'production' : 'development'}`)
116116
d(`Build target: ${process.env.VUE_ENV || 'browser'}`)
117117

118+
if (!opts.normalizer) opts.normalizer = '~vue-runtime-helpers/normalize-component.js'
119+
if (!opts.styleInjector) opts.styleInjector = '~vue-runtime-helpers/inject-style/browser.js'
120+
if (!opts.styleInjectorSSR) opts.styleInjectorSSR = '~vue-runtime-helpers/inject-style/server.js'
121+
118122
createVuePartRequest.defaultLang = {
119123
...createVuePartRequest.defaultLang,
120124
...opts.defaultLang
@@ -207,8 +211,10 @@ export default function VuePlugin(opts: VuePluginOptions = {}): Plugin {
207211
descriptors.set(filename, descriptor)
208212
const input: any = {
209213
scopeId,
210-
styles: descriptor.styles.map(style =>
211-
compiler.compileStyle(filename, scopeId, style)
214+
styles: await Promise.all(
215+
descriptor.styles.map(style =>
216+
compiler.compileStyleAsync(filename, scopeId, style)
217+
)
212218
),
213219
customBlocks: []
214220
}

test/setup/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const cache = {}
1717
export async function build(filename, css = false): Promise<string> {
1818
const cacheKey = JSON.stringify({filename, css})
1919
if (cacheKey in cache) return cache[cacheKey]
20-
let style: string | undefined
20+
let style: string = ''
2121
const input = filename + '__app.js'
2222
const options = {defaultLang: {markdown: 'pluginMarkdown'}, css: css, style: {
2323
postcssPlugins: [assets({ basePath: '/' })]

yarn.lock

+7-3
Original file line numberDiff line numberDiff line change
@@ -1269,9 +1269,9 @@
12691269
source-map "^0.5.6"
12701270
vue-template-es2015-compiler "^1.6.0"
12711271

1272-
"@vue/component-compiler@^3.4.4":
1273-
version "3.4.4"
1274-
resolved "https://registry.yarnpkg.com/@vue/component-compiler/-/component-compiler-3.4.4.tgz#4bec11116116c292f1f865afc2d88421953fc393"
1272+
"@vue/component-compiler@^3.6":
1273+
version "3.6.0"
1274+
resolved "https://registry.yarnpkg.com/@vue/component-compiler/-/component-compiler-3.6.0.tgz#8db313e50eaa2903cef5aac68c37a09364dba79d"
12751275
dependencies:
12761276
"@vue/component-compiler-utils" "^2.1.0"
12771277
clean-css "^4.1.11"
@@ -8902,6 +8902,10 @@ vue-router@^3.0.1:
89028902
version "3.0.1"
89038903
resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-3.0.1.tgz#d9b05ad9c7420ba0f626d6500d693e60092cc1e9"
89048904

8905+
vue-runtime-helpers@^0.2.0:
8906+
version "0.2.0"
8907+
resolved "https://registry.yarnpkg.com/vue-runtime-helpers/-/vue-runtime-helpers-0.2.0.tgz#8f8aa9e5ed40be2f3716c3ef8ee5e319290bedde"
8908+
89058909
vue-server-renderer@^2.5.16:
89068910
version "2.5.16"
89078911
resolved "https://registry.yarnpkg.com/vue-server-renderer/-/vue-server-renderer-2.5.16.tgz#279ef8e37e502a0de3a9ae30758cc04a472eaac0"

0 commit comments

Comments
 (0)