Skip to content

Support extending globalWhitelist in vue compiler #3386

@SasanFarrokh

Description

@SasanFarrokh

What problem does this feature solve?

Vue compiler prefixes all identifiers used in template syntax with this or _ctx except these:

https://github.com/vuejs/vue-next/blob/master/packages/shared/src/globalsWhitelist.ts

Is there a way that we can add some custom globals like window , or __MY_GLOBAL_CONSTANT__ to globals?
If we could, then we can use env variables (or ...) directly and it makes tree-shaking works inside render-tree.

I encountered this problem here

https://github.com/SasanFarrokh/vite-plugin-multi-device#caveats

What does the proposed API look like?

inside vueCompilerOptions add another field to extend the globalsWhitelist like

vueCompilerOptions: {
   globalsWhitelist: ['window', '__DEVICE__']
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions