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

Process to clean up unused framework files #65

Open
alexkn1 opened this issue Apr 6, 2023 · 3 comments
Open

Process to clean up unused framework files #65

alexkn1 opened this issue Apr 6, 2023 · 3 comments

Comments

@alexkn1
Copy link

alexkn1 commented Apr 6, 2023

Hi,

I am trying to optimize the size of the app. Is there a built in process to only import kopytko modules that are being used or delete ones that are not being used during build process?

Thanks!

@pawelhertman
Copy link
Contributor

Hi @alexkn1

No, there is no such mechanism. There are plans for it, but it's a huge feature (e.g. determining which components have been used in the app is a non-obvious task).
You can create your plugin removing unneeded files.

@bchelkowski
Copy link
Member

Here is described how plugins work.
https://github.com/getndazn/kopytko-packager/blob/master/docs/PLUGINS.md

Example of the plugin code, that removes Roku roChannelStore mocks and TrackerTask.xml from the package build.

const fs = require('fs').promises;
const glob = require('glob-promise');

const RALE_TRACKER_PATH_PATTERN = '/components/**/TrackerTask.xml';
const ROKU_STORE_FAKES_DIR = '/csfake';

module.exports = async function removeDevelopmentCode(rootDir) {
  const raleTrackerPath = await glob(`${rootDir}${RALE_TRACKER_PATH_PATTERN}`);

  await Promise.all([...raleTrackerPath].map(filePath => fs.unlink(filePath)));

  await fs.rm(`${rootDir}${ROKU_STORE_FAKES_DIR}`, { recursive: true, force: true });
};

@alexkn1
Copy link
Author

alexkn1 commented Apr 9, 2023

Here is described how plugins work. https://github.com/getndazn/kopytko-packager/blob/master/docs/PLUGINS.md

Example of the plugin code, that removes Roku roChannelStore mocks and TrackerTask.xml from the package build.

const fs = require('fs').promises;
const glob = require('glob-promise');

const RALE_TRACKER_PATH_PATTERN = '/components/**/TrackerTask.xml';
const ROKU_STORE_FAKES_DIR = '/csfake';

module.exports = async function removeDevelopmentCode(rootDir) {
  const raleTrackerPath = await glob(`${rootDir}${RALE_TRACKER_PATH_PATTERN}`);

  await Promise.all([...raleTrackerPath].map(filePath => fs.unlink(filePath)));

  await fs.rm(`${rootDir}${ROKU_STORE_FAKES_DIR}`, { recursive: true, force: true });
};

Yes, using something like that. That helps. Thought

Hi @alexkn1

No, there is no such mechanism. There are plans for it, but it's a huge feature (e.g. determining which components have been used in the app is a non-obvious task). You can create your plugin removing unneeded files.

Just to add if there was also a way to combine/minify all the common functions that would be good too. This is how all JS libraries work.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants