function acornEnvPlugin(env, ctx) {
	return ({ types: t }) => {
		return {
			name: 'transform-env',
			visitor: {
				// False positive: When a binding is in scope with `process` as name.
				// Example: `import * as process from "./process.js";`
				ImportDeclaration(path) {
					for (let i = 0; i < path.node.specifiers.length; i++) {
						const spec = path.node.specifiers[i];
						if (t.isImportNamespaceSpecifier(spec) || t.isImportDefaultSpecifier(spec) || t.importSpecifier(spec)) {
							if (t.isIdentifier(spec.local) && spec.local.name === 'process') {
								ctx.falsePositive = true;
								return;
							}
						}
					}
				},
				MemberExpression(path) {
					if (ctx.falsePositive) return;

					const source = path.getSource();
					const match = source.match(/^(?:import\.meta|process)\.env\.(.+)/);

					if (match) {
						const value = env[match[1]];
						// Replace non-existing env variables with undefined
						if (value === undefined) {
							path.replaceWith({
								type: 'Identifier',
								name: 'undefined'
							});
						} else {
							path.replaceWithString(JSON.stringify(value));
						}
					}
				}
			}
		};
	};
}
Plugin to replace `process.env.MY_VAR` or `import.meta.env.MY_VAR` with
the actual value.
@param {Record<string, string>} env
@param {{falsePositive: boolean}} ctx