WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@dav-is
Copy link
Member

@dav-is dav-is commented Dec 1, 2025

We should consider the case where Windows returns \ as the path separator and C:/ without a leading slash. We can use the node:url module to convert from the URL to a path when accessing the filesystem. When we want to analyze and transform the URL, we can normalize it. file:///C:\ is how paths on Windows start. If you run new URL('file:///C:\').pathname, it returns /C:\ with the leading slash, invalid in the filesystem, but compatible with POSIX path transforms after replacing every \. We can do this without the node:url module by simply removing the file://. This also follows the pattern that each factory has its own distinct URL and makes logs more useful.

@dav-is dav-is added type: bug It doesn't behave as expected. scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305). labels Dec 1, 2025
@mui-bot
Copy link

mui-bot commented Dec 1, 2025

Bundle size report

Bundle Parsed size Gzip size
@base-ui-components/react 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
config.module.rules.push({
test: /\/demos\/[^/]+\/client\.ts$/,
test: /[/\\]demos[/\\][^/\\]+[/\\]client\.ts$/,
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't be necessary, webpack normalizes paths to posix

Copy link
Member Author

@dav-is dav-is Dec 1, 2025

Choose a reason for hiding this comment

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

I thought so too, but it seemed to make a difference when Zeeshan tested it

@dav-is dav-is marked this pull request as ready for review December 4, 2025 03:19
* which only supports POSIX paths. The key insight is that by stripping the `file://`
* prefix and normalizing backslashes to forward slashes, we get a path that:
* - On Unix: `/home/user/file.ts` - works directly with path-module
* - On Windows: `/C:/Users/file.ts` - also works with path-module because it starts with `/`
Copy link
Member

@Janpot Janpot Dec 4, 2025

Choose a reason for hiding this comment

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

Don't we use path-module only as a browser shim? It feels wrong to me that it would ever receive absolute paths witha drive letter, regardless of the platform. I'd expect them to be project-relative at least.

Copy link
Member Author

@dav-is dav-is Dec 8, 2025

Choose a reason for hiding this comment

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

As we discussed, the intention is to preserve the value of import.meta.url as long as possible because it is fairly portable. Then if we need to transform the path, we can convert it to a portable POSIX path, then back into a file:// URL when finished. If we need to modify the filesystem, we can use the Node.js url module to convert it into a compatible Windows path.

path-module only has POSIX support so fails with native windows paths. We can normalize the paths and still use the isomorphic path-module.

If this code runs on the client side, it would be receiving an https:// URL and transforming its path.

@oliviertassinari oliviertassinari removed the type: bug It doesn't behave as expected. label Dec 8, 2025
@oliviertassinari oliviertassinari added the type: regression A bug, but worse, it used to behave as expected. label Dec 8, 2025
@Janpot
Copy link
Member

Janpot commented Dec 11, 2025

Adding #948, after merging we can enable windows on this PR to prove it works

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Dec 11, 2025
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Dec 11, 2025
@dav-is
Copy link
Member Author

dav-is commented Dec 11, 2025

Adding #948, after merging we can enable windows on this PR to prove it works

Thanks, merged your change and enabled windows and it's working with this PR now

@dav-is dav-is merged commit 04aa71c into master Dec 12, 2025
12 checks passed
@dav-is dav-is deleted the davis/fix-docs-infra-windows-support branch December 12, 2025 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305). type: regression A bug, but worse, it used to behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants