Skip to content

Commit

Permalink
fix: add template as plugin on manual mode
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Jul 11, 2022
1 parent 16b877a commit 449d4dc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions packages/nuxt-delay-hydration/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export interface ModuleOptions {
* Controls which browser events should trigger the hydration to resume. By default, it is quite aggressive to avoid
* possible user experience issues.
*
* By default it uses the events: 'mousemove' | 'scroll' | 'wheel' | 'keydown' | 'click' | 'touchstart'
* @default 'mousemove' | 'scroll' | 'wheel' | 'keydown' | 'click' | 'touchstart'
*/
hydrateOnEvents: EventTypes[]
/**
* When waiting for an idle callback, it's possible to define a max amount of time to wait in milliseconds. This is
* useful when there are a lot of network requests happening.
*
* By default it's 7000ms.
* @default 7000ms
*/
idleCallbackTimeout: number
/**
Expand All @@ -40,13 +40,13 @@ export interface ModuleOptions {
/**
* Log details in the console on when hydration is blocked and when and why it becomes unblocked.
*
* Default: false
* @default false
*/
debug: boolean
/**
* Run the delay forever, useful for testing your app without scripts.
*
* Default: false
* @default false
*/
forever: boolean
}
4 changes: 2 additions & 2 deletions packages/nuxt-delay-hydration/src/module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { addTemplate, createResolver, defineNuxtModule } from '@nuxt/kit'
import {addComponentsDir, addPluginTemplate, addTemplate, createResolver, defineNuxtModule} from '@nuxt/kit'
import type { ModuleOptions } from './interfaces'
import { CONFIG_KEY, MODE_DELAY_APP_INIT, MODE_DELAY_APP_MOUNT, MODE_DELAY_MANUAL, NAME } from './constants'
import templateUtils from './util/template'
Expand Down Expand Up @@ -86,7 +86,7 @@ const nuxtDelayHydration = defineNuxtModule<ModuleOptions>({
})

if (config.mode === MODE_DELAY_MANUAL) {
addTemplate({
addPluginTemplate({
src: resolve('runtime/plugin/injectDelayHydrationApi.mjs'),
fileName: 'hydration/pluginDelayHydration.client.mjs',
options: config,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import hydrationRace from './hydrationRace.js'
import hydrationRace from './hydrationRace.mjs'
<% if (options.replayClick) { %>
import replayPointerEvent from './replayPointerEvent.js'
import replayPointerEvent from './replayPointerEvent.mjs'
<% } %>

const injectDelayHydrationApi = (ctx, inject) => {
Expand Down

0 comments on commit 449d4dc

Please sign in to comment.