Skip to content

Commit 55c38b6

Browse files
Merge pull request #18 from richardeschloss/development
Improved compilePlugin method
2 parents 112f438 + fd975b3 commit 55c38b6

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

io/plugin.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ function nuxtSocket(ioOpts) {
104104
Object.prototype.hasOwnProperty.call(watchProp, '__ob__')
105105
) {
106106
const errMsg =
107-
emitBack +
108-
' is a vuex module. You probably want to watch its properties'
107+
`${emitBack} is a vuex module. You probably want to watch its properties`
109108
throw new Error(errMsg)
110109
}
111110
return watchProp

test/utils.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import fs from 'fs'
33
import template from 'lodash/template'
44
import { Nuxt, Builder } from 'nuxt'
5+
import serialize from 'serialize-javascript'
56
import config from '@/nuxt.config'
67
import { IOServer } from '@/server/io'
78

@@ -11,8 +12,8 @@ const oneMinute = 60 * oneSecond
1112
export async function compilePlugin({ src, tmpFile, options }) {
1213
const content = fs.readFileSync(src, 'utf-8')
1314
try {
14-
const compiled = template(content)
15-
const pluginJs = compiled({ options })
15+
const compiled = template(content, { interpolate: /<%=([\s\S]+?)%>/g })
16+
const pluginJs = compiled({ options, serialize })
1617
fs.writeFileSync(tmpFile, pluginJs)
1718
const { default: Plugin, pOptions } = await import(tmpFile).catch((err) => {
1819
throw new Error('Err importing plugin: ' + err)

0 commit comments

Comments
 (0)