-
Notifications
You must be signed in to change notification settings - Fork 309
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
getting errors with using the stylex CLI in next 15 App dir. #774
Comments
I actually dont know why the whole text is messed up. Ill create a github repo and post the link here in a bit. sorry lol |
I don't see anything wrong with your setup. Might be missing something small. Please put up your project on Github so I can check. One additional script might be |
heyo im sorry I forgot to put the project on github. Ill put it up today and comment the link. |
https://github.com/Lolhp0/stylexnextjs-cli-error theres also some issues i forgot to state. i had renamed the source file and everything but when i run npm run dev everytime it creates a new src and a layout.js and page.js and all that. I don't really know how to fix those stuff |
I was going to message but looks like you merged my PR already. Hopefully it's working on your machine as well. There are a few of limitations of the CLI for now:
We're working to fix all of these issues and it should be done soon. |
thanks for all this help. Im having an issue of when i try to run npm run dev now, its generating a new src folder along with layout.js page.js etc. which is giving me this error: ERROR
Codes being generated from the npm run dev command:layout.js import "..\\stylex_bundle.css";
import * as stylex from "@stylexjs/stylex";
import "./globals.css";
export const metadata = {
title: "Create Next App",
description: "Generated by create next app"
};
export default function RootLayout({
children
}) {
return <html {...{
className: "x1ghz6dp x1717udv"
}} lang="en">
<body {...{
className: "x1ghz6dp x1717udv xg6iff7 x100uywg"
}}>{children}</body>
</html>;
} page.js: import "..\\stylex_bundle.css";
import { props, create, keyframes } from "@stylexjs/stylex";
// Although StyleX can compile `@/` paths, TS can only resolve
// them to one location. This will be fixed in the CLI soon.
import { fonts, tokens } from "../vars.stylex";
export default function Home() {
return <main {...{
className: "xg6iff7 x100uywg x78zum5 xdt5ytf x6s0dn4 xl56j7k"
}}>
<h1 {...{
className: "xer8iyq x8cw2a4 xo5v014 x1ghz6dp"
}}>Welcome to Next.js & StyleX!</h1>
<p {...{
className: "xer8iyq xvewgow x1evy7pa xman319"
}}>
Get started by editing <code>pages/index.tsx</code>
</p>
<div {...{
className: "xpyat2d x1oysuqx xybe50t xtursrm x1ke1kyy x18ebdri xa4qsjk"
}} />
</main>;
}
const gradientColors = ["#ffadad", "#ffd6a5", "#fdffb6", "#caffbf", "#9bf6ff", "#a0c4ff", "#bdb2ff", "#ffc6ff", "#ffadad"].join(", ");
const rotate = "xa503dy-B"; along with stylex_bundle.css which has alot of css classes with styles aswell as vars.stylex.js. I don't think those file contents have anything to do with the error so i wont share it but if neccessary I will. Is there any way to stop generating a new src file when i run npm run dev? |
and I still don't know why github is ruining the text formatting |
(The text formatting is broken, because you're not putting a new line after the triple backticks. Try to edit your comment again and see the correct way to define codeblocks.) Seeing the error message, there seems to be a Windows-specific bug with import paths. import "..\\stylex_bundle.css"; with import "../stylex_bundle.css"; in the generated files and see if that fixes the problem? Explanation: Windows uses backslash for file paths instead of forward slash like mac/unix/linux. We're using Node APIs to get relative file paths which are being returned with backslashes, but I think the If this is indeed the problem, the fix should be pretty straightforward. |
If you'd like to help fix the problem (or patch it and unblock yourself), look at the last 7 lines in Patching those files to return forward slashes instead of backslashes should fix the problem. |
I tried doing that, it's giving me this error.
Also how can i stop it from generating a new src folder everytime with a layout.js and page.js since I already have a layout.tsx and page.tsx ? |
this is what the current import looks like : |
In your own comment, you stated that the generated file had: import "..\\stylex_bundle.css"; It'll take me a bit longer to debug the windows issue as I don't have windows on me handy at the moment, but I'll work on it soon. |
yes i edited the
to
which is what you told me to try. |
@Lolhp0 and Next still can't compile it? Is the |
ISSUE
'stylex.create' should never be called at runtime. It should be compiled away by '@stylexjs/babel-plugin'
CODES
.stylex.json5:
next.config.ts (default nothing changed.):
and here's my package.json incase its needed:
and here's the code of me trying to use the stylex.create() in app/page.tsx
I have made all the changes relating to the src also.
If needed, ill put the project up on github.
The text was updated successfully, but these errors were encountered: