Repository navigation
Tests: Fix PostCSS browser-externalized warnings in Vitest - #83091
Conversation
🤖 PR meta 🤖📦 Bundle sizeSize Change: -16 B (0%) Total Size: 8.22 MB 📦 View Changed
|
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
I'm seeing the following when running the first steps. Is this expected? |
3d868d8 to
64213f5
Compare
|
@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. |
b1bd806 to
b29f48e
Compare
…#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>
Follow-up to #80855.
Upstream tracking:
fromwarning: proposed fix madyankin/postcss-modules#173, related issue vitejs/vite#15410.What?
Remove PostCSS's browser-externalized
path,url,source-map-js, andfswarnings 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.mjsand 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
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.npm run test:unit -- packages/block-editor/src/utils/test/transform-styles.js.npm run test:unit -- --project=browser --maxWorkers=4. The worker limit retains every test and reduces local CPU contention.The separate missing-
fromwarning 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 loadstransformStyles, thenpostcss/lib/processor. Throughlazy-result, this reaches PostCSS'smap-generator,input, andprevious-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
fromoption and Vite's unanalyzable dynamic import inuse-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.