Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 391a401

Browse files
author
Je
committed
refactor: improve import props
1 parent bc1e179 commit 391a401

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

importor.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@ export function resetImports() {
1212

1313
interface ImportProps {
1414
from: string
15-
rawPath: string
16-
resolveDir: string
1715
}
1816

19-
export function Import({ from, rawPath, resolveDir }: ImportProps) {
17+
export function Import(props: ImportProps) {
18+
const { from: path, rawPath, resolveDir } = props as any
2019
if (reStyleModuleExt.test(rawPath)) {
21-
return React.createElement(StyleLoader, { path: from, rawPath, resolveDir })
20+
return React.createElement(StyleLoader, { path: util.cleanPath(`${resolveDir}/${path}`), rawPath })
2221
}
2322
// todo: more loaders
2423
return null
@@ -27,16 +26,15 @@ export function Import({ from, rawPath, resolveDir }: ImportProps) {
2726
interface LoaderProps {
2827
path: string
2928
rawPath: string
30-
resolveDir: string
3129
}
3230

33-
export function StyleLoader({ path, rawPath, resolveDir }: LoaderProps) {
31+
export function StyleLoader({ path }: LoaderProps) {
3432
if (typeof Deno !== 'undefined') {
35-
serverImports.add(util.cleanPath(`${resolveDir}/${path}`))
33+
serverImports.add(path)
3634
}
3735

3836
useEffect(() => {
39-
import(util.cleanPath(`/_aleph/${resolveDir}/${path}`))
37+
import(`/_aleph${path}`)
4038
return () => { }
4139
}, [])
4240

0 commit comments

Comments
 (0)