Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isServer doesn't work as import.meta.env.SSR #48

Open
2 tasks done
davidmeirlevy opened this issue Nov 26, 2021 · 1 comment
Open
2 tasks done

isServer doesn't work as import.meta.env.SSR #48

davidmeirlevy opened this issue Nov 26, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@davidmeirlevy
Copy link
Collaborator

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

3.23.1

Plugin version

2.3.0

Node.js version

14.7

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

11.6

Description

my app is using vue-ts

SSR code should be tree-shaked from client dist

Steps to Reproduce

write something like:

if(import.meta.env.SSR) {
  // code that will tree-shaked from client dist.
}

when doing:

import {isServer} from 'fastify-vite-vue/client.mjs';

if(isServer) {
  // code that will NOT tree-shaked from client dist.
}

Expected Behavior

SSR code should be tree-shaked from client dist

@galvez
Copy link
Member

galvez commented Nov 26, 2021

Good catch — I think the workaround for now is to just use import.meta if you we're using /client.mjs — probably doesn't make sense to keep /client.js available in renderer adapters given all Vite application code is ESM. So not really a workaround but rather a fix. Feel free to put a PR up, I should be able to get to it (and a new release) tomorrow in any case.

@galvez galvez self-assigned this Nov 26, 2021
@galvez galvez added the bug Something isn't working label Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants