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

Assigning same component to multiple Viewports breaks build script #929

Open
johno-stripe opened this issue Aug 22, 2023 · 0 comments
Open
Labels
bug Something isn't working

Comments

@johno-stripe
Copy link

johno-stripe commented Aug 22, 2023

Describe the bug

My Stripe App uses the same component for every screen, but I'd like it to have access to the objectContext so it can try retrieving the object and checking that it has the correct shape. However, if I use the same component for more than one viewport, the line gets duplicated in the generated build (.build/manifest.js) and causes an error.

To Reproduce
Steps to reproduce the behavior:

  1. Initialize a fresh Stripe App, or take one you already have
  2. Update the ui_extension.views field in stripe-app.json to include the same component for multiple viewports (example below)
  3. Run stripe apps start and get a build error about the component already having been imported
"ui_extension": {
    "views": [
      {
        "viewport": "stripe.dashboard.customer.detail",
        "component": "AppView"
      },
      {
        "viewport": "stripe.dashboard.drawer.default",
        "component": "AppView"
      }
    ]

Expected behavior

I would expect the build script to de-dupe the set of exported components when generating .build/manifest.js and just re-use the name. More generally, I think the user should get to decide where they handle per-object variations in their component tree. While there may be different code for different objects, I don't think that necessarily means the user should have to create separate entry points.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: macOS Ventura, 13.5
  • Browser: Chrome
  • Version: 116.0.5845.96 (Official Build) (arm64)

Additional context

My usecase involves going through a series of prompts which ask you to create objects; each prompt includes a JSON schema of the expected object, as well as the names of the events to search for a matching object. As such, while the logic sort of varies for different objects, I'm leveraging the same components and functions every time.

I'm currently working around this by creating dedicated files for each viewport which all contain variations of:

// Stub to satisfy Stripe Apps assumption that each detail view
// should map to a separate React component.

import MainView from './MainView';

export const CustomerView = MainView;

export default CustomerView;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants