plugins
plugins copied to clipboard
loadable-components should transpile `lazy` too
Plugin loadable-components
should transpile lazy
from @loadable/component
like loadable
Why ?
lazy
from @loadable/component
supports react Suspense unlike loadable
Helpful info
-
Original (babel) plugin tests - https://github.com/gregberge/loadable-components/blob/main/packages/babel-plugin/src/index.test.js#L24
-
Plugin shouldn't transpile
lazy
iflazy
imported not from@loadable/component
, becauselazy
from 'react' (and other libraries) shouldn't be transpiled. -
Plugin should transpile
lazy
if it's renamedimport { lazy as renamedLazy } from '@loadable/component'
If you want to transpile lazy
you can use workaround with renaming like
import { lazy as loadable } from '@loadable/components'
Current swc plugin behavior differs from babel-plugin
It started from https://github.com/gregberge/loadable-components/pull/929
And then https://github.com/gregberge/loadable-components/pull/966