Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per Method Packages #30

Closed
ammoradi opened this issue Jan 10, 2021 · 5 comments
Closed

Per Method Packages #30

ammoradi opened this issue Jan 10, 2021 · 5 comments
Assignees
Labels
enhancement New feature or request
Projects

Comments

@ammoradi
Copy link

ammoradi commented Jan 10, 2021

As you know, lodash has a capability to import modularized sub-packages called per method packages
It is good for you to make this package modularized especially for the independent functionalities.
for example when a project only needs one of these package functionalities e.g. Sheba, it is better to add and import it like this:

yarn add persian-tools.sheba
import Sheba from 'persian-tools.sheba'

this approach is good for minimizing projects bundle size when using this package because many projects don't need all of these package functionalities

@ali-master
Copy link
Member

ali-master commented Jan 10, 2021

Hi @ammoradi

What a good point, I thought a few days ago to refactor the Persian-Tools in order to convert all modules to a standalone module.

So, My suggestion to do the idea is to use the Lerna. Do you have a better idea?

@ali-master ali-master added this to To do in v1.6.0 Jan 10, 2021
@ali-master ali-master added the enhancement New feature or request label Jan 10, 2021
@ali-master ali-master self-assigned this Jan 10, 2021
@ali-master
Copy link
Member

For your information, I've created the Persian-Tools organization in the NPM, and in the next release, the Persian-tools package path will be:

$ npm i --save @persian-tools/persian-tools

@ammoradi
Copy link
Author

ammoradi commented Jan 10, 2021

@ali-master I didn't use Lerna yet. I will investigate the ways to do this modularization and will mention here if I find a good way

@ali-master
Copy link
Member

I appreciate your help and attention.

@moh3n9595
Copy link
Member

moh3n9595 commented Jan 11, 2021

If you import or require methods directly, e.g. const sheba = require('persian-tools2/sheba'), only the subset of persian-tools2 your package uses will be bundled in projects that use your package.
So another way can be that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
v1.6.0
  
To do
Development

No branches or pull requests

3 participants