plugins icon indicating copy to clipboard operation
plugins copied to clipboard

loadable-components should transpile `lazy` too

Open Themezv opened this issue 1 year ago • 2 comments

Plugin loadable-components should transpile lazy from @loadable/component like loadable

Why ?

lazy from @loadable/component supports react Suspense unlike loadable

Helpful info

  1. Original (babel) plugin tests - https://github.com/gregberge/loadable-components/blob/main/packages/babel-plugin/src/index.test.js#L24

  2. Plugin shouldn't transpile lazy if lazy imported not from @loadable/component, because lazy from 'react' (and other libraries) shouldn't be transpiled.

  3. Plugin should transpile lazy if it's renamed import { lazy as renamedLazy } from '@loadable/component'

Themezv avatar Dec 18 '23 13:12 Themezv

If you want to transpile lazy you can use workaround with renaming like

import { lazy as loadable } from '@loadable/components'

Themezv avatar Jan 10 '24 15:01 Themezv

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

Themezv avatar Mar 23 '24 19:03 Themezv