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

cli: update to support local development with Node16 module resolution #13242

Closed
wants to merge 5 commits into from

Conversation

Rugvip
Copy link
Member

@Rugvip Rugvip commented Aug 19, 2022

Hey, I just made a Pull Request!

Work towards #7926. This is one of the tricky pieces since the dynamic import()s in the CLI end up being treated as ESM when we switch resolution to Node16. The proposed solution is to switch the local development execution to use ts-node in ESM mode and refactor the imports.

We need to access the exported commands on the dynamically imported module via the default export. This is because we're relying on Node.js's built-in CJS compatibility layer, which is unable to find the named exports. As far as I can tell Node.js fails to do this because it tries to parse the exports from the source file rather than the transpiled code. It reads the .ts files from the filesystem and tries to parse exports.<name> = ... from those, which of course fails. A big downside of this is that type checks and runtime are inconsistent. TypeScript claims that (await import('./build.js')).command works just fine, but at runtime it does not. This still seems to be the best solution as far as I can tell.

Overall this PR is supposed to have no impact just yet, it's just making the future move to support Node16 resolution more smooth.

This is blocked by #12558

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message. (more info)

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
@github-actions
Copy link
Contributor

github-actions bot commented Aug 19, 2022

Missing Changesets

The following package(s) are changed by this PR but do not have a changeset:

  • @backstage/cli

See CONTRIBUTING.md for more information about how to add changesets.

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage/cli packages/cli none v0.19.0-next.1

@github-actions
Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If you are the author and the PR has been closed, feel free to re-open the PR and continue the contribution!

@github-actions github-actions bot added the stale label Aug 26, 2022
@github-actions github-actions bot closed this Aug 31, 2022
@benjdlambert benjdlambert reopened this Aug 31, 2022
@github-actions github-actions bot removed the stale label Aug 31, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2022

This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If you are the author and the PR has been closed, feel free to re-open the PR and continue the contribution!

@github-actions
Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If you are the author and the PR has been closed, feel free to re-open the PR and continue the contribution!

@github-actions github-actions bot added the stale label Sep 21, 2022
@github-actions github-actions bot closed this Sep 26, 2022
@Rugvip Rugvip reopened this Sep 27, 2022
@Rugvip Rugvip removed the stale label Sep 27, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2022

This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If you are the author and the PR has been closed, feel free to re-open the PR and continue the contribution!

@github-actions github-actions bot added the stale label Oct 4, 2022
@Rugvip Rugvip removed the stale label Oct 6, 2022
@github-actions
Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If you are the author and the PR has been closed, feel free to re-open the PR and continue the contribution!

@github-actions github-actions bot added the stale label Oct 13, 2022
@github-actions github-actions bot closed this Oct 18, 2022
@Rugvip Rugvip reopened this Oct 24, 2022
@Rugvip Rugvip removed the stale label Oct 24, 2022
@github-actions
Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If the PR was closed and you want it re-opened, let us know and we'll re-open the PR so that you can continue the contribution!

@github-actions github-actions bot added the stale label Oct 31, 2022
@Rugvip Rugvip removed the stale label Oct 31, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Nov 8, 2022

This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If the PR was closed and you want it re-opened, let us know and we'll re-open the PR so that you can continue the contribution!

@github-actions github-actions bot added the stale label Nov 8, 2022
@Rugvip Rugvip removed the stale label Nov 8, 2022
@github-actions
Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If the PR was closed and you want it re-opened, let us know and we'll re-open the PR so that you can continue the contribution!

@github-actions github-actions bot added the stale label Nov 15, 2022
@Rugvip Rugvip removed the stale label Nov 19, 2022
@github-actions
Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If the PR was closed and you want it re-opened, let us know and we'll re-open the PR so that you can continue the contribution!

@github-actions github-actions bot added the stale label Nov 26, 2022
@Rugvip Rugvip removed the stale label Nov 27, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2022

This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If the PR was closed and you want it re-opened, let us know and we'll re-open the PR so that you can continue the contribution!

@github-actions github-actions bot added the stale label Dec 4, 2022
@github-actions github-actions bot closed this Dec 9, 2022
@Rugvip Rugvip reopened this Dec 20, 2022
@Rugvip Rugvip removed the stale label Dec 20, 2022
@github-actions
Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If the PR was closed and you want it re-opened, let us know and we'll re-open the PR so that you can continue the contribution!

@github-actions github-actions bot added the stale label Dec 27, 2022
@benjdlambert
Copy link
Member

I wonder if we want to keep this hanging around or if we should create a ticket based off the moduleResolution: bundler stuff that we looked at this morning when that comes around?

@github-actions github-actions bot removed the stale label Dec 27, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jan 3, 2023

This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If the PR was closed and you want it re-opened, let us know and we'll re-open the PR so that you can continue the contribution!

@github-actions github-actions bot added the stale label Jan 3, 2023
@Rugvip
Copy link
Member Author

Rugvip commented Jan 7, 2023

Closing as we'll likely end up going down the route of using the new bundler module resolution instead once that is available

@Rugvip Rugvip closed this Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants