Aliases not working on windows
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
Still no one want to answer me?
Thanks for reporting the issue
Piggy backing off this.
I'm using the CLI on windows via a config file. (v.0.14.0) I've tried using the styleXConfig property like it is in the cli example
styleXConfig: {
aliases: {
'@/*': ['./source/*'],
},
},
But that doesn't work.
I get the same error as @me16eskandari
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
A coworker is having the same issue on Windows, while the setup we have perfectly work on unix system.
Could #856 help ?
Sorry to bother with this issue, but that's actually a simple problem that could happen to people using Windows with typescript aliases, something people are using more and more since various projects setup alias in there default app template. I am not myself using Windows, but some coworkers are and cannot contribute to the project since it's just no building correctly since I introduced stylex (via RSD).
Could you point me where to have a look to resolve this Windows related issue ? This must have to do with path resolving and I am not sure where to look. Also, maybe, as mentioned earlier, it could be nice to know if work done in #856 could help and solve this issue ?