Skip to content

Commit

Permalink
[core] Fix thrown error during eval phase (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
brijeshb42 authored Aug 7, 2024
1 parent a0dd322 commit 794b443
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/pigment-css-next-app/src/app/grid/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Item = styled.div`

function GridDemo1() {
return (
<Grid container spacing={2}>
<Grid container spacing={2} sx={{ color: '#070707' }}>
<Grid size={8}>
<Item>size=8</Item>
</Grid>
Expand Down
8 changes: 8 additions & 0 deletions packages/pigment-css-react/src/css.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
/**
* `__wyw_dynamic_import` is a special global var that is set during the evaluation phase by wyw.
* So during eval phase, it can happen that some code is calling the runtime function.
* We do not want to throw error in that case as we want the evaluation to happen.
*/
export default function css() {
if (typeof __wyw_dynamic_import !== 'undefined') {
return;
}
throw new Error(
`${process.env.PACKAGE_NAME}: You were trying to call "css" function without configuring your bundler. Make sure to install the bundler specific plugin and use it. @pigment-css/vite-plugin for Vite integration or @pigment-css/nextjs-plugin for Next.js integration.`,
);
Expand Down
8 changes: 8 additions & 0 deletions packages/pigment-css-react/src/generateAtomics.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import cx from 'clsx';

/**
* `__wyw_dynamic_import` is a special global var that is set during the evaluation phase by wyw.
* So during eval phase, it can happen that some code is calling the runtime function.
* We do not want to throw error in that case as we want the evaluation to happen.
*/
export function generateAtomics() {
if (typeof __wyw_dynamic_import !== 'undefined') {
return;
}
throw new Error(
`${process.env.PACKAGE_NAME}: You were trying to call "generateAtomics" function without configuring your bundler. Make sure to install the bundler specific plugin and use it. @pigment-css/vite-plugin for Vite integration or @pigment-css/nextjs-plugin for Next.js integration.`,
);
Expand Down
8 changes: 8 additions & 0 deletions packages/pigment-css-react/src/globalCss.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
/**
* `__wyw_dynamic_import` is a special global var that is set during the evaluation phase by wyw.
* So during eval phase, it can happen that some code is calling the runtime function.
* We do not want to throw error in that case as we want the evaluation to happen.
*/
export default function globalCss() {
if (typeof __wyw_dynamic_import !== 'undefined') {
return;
}
throw new Error(
`${process.env.PACKAGE_NAME}: You were trying to call "globalCss" function without configuring your bundler. Make sure to install the bundler specific plugin and use it. @pigment-css/vite-plugin for Vite integration or @pigment-css/nextjs-plugin for Next.js integration.`,
);
Expand Down
8 changes: 8 additions & 0 deletions packages/pigment-css-react/src/keyframes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
/**
* `__wyw_dynamic_import` is a special global var that is set during the evaluation phase by wyw.
* So during eval phase, it can happen that some code is calling the runtime function.
* We do not want to throw error in that case as we want the evaluation to happen.
*/
export default function keyframes() {
if (typeof __wyw_dynamic_import !== 'undefined') {
return;
}
throw new Error(
`${process.env.PACKAGE_NAME}: You were trying to call "keyframes" function without configuring your bundler. Make sure to install the bundler specific plugin and use it. @pigment-css/vite-plugin for Vite integration or @pigment-css/nextjs-plugin for Next.js integration.`,
);
Expand Down
8 changes: 8 additions & 0 deletions packages/pigment-css-react/src/useTheme.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
/**
* `__wyw_dynamic_import` is a special global var that is set during the evaluation phase by wyw.
* So during eval phase, it can happen that some code is calling the runtime function.
* We do not want to throw error in that case as we want the evaluation to happen.
*/
export default function useTheme() {
if (typeof __wyw_dynamic_import !== 'undefined') {
return;
}
throw new Error(
`${process.env.PACKAGE_NAME}: You were trying to call "useTheme" function without configuring your bundler. Make sure to install the bundler specific plugin and use it. @pigment-css/vite-plugin for Vite integration or @pigment-css/nextjs-plugin for Next.js integration.`,
);
Expand Down

0 comments on commit 794b443

Please sign in to comment.