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

Support sub path import, e.g. import { GetElementEvent } from "@ember-nexus/web-sdk/BrowserEvent/Element"; #80

Open
Syndesi opened this issue May 26, 2024 · 0 comments
Labels
Enhancement Improving existing functionalities. Help Wanted Seeking community assistance. Question Seeking clarifications or information.

Comments

@Syndesi
Copy link
Member

Syndesi commented May 26, 2024

Supporting sub path imports would not only look nicer, but will likely make tree shaking etc. easier to realize.
Furthermore the current workaround is more verbose:

Variant A:

import * as EmberNexus from "@ember-nexus/web-sdk";

const event = new EmberNexus.BrowserEvent.Element.GetElementEvent(
  EmberNexus.Type.Definition.validateUuidFromString("2d3cec20-6311-4bec-9626-9c04458e91dd")
);

Variant B:

import * as EmberNexus from "@ember-nexus/web-sdk";
const { GetElementEvent } = EmberNexus.BrowserEvent.Element;
const { validateUuidFromString } = EmberNexus.Type.Definition;

const event = new GetElementEvent(
  validateUuidFromString("2d3cec20-6311-4bec-9626-9c04458e91dd")
);

But ideally it should something like this:

import { GetElementEvent } from "@ember-nexus/web-sdk/BrowserEvent/Element";
import { validateUuidFromString } from "@ember-nexus/web-sdk/Type/Definition";

const event = new GetElementEvent(
  validateUuidFromString("2d3cec20-6311-4bec-9626-9c04458e91dd")
);

It should technically be possible to support such a use case, although in reality it turns out to be non trivial in every scenario.
The key aspects are, that this library uses type="module" within its package.json, and it as well as other Ember Nexus web projects are using moduleResolution="bundler".

The following articles might provide additional context:

@Syndesi Syndesi added Help Wanted Seeking community assistance. Enhancement Improving existing functionalities. Question Seeking clarifications or information. labels May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Improving existing functionalities. Help Wanted Seeking community assistance. Question Seeking clarifications or information.
Projects
Status: No status
Development

No branches or pull requests

1 participant