-
Notifications
You must be signed in to change notification settings - Fork 143
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
Conversation
…ig and warning about it
use underscore as separator that has special highlighting in gjs
There was a problem hiding this 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
I would imagine this is a bugfix rather than an enhancement but I defer to you @mansona |
@void-mAlex your changes to |
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> |
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'); |
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
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.
I merged this into my other PR which includes test coverage, and this PR causes helpers like Let's take another stab at this PR, but I'm reverting for the present. |
Revert "Merge pull request #2271 from embroider-build/template-tag-co…
I reopened this PR here #2280 sorry for the confusion everyone 🙈 |
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 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 |
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