Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@react-aria/optimize-locales-plugin does not work on Windows #7462

Closed
mikecao opened this issue Dec 4, 2024 · 1 comment · Fixed by #7568
Closed

@react-aria/optimize-locales-plugin does not work on Windows #7462

mikecao opened this issue Dec 4, 2024 · 1 comment · Fixed by #7568
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@mikecao
Copy link

mikecao commented Dec 4, 2024

Provide a general summary of the issue here

When using esbuild and adding the following entry to plugins:

optimizeLocales.esbuild({
  locales: ['en-US'],
})

I get the following error:

X [ERROR] Do not know how to load path: locales-plugin:E:\dev\project\node_modules\@react-aria\optimize-locales-plugin/empty.js

    node_modules/react-aria-components/dist/intlStrings.mjs:1:32:
      1 │ import $bK1z9$arAEmodulejs from "./ar-AE.mjs";
        ╵                                 ~~~~~~~~~~~~~

This is due to this line:

Windows uses backslashes so if you simply concatenate strings you'll get malformed paths. You need to use the node path module.

🤔 Expected Behavior?

It should not throw errors.

😯 Current Behavior

It throws an error because the path is malformed.

💁 Possible Solution

Use path.join or path.resolve.

🔦 Context

No response

🖥️ Steps to Reproduce

You just need to run esbuild with the plugin on Windows.

import {build} from 'esbuild';
import optimizeLocales from '@react-aria/optimize-locales-plugin';

build({
  plugins: [
    optimizeLocales.esbuild({
      locales: ['en-US', 'fr-FR']
    })
  ]
});

Version

@react-aria/optimize-locales-plugin v1.1.3

What browsers are you seeing the problem on?

Other

If other, please specify.

Node v21.7.1

What operating system are you using?

Windows 11

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

@snowystinger snowystinger added bug Something isn't working good first issue Good for newcomers labels Dec 4, 2024
@snowystinger
Copy link
Member

Thanks for reporting, I think we can solve this using node's pathSep/path.join to handle this for us. Are you willing to submit a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants