react-loadable-ts-transformer

0.0.5 • Public • Published

react-loadable-ts-transformer

This is an analog of the babel plugin included with react-loadable.
The differences are:

  • transformer does not support Loadable.Map case
  • moudles prop contains only relative path (as is in loader prop)

Providing opts.webpack and opts.modules for every loadable component is a lot of manual work to remember to do.

Instead you can add the ts transformer to your config and it will automate it for you:

const reactLoadableTransformer = require('react-loadable-ts-transformer');
config = {
    module: {
        rules: [
            {
                test: /\.tsx?$/,
                loader: 'ts-loader',
                options: {
                    transpileOnly: true,
                    getCustomTransformers: () => ({
                        before: [reactLoadableTransformer],
                    }),
                },
            },
        ],
    },
}

Input

import Loadable from 'react-loadable';

const LoadableMyComponent = Loadable({
    loader: () => import('./MyComponent'),
});

Output

import Loadable from 'react-loadable';
import path from 'path';

const LoadableMyComponent = Loadable({
    loader: () => import('./MyComponent'),
    webpack: () => [require.resolveWeak('./MyComponent')],
    modules: ['./MyComponent'],
});

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.5
    2,794
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.5
    2,794
  • 0.0.4
    3
  • 0.0.2
    3
  • 0.0.1
    2

Package Sidebar

Install

npm i react-loadable-ts-transformer

Weekly Downloads

371

Version

0.0.5

License

ISC

Unpacked Size

4.53 kB

Total Files

3

Last publish

Collaborators

  • sasha.p