Skip to content

Commit

Permalink
fix: remove h from vue3 in inbrowser compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
elevatebart committed Jan 18, 2022
1 parent 9e1f315 commit cf7305a
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 48 deletions.
95 changes: 49 additions & 46 deletions packages/vue-inbrowser-compiler/package.json
Original file line number Diff line number Diff line change
@@ -1,47 +1,50 @@
{
"name": "vue-inbrowser-compiler",
"version": "4.44.0",
"description": "compile vue single file components right in your browser",
"module": "lib/vue-inbrowser-compiler.esm.js",
"main": "lib/vue-inbrowser-compiler.cjs.js",
"types": "lib/types/index.d.ts",
"scripts": {
"compile": "rollup -c",
"compile:watch": "rollup -c --watch"
},
"keywords": [
"vue",
"compile",
"live",
"browser",
"buble",
"acorn"
],
"dependencies": {
"acorn": "^6.4.2",
"acorn-jsx": "^5.3.1",
"buble": "^0.20.0",
"camelcase": "^5.3.1",
"detect-browser": "^5.2.0",
"vue-inbrowser-compiler-utils": "^4.44.0",
"walkes": "^0.2.1"
},
"devDependencies": {
"@rollup/plugin-commonjs": "15.1.0",
"@rollup/plugin-node-resolve": "9.0.0",
"@rollup/plugin-typescript": "8.3.0",
"@types/buble": "0.20.1",
"@vue/test-utils": "1.3.0",
"rollup": "2.64.0",
"typescript": "4.5.4",
"vue": "2.6.14"
},
"author": "Bart Ledoux <ledouxb@me.com>",
"license": "MIT",
"homepage": "https://vue-styleguidist.github.io",
"repository": {
"type": "git",
"url": "https://github.com/vue-styleguidist/vue-styleguidist.git",
"directory": "packages/vue-inbrowser-compiler"
}
}
"name": "vue-inbrowser-compiler",
"version": "4.44.0",
"description": "compile vue single file components right in your browser",
"module": "lib/vue-inbrowser-compiler.esm.js",
"main": "lib/vue-inbrowser-compiler.cjs.js",
"types": "lib/types/index.d.ts",
"scripts": {
"compile": "rollup -c",
"compile:watch": "rollup -c --watch"
},
"keywords": [
"vue",
"compile",
"live",
"browser",
"buble",
"acorn"
],
"dependencies": {
"acorn": "^6.4.2",
"acorn-jsx": "^5.3.1",
"buble": "^0.20.0",
"camelcase": "^5.3.1",
"detect-browser": "^5.2.0",
"vue-inbrowser-compiler-utils": "^4.44.0",
"walkes": "^0.2.1"
},
"devDependencies": {
"@rollup/plugin-commonjs": "15.1.0",
"@rollup/plugin-node-resolve": "9.0.0",
"@rollup/plugin-typescript": "8.3.0",
"@types/buble": "0.20.1",
"@vue/test-utils": "1.3.0",
"rollup": "2.64.0",
"typescript": "4.5.4",
"vue": "2.6.14"
},
"peerDependencies": {
"vue": ">=2"
},
"author": "Bart Ledoux <ledouxb@me.com>",
"license": "MIT",
"homepage": "https://vue-styleguidist.github.io",
"repository": {
"type": "git",
"url": "https://github.com/vue-styleguidist/vue-styleguidist.git",
"directory": "packages/vue-inbrowser-compiler"
}
}
2 changes: 1 addition & 1 deletion packages/vue-inbrowser-compiler/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ export default {
// Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs, `require()`)
commonjs()
],
external: Object.keys(pkg.dependencies)
external: [...Object.keys(pkg.dependencies), ...Object.keys(pkg.peerDependencies)]
}
5 changes: 4 additions & 1 deletion packages/vue-inbrowser-compiler/src/normalizeSfcComponent.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import walkes from 'walkes'
import * as Vue from 'vue'
import { parseComponent, VsgSFCDescriptor } from 'vue-inbrowser-compiler-utils'
import getAst from './getAst'
import transformOneImport from './transformOneImport'

const isVue3 = !!(Vue as any).h

const buildStyles = function (styles: string[] | undefined): string | undefined {
let _styles = ''
if (styles) {
Expand Down Expand Up @@ -98,7 +101,7 @@ export function parseScriptCode(code: string): {
if (startIndex === -1) {
throw new Error('Failed to parse single file component: ' + code)
}
if (renderFunctionStart > 0) {
if (renderFunctionStart > 0 && !isVue3) {
renderFunctionStart += offset
code = insertCreateElementFunction(
code.slice(0, renderFunctionStart + 1),
Expand Down

0 comments on commit cf7305a

Please sign in to comment.