Files
danny-avila--librechat/client/test/babel-plugin-transform-import-meta-hot.cjs
wehub-resource-sync e115934061
Publish `@librechat/data-schemas` to NPM / pack (push) Failing after 8s
Publish `@librechat/client` to NPM / pack (push) Failing after 0s
GitNexus Index / index (push) Failing after 1s
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Has been skipped
Sync Helm Chart Tags / Sync chart tags (push) Failing after 2s
Publish `librechat-data-provider` to NPM / pack (push) Failing after 1s
Docker Dev Images Build / build (Dockerfile, librechat-dev, node) (push) Failing after 1s
Docker Dev Images Build / build (Dockerfile.multi, librechat-dev-api, api-build) (push) Failing after 0s
Sync Helm Chart Tags / Ignore non-main push (push) Has been skipped
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Failing after 1s
Publish `@librechat/client` to NPM / publish-npm (push) Has been cancelled
Publish `librechat-data-provider` to NPM / publish-npm (push) Has been cancelled
GitNexus Index / post-index (push) Has been cancelled
Publish `@librechat/data-schemas` to NPM / publish-npm (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:08:12 +08:00

32 lines
1.1 KiB
JavaScript

/**
* Babel plugin that replaces `import.meta.hot` with `undefined`.
*
* `babel-plugin-transform-import-meta` handles standard properties (url,
* filename, dirname, resolve) but does NOT handle the Vite-specific `hot`
* property. Jest runs in CommonJS/Node where `import.meta` is unavailable,
* so any reference to `import.meta.hot` causes a SyntaxError.
*
* Replacing it with `undefined` makes the HMR guard blocks dead-code:
* import.meta.hot?.data → undefined?.data → undefined
* if (import.meta.hot) → if (undefined) → skipped
*/
module.exports = function transformImportMetaHot() {
return {
name: 'transform-import-meta-hot',
visitor: {
MemberExpression(path) {
const { node } = path;
if (
node.object.type === 'MetaProperty' &&
node.object.meta.name === 'import' &&
node.object.property.name === 'meta' &&
node.property.type === 'Identifier' &&
node.property.name === 'hot'
) {
path.replaceWith({ type: 'Identifier', name: 'undefined' });
}
},
},
};
};