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

Template tag codemod stability fixes #2271

Merged
merged 6 commits into from
Feb 17, 2025

Conversation

void-mAlex
Copy link
Collaborator

documents codemod usage in readme
fixes case when codemod is run against stable build of an app
make codemod work oob without failing on self resolvability

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 like some good fixes, I've just added some micro comments that I'm fine with us fixing after this is merged since it's such a benefit to update the instructions

@mansona mansona added the enhancement New feature or request label Feb 16, 2025
@void-mAlex
Copy link
Collaborator Author

I would imagine this is a bugfix rather than an enhancement but I defer to you @mansona

@mansona
Copy link
Member

mansona commented Feb 17, 2025

@void-mAlex your changes to externalNameHint I think warrant the enhancement label but it doesn't really matter since everything is being released as an alpha at the moment 😂

@mansona mansona merged commit 8e24dae into main Feb 17, 2025
218 checks passed
@mansona mansona deleted the template-tag-codemod-stability-fixes branch February 17, 2025 09:41
@github-actions github-actions bot mentioned this pull request Feb 17, 2025
@ef4
Copy link
Contributor

ef4 commented Feb 17, 2025

We discussed making this configurable.

I think the new default behavior here is debatable. I don't like it because namespacing on component names is an old habit based on having all components in one big global pool. Now that they're imported, it's not great style.

By analogy, which of these do you do?

import { uniq } from 'lodash';
import { uniq as lodash_uniq } from 'lodash';

The default here is equivalent to the second one of those.

A better default for namespaced stuff would probably be dropping everything before the last ::.

// before
<Widgets::Big />

// after
import Big from './widgets/big';
<template><Big /></template>

@NullVoxPopuli
Copy link
Collaborator

Agreed. Namespacing by default doesn't make sense today

@@ -86,7 +86,12 @@ export function optionsWithDefaults(options?: Options): OptionsWithDefaults {
type OptionsWithDefaults = Required<Options>;

export async function ensurePrebuild() {
if (!existsSync('node_modules/.embroider')) {
const stablePrebuildExists = existsSync('node_modules/.embroider/rewritten-app');
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not good. It leaves the bug behind to bite us again anytime there's version skew between the embroider that wrote node_modules/.embroider and the embroider that's running. We should use a version marker instead.

@@ -105,7 +110,11 @@ export async function ensureAppSetup() {
process.exit(-1);
}
if (!pkg.packageJSON.exports) {
throw new Error(`must use package.json exports for self-resolvability. Plase add this to package.json:
pkg.packageJSON.exports = {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is mutating the package cache. It might happen to work, but it changes the meaning of the package cache from an optimization to a correctness requirement.

I'm in favor of auto-fixing this problem for users, but we should do it by writing their real package.json. Not trying to maintain an inconsistency in the package cache.

@ef4
Copy link
Contributor

ef4 commented Feb 17, 2025

I merged this into my other PR which includes test coverage, and this PR causes helpers like t to become capitalized. I think that's going to drive people nuts.

Let's take another stab at this PR, but I'm reverting for the present.

ef4 added a commit that referenced this pull request Feb 17, 2025
…demod-stability-fixes"

This reverts commit 8e24dae, reversing
changes made to 2fb41fc.
ef4 added a commit that referenced this pull request Feb 17, 2025
Revert "Merge pull request #2271 from embroider-build/template-tag-co…
@github-actions github-actions bot mentioned this pull request Feb 17, 2025
@mansona mansona restored the template-tag-codemod-stability-fixes branch February 17, 2025 14:58
@mansona
Copy link
Member

mansona commented Feb 17, 2025

I reopened this PR here #2280 sorry for the confusion everyone 🙈

@void-mAlex
Copy link
Collaborator Author

We discussed making this configurable.

I think the new default behavior here is debatable. I don't like it because namespacing on component names is an old habit based on having all components in one big global pool. Now that they're imported, it's not great style.

By analogy, which of these do you do?

import { uniq } from 'lodash';
import { uniq as lodash_uniq } from 'lodash';

The default here is equivalent to the second one of those.

A better default for namespaced stuff would probably be dropping everything before the last ::.

// before
<Widgets::Big />

// after
import Big from './widgets/big';
<template><Big /></template>

namespecing is actually more important now in the new world order where we have

import { hash } from '@ember/helper';
import { hash } from 'rsvp';

and these are far from the only examples and they will be pushed to the extereme once route templates gain traction

namepsacing is also a closer to existing behaviour that people are used to with the framework
ask too much change at once and it will reflect negatively in the experience they have with the new format
I agree that having the option for shorter names should be presented but I strongly believe the ootb experience should the the one closer to what people are already familiar with to make the transition smoother

while you may have your opinions on what may or may not make sense in a gjs world fact is if you're using this piece of code to do transformations chances are you have an older codebase with namespacing folders in place and there is a high likelyhoold of multiple Cards/Card/Slideup in skeleton/provider/loader etc variants and having that be preserved is much more valuable than haing a poorly mangled Card/Card0/Card1 name

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.

4 participants