Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

[expo-cli] add --experimental-bundle flag to 'export' command #3074

Merged
merged 17 commits into from
Jan 20, 2021

Conversation

jkhales
Copy link
Contributor

@jkhales jkhales commented Jan 11, 2021

For EAS, we are separating the creation of the bundles from their publication.

expo export does a lot of other stuff with the assumption that the user will be hosting a personal, non-EAS, static manifest and asset server.

expo export --eas strips away all of the extraneous work in expo export and introduces a standardized format to save bundles in for preparation use by eas publish.

dist
├── assets
│   └── *
├── bundles
│   ├── android.js
│   └── ios.js
└── metadata.json

Where metadata.json has type:

type Metadata = {
  version: number;
  bundler: 'metro';
  fileMetadata: {
    [key in Platform]: {
      bundle: string; 
      assets: { [key in 'path' | 'ext']: string }[]; 
    };
  };
}

This allows for easy expansion of the bundlers we support (which is the key reason for the separation of the bundling and the publishing). The versioning allows us to accommodate dramatic format changes.

Test Plan:
run:
expo export --experimental-bundle and confirm it creates the new file structure.
expo export --public-url test.com and confirm it creates the old file structure.

Copy link
Contributor

@fson fson left a comment

Choose a reason for hiding this comment

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

Thanks, this looks good! Left a few comments/questions below.

packages/expo-cli/src/commands/bundle.ts Outdated Show resolved Hide resolved
packages/expo-cli/src/commands/bundle.ts Outdated Show resolved Hide resolved
packages/expo-cli/src/commands/bundle.ts Outdated Show resolved Hide resolved
packages/expo-cli/src/commands/bundle.ts Outdated Show resolved Hide resolved
@jkhales jkhales requested a review from fson January 12, 2021 21:34
Copy link
Contributor

@fson fson left a comment

Choose a reason for hiding this comment

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

:shipit:

Copy link
Contributor

@EvanBacon EvanBacon left a comment

Choose a reason for hiding this comment

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

  • if this is supposed to be part of EAS, it should maybe be in EAS?
  • if this shares a majority of features with export, then it should share code too.
  • I'm not sure why we need two CLI commands for generating the static output of a project, this should really be consolidated.
  • we want to limit the amount of commands in the expo-cli since there are already a ton and the --help prompt is too large.

Copy link
Member

@brentvatne brentvatne left a comment

Choose a reason for hiding this comment

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

i agree with @EvanBacon that we should hide this from --help for now. we may want to consolidate expo export into this command and put it behind a flag (or the other way around), ping me on slack and we can chat about that more

packages/expo-cli/src/commands/bundle.ts Outdated Show resolved Hide resolved
@jkhales
Copy link
Contributor Author

jkhales commented Jan 14, 2021

  • if this is supposed to be part of EAS, it should maybe be in EAS?

There is a big push to seperate the bundler from EAS. @fson, @ide, and @ccheever have suggested going even further in the future and allowing arbitrary bundlers (not included in expo-cli) with an expo plugin.

  • if this shares a majority of features with export, then it should share code too.

Agreed. I made sure to reuse the relevant code from expo export. See, for example, the reuse of buildPublishBundlesAsync: https://github.com/expo/expo-cli/pull/3074/files#diff-3b46ddce3f17b5ba410e409f3404d47ddbb44c0a45fa865ff8f0cf5404190ed7R71

  • I'm not sure why we need two CLI commands for generating the static output of a project, this should really be consolidated.

I initially started writing this as a flag for expo export. I stopped as expo export does more than just create a bundle (for example it modifies the plist) and its output is tailored to the assumption that the user will be hosting the update from a static server.

Note: "hosting an update from a static server" is different from "generating the static output":

Hosting on a static server means we create the manifest as well as the bundles and that the client's plist looks for the manifest along a different route */android-index.json or */ios-index.json.

Creating just the static output means the bundles and the assets. But we also wanted to add some metadata about the assets (their extension) as that is required for the way we store assets in EAS (thus the metadata.json file). I also added versioning and the bundler name to this file in preparation for issues with multi-bundler support.

Combining these commands is possible, but because the output is rather different it seems confusing for the user and from the maintenance perspective the code becomes littered with if/else statements.

@jkhales
Copy link
Contributor Author

jkhales commented Jan 14, 2021

i agree with @EvanBacon that we should hide this from --help for now. we may want to consolidate expo export into this command and put it behind a flag (or the other way around), ping me on slack and we can chat about that more

cool, pinged you on slack!

): Promise<void> {
const absoluteOutputDir = path.resolve(process.cwd(), outputDir);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This used to be called right before ExportAppAsync. I brought it inside and replaced the relevant outputDir with absoluteOutputDir.

@@ -1586,7 +1651,7 @@ export async function startReactNativeServerAsync({
_logPackagerOutput(projectRoot, 'error', data);
}
});
const exitPromise = new Promise((resolve, reject) => {
const exitPromise = new Promise<void>((resolve, reject) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(Unrelated typescript error that I tacked onto this PR)

},
};
// Skip the hooks and manifest creation if building for EAS.
if (!eas) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Everything in this if statement is copied over from before. Because if (options.dumpSourcemap) got shifted above the "hooks" block it looks like more change than it is.

@jkhales jkhales changed the title [expo-cli] add bundle command [expo-cli] add --eas flag to 'export' command Jan 18, 2021
@jkhales
Copy link
Contributor Author

jkhales commented Jan 18, 2021

@EvanBacon @brentvatne changed from a new command to a flag!

@ide
Copy link
Member

ide commented Jan 19, 2021

The flag name looks fine for a temporary option but ideally the exported format would be largely compatible with any host.

old:
expo publish: publish to classic Expo updates
expo export: command for self-hosting classic Expo updates

new:
expo export --eas: there is no difference between Expo-hosting and self-hosting; there is just hosting. command for exporting an update that can be uploaded to EAS or to any other compatible server. EAS-specific details are the responsibility of eas-cli.

@jkhales
Copy link
Contributor Author

jkhales commented Jan 19, 2021

The flag name looks fine for a temporary option but ideally the exported format would be largely compatible with any host.

old:
expo publish: publish to classic Expo updates
expo export: command for self-hosting classic Expo updates

new:
expo export --eas: there is no difference between Expo-hosting and self-hosting; there is just hosting. command for exporting an update that can be uploaded to EAS or to any other compatible server. EAS-specific details are the responsibility of eas-cli.

Good point, talking with @jonsamp about this a bit and maybe --bundle would work? 😅

@ide
Copy link
Member

ide commented Jan 19, 2021

tbh I think the right path is to work towards making it the default to export the EAS-compatible update format. The old format just needs to stick around to not break existing workflows. Don't need to get there right away but the new format works for all conformant hosts - EAS and otherwise - so there eventually won't be a need for old "expo export" behavior except for compat reasons.

Copy link
Contributor

@EvanBacon EvanBacon left a comment

Choose a reason for hiding this comment

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

looks good but at least add a test plan to the PR description

@jkhales jkhales changed the title [expo-cli] add --eas flag to 'export' command [expo-cli] add --experimental-bundle flag to 'export' command Jan 20, 2021
@jkhales jkhales merged commit 1c778c1 into master Jan 20, 2021
@jkhales jkhales deleted the @jkhales/add-bundle-command branch January 20, 2021 22:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants