Skip to content

Commit d7f1f34

Browse files
committed
fix: import defineNuxtPlugin in intercept plugin (#842)
1 parent 153f835 commit d7f1f34

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎packages/script/src/plugins/intercept.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
*/
1414
export function generateInterceptPluginContents(proxyPrefix: string, options?: { testMode?: boolean, domainAliases?: Record<string, string> }): string {
1515
const testMode = options?.testMode ?? false
16-
return `export default defineNuxtPlugin({
16+
return `import { defineNuxtPlugin } from 'nuxt/app'
17+
18+
export default defineNuxtPlugin({
1719
name: 'nuxt-scripts:intercept',
1820
enforce: 'pre',
1921
setup() {

‎test/unit/proxy-alias-generators.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ describe('proxy alias - generated runtime code (#814)', () => {
2929
})
3030

3131
describe('generateInterceptPluginContents', () => {
32+
it('imports defineNuxtPlugin when Nuxt auto imports are disabled (#841)', () => {
33+
const code = generateInterceptPluginContents('/_scripts/p')
34+
expect(code).toContain('import { defineNuxtPlugin } from \'nuxt/app\'')
35+
})
36+
3237
it('embeds the alias map into the client intercept plugin', () => {
3338
const code = generateInterceptPluginContents('/_scripts/p', { domainAliases: ALIASES })
3439
expect(code).toContain('const domainAliases = {"us.i.posthog.com":"ph"}')

0 commit comments

Comments
 (0)