Skip to content

Commit

Permalink
refactor: misc improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Mar 31, 2024
1 parent cd1248e commit d081c37
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function extendTypes(module: string, template: (options: { typesPath: str
const { resolve } = createResolver(import.meta.url)
// paths.d.ts
addTemplate({
filename: `module/${module}.d.ts`,
filename: `modules/${module}.d.ts`,
getContents: async () => {
const typesPath = relative(resolve(nuxt!.options.rootDir, nuxt!.options.buildDir, 'module'), resolve('runtime/types'))
const s = await template({ typesPath })
Expand Down
8 changes: 6 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export interface ModuleOptions {
* @default '/_scripts/'
*/
prefix?: string
/** Currently scripts assets are exposed as public assets as part of the build. This will be configurable in future */
/**
* Scripts assets are exposed as public assets as part of the build.
*
* TODO Make configurable in future.
*/
strategy?: 'public'
}
/**
Expand Down Expand Up @@ -163,7 +167,7 @@ export default defineNuxtModule<ModuleOptions>({
export default defineNuxtPlugin({
name: "${name}:init",
setup() {
${config.globals?.map(g => !Array.isArray(g)
${(config.globals || []).map(g => !Array.isArray(g)
? ` useScript("${g.toString()}")`
: g.length === 2
? ` useScript(${JSON.stringify(g[0])}, ${JSON.stringify(g[1])} })`
Expand Down
5 changes: 3 additions & 2 deletions src/runtime/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ export interface NuxtAppScript {
$script: VueScriptInstance<any>
events: {
type: string
fn?: string
fn?: string | symbol
args?: any
trigger?: string
status?: string
trigger?: NuxtUseScriptOptions['trigger']
at: number
}[]
}
Expand Down

0 comments on commit d081c37

Please sign in to comment.