Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

fix(plugins): render components in production #1250

Merged
merged 3 commits into from May 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/renderer/services/plugin-manager.js
Expand Up @@ -5,7 +5,10 @@ import { ipcRenderer } from 'electron'
import { camelCase, isBoolean, isEmpty, isObject, isString, partition, uniq, upperFirst } from 'lodash'
import { PLUGINS } from '@config'

const rootPath = path.resolve(__dirname, '../../../')
let rootPath = path.resolve(__dirname, '../../../')
if (process.env.NODE_ENV === 'production') {
rootPath = path.resolve(__dirname, '../../')
}

class PluginManager {
constructor () {
Expand Down Expand Up @@ -131,7 +134,7 @@ class PluginManager {
}

// Inline method to format context based on "this"
const componentContext = function (that) {
const componentContext = function (that, componentData = component) {
let context = that._data
if (!context) {
context = {}
Expand All @@ -142,13 +145,13 @@ class PluginManager {
context[key] = that[key]
}

for (const computedName of Object.keys(component.computed || {})) {
for (const computedName of Object.keys(componentData.computed || {})) {
context[computedName] = that[computedName]
}

for (const methodName of Object.keys(component.methods || {})) {
for (const methodName of Object.keys(componentData.methods || {})) {
context[methodName] = function () {
return component.methods[methodName].apply(componentContext(that))
return componentData.methods[methodName].apply(componentContext(that, componentData))
}
}

Expand Down Expand Up @@ -191,7 +194,7 @@ class PluginManager {
component.staticRenderFns = compiled.staticRenderFns
} else {
component.render = function () {
return compiled.render.apply(componentContext(this), [ ...arguments ])
return compiled.render.apply(componentContext(this, component), [ ...arguments ])
}
}
delete component.template
Expand Down