From 6b54dd863044c9aef03e38a1edda05730a44ec38 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Thu, 12 Mar 2026 12:21:00 +0100 Subject: [PATCH] Fix internal source map warnings (#19788) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR fixes an internal source map warning when running tests. To solve this, we encode the `=` as `\x3d` instead. I'm not 100% sure if Vitest was hanging on this but it solved the following warning: ``` ✓ @tailwindcss/cli src/utils/format-ns.test.ts (21 tests) 3ms 11:43:59 AM [vite] (ssr) Failed to load source map for /Users/robin/github.com/tailwindlabs/tailwindcss/packages/@tailwindcss-node/dist/index.mjs. Error: An error occurred while trying to read the map file at ${i} Error: ENOENT: no such file or directory, open '/Users/robin/github.com/tailwindlabs/tailwindcss/packages/@tailwindcss-node/dist/${i}' at open (node:internal/fs/promises:634:25) at Object.readFile (node:internal/fs/promises:1238:14) at extractSourcemapFromFile (file:///Users/robin/github.com/tailwindlabs/tailwindcss/node_modules/.pnpm/vite@7.0.0_@types+node@20.19.1_jiti@2.6.1_lightningcss@1.31.1_patch_hash=tzyxy3asfxcqc7ihroou_7epcep7uhfc7zidzdmxzgvdzwi/node_modules/vite/dist/node/chunks/dep-Bsx9IwL8.js:8349:65) at loadAndTransform (file:///Users/robin/github.com/tailwindlabs/tailwindcss/node_modules/.pnpm/vite@7.0.0_@types+node@20.19.1_jiti@2.6.1_lightningcss@1.31.1_patch_hash=tzyxy3asfxcqc7ihroou_7epcep7uhfc7zidzdmxzgvdzwi/node_modules/vite/dist/node/chunks/dep-Bsx9IwL8.js:26405:22) ``` ## Test plan 1. Existing tests pass 2. Added a failing test to ensure that the source maps are emitted correctly --- packages/@tailwindcss-node/src/source-maps.test.ts | 8 ++++++++ packages/@tailwindcss-node/src/source-maps.ts | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 packages/@tailwindcss-node/src/source-maps.test.ts diff --git a/packages/@tailwindcss-node/src/source-maps.test.ts b/packages/@tailwindcss-node/src/source-maps.test.ts new file mode 100644 index 000000000..96ff8f05c --- /dev/null +++ b/packages/@tailwindcss-node/src/source-maps.test.ts @@ -0,0 +1,8 @@ +import { expect, it } from 'vitest' +import { toSourceMap } from './source-maps' + +it('should emit source maps', () => { + let map = toSourceMap('{"version":3,"sources":[],"names":[],"mappings":""}') + + expect(map.comment('app.css.map')).toBe('/*# sourceMappingURL=app.css.map */\n') +}) diff --git a/packages/@tailwindcss-node/src/source-maps.ts b/packages/@tailwindcss-node/src/source-maps.ts index 8810b106c..58b79cb25 100644 --- a/packages/@tailwindcss-node/src/source-maps.ts +++ b/packages/@tailwindcss-node/src/source-maps.ts @@ -46,7 +46,7 @@ export function toSourceMap(map: DecodedSourceMap | string): SourceMap { let raw = typeof map === 'string' ? map : serializeSourceMap(map) function comment(url: string) { - return `/*# sourceMappingURL=${url} */\n` + return `/*# sourceMappingURL\x3d${url} */\n` } return {