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

chore: convert bundle command to TS #695

Merged
merged 12 commits into from
Sep 11, 2019
Merged

chore: convert bundle command to TS #695

merged 12 commits into from
Sep 11, 2019

Conversation

Quadriphobs1
Copy link
Contributor

Summary:

Part of #683
Converted commands/bundle/ to typescript

Test Plan:

yarn test

@thymikee thymikee changed the title [#683] convert bundle from flow to typescript chore: convert bundle command to TS Sep 10, 2019
Copy link
Member

@thymikee thymikee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for sending a PR! Left some notes to address

packages/cli/src/commands/bundle/assetPathUtils.ts Outdated Show resolved Hide resolved
packages/cli/src/commands/bundle/buildBundle.ts Outdated Show resolved Hide resolved
packages/cli/src/commands/bundle/buildBundle.ts Outdated Show resolved Hide resolved
packages/cli/src/commands/bundle/buildBundle.ts Outdated Show resolved Hide resolved
packages/cli/src/commands/bundle/bundle.ts Outdated Show resolved Hide resolved
packages/cli/src/commands/bundle/bundle.ts Outdated Show resolved Hide resolved
packages/cli/src/commands/bundle/ramBundle.ts Outdated Show resolved Hide resolved
packages/cli/src/commands/bundle/saveAssets.ts Outdated Show resolved Hide resolved
packages/cli/src/commands/bundle/saveAssets.ts Outdated Show resolved Hide resolved
...Server.DEFAULT_BUNDLE_OPTIONS,
...requestOpts,
bundleType: 'todo',
});

// When we're done saving bundle output and the assets, we're done.
// @ts-ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why ts ignore? can you leave a comment explaining?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the value args.platform is actually seen as string | undefined however in the function saveAssets() it is required which causes type error... looking at the code it looks like the args.platform would be provided at all times which makes no sense to actually make it optional from the code as well which is why I suppress the warning but what do you think of it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely shouldn't be suppressed. This is possible failure point and we need to make sure args.platform is defined before passing it further

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked in now the args.platform has a default value of ios which means making it options is actually not necessary

*/

import {Config} from '@react-native-community/cli-types';
import {CommandLineArgs} from './bundleCommandLineArgs';
import buildBundle from './buildBundle';
import bundleCommandLineArgs from './bundleCommandLineArgs';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove line 9 nad move the import here

Suggested change
import bundleCommandLineArgs from './bundleCommandLineArgs';
import bundleCommandLineArgs, {CommandLineArgs} from './bundleCommandLineArgs';

*/

import path from 'path';
import type {PackagerAsset} from './assetPathUtils';
import {PackagerAsset} from './assetPathUtils';

import assetPathUtils from './assetPathUtils';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please consolidate imports :)

Suggested change
import assetPathUtils from './assetPathUtils';
import assetPathUtils, {PackagerAsset} from './assetPathUtils';

import outputUnbundle from 'metro/src/shared/output/RamBundle';

import {CommandLineArgs} from './bundleCommandLineArgs';
import {withOutput as bundleWithOutput} from './bundle';
import bundleCommandLineArgs from './bundleCommandLineArgs';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import bundleCommandLineArgs from './bundleCommandLineArgs';
import bundleCommandLineArgs, {CommandLineArgs} from './bundleCommandLineArgs';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad 🙈

Copy link
Member

@thymikee thymikee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @Esemesek please check once the feedback is addressed

import saveAssets from './saveAssets';
import loadMetroConfig from '../../tools/loadMetroConfig';
// @ts-ignore FIXME after converting tools/loadMetroConfig
import loadMetroConfig from '../../tools/loadMetroConfig'; // eslint-disable-line import/namespace, import/default
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove the ignores after a rebase :)

@thymikee thymikee merged commit 66f5a51 into react-native-community:master Sep 11, 2019
@thymikee
Copy link
Member

Thank you!

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

Successfully merging this pull request may close these issues.

2 participants