Files
langflow/src/frontend/transform-import-meta.js
Cristhian Zanforlin Lousa cd74c19cdd fix: Migrate env vars from process.env to import.meta.env (#10315)
* 🐛 (feature-flags.ts): update usage of process.env to import.meta.env for Vite compatibility
🔧 (vite.config.mts): replace process.env with import.meta.env in Vite configuration for better integration with Vite bundler

* 🔧 (constants.ts): replace process.env with import.meta.env for Vite compatibility
🔧 (vite-env.d.ts): declare ImportMetaEnv and ImportMeta interfaces for Vite compatibility

*  (jest.config.js): Update Jest configuration to use a custom transformer for replacing import.meta.env with process.env for compatibility
 (transform-import-meta.js): Add custom Jest transformer to replace import.meta.env with process.env for compatibility with Jest testing framework

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Carlos Coelho <80289056+carlosrcoelho@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-10-22 17:43:10 +00:00

23 lines
657 B
JavaScript

// Custom Jest transformer to replace import.meta.env with process.env
const tsJest = require("ts-jest").default;
module.exports = {
createTransformer() {
const tsJestTransformer = tsJest.createTransformer();
return {
...tsJestTransformer,
process(sourceText, sourcePath, options) {
// Replace import.meta.env with process.env before ts-jest processes it
let modifiedSource = sourceText.replace(
/import\.meta\.env/g,
"process.env",
);
// Call the original ts-jest transformer
return tsJestTransformer.process(modifiedSource, sourcePath, options);
},
};
},
};