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

add json5, line-numbers, and normalize-whitespace #58

Merged
merged 1 commit into from
Sep 29, 2023
Merged

add json5, line-numbers, and normalize-whitespace #58

merged 1 commit into from
Sep 29, 2023

Conversation

lupestro
Copy link
Contributor

@lupestro lupestro commented Aug 31, 2023

Edit from @mansona : this PR has been simplified to add the required config to prism by default 👍

Before this change, if app.options['ember-prism'] has been initially set up by another add-on, the components this addon wanted to use would be ignored. Now it adds any that aren't already there.

If the central idea of the PR, that the set of ember-prism components should be additive between addons, isn't deemed wise, then reject the PR. In the abstract, I can imagine a component using ember-showdown-prism that wants to narrow the range of prism components from 14 to perhaps two or three to keep the runtime size down. With this PR, they would no longer be able to do so. In practice, I doubt that's likely to be a serious concern, but I leave that to the maintainers to decide. They may know of cases where it applies.

The original impetus for this fix was that the typescript component had been added here and was being ignored when providing typescript examples in the guides. (We also wanted to add json5 examples.) As it turns out, the add-on that was setting a list that pre-empted this one was guidemaker itself. That leaves an open question whether typescript and json5 belong in this list or that one.

Since typescript is now more central to Ember work in general, I think the typescript component, at least, probably belongs in the base list for this add-on next to javascript. json5 might be more debatable. It's definitely slated for use in the Typescript portion of the guides. We can pull json5 from the PR and move it to the list in guidemaker if desired. If this PR is accepted, guidemaker could either specify precisely what components the guides use or trim its list to things it wants to add. (I suspect they both have the same maintainer. Right, Chris? ;) However you want to architect it.)

@netlify
Copy link

netlify bot commented Aug 31, 2023

Deploy Preview for ember-showdown-prism ready!

Name Link
🔨 Latest commit 1d23b8f
🔍 Latest deploy log https://app.netlify.com/sites/ember-showdown-prism/deploys/6516fc805ebc210008f6ed89
😎 Deploy Preview https://deploy-preview-58--ember-showdown-prism.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

index.js Outdated
'apacheconf',
'bash',
'css',
'handlebars',
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't want handlebars -- because we don't use this syntax (see the removed list, it's not present)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Git history is correct - I built from after your change. but, I copy/pasted a chunk of code from where I was debugging it over in the guides, which hadn't picked up your change yet. Sorry about that. I went back and double-checked everything else in this file and it doesn't look like I missed anything further.

Copy link
Contributor

@NullVoxPopuli NullVoxPopuli 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 branch may not have been update upon PR creation?

But also, Thank you for fixing this!!!

index.js Outdated
Comment on lines 31 to 37
const existingComponents = app.options['ember-prism']?.components ?? [];
const newComponents = existingComponents.slice();
for (const component of desiredComponents) {
if (!existingComponents.includes(component)) {
newComponents.push(component);
}
}

Choose a reason for hiding this comment

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

If this logic is only needed if there are app.options['ember-prism'] then let's move it to the appropriate branch below.

Copy link
Contributor Author

@lupestro lupestro Sep 2, 2023

Choose a reason for hiding this comment

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

I had figured that, by ensuring the only significant block of code was always executed, we guaranteed it would always be well tested, especially where this code was in a difficult place to test independently of normal operation. I was killing risk, which is usually my first consideration, by exposing it to light. With only a dozen or so items, performance doesn't enter into it in any significant way. (I had actually had it the other way first.)

However, I can move it around. Sure.

index.js Outdated
newComponents.push(component);
}
}

if (!app.options['ember-prism']) {

Choose a reason for hiding this comment

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

Since we're adding an else block, let's switch the branches around to avoid "if not, else"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes good sense.

Copy link

@gitKrystan gitKrystan left a comment

Choose a reason for hiding this comment

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

see comments. The logic is generally good, just needs a bit of cleanup. Accidentally hit the approve button above and can't figure out how to un-approve. 😓

@lupestro
Copy link
Contributor Author

lupestro commented Sep 16, 2023

As per Chris Manson's indication of direction, I reverted all of my changes, just added json5 and the plugins that guidemaker was supplying. Once this change is in play, we can remove the code from guidemaker that was overriding this. (Once I'm absolutely sure the work I did won't need to be reinstated, I'll also squeeze out all the intermediate revisions.)

I doubt that this will pass all ember-try tests - I ran ember-try on it locally and it failed on 3.16, 3.20, and 3.24 for the absence of @glimmer/manager and on 3.28 and 4.4 on the absence of @ember/renderer. It failed on embroider optimized saying Ember is not defined. I verified that the same failures also occur when run with the head of the main branch.

@mansona mansona changed the title Fix for situation where multiple addons set ember-prism options add json5, line-numbers, and normalize-whitespace Sep 29, 2023
@mansona
Copy link
Member

mansona commented Sep 29, 2023

embroider-optimised is failing because of a bug in ember-cli-fastboot (that I need to fix 😫) so I am safe to merge this 👍

@mansona mansona merged commit 2272718 into empress:main Sep 29, 2023
@mansona mansona added the enhancement New feature or request label Sep 29, 2023
@lupestro lupestro deleted the multiple-addons-asking-for-components branch September 30, 2023 15:37
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