Skip to content

Conversation

@chancancode
Copy link

This is not so much a PR intended to be merged, but rather just sharing the quick and dirty code I wrote for a specific task, and perhaps the code here can be useful to others as a starting point. (Thanks @IgnaceMaes for getting it started!)

Hardcoded a bunch of things to make it work with Discourse – the chat plugin to be specific.

We have a bunch of custom resolver rules that needs to be ported over to make this work.

The overall strategry should be generalizable. We have a bunch of custom resolver logic that needs to be ported over, the average app can probably try to share code with the Embroider resolver – or use the Resolver from @embroider/core directly with .resolver.json.

See discourse/discourse#24260 for how this code was used in context.

@changeset-bot
Copy link

changeset-bot bot commented Nov 7, 2023

⚠️ No Changeset found

Latest commit: 47c0ecf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Hardcoded a bunch of thins to make it work with Discourse – the
chat plugin to be specific.

We have a bunch of custom resolver rules that needs to be ported
over to make this work.

The overall strategry should be generalizable. We have a bunch of
custom resolver logic that needs to be ported over, the average app
can probably try to share code with the Embroider resolver – or use
the Resolver from `@embroider/core` directly with `.resolver.json`.

See discourse/discourse#24260 for how this
code was used in context.
}

if (converted.length) {
console.log('Successfully converted %d files:\n', converted.length);
Copy link
Owner

Choose a reason for hiding this comment

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

Love the console stats, definitely something that's missing currently.


import type { Options } from '../types/index.js';

export default function finalize(options: Options): void {
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think most codemods do this step automatically as everyone tends to have their own setup. But nice to see it worked for your use case 😄

module: string;
}

class Resolver {
Copy link
Owner

Choose a reason for hiding this comment

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

Okay, this is super nice!

I do wonder what it would take to also support third party addon imports. I suppose crawling node_modules would be one way.

@IgnaceMaes
Copy link
Owner

Nice to see it already covered a bunch of conversions for Discourse!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants