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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help needed for build checking #269

Closed
sahandsn opened this issue Sep 20, 2024 · 5 comments
Closed

help needed for build checking #269

sahandsn opened this issue Sep 20, 2024 · 5 comments

Comments

@sahandsn
Copy link

is there any more documentation/tutorials on how can i integrate unjs/jiti for checking env variables at build time with next.config.mjs?

@tiavina-mika
Copy link

+1

@tiavina-mika
Copy link

here is an example of how to use it
https://github.com/t3-oss/t3-env/tree/main/examples/nextjs

@Teekola
Copy link

Teekola commented Oct 2, 2024

It seems like using jiti with a higher version than in the example (1.21.0) will cause a webpack warning.

Next config file

// next.config.mjs

import createJiti from "jiti";
import { fileURLToPath } from "node:url";

const jiti = createJiti(fileURLToPath(import.meta.url));

// Import env here to validate during build. Using jiti we can import .ts files
jiti("./src/env/server");
jiti("./src/env/client");

Warning that is logged on both locale development and on Vercel. On locale development this is logged even on npm run dev, on Vercel this is during build.

<w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Parsing of /vercel/path0/node_modules/jiti/lib/jiti.mjs for build dependencies failed at 'import(id)'.
<w> Build dependencies behind this expression are ignored and might cause incorrect cache invalidation.

Switching to the older jiti version (1.21.0) made the warning disappear.

@kduprey
Copy link

kduprey commented Oct 5, 2024

Is there a way to resolve this warning with the latest version of jiti? Or would this be a defect of the t3-env library?

@juliusmarminge
Copy link
Member

i think this is an incompatibility with jiti and next.config - not sure what this pacakge can do other than keep recommending people use next.config.mjs (or .js with type: module) and jsdoc for types. I personally think Next shipped TS config support "too early" and doesn't match expectations

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

No branches or pull requests

5 participants