-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
Debug mode #120
Comments
Hello there 👋 My recommendation regarding env vars has always been "use them at runtime, not build time". Here's how I usually use them: publicRuntimeConfig: {
BASE_URL: process.env.BASE_URL,
SERVICE_STUFF_URL: process.env.SERVICE_STUFF_URL,
ENABLE_CIMODE:
process.env.ENABLE_CIMODE === 'true' ||
process.env.NODE_ENV !== 'production',
}, Then, from any file: import getConfig from 'next/config';
const { SERVICE_STUFF_URL } = getConfig().publicRuntimeConfig; The reason why is I have multiple environments (dev, staging, prod...), and I need to update these values for each environment, but with a single build. Is that of any inspiration to you?
What do you mean? |
That said, this is an interesting problem, I am not sure if this is in scope of this plug-in, but I'd be curious to know how you managed to fix it. |
Public runtime config can be problematic in Next as you lose the serverless target and they are not really recommended, I need to keep the code as generic/"raw Next" as possible. I am not fond of Next config system anyway, I don't see the point of making it runtime only, I would rather use By call to debug I mean more precisely we should have messages about whether the node modules were found, and whether they are transpiled or ignored. Currently, if I try to transpile "whatever-module" that do not even exist, I don't get any message, so I can't tell whether my module is actually being transpiled or not. But the code is run, because if I put They way I understand it, In the meantime, my solution is just to not publish those packages on NPM, I just store them in my Next boilerplate. I publish only actual, non-specific to Next NPM packages. I think there should be more official guidelines about publishing packages for Next (vercel/next.js#9133 (comment)) |
Ah, I see. A debug mode could be interesting, but it will be really verbose in the console (you'll have thousands of modules displayed). What I could is only list the modules that are transpiled. Any preferences?
Yes and no. What the plugin does is tell Webpack/Babel to not ignore some directories in I have no idea of the incidence on |
Thanks! Yeah that's what I thought, just displaying the transpiled modules specified in the options, that are actually found by your plugin. I didn't dig the code that much to be fair, as I have a workaround for now, we don't expect an usage at scale of those Next packages until a few months. |
Fixed in #132 It's noisy, but convenient. If you would like to see other things logged, don't hesitate to open a PR or open a new issue 👍 |
Is your feature request related to a problem? Please describe.
I am using a rather complex setup:
I am hitting this issue: vercel/next.js#17262, I can't have
process.env
to be correctly transpiled.I think that I should provide Next specific plugins as raw packages instead of building them and then publishing, and expect end users to use
next-transpile-modules
.But I suspect that my package is not even transpiled in the first place. If I had packages that do not exist in the first place, I don't see if they are actually transpiled.
Describe the solution you'd like
Calls to
debug
everywhere :)The text was updated successfully, but these errors were encountered: