Skip to content

Commit a3d6e24

Browse files
danielroeposva
authored andcommitted
fix: use lodash.template directly to compile templates
1 parent 0c9184e commit a3d6e24

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

packages/nuxt/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"dependencies": {
4141
"@nuxt/kit": "^3.10.3",
4242
"@posva/lru-cache": "^10.0.1",
43+
"lodash-es": "^4.17.21",
4344
"strip-json-comments": "^5.0.1"
4445
},
4546
"peerDependencies": {

packages/nuxt/src/module.ts

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { readFileSync } from 'node:fs'
2+
import { template } from 'lodash-es'
13
/**
24
* @module nuxt-vuefire
35
*/
@@ -169,7 +171,13 @@ export default defineNuxtModule<VueFireNuxtModuleOptions>({
169171

170172
// this adds the VueFire plugin and handle SSR state serialization and hydration
171173
addPluginTemplate({
172-
src: normalize(resolve(templatesDir, 'plugin.ejs')),
174+
getContents({ options }) {
175+
const contents = readFileSync(
176+
normalize(resolve(templatesDir, 'plugin.ejs')),
177+
'utf-8'
178+
)
179+
return template(contents)({ options })
180+
},
173181
filename: 'vuefire-plugin.mjs',
174182
options: {
175183
ssr: nuxt.options.ssr,
@@ -232,7 +240,13 @@ export default defineNuxtModule<VueFireNuxtModuleOptions>({
232240
if (options.auth.enabled) {
233241
// hydrates the user if any
234242
addPluginTemplate({
235-
src: normalize(resolve(runtimeDir, 'auth/plugin.client.ejs')),
243+
getContents({ options }) {
244+
const contents = readFileSync(
245+
normalize(resolve(runtimeDir, 'auth/plugin.client.ejs')),
246+
'utf-8'
247+
)
248+
return template(contents)({ options })
249+
},
236250
filename: 'vuefire-auth-plugin.client.mjs',
237251
options: {
238252
...options.auth,

pnpm-lock.yaml

+8-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)