Files
gui/pkgs/build/babel-plugin-process-env-to-meta.js
zeekay 6d0dd44bfd chore: flatten pkgs/packages/* → pkgs/* (one canonical pkgs dir)
ONE WAY ONLY: 'pkgs' is the canonical name for any directory holding
packages. The redundant 'pkgs/packages/' sub-level is dropped — every
package now lives at pkgs/<name>/ (with categorical sub-groups
pkgs/compiler/, pkgs/core/, pkgs/ui/ unchanged since they are
sub-systems, not just 'packages').

- mv pkgs/packages/* → pkgs/* (24 packages)
- rm pkgs/packages/hanzogui-dev-config (orphan: only had dist/ artifacts,
  no source; gui-dev-config is the canonical @hanzogui/dev-config)
- package.json workspaces: drop pkgs/packages glob, add ./pkgs/*
- tsconfig.json: rewrite paths + 15 references entries
- apps/{demos,kitchen-sink,gui.hanzo.ai}/tsconfig.json: reference paths
- .github/workflows/publish-gui.yml: directory walk list
- pkgs/{get,recipes}/package.json: repository.directory

bun.lock will regenerate on next install.
2026-05-27 17:33:42 -07:00

34 lines
933 B
JavaScript

const hasReplaced = Symbol()
module.exports = function viteMetaEnvBabelPlugin({ template, types: t }) {
return {
name: 'vite-process-to-meta-env',
visitor: {
MemberExpression(path) {
if (path[hasReplaced]) return
const envNode = t.isMemberExpression(path.node.object) && path.node.object
const variableName = t.isIdentifier(path.node.property) && path.node.property.name
if (!envNode || !variableName) {
return
}
const isProcess =
t.isIdentifier(envNode.object) && envNode.object.name === 'process'
const isEnvVar =
t.isIdentifier(envNode.property) && envNode.property.name === 'env'
if (!isProcess || !isEnvVar) {
return
}
path.replaceWith(
template.expression('import.meta.env.%%variableName%%')({ variableName })
)
path[hasReplaced] = true
},
},
}
}