Giter Club home page Giter Club logo

react-typescript-module's Introduction

react-typescript-module

This repo lets you create a module using react and typescript with minimal build configuration.

Get started

  • Clone this repo, remove origin and install modules
    • git clone https://github.com/dumbape/react-typescript-module.git <Your Module Name>
    • cd <Your Module Name>
    • git remote remove origin
    • npm install
  • Build your React Typescript module as usual in the src folder.
  • Make a separate .ts file which would have all the exports from the module. For convenience, an index.ts has been provided, however, you may make your own anywhere.
  • Open rollup.config.js and adjust the input parameter (by default points to sec/index.ts) so that it points to the .ts file containing all the exports.
  • Run npm run build. A build folder will be generated.
  • Open package.json and change name and version to your module name and version. Optionally, you may add a description. Point types to the .d.ts file generated in build folder, which contains all exports. Do not change main, module and jsnext:main.
  • Your module is ready to be used.

Test the module

  • Create a new react project (with or wihout typescript).
    • npx create-react-app testapp && cd testapp OR
    • npx create-react-app testapp --typescript && cd testapp
  • Install the created module.
    • npm install <Path to the root folder of your module>
  • Try using your component as any other module by including it in any .tsx or .jsx file.
    • import { <Your Component> } from 'your-module'

Publish the module

  • The module is ready to be published for react users (with and without typescript!).
  • Login to npm and publish
    • npm login
    • npm publish

Contribute

You are free to raise issues and PR's to improve the repo and help people build modules with ease :)

react-typescript-module's People

Stargazers

 avatar

Watchers

 avatar  avatar

react-typescript-module's Issues

npm run watch

Hi!
You could improve it by adding {"watch": "rollup -c -w"} in package.json.
On the other hand, you can also use the npm link command for local testing.

You have saved me a lot of work! It works perfectly! Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.