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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

poc: Fix Basic Vite Support #2286

Closed
wants to merge 8 commits into from

Conversation

bnussman
Copy link
Contributor

Description 馃摑

This is a POC that shows how @tamagui/config/v3 is broken for Vite

The main two issues with basic Vite support are

  • process.env.TAMAGUI_BAIL_AFTER_SCANNING_X_CSS_RULES makes Vite dev mode not work
  • @tamagui/config/v3 exports react native code I think?

Before

Screenshot from 2024-02-17 12-03-31

After

Screencast.from.02-17-2024.11.41.30.AM.webm

Copy link

vercel bot commented Feb 17, 2024

@bnussman is attempting to deploy a commit to the Tamagui Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

New dependencies detected. Learn more about Socket for GitHub 鈫楋笌

Package New capabilities Transitives Size Publisher
npm/@vitejs/plugin-react@4.2.1 None +19 31 MB vitebot

View full report鈫楋笌

// https://vitejs.dev/config/
export default defineConfig({
define: {
'process.env.TAMAGUI_BAIL_AFTER_SCANNING_X_CSS_RULES': false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somethig is going to have to be done with process.env.TAMAGUI_BAIL_AFTER_SCANNING_X_CSS_RULES in insetStyleRule.tsx. This won't work in the browser

I tried removing it but that package would break when it was rebuilt.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what to do about import.meta.env. Webpack doesn't support it:

webpack/webpack#15833

So you're sort of stuck. It's actually a bit wild that we have the two most popular bundlers set up in a way that you can't really access env without some really weird hacks.

I think I've done something like typeof import.meta !== 'undefined' ? import.meta.env.X : process.env.X before.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This solved the main problem

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The react plugin?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My goal was to see what it would take to tamagui without any plugins.

These changes in this file allowed me to do so.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created this vite app just for testing.

@natew
Copy link
Member

natew commented Feb 18, 2024

Merged on another branch :)

@natew natew closed this Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants