question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom directive is missing corresponding SSR transform and will be ignored

See original GitHub issue

I’m currently trying to implement vue3-lazyload package to lazy load some of my images.

modules/lazyload.ts

import { UserModule } from "../utils/types";

export const install: UserModule = async ({ isClient, router, app }) => {
    if (!isClient) return;
    const vueLazyLoad = await import("vue3-lazyload");
    app.use(vueLazyLoad.default || vueLazyLoad, {
        log: false,
        lifecycle: {
            loading: () => {
                 console.log('loading...')
            },
            error: () => {
                 console.log('error loading image...')
            },
            loaded: () => {
                 console.log('loaded')
            }
        }
    });
};

and then I have this within my component template

<template>
    <img v-lazy="{ src: 'image source', loading: '/img/placeholder.jpg', error: '/img/placeholder.jpg' }"  alt="title"/>
</template>

However it works on development, but when I run build I get this error

SyntaxError: Custom directive is missing corresponding SSR transform and will be ignored.

Please any solution to fixing this will be appreciated?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
cimchdcommented, Dec 15, 2021

I had the same problem. Assuming your custom directives are named v-custom-directive1 and v-custom-directive2 you can fix it for ssr by adding the following code to the vue plugin in your vite config.

// vite.config.ts
import { defineConfig } from 'vite';
import Vue from "@vitejs/plugin-vue";

export default defineConfig({
  plugins: [
    Vue({
      template: {
        compilerOptions: {
          directiveTransforms: {
            customDirective1: () => ({
              props: [],
              needRuntime: true,
            }),
            customDirective2: () => ({
              props: [],
              needRuntime: true,
            })
          }
        }
      }
    })
  ]
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom directive is missing corresponding SSR transform and ...
SyntaxError: Custom directive is missing corresponding SSR transform and will be ignored. at Object.createCompilerError (C:\study\cfsw\ ...
Read more >
How to make custom directive in Vue.js 3? - Stack Overflow
I got error like "Cannot read property 'created' of undefined" in console. And nothing is displayed. createApp is missing, I editted my question ......
Read more >
Custom directive is missing corresponding SSR ... - 博客园
关于在vue3.0中使用ssr/ssg渲染时出现Custom directive is missing corresponding SSR transform and will be ignored.
Read more >
Custom directive is missing corresponding SSR transform and ...
关于在 vue3.0 中使用 ssr/ssg 渲染时出现 Custom directive is missing corresponding SSR transform and will be ignored. 错误的修复。
Read more >
I have problem with new v-directive in nuxt3 project
vue: Custom directive is missing corresponding SSR transform and will be ignored. ... [Vue warn]: Invalid vnode type when creating vnode: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found