X Tutup
Skip to content

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

Merged
AlemTuzlak merged 4 commits intoTanStack:mainfrom
Nsttt:fix/rspack-import-meta-property-access
Mar 10, 2026
Merged

fix(devtools): avoid direct import.meta access in rspack#349
AlemTuzlak merged 4 commits intoTanStack:mainfrom
Nsttt:fix/rspack-import-meta-property-access

Conversation

@Nsttt
Copy link
Contributor

@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: 65c525a

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
@Nsttt Nsttt force-pushed the fix/rspack-import-meta-property-access branch from 3730cba to 65c525a Compare March 10, 2026 10:22
@nx-cloud
Copy link

nx-cloud bot commented Mar 10, 2026

View your CI Pipeline Execution ↗ for commit 65c525a

Command Status Duration Result
nx affected --targets=test:eslint,test:sherif,t... ✅ Succeeded 1m 14s View ↗
nx run-many --targets=build --exclude=examples/** ✅ Succeeded 11s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-10 15:54:55 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 10, 2026

More templates

@tanstack/devtools

npm i https://pkg.pr.new/@tanstack/devtools@349

@tanstack/devtools-client

npm i https://pkg.pr.new/@tanstack/devtools-client@349

@tanstack/devtools-ui

npm i https://pkg.pr.new/@tanstack/devtools-ui@349

@tanstack/devtools-utils

npm i https://pkg.pr.new/@tanstack/devtools-utils@349

@tanstack/devtools-vite

npm i https://pkg.pr.new/@tanstack/devtools-vite@349

@tanstack/devtools-event-bus

npm i https://pkg.pr.new/@tanstack/devtools-event-bus@349

@tanstack/devtools-event-client

npm i https://pkg.pr.new/@tanstack/devtools-event-client@349

@tanstack/preact-devtools

npm i https://pkg.pr.new/@tanstack/preact-devtools@349

@tanstack/react-devtools

npm i https://pkg.pr.new/@tanstack/react-devtools@349

@tanstack/solid-devtools

npm i https://pkg.pr.new/@tanstack/solid-devtools@349

@tanstack/vue-devtools

npm i https://pkg.pr.new/@tanstack/vue-devtools@349

commit: d68697d

@AlemTuzlak AlemTuzlak merged commit 0dfc04a into TanStack:main Mar 10, 2026
4 checks passed
@github-actions github-actions bot mentioned this pull request Mar 10, 2026
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

3 participants

X Tutup