facebook / facebook/stylex

Aliases not working on windows

Open
#1,045 8 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
10.3k
Forks
481
Avg merge
3d 8h
Merged PRs (30d)
13

Description

### Describe the issue

In my next.js app I configure stylex.js using postcss

**babel.config.js**
```
const path = require("path");

module.exports = {
presets: ['next/babel'],
plugins: [
[
'@stylexjs/babel-plugin',
{
dev: process.env.NODE_ENV === 'development',
stylexSheetName: '<>',
runtimeInjection: false,
genConditionalClasses: true,
treeshakeCompensation: true,
aliases: {
"@/stylex/*": [path.join(__dirname, "src", "stylex", "*")]
},
unstable_moduleResolution: {
type: 'commonJS',
rootDir: __dirname,
},
},
],
],
};
```

**postcss.config.js**

```
const babelConfig = require('./babel.config.js');

module.exports = {
plugins: {
'@stylexjs/postcss-plugin': {
include: [
'./**/*.{js,jsx,ts,tsx}',
// any other files that should be included
// this should include NPM dependencies that use StyleX
],
useCSSLayers: false,
babelConfig
},
},
};
```

and I import colors from src/vars.stylex.ts like this
`import { colors } from '@/stylex/vars.stylex';`

It worked fine on macOs and linux, but got build error on windows
`SyntaxError: Could not resolve the path to the imported file.
Please ensure that the theme file has a .stylex.js or .stylex.ts file extension and follows the
rules for defining variariables:`

### Expected behavior

It should build successfully on windows,

### Steps to reproduce

run yarn build on terminal on windows

### Test case

_No response_

### Additional comments

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.