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

fix failure on first-run and auto-apply package.json updates #2279

Merged
merged 1 commit into from
Feb 17, 2025

Conversation

ef4
Copy link
Contributor

@ef4 ef4 commented Feb 17, 2025

This fixes #2264 (comment) and also addresses automatically adding exports to package.json, since they're both in the same function.

The problem with first-run failures was that Resolver expects to get constructed after any prebuilding is done. We were constructing it in ensureAppSetup before the prebuild.

This class of bug is harder to see now that prebuilds are optional. ResolverLoader will happily construct a Resolver with no prebuilt output present. But the resulting Resolver won't know anything about any v1 addons that were present.

This fixes #2264 (comment) and also addresses automatically adding `exports` to package.json, since they're both in the same function.

The problem with first-run failures was that Resolver expects to get constructed after any prebuilding is done. We were constructing it in ensureAppSetup before the prebuild.
@ef4 ef4 added the bug Something isn't working label Feb 17, 2025
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.

Looks good 👍

@mansona mansona merged commit 9c98a68 into main Feb 17, 2025
220 checks passed
@mansona mansona deleted the fix-first-run branch February 17, 2025 15:35
@github-actions github-actions bot mentioned this pull request Feb 17, 2025
'./tests/*': './tests/*',
'./*': './app/*',
};
writeFileSync(filename, JSON.stringify(json, null, 2));
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is touching files I would never expect a codemod to touch and messing with my indentation at the same time

try {
pkg = resolverLoader.resolver.packageCache.get(process.cwd());
content = readFileSync(filename, 'utf8');
Copy link
Collaborator

Choose a reason for hiding this comment

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

this no longer serves the purpose of ensuring an ember app
I had fun digging into what it was actually doing because it was buried very deep inside resolver code but it actually ensures ember-source is in package json which may not be the case for a v2 addon but I wonder if that was the intention here

Copy link
Member

Choose a reason for hiding this comment

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

That sounds like a good case to add to the test suite. I'm assuming we want to encourage people to be able to use this to update a v2 addon?

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

Successfully merging this pull request may close these issues.

3 participants