frintjs / frint

Modular JavaScript framework for building scalable and reactive applications
https://frint.js.org/
MIT License
756 stars 37 forks source link

frint-react: load only required modules for `render` #341

Closed fahad19 closed 6 years ago

fahad19 commented 6 years ago

What's done

1: Import only required modules

We were loading the entire frint-react library inside the render function, when we only needed one specific module there.

We were doing it like this so far for frint-compat for supporting v0.x users, which is not needed any more.

2: react-dom imported inside render

react-dom is now imported inside the render function. This has no side-effect, and is mainly done for making way for supporting React Native soon.

React Native doesn't require react-dom, and react-dom is treated as a peer dependency of frint-react.

This means when frint-react will be used in a React Native project, where the developer doesn't need to install react-dom, it will not throw any error when any module is imported from the package like this:

import { observe } from 'frint-react';

Directly importing the module from package like this will also bring inrender as a function, but since that function will never be executed, it means react-dom will also never be required, resulting in no error.

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-0.006%) to 97.47% when pulling b84f04c94e4e50ee88ba321209c5105ad4448738 on frint-react-render into 82ce4baf11ac98d0059f33cd502e45e3309f6644 on master.