Skip to content

Commit 0430e86

Browse files
committed
fix: update tests and detect *all* relative paths
1 parent 639a876 commit 0430e86

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

packages/babel-plugin/__tests__/stylex-transform-alias-config-test.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ describe('StyleX Alias Configuration', () => {
5858
const manager = new StateManager(state);
5959

6060
expect(manager.options.aliases).toEqual({
61-
components: ['./src/components'],
62-
'utils/*': ['./src/utils/*'],
61+
components: [path.join(tmpDir, './src/components')],
62+
'utils/*': [path.join(tmpDir, './src/utils/*')],
6363
});
6464
});
6565

@@ -80,8 +80,8 @@ describe('StyleX Alias Configuration', () => {
8080
const manager = new StateManager(state);
8181

8282
expect(manager.options.aliases).toEqual({
83-
'@components': ['src/components'],
84-
'@utils': ['src/utils'],
83+
'@components/*': [path.join(tmpDir, 'src/components/*')],
84+
'@utils/*': [path.join(tmpDir, 'src/utils/*')],
8585
});
8686
});
8787

@@ -99,8 +99,8 @@ describe('StyleX Alias Configuration', () => {
9999
const manager = new StateManager(state);
100100

101101
expect(manager.options.aliases).toEqual({
102-
'@components/': ['./src/components/'],
103-
'@utils/': ['./src/utils/'],
102+
'@components/': [path.join(tmpDir, 'src/components')],
103+
'@utils/': [path.join(tmpDir, 'src/utils')],
104104
});
105105
});
106106

@@ -130,9 +130,9 @@ describe('StyleX Alias Configuration', () => {
130130
const manager = new StateManager(state);
131131

132132
expect(manager.options.aliases).toEqual({
133-
components: ['./src/components'],
134-
'@utils': ['src/utils'],
135-
'@styles/': ['./src/styles/'],
133+
components: [path.join(tmpDir, 'src/components')],
134+
'@utils/*': [path.join(tmpDir, 'src/utils/*')],
135+
'@styles/': [path.join(tmpDir, 'src/styles')],
136136
});
137137
});
138138

@@ -148,14 +148,14 @@ describe('StyleX Alias Configuration', () => {
148148

149149
state.opts = {
150150
aliases: {
151-
components: './custom/path',
151+
components: path.join(tmpDir, 'custom/path'),
152152
},
153153
};
154154

155155
const manager = new StateManager(state);
156156

157157
expect(manager.options.aliases).toEqual({
158-
components: ['./custom/path'],
158+
components: [path.join(tmpDir, 'custom/path')],
159159
});
160160
});
161161

packages/babel-plugin/src/utils/state-manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ export default class StateManager {
644644
(Array.isArray(value) ? value : [value]).map((p) => {
645645
const endsWithStar = p.endsWith('/*');
646646
let basePath = p.replace(/\/\*$/, '');
647-
if (basePath.startsWith('.')) {
647+
if (!path.isAbsolute(basePath)) {
648648
basePath = path.resolve(projectDir, basePath);
649649
}
650650
if (endsWithStar) {

0 commit comments

Comments
 (0)