Skip to content

Commit

Permalink
fix:windows system should format slash
Browse files Browse the repository at this point in the history
  • Loading branch information
nonzzz committed Jan 9, 2024
1 parent 54cf9de commit cdf96d3
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion e2e/fixtures/open-props/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
</head>
<body>
<div id="app"></div>
<script type="module" src="./main.tsx"></script>
<script type="module" src="./src/main.tsx"></script>
</body>
</html>
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions e2e/fixtures/path-alias/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
/* eslint-disable jsx-a11y/click-events-have-key-events */
import * as stylex from '@stylexjs/stylex'
import { useState } from 'react'
import { colors } from '@/themes/color.stylex'

const styles = stylex.create({
text: { fontSize: '20px', cursor: 'pointer' },
blue: {
color: 'blue'
color: colors.blue
},
red: {
color: 'red'
color: colors.red
}
})

Expand Down
6 changes: 6 additions & 0 deletions e2e/fixtures/path-alias/src/themes/color.stylex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineVars } from '@stylexjs/stylex'

export const colors = defineVars({
blue: 'blue',
red: 'red'
})
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
"./url.js": {
"types": "./dist/url.d.ts",
"import": "./dist/url.mjs",
"require": "./dist/url.js"
},
"./*": "./*"
},
"files": [
Expand Down
6 changes: 3 additions & 3 deletions src/patch-alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// convert:
// import { kind } from './x.stylex'
import path from 'path'
import { normalizePath } from 'vite'
import MagicString from 'magic-string'
import type { ImportSpecifier } from 'es-module-lexer'
import type { Alias, AliasOptions, Plugin } from 'vite'
Expand All @@ -22,9 +23,8 @@ interface PatchAliasOptions {
type AliasPath = ImportSpecifier & { relative: string }

function handleRelativePath(from: string, to: string) {
let relativePath = path.relative(path.dirname(from), to).replace(/\.\w+$/, '')
relativePath = `./${relativePath}`
return relativePath
const relativePath = path.relative(path.dirname(from), to).replace(/\.\w+$/, '')
return `./${normalizePath(relativePath)}`
}

export function createPatchAlias(alias: AliasOptions & Alias[], opts: PatchAliasOptions) {
Expand Down

0 comments on commit cdf96d3

Please sign in to comment.