Permalink
Browse files

feat: Use runtime helper package instead of inline generated code

  • Loading branch information...
znck committed Aug 29, 2018
1 parent c2d0a7c commit 3285740379f0a51ab6ee3088b9aefb07ba6d89d1
Showing with 19 additions and 8 deletions.
  1. +3 −2 package.json
  2. +8 −2 src/index.ts
  3. +1 −1 test/setup/index.ts
  4. +7 −3 yarn.lock
@@ -44,12 +44,13 @@
],
"dependencies": {
"@babel/runtime": "^7.0.0-beta.46",
"@vue/component-compiler": "^3.4.4",
"@vue/component-compiler": "^3.6",
"@vue/component-compiler-utils": "^2.1.0",
"debug": "^2.6.0",
"hash-sum": "^1.0.2",
"querystring": "^0.2.0",
"rollup-pluginutils": "^2.0.1"
"rollup-pluginutils": "^2.0.1",
"vue-runtime-helpers": "^0.2.0"
},
"devDependencies": {
"@babel/core": "^7.0.0-beta.46",
@@ -115,6 +115,10 @@ export default function VuePlugin(opts: VuePluginOptions = {}): Plugin {
d(`Build environment: ${isProduction ? 'production' : 'development'}`)
d(`Build target: ${process.env.VUE_ENV || 'browser'}`)

if (!opts.normalizer) opts.normalizer = '~vue-runtime-helpers/normalize-component.js'
if (!opts.styleInjector) opts.styleInjector = '~vue-runtime-helpers/inject-style/browser.js'
if (!opts.styleInjectorSSR) opts.styleInjectorSSR = '~vue-runtime-helpers/inject-style/server.js'

createVuePartRequest.defaultLang = {
...createVuePartRequest.defaultLang,
...opts.defaultLang
@@ -207,8 +211,10 @@ export default function VuePlugin(opts: VuePluginOptions = {}): Plugin {
descriptors.set(filename, descriptor)
const input: any = {
scopeId,
styles: descriptor.styles.map(style =>
compiler.compileStyle(filename, scopeId, style)
styles: await Promise.all(
descriptor.styles.map(style =>
compiler.compileStyleAsync(filename, scopeId, style)
)
),
customBlocks: []
}
@@ -17,7 +17,7 @@ const cache = {}
export async function build(filename, css = false): Promise<string> {
const cacheKey = JSON.stringify({filename, css})
if (cacheKey in cache) return cache[cacheKey]
let style: string | undefined
let style: string = ''
const input = filename + '__app.js'
const options = {defaultLang: {markdown: 'pluginMarkdown'}, css: css, style: {
postcssPlugins: [assets({ basePath: '/' })]

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 3285740

Please sign in to comment.