-
Notifications
You must be signed in to change notification settings - Fork 295
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
NonErrorEmittedError when used in next.js and monorepo project #850
Comments
Hi @Kalesberg did you ever figure out what's happening? |
I'm actually getting a very similar error, but with the Webpack plugin (which the next plugin uses)
This is happening in an app that has a dependency that has vars. The stacktrace points to this line https://github.com/vanilla-extract-css/vanilla-extract/blob/master/packages/webpack-plugin/src/loader.ts#L61 I think it could possibly be related to this? #963 |
Closing this as I'm pretty sure it's the same issue described in #1043. See this comment for an explanation. TL;DR: Exporting both classnames and components from the same barrel file ( One possible solution could be to export your styles ( |
Hello @askoufis, If you don't have any difficulty, could you please provide a basic reproduction of exactly how you fixed this error? I would be very grateful. |
If you're not publishing the package with the issue, i.e. you just have an app, then the simplest way would just be to ensure you separate the file that exports your components from the file that exports your styles. E.g. // src/components/index.ts
export { MyComponent } from './MyComponent'; // src/styles/index.ts
export { vars } from './theme.css';
export { sprinkles } from './sprinkles.css'; In your consuming code, you would then just import directly from those files: // src/App.tsx
import { MyComponent } from './components';
import { vars, sprinkles } from './styles'; If you have a component+styles package (e.g. as a separate package or within a monorepo), then the best approach would be to set up some entrypoints via package.json exports: // package.json
{
"name": "design-system",
"exports": {
".": {
// This is not a full example, please read the package.json exports docs linked above
// This example assumes you are not bundling your package or just consuming it within a monorepo
"import": "./src/components/index.ts"
},
// You can name this entrypoint whatever you like
"./styles": {
"import": "./src/styles/index"
}
}
} You would then consume this the components and styles like this (after adding the import { MyComponent } from 'design-system';
import { vars, sprinkles } from 'design-system/styles'; Hope that helps. |
I'm using a Turborepo based monorepository that has a consuming application and a package that needs to provide tokens. From that package, in this example I am not exporting anything other than the result of the However, when I try to use these styles, I get an error in the NextJS application: import { cssVars } from "@example-monorepo/design-system";
export const homePageRoot = style({
background: "teal",
color: "white",
// ^^
padding: cssVars.spacing["spacing-2x"],
});
I could probably be wrong somewhere, but from the looks of it you have experience organizing styles created with vanilla-extract in separate packages. Could you take a look at a reproducible example and suggest what the problem might be? Repository with a reproducible example Thanks. |
Describe the bug
Summary
Loading Vanilla vars externally from monorepo package results in error when used in next.js project
Environment
next.js: 12.x
vanilla-extract/css: 1.7+
lerna: 5.4
Reproduce
Just clone the repo and run
yarn dev
Screenshot
Highlighted snippets
src/pages/styles.css.ts
And when using
textSample
class in next.js page ends up with the error posted above.Reproduction
https://github.com/Kalesberg/vanilla-issue-demo
System Info
Used Package Manager
yarn
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: