Skip to content

Commit

Permalink
fix: remove lodash.template usage (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Mar 19, 2024
1 parent bcabdcc commit e4b1bbd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -36,7 +36,6 @@
},
"dependencies": {
"@nuxt/kit": "^3.8.2",
"lodash.template": "^4.5.0",
"pathe": "^1.1.1"
},
"devDependencies": {
Expand Down
48 changes: 24 additions & 24 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/module.ts
@@ -1,6 +1,5 @@
import { promises as fsp } from 'fs'
import { join, resolve } from 'pathe'
import template from 'lodash.template'
import { addPlugin, addTemplate, defineNuxtModule, isNuxt2, addComponent, addImports, createResolver } from '@nuxt/kit'

import { name, version } from '../package.json'
Expand Down Expand Up @@ -33,7 +32,8 @@ export default defineNuxtModule({
// Read script from disk and add to options
const scriptPath = await resolver.resolve('./script.min.js')
const scriptT = await fsp.readFile(scriptPath, 'utf-8')
options.script = template(scriptT)({ options })
type ScriptOption = 'storageKey' | 'preference' | 'globalName' | 'classPrefix' | 'classSuffix' | 'dataValue' | 'classPrefix' | 'classSuffix' | 'dataValue' | 'fallback'
options.script = scriptT.replace(/<%= options\.([^ ]+) %>/g, (_, option: ScriptOption) => options[option])

// Inject options via virtual template
nuxt.options.alias['#color-mode-options'] = addTemplate({
Expand Down

0 comments on commit e4b1bbd

Please sign in to comment.