1.0.0 • Published 2 years ago

@ts-plugin/loadable v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@ts-plugin/loadable

CI

Install

  • pnpm add @ts-plugin/loadable -D
  • yarn add @ts-plugin/loadable -D
  • npm install @ts-plugin/loadable --save-dev

Usage

With webpack

Checkout example for the usage.

Clone this repository and run:

  • yarn install
  • yarn build
  • yarn build:example
  • yarn start

to play with the example.

// webpack.config.js

const { createLoadableNodeTransformer } = require('@ts-plugin/loadable')

module.export = {
  ...
  module: {
+   parser: {
+     javascript: {
+       commonjsMagicComments: true,
+     },
+   },
    rules: [
      {
        test: /\.(j|t)sx?$/,
        use: {
          loader: 'ts-loader',
          /** @type {import('ts-loader').Options} */
          options: {
+           happyPackMode: true,
            compilerOptions: {
+             module: 'esnext',
            },
+           getCustomTransformers: () => ({ before: [createLoadableNodeTransformer(process.env.BUILD_TYPE === 'ssr' ? 'node' : 'web')] }),
          },
        },
        exclude: [/node_modules/]
      },
    ],
  },
}
1.0.0

2 years ago