Skip to content

Tests: Fix PostCSS browser-externalized warnings in Vitest - #83091

Merged
ciampo merged 4 commits into
trunkfrom
codex/fix-browser-externalized-warnings
Sep 25, 2026
Merged

ciampo merged 4 commits into
trunkfrom
codex/fix-browser-externalized-warnings

Conversation

@ciampo

@ciampo ciampo commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #80855.

Upstream tracking:

What?

Remove PostCSS's browser-externalized path, url, source-map-js, and fs warnings from successful Vitest Browser Mode runs.

Why?

PostCSS explicitly disables these modules in its browser mappings. Vite replaces them with proxies that warn when PostCSS checks which APIs are available. The LinkControl keyboard tests reproduce 23 warnings despite passing. PostCSS's public entry point produces the same warnings.

How?

Honor the installed PostCSS package's disabled browser imports during Browser dependency optimization. Resolution for other packages and the existing console enforcement stay unchanged.

The temporary resolver links to the upstream issue. Once the installed Vite version fixes it, remove postcss-browser-plugin.mjs and its optimizer registration. Keep the Browser regression test and rerun the full Browser suite to verify removal.

The regression imports the real editor style transformer inside the test, checks for warnings, and verifies selector prefixing and asset URL rebasing. Existing tests provide broader coverage.

Testing Instructions

  1. Run npm run test:unit -- --project=browser test/unit/config/postcss.browser.test.js packages/block-editor/src/components/link-control/test/keyboard-selection.browser.test.js. Both files should pass without browser-externalized warnings. The new regression fails with the resolver removed.
  2. Run npm run test:unit -- packages/block-editor/src/utils/test/transform-styles.js.
  3. Run the full Browser suite with npm run test:unit -- --project=browser --maxWorkers=4. The worker limit retains every test and reduces local CPU contention.

The separate missing-from warning can still appear. It also reproduces on trunk and remains pending the CSS Modules fix linked above.

Import trace and verification

The LinkControl search input imports the components barrel, which exports __unstableEditorStyles. That loads transformStyles, then postcss/lib/processor. Through lazy-result, this reaches PostCSS's map-generator, input, and previous-map, which probe the disabled APIs during initialization.

The resolver reads the installed PostCSS browser mappings through the block-editor workspace. It affects only Browser dependency optimization. Production imports and Node/jsdom resolution are unchanged.

After rebasing onto trunk 72e0cc4f894, a fresh dependency install and full Browser run passed all 122 files with zero browser-externalized warnings. The 30 existing transformer tests, build, typecheck, targeted lint, test conventions, and test routing also passed.

Two pre-existing diagnostics remain: PostCSS's missing from option and Vite's unanalyzable dynamic import in use-widget-types.ts. Npm installation diagnostics, failure artifacts, and console enforcement are outside this change.

Use of AI Tools

Codex investigated, implemented, and verified the change. An independent Codex agent performed an adversarial review.

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

📦 Bundle size

Size Change: -16 B (0%)

Total Size: 8.22 MB

📦 View Changed
Filename Size Change
build/scripts/editor/index.min.js 613 kB -16 B (0%)

b29f48e Run

@ciampo ciampo added the [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. label Sep 22, 2026
@ciampo ciampo self-assigned this Sep 24, 2026
@ciampo
ciampo marked this pull request as ready for review September 24, 2026 09:40
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka

Copy link
Copy Markdown
Member

I'm seeing the following when running the first steps. Is this expected?

A PostCSS plugin did not pass the `from` option to `postcss.parse`. This may cause imported assets to be incorrectly transformed. If you've recently added a PostCSS plugin that raised this warning, please contact the package author to fix the issue.

@ciampo
ciampo force-pushed the codex/fix-browser-externalized-warnings branch from 3d868d8 to 64213f5 Compare September 24, 2026 16:48
@ciampo

ciampo commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

@Mamaduka Yes, I reproduced this on trunk too. The CSS Modules warning has a proposed fix in postcss-modules#173, with the related asset-path issue tracked in vite#15410.

This PR addresses the separate browser-externalized warnings tracked in vite#23512. I've linked both problems in the description and code comments.

@manzoorwanijk manzoorwanijk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks good now.

Comment thread test/unit/config/postcss.browser.test.js Outdated
@ciampo
ciampo force-pushed the codex/fix-browser-externalized-warnings branch from b1bd806 to b29f48e Compare September 25, 2026 09:08
@ciampo
ciampo enabled auto-merge (squash) September 25, 2026 09:15
@ciampo
ciampo merged commit fb606df into trunk Sep 25, 2026
65 of 66 checks passed
@ciampo
ciampo deleted the codex/fix-browser-externalized-warnings branch September 25, 2026 09:20
@github-actions github-actions Bot added this to the Gutenberg 24.2 milestone Sep 25, 2026
widoz pushed a commit to widoz/gutenberg that referenced this pull request Oct 2, 2026
…#83091)

* Tests: Honor PostCSS browser mappings in Vitest

* Tests: Document upstream tracking for PostCSS workaround

* Tests: Link upstream tracking for remaining PostCSS warning

* Tests: Rely on shared PostCSS warning checks

---

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants