https://github.com/ahabhgk/ts-dyn2static-import-plugin
https://github.com/ahabhgk/ts-dyn2static-import-plugin
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ahabhgk/ts-dyn2static-import-plugin
- Owner: ahabhgk
- Created: 2020-11-22T07:05:31.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2020-11-22T08:33:30.000Z (over 4 years ago)
- Last Synced: 2025-01-17T03:42:03.419Z (5 months ago)
- Language: TypeScript
- Size: 39.1 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ts-dyn2static-import-plugin
> maybe impl for [ies-fe-sh/hire 简单的 TypeScript transform plugin](https://github.com/ies-fe-sh/hire/tree/master/ts-plugin)
```tsx
import React, { useState, useEffect } from 'react'export function AsyncLogin() {
const [Login, setLogin] = useState()
useEffect(() => {
import('./login').then(({ LoginComponent }) => {
setLogin(() => LoginComponent)
})
}, [])if (!Login) {
return
}
return
}
```↓ ↓ ↓ ↓ ↓ ↓
```tsx
import * as _$login from './login'
import React, { useState, useEffect } from 'react'export function AsyncLogin() {
const [Login, setLogin] = useState()
useEffect(() => {
Promise.resolve(_$login).then(({ LoginComponent }) => {
setLogin(() => LoginComponent)
})
}, [])if (!Login) {
return
}
return
}
```