Skip to content

Strip off code inside #regions from your bundle and be happy with your isomorphic javascript/typescipt apps.

Notifications You must be signed in to change notification settings

darekf77/isomorphic-region-loader

Repository files navigation

Isomorphic #region Loader

A loader for webpack that lets you strip #regions code from bundle.

Install

npm install --save-dev isomorphic-region-loader

Usage

This load is very helpfull if you wanna write isomorphic applications in javascript or typescript. Just specify region and this loader will cut it from bundle. Example:

import * as jquery from 'jquery'
//#region nodejs
import * as fs from 'fs'
//#endregion

class ExampleIsomorphicClass {
  ...
}

With webpack configuraiton below:

module.exports = {
  module: {
    rules: [
      {
        test: /\.ts$/,
        use: 'isomorphic-region-loader',
        options: { platform: 'browser' }  // 'borwser' default platform, also there is 'nodejs'
      }
    ]
  }
}

You will get:

import * as jquery from 'jquery'

class ExampleIsomorphicClass {
  ...
}

As result, code inside #region nodejs has been stripped. Also you can do similar things to your nodejs code and strip off browser things.

Inline

In your application

import {  ExampleIsomorphicClass } from '!isomorphic-region-loader!./isomorphic-class.ts';

About

Strip off code inside #regions from your bundle and be happy with your isomorphic javascript/typescipt apps.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published