local: node:22.3.0 nextjs:14.1.1 sdk-react:1.0.31
prod: FROM node:18.17.0-alpine AS base
When running on localhost, the code showIf: options => options.get('col') === 'other' works correctly. However, when deployed to the testing or production environment, it doesn’t work despite the code being the same. Is there a specific setting that needs to be configured?
It looks like you’re encountering an issue where the showIf function works correctly on your local development environment but fails when deployed to a testing or production environment. This discrepancy can arise due to differences in environments, such as how JavaScript is processed or differences in the builder SDK or runtime environments.
Here are some steps and considerations that might help you identify and resolve the issue:
Step-by-Step Debugging and Resolution
Check Node Version Compatibility:
Ensure that both local and production environments are using compatible Node.js versions. Since there is a significant version difference (22.3.0 locally and 18.17.0 in production), this might cause inconsistencies. Try aligning the Node.js versions and see if this resolves the issue.
Update your Dockerfile to use Node.js 22.3.0 for production:
FROM node:22.3.0-alpine AS base
Verify SDK and Configuration:
Ensure that the builder SDK and configurations are consistent across environments. Here’s how you can debug and ensure configurations are correctly aligned.
Check Environment Variables:
Verify that you have the correct environment variables set in all environments. Sometimes the build process or runtime environment might have different configurations which can cause inconsistencies.
Add Debug Logs in the showIf Function:
Add console logs to the showIf function to debug what’s being passed to the function in the production environment:
After deploying, check the console logs in your production environment to see what is being logged.
Inspect Build Output and Bundling:
Ensure that the showIf function is not being altered or stripped out during the build process. Check the resulting JS bundles to ensure the code remains intact.
Alternative Approach
If the above steps don’t resolve the issue, consider using a more indirect approach such as using state or context to maintain options and conditionally display components.
Following these debugging steps will help you identify why the behavior differs between environments. Aligning the Node.js versions, adding debug logs, and ensuring consistent configurations should help resolve the issue.
If the issue persists, consider reaching out to Builder.io support with detailed logs and the specific discrepancies observed between local and production environments for further assistance.
prod console
fs.js:4 Evaluation error: SyntaxError: Unexpected token '=>'
at new Function (<anonymous>)
at safeEvaluate (main.2b9a90dc.chunk.js:541:136)
at 233.b9216e5b.chunk.js:197:34152
at Array.filter (<anonymous>)
at FieldsForm_FieldsFormEditor.render (233.b9216e5b.chunk.js:197:33870)
at allowStateChanges (216.daddc10f.chunk.js:30:14474)
at 216.daddc10f.chunk.js:417:1276
at trackDerivedFunction (216.daddc10f.chunk.js:30:10780)
at Reaction2.track (216.daddc10f.chunk.js:45:1548)
at FieldsForm_FieldsFormEditor.reactiveRender [as render] (216.daddc10f.chunk.js:417:1185) in return (function e=>(console.log("showIf options in production:",e),console.log('showIf options.get("btn"):',e.get("btn")),!0===e.get("btn"))).apply(this, arguments)