This is our plan to move the code in the `sdc` module to the core namespace while maintaining backwards compatibility with the experimental module.

Merge Request Strategy

We have this META issue to move all the core from the current location in the experimental module into the Drupal\Core namespace. This meta issue will have a **draft** MR associated against HEAD (currently 11.x).

We will break tasks to move the code into smaller issues which will contain any potential discussion on the implementation. This will allow us to make more sense of the conversations, and to parallelize tasks with other contributors. Each one of these smaller issues will contain an MR against the branch for the META issue. As we merge these MRs for the smaller issues, the bigger diff will start to build up in the draft MR associated to the META issue.

Once we have all the smaller issues merged, we will work to clear the release manager and commit manager tags from the big MR, in order to get it merged. We also plan on requesting validation from core committers in these smaller issues, in order to raise any concerns early on.

Backwards Compatibility

The `sdc.module` file contains the following:

// Set class aliases for the classes that will go into core.
// See the experimental modules policy https://www.drupal.org/core/experimental
// @todo: remove class aliases in #3354389
@class_alias('Drupal\sdc\Element\ComponentElement', 'Drupal\Core\Render\Element\ComponentElement');
@class_alias('Drupal\sdc\Exception\ComponentNotFoundException', 'Drupal\Core\Render\Component\Exception\ComponentNotFoundException');
@class_alias('Drupal\sdc\Exception\IncompatibleComponentSchema', 'Drupal\Core\Render\Component\Exception\IncompatibleComponentSchema');
@class_alias('Drupal\sdc\Exception\InvalidComponentDataException', 'Drupal\Core\Render\Component\Exception\InvalidComponentDataException');
@class_alias('Drupal\sdc\Exception\InvalidComponentException', 'Drupal\Core\Render\Component\Exception\InvalidComponentException');

All classes in sdc are marked as @internal. We understand that the Drupal core backwards compatibility policy includes classes and services marked internal. All classes in sdc are also final (with the exception of Drupal\sdc\Element\ComponentElement) which will make it impossible to extend them. However, we acknowledge that manual instantiation and execution of static public methods still require backwards compatibility.

In order to provide backwards compatibility, we propose to use class_alias. This will handle the namepace changes. A deprecation notice will be thrown because the module itself is deprecated. In order to clear the deprecation the user will need to change their use statements using the list of class_alias in sdc.module as a reference.

Additional Considerations

We will not merge this until feedback from experimental users is done in regards to the other issues in our roadmap to stability. Therefore, we will keep this updated during the process and then merge as a last step.

Remove deprecated twig functions declared in #3409456: Remove SDC deprecated code before 11.0.0

Issues

File Issue
Component\ComponentMetadata.php
#3365467: Move SDC Component namespace to Core namespace
Component\ComponentValidator.php
#3365467: Move SDC Component namespace to Core namespace
Component\SchemaCompatibilityChecker.php
#3365467: Move SDC Component namespace to Core namespace
ComponentNegotiator.php
#3365686: Move SDC ComponentNegotiator to Core namespace
ComponentPluginManager.php
#3365690: Move SDC ComponentPluginManager namespace to Core namespace
Element\ComponentElement.php
#3365693: Move SDC Element\ComponentElement to Core namespace
Exception\ComponentNotFoundException.php
#3365468: Move SDC Exceptions to Core namespace
Exception\IncompatibleComponentSchema.php
#3365468: Move SDC Exceptions to Core namespace
Exception\InvalidComponentDataException.php
#3365468: Move SDC Exceptions to Core namespace
Exception\InvalidComponentException.php
#3365468: Move SDC Exceptions to Core namespace
ExtensionType.php
#3365695: Move SDC ExtensionType to Core namespace
Plugin\Component.php
#3365699: Move SDC Component to Core namespace
Plugin\Discovery\DirectoryWithMetadataDiscovery.php
#3365700: Move SDC Discovery namespace to Core namespace
Plugin\Discovery\DirectoryWithMetadataPluginDiscovery.php
#3365700: Move SDC Discovery namespace to Core namespace
Plugin\Discovery\RegexRecursiveFilterIterator.php
#3365700: Move SDC Discovery namespace to Core namespace
Twig\ComponentNodeVisitor.php
#3365702: Move SDC Drupal\sdc\Twig to Core namespace
Twig\TwigComponentLoader.php
#3365702: Move SDC Drupal\sdc\Twig to Core namespace
Twig\TwigExtension.php
#3365702: Move SDC Drupal\sdc\Twig to Core namespace
Utilities.php
#3352858: Move isRenderArray from SDC to Drupal\Core\Render\Element
metadata-full.schema.json
#3365711: Move SDC *.schema.json to Core namespace
metadata.schema.json
#3365711: Move SDC *.schema.json to Core namespace
sdc.module
#3365714: Move SDC sdc.module functions to Core namespace
sdc.services.yml
No issue necessary, it will be handled in the issues moving each of the service classes.
tests/*
#3406356: Move SDC tests/* to Core namespace

Release notes

The single directory components module is now deprecated. The functionality has been moved to Drupal core.

Issue fork drupal-3352256

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mherchel created an issue. See original summary.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

e0ipso’s picture

Title: Move code from the experimental SDC module to core » [META] Move code from the experimental SDC module to core
Category: Task » Plan
Status: Postponed » Active
Issue tags: +SDC Sprint DrupalConNA 2023
e0ipso’s picture

Issue summary: View changes
bbrala’s picture

Issue summary: View changes

Lets add a todo list of the stuff that needs moving.

bbrala’s picture

Issue summary: View changes
bbrala’s picture

Issue summary: View changes
bbrala’s picture

Issue summary: View changes

It doesnt like wide table, sorry.

bbrala’s picture

bbrala’s picture

Issue summary: View changes
bbrala’s picture

Issue summary: View changes
dww’s picture

Thanks for organizing all this as a meta issue!

From reading some of the child issues, it seems like the idea is that each issue will open MRs vs this one branch, not against core itself? So someone will decide to merge MRs into here and then the final commit to core will be a monolithic, giant commit? It’d be great to be clear in this parent meta issue so everyone working on this knows what to expect.

Also, not clear what we need a table for here. 😅 seems like a <dl> would be easier to work with and make more semantic sense. 🤓 Unless there are going to be more columns that don’t yet exist for other things?

Thanks again!
-Derek

bbrala’s picture

Yeah we merge against this feature branch. I will open the branches and mr's to this branch today so we dont need to figure that out later.

THere were more columns in my original table, but that broke the layout of the issue. I will convert it to a definition list when i arrive in the contrib rooms in pittsburgh.

e0ipso’s picture

We will also need a plan to move sdc_library_info_build to the corresponding location. Likely close to the code that is firing hook_library_info_build.

bbrala’s picture

Issue summary: View changes
bbrala’s picture

Issue summary: View changes
bbrala’s picture

Issue summary: View changes
bbrala’s picture

Issue summary: View changes
e0ipso’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update

Updated issue summary.

bbrala’s picture

Issue summary: View changes
bbrala’s picture

Issue summary: View changes
bbrala’s picture

Issue summary: View changes
bbrala’s picture

Issue summary: View changes
bbrala’s picture

Issue summary: View changes
bbrala’s picture

Issue summary: View changes
bbrala’s picture

Issue summary: View changes
bbrala’s picture

Issue summary: View changes
dww’s picture

Fantastic, thanks! That's much more clear. 😅

Today is packed, then I travel tomorrow, but hopefully I can spare some cycles on some of the child issues next week... 🤞 Following them all now, at least. 😉

Cheers,
-Derek

bbrala’s picture

Issue summary: View changes

I've also opened a draft merge request to this issue for each child issue. Mostly because we don't use the default workflow since we are merging those issues towards this issue branch instead of main itself.

#3365714: Move SDC sdc.module functions to Core namespace might need splitting, because it is about 2 functions in the module file.

Also i didnt open an issue for the tests, they would also need updating in eather the issues that change them, or centrally. But i think there will be less discussion on those, since they might live in places based on the results of the child issues.

bbrala’s picture

Currently the MR in this issue is not mergable, but that should resolve itself when code has actually changed in the branch. Which is hasn't right now.

dww’s picture

Whoops. I was trying to help move #3352858: Move isRenderArray from SDC to Drupal\Core\Render\Element forward, cherry-pick'ed my commit into this branch and pushed. I now realize I believe y'all wanted that in MR form, not a direct push. 😬 Should I revert, or do y'all wanna just leave it? It was already RTBC when it was a stand-alone commit. Sorry!

e0ipso’s picture

@dww I think all is fine. As you say, code was already RTBC. First one is in! Thanks for moving it! Let's keep rolling them in.

dieterholvoet’s picture

Component: theme system » single directory components
e0ipso’s picture

Issue summary: View changes
Status: Active » Needs work

e0ipso credited plopesc.

e0ipso’s picture

#3365711: Move SDC *.schema.json to Core namespace was merged. Creditting @plopesc for that part.

e0ipso’s picture

e0ipso’s picture

#3365686: Move SDC ComponentNegotiator to Core namespace is also done. Thanks to @plopesc again!

e0ipso’s picture

I just re-rolled 11.x. Likely we won't need to do this again since this issue is the last blocker for stable.

plopesc changed the visibility of the branch 3352256-meta-move-code-merge to hidden.

e0ipso’s picture

e0ipso’s picture

e0ipso’s picture

Issue summary: View changes
e0ipso’s picture

e0ipso’s picture

e0ipso’s picture

plopesc’s picture

e0ipso’s picture

e0ipso’s picture

e0ipso’s picture

StatusFileSize
new209.06 KB

Only tests are missing now.

Only tests are missing

e0ipso’s picture

Issue summary: View changes

e0ipso’s picture

Status: Needs work » Needs review

Tests are green and all the initial tasks are done. I think it's time for a review.

e0ipso’s picture

StatusFileSize
new116.23 KB

We are done

e0ipso’s picture

I scaffolded https://www.drupal.org/node/3410260 so we can have a URL to reference in the deprecation messages.

catch’s picture

@e0ipso if the entire module is deprecated, then the code doesn't need to be deprecated too as such - people will know they need to uninstall it.

e0ipso’s picture

Status: Needs review » Needs work

I think I got the class_alias wrong. I believe I need to change the alias direction.

e0ipso’s picture

I also see this error:

Drupal\Core\Extension\InfoParserException: Extension Single Directory Components (core/modules/sdc/sdc.info.yml) has 'lifecycle: deprecated' but is missing a 'lifecycle_link' entry. in Drupal\Core\Extension\InfoParserDynamic->parse() (line 95 of core/lib/Drupal/Core/Extension/InfoParserDynamic.php).
e0ipso’s picture

Status: Needs work » Needs review
e0ipso’s picture

Status: Needs review » Needs work

Some tests are failing. Investigating.

e0ipso’s picture

I forgot to remove the dependency of Umami on SDC. Let's see if tests pass now.

e0ipso’s picture

Status: Needs work » Needs review

Tests are green now. This is finally ready for review.

e0ipso’s picture

Issue summary: View changes
needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

e0ipso’s picture

Status: Needs work » Needs review

Merged 11.x into this branch.

e0ipso’s picture

Title: [META] Move code from the experimental SDC module to core » Move code from the experimental SDC module to core
Category: Plan » Feature request
catch’s picture

Category: Feature request » Task
quietone’s picture

The IS has this

Once we have all the smaller issues merged, we will work to clear the release manager and commit manager tags from the big MR,

But what is 'the big MR'?

e0ipso’s picture

@quietone we created a feature branch for this issue. We then opened MRs to this issue's branch to start contributing code in smaller bits. This allowed us to have a more manageable scope for peer review and for comments. All the code accumulated in this branch, as soon as we thought it was ready.

Now this issue's branch contains all the code, it is the big MR against 11.x.

I hope that makes sense.

plopesc’s picture

Status: Needs review » Reviewed & tested by the community

Given that Mateu, Stephen and myself have been reviewing all the individual parts that make up this MR, I feel confident in setting this to RTBC.

Thank you!

catch’s picture

Status: Reviewed & tested by the community » Needs work

The MR pipeline failed three weeks ago, I just re-ran it and it failed again.

e0ipso’s picture

I just re-rolled it. Let's see if that fixes it.

e0ipso’s picture

Status: Needs work » Needs review

This commit above adapts some of the code after #3414807: \Drupal\Core\Asset\LibraryDiscoveryParser should use FileCache to cache the parsed YAML.

Let's see if we get a green.

plopesc’s picture

Status: Needs review » Reviewed & tested by the community

Once the MR has been rebased and the merge conflicts solved, I think it is OK to move it back to RTBC.

Thank you!

longwave’s picture

Status: Reviewed & tested by the community » Needs work

After applying the MR there are a number of references to sdc remaining, added some comments to see if we can reduce/remove these.

e0ipso’s picture

Status: Needs work » Needs review

@longwave I addressed your comments in the MR.

e0ipso’s picture

@longwave are you good to move it back to RTBC?

longwave’s picture

Status: Needs review » Needs work

Added another round of questions/feedback to the MR.

e0ipso’s picture

@longwave most of those comments belong to code that has been moved, rather than changed. This MR is scoped only to moving the code that was approved in the experimental module to its final home. There will be minor changes in code to ensure BC, and some new code in the LibraryDiscoveryParser, but that should be it.

Even if the diff is very big, the changes are not that big.

That being said, I am interested in pursuing the conversations you started but I fear that might derail the scope of this big-enough MR. What do you thing is the best way to address your concerns? Would a follow up issue be a good place for it, or would you rather do it all here?

longwave’s picture

As mentioned in Slack the only two three things I am really concerned about here are:

  • The library prefix - do we need to consider BC?
  • TwigExtension is getting quite large, should the component extension just be a separate service?
  • The BC layer for the component validator service is incorrect.

I think the others can wait for followups.

longwave’s picture

Oh, would also be interested in your thoughts on service naming as well, because all other core services have friendly string names instead of just class names.

e0ipso’s picture

The library prefix - do we need to consider BC?

Yes. This is how we tried to handle it. This section of the code generates the libraries with the old names for backwards compatibility reasons.

I see that there is a small error with the wording of the deprecation message that I will fix right away.

The relevant conversations can be found in #3365714: Move SDC sdc.module functions to Core namespace and in its corresponding MR.

e0ipso’s picture

TwigExtension is getting quite large, should the component extension just be a separate service?

Yeah. We touched on that during our conversations while moving it. This is the comment from @plopesc:

Creating a new twig extension would be much simpler, but in the long term, I believe that will be better to have a single one.
I'll work on the BC approach for now.

Do you think that reverting the changes to TwigExtension and moving the SDC Twig extension to Drupal\Core\Template\ComponentsTwigExtension is a better approach? I felt good about both options back in the day, so I'll be happy to implement it.

The relevant conversations can be found in #3365702: Move SDC Drupal\sdc\Twig to Core namespace, and its corresponding MR.

e0ipso’s picture

The BC layer for the component validator service is incorrect.

You are correct, I will push a fix right away.

e0ipso’s picture

@longwave thank you so much for your rounds of review. I know this is a big MR, with lots of context, and most of it is hidden behind children issues. I tried to organize it in sub-issues to facilitate development and review, it turns out it's been more difficult for everyone involved. Sorry.

e0ipso’s picture

Throwing something at the CI before logging off. I will finish applying the feedback in the morning.

e0ipso’s picture

Oh, would also be interested in your thoughts on service naming as well, because all other core services have friendly string names instead of just class names.

This is something suggested by @larowlan in the MR that got SDC in core as experimental.

e0ipso’s picture

Status: Needs work » Needs review

Setting back to Needs Review.

longwave’s picture

Thanks for fixing the BC layer in the constructor.

I added a question about the library BC layer - not sure strtr() does what you expect here, as it replaces bytes in a string?

Going to ask the framework managers for input on:

  • Whether to have one combined TwigExtension class or keep the components TwigExtension as a separate service
  • Whether to add class aliases or if we are OK just to name services with their FQCN
e0ipso’s picture

@longwave I fixed the library bc layer and added a test for it.

longwave’s picture

Tagging for the framework managers to answer #93 but other than that I think we are done here, thank you for all your work on getting this in!

catch’s picture

Eventually we're likely to remove service aliases for things where we don't expect anyone to interact with the service name, but not sure why we're setting a precedent here. On the other hand, is it worth adding the aliases only to remove them later. Don't feel strongly about this to be honest.

I'm confused about what's going on with the TwigExtension - it looks like there's now a dedicated component twig extension, but there are still two additional arguments for the main twig extension, was the separate twig extension already created and those are just cruft, or am I missing something? Looking at the long list of arguments to TwigExtension, I think keeping two separate classes makes sense, but then why would we be adding extra dependencies to the main one?

longwave’s picture

Status: Needs review » Needs work

Many tests are failing.

e0ipso’s picture

Status: Needs work » Needs review

Sorry @longwave it seems the suppression file had a syntax issue. It is fixed now.

e0ipso’s picture

@catch you are correct, that is some cruft from the other day when I split that service in two. I will fix now.

nod_’s picture

Just wanted to raise a point for Framework Managers about the $schema URL in the components definition.

What we expect folks to add to their metadata yml file is $schema: https://git.drupalcode.org/project/drupal/-/raw/HEAD/core/assets/v1/metadata.schema.json for better DX so that IDEs can provide autocompletion.

I'm not sure pointing to the repo HEAD is the best thing. We can change the schema version by adding a v2 folder and updating the URL, keeping all the versions all the time in the repo.

what I'm not sure is if this URL is going to last 10 years, and if having all the different versions in HEAD is what we want, sounds like it could be somewhere else and not tied to the source of Drupal. Then again it makes sense to have it in the source since that's where all the stuff is defined to begin with.

I don't have a good answer, just questions but I don't think they should hold up this patch.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

nod_’s picture

I committed a couple of umami components, please update their $schema url as part of this MR :)

#3365497: Create new SDC component for Umami Banner
#3404302: Create header component for Umami, with JS

e0ipso’s picture

Status: Needs work » Needs review

Pipeline is back to green.

I resolved merge conflicts and addressed @nod_'s request in #102.

plopesc’s picture

Status: Needs review » Reviewed & tested by the community

Feedback has been addressed and tests are green.

I think we can move it back to RTBC.

longwave’s picture

Status: Reviewed & tested by the community » Needs review

Added some questions about the schema URLs.

e0ipso’s picture

Added some questions about the schema URLs.

Yeah. I have addressed that. Sorry for the hasty change, I keep finding myself out of context for this issue every time I work on it. Thanks for catching it. Schema URLs are not super important but we got to get them right.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

I've read over the MR multiple times now and there are only really minor nits remaining that ultimately don't matter and could be fixed in followups if needed, so this looks ready to go to me now.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

nod_’s picture

Status: Needs work » Reviewed & tested by the community

merged and tests still passing

larowlan’s picture

Status: Reviewed & tested by the community » Needs work

Nice work folks, left a couple of items on the MR, mostly minor stuff

e0ipso’s picture

Status: Needs work » Needs review

Review feedback implemented. Everything is back to green. Setting back to NR.

e0ipso’s picture

Status: Needs review » Needs work

Oh no, I might have been looking at the wrong thing. I see an issue about deprecation messages. Investigating.

e0ipso’s picture

Status: Needs work » Needs review

Review feedback implemented. Everything is back to green. Setting back to NR.

[déjà vu]

longwave’s picture

Status: Needs review » Reviewed & tested by the community

I retitled the CR as it sounded previously like we were deprecating SDC if you did not read it carefully. All the recent changes look good so back to RTBC.

e0ipso’s picture

Resolved merge conflicts and fixed an issue number to point the the CR.

larowlan’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: -Needs framework manager review

Looks like one item still open in the MR

e0ipso’s picture

Status: Needs review » Reviewed & tested by the community

Moving back to RTBC.

  • larowlan committed 069d3c01 on 10.3.x
    Issue #3352256 by e0ipso, plopesc, bbrala, longwave, dww, catch,...

  • larowlan committed e1e95969 on 11.x
    Issue #3352256 by e0ipso, plopesc, bbrala, longwave, dww, catch,...

larowlan’s picture

Version: 11.x-dev » 10.3.x-dev
Issue summary: View changes
Status: Reviewed & tested by the community » Fixed
Issue tags: +10.3.0 release highlights

Committed to 11.x and backported to 10.3.x

Published change record

🎉 Congratulations - huge effort

Added a release note snippet

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

agentrickard changed the visibility of the branch 11.x to hidden.

agentrickard changed the visibility of the branch 11.x to hidden.