Skip to content

fix(devtools): avoid direct import.meta access in rspack#349

Open
Nsttt wants to merge 3 commits intoTanStack:mainfrom
Nsttt:fix/rspack-import-meta-property-access
Open

fix(devtools): avoid direct import.meta access in rspack#349
Nsttt wants to merge 3 commits intoTanStack:mainfrom
Nsttt:fix/rspack-import-meta-property-access

Conversation

@Nsttt
Copy link

@Nsttt Nsttt commented Feb 13, 2026

Summary

Closes #348

  • switch import.meta?.env usages in devtools runtime code to property access (import.meta.env?.*)
  • keep behavior unchanged while avoiding rspack's direct import.meta parser warning path
  • add a regression test that scans packages/devtools/src and fails on direct import.meta forms (import.meta?., typeof import.meta, = import.meta)

Why

Rspack warns on direct import.meta access:

Critical dependency: Accessing import.meta directly is unsupported (only property access or destructuring is supported)

This change hardens devtools source against those patterns.

Validation

  • pnpm --filter @tanstack/devtools test:eslint
  • pnpm --filter @tanstack/devtools test:lib
  • pnpm nx run @tanstack/devtools:build
  • pnpm --filter @tanstack/devtools test:types
  • pnpm --filter @tanstack/devtools test:build

Copilot AI review requested due to automatic review settings February 13, 2026 11:56
@changeset-bot
Copy link

changeset-bot bot commented Feb 13, 2026

🦋 Changeset detected

Latest commit: 796db7c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@tanstack/devtools Patch
@tanstack/preact-devtools Patch
@tanstack/react-devtools Patch
@tanstack/solid-devtools Patch
@tanstack/vue-devtools Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Rspack compatibility issues by avoiding direct import.meta access patterns that trigger Rspack parser warnings. The changes move optional chaining from import.meta itself to its properties (e.g., import.meta?.envimport.meta.env?.), maintaining the same runtime behavior while satisfying Rspack's requirement for property-only access.

Changes:

  • Replaced import.meta?.env with import.meta.env?. in two locations to avoid direct import.meta access
  • Added a regression test that scans source files and fails on forbidden patterns: import.meta?., typeof import.meta, and = import.meta

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
packages/devtools/tests/import-meta-compat.test.ts New test file that recursively scans src/ for forbidden import.meta patterns to prevent regressions
packages/devtools/src/core.tsx Changed import.meta?.env?.SSR to import.meta.env?.SSR for Rspack compatibility
packages/devtools/src/components/source-inspector.tsx Changed import.meta?.env?.BASE_URL to import.meta.env?.BASE_URL for Rspack compatibility

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Nsttt Nsttt marked this pull request as draft February 13, 2026 12:00
@Nsttt Nsttt marked this pull request as ready for review February 15, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Rspack critical dependency warning from @tanstack/devtools import.meta access

1 participant