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

Rename @embroider/core/entrypoint to @embroider/virtual/compat-modules #2131

Merged
merged 3 commits into from
Oct 3, 2024

Conversation

NullVoxPopuli
Copy link
Collaborator

Resolves #2025

@NullVoxPopuli NullVoxPopuli marked this pull request as ready for review October 2, 2024 01:37
Copy link
Member

@mansona mansona left a comment

Choose a reason for hiding this comment

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

I'm inclined to approve this since it does what it says on the tin and solves a serious type issue that we had. I wonder though if there could be more discussion about the approach and see if we can't do something a little smarter rather than having another package to deploy 🙈 (see my question in a comment)

@@ -17,7 +17,7 @@
{{content-for "body"}}

<script src="/@embroider/core/vendor.js"></script>
<script src="/@embroider/core/entrypoint" type="module"></script>
<script src="/@embroider/virtual/compat-modules" type="module"></script>
Copy link
Member

Choose a reason for hiding this comment

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

this will literally do nothing 🤔 are these tests even run?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Better to be updated than to lie?

🤷🙈🙃

Copy link
Member

Choose a reason for hiding this comment

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

I mean if you delete the line no test will fail, if you delete the file no test will probably fail 🤷

there is no side-effect of importing /@embroider/virtual/compat-modules any more so just adding a script will do nothing to any app ever

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

should we delete the whole dummy folder?

I can't leave @embroider/core/entrypoint because it doesn't exist anymore

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ef4
Copy link
Contributor

ef4 commented Oct 2, 2024

I think we should do the same thing vite does for extra types (import.meta.glob, for example, needs a type declaration).

They tell you to put this in your tsconfig:

"compilerOptions": {
    "types": ["vite/client"]
  }

For us that could be:

"compilerOptions": {
    "types": ["vite/client", "@embroider/core"]
  }

And I think then we just need some declare module in core/src/index.ts.

@ef4
Copy link
Contributor

ef4 commented Oct 2, 2024

Link to their docs: https://vitejs.dev/guide/features.html#client-types

@ef4
Copy link
Contributor

ef4 commented Oct 2, 2024

Possibly it would be safer for us to pick a subpath like @embroider/core/client, since it's not clear that it would be good for frontend code to need to see the types for all of our build-time things.

@mansona
Copy link
Member

mansona commented Oct 2, 2024

@ef4 what about @embroider/core/virtual so that it makes a reference to the fact that we're typing the @embroider/virtual things?

@ef4
Copy link
Contributor

ef4 commented Oct 2, 2024

I'm not sure if everything we'll ever want to put in there is under @embroider/virtual. We might want to put in import.meta.resolve for example.

@NullVoxPopuli
Copy link
Collaborator Author

As I was poking around in here , I noticed that test-support and vendor are also virtual files -- should those be under the same prefix fake-package? (maybe in a separate PR, once we work out the mechanics here?)

@mansona
Copy link
Member

mansona commented Oct 2, 2024

everything that is virtual should be renamed as such, and yes they should be separate PRs 👍

@NullVoxPopuli NullVoxPopuli force-pushed the create-embroider-virtual branch from bac31d9 to ac242d3 Compare October 2, 2024 14:51
@NullVoxPopuli
Copy link
Collaborator Author

I think we should do the same thing vite does

this is also the same thing we do :P 🎉
(for ember-source types)

@NullVoxPopuli
Copy link
Collaborator Author

@ef4 I've updated this PR to

Possibly it would be safer for us to pick a subpath like @embroider/core/client

But used @embroider/core/virtual.

Additionally, I think I found a bug with TS where @-prefixed libraries are not resolvable from compilerOptions.types :(
So, for now, we have a /// <reference thing.

@@ -1,3 +1,4 @@
/// <reference types="@embroider/core/virtual" />
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is the only way I could get the types present when type-checking.

The (imo) nicer way, via compilerOptions.types doesn't seem to work for @-prefixed package names.

@NullVoxPopuli NullVoxPopuli force-pushed the create-embroider-virtual branch from 513040c to 701da5c Compare October 2, 2024 20:20
@NullVoxPopuli NullVoxPopuli force-pushed the create-embroider-virtual branch from 701da5c to 5fe5999 Compare October 2, 2024 21:05
@NullVoxPopuli NullVoxPopuli added the enhancement New feature or request label Oct 2, 2024
…s, Resolving #2025

Approach #1: Create package, @embroider/virtual
@NullVoxPopuli NullVoxPopuli force-pushed the create-embroider-virtual branch from 5fe5999 to 9fe67fc Compare October 2, 2024 22:02
@NullVoxPopuli NullVoxPopuli merged commit 72d2f54 into main Oct 3, 2024
152 checks passed
@NullVoxPopuli NullVoxPopuli deleted the create-embroider-virtual branch October 3, 2024 12:28
@github-actions github-actions bot mentioned this pull request Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename @embroider/core/entrypoint to @embroider/virtual/compat-modules
3 participants