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

Request for input: make pattern engine loading explicit via the PL config #1251

Closed
ringods opened this issue Aug 28, 2020 · 4 comments · Fixed by #1256
Closed

Request for input: make pattern engine loading explicit via the PL config #1251

ringods opened this issue Aug 28, 2020 · 4 comments · Fixed by #1256

Comments

@ringods
Copy link
Contributor

ringods commented Aug 28, 2020

This issue is to discuss the changes in loading pattern engines. It requires input from the core team: @bmuenzenmeyer @bradfrost @sghoweri @JosefBredereck and whoever I am forgetting.

In #1225 & #1246, I changed the way how resources from UIKits are loaded: via the NodeJS resolver (require.resolve). For this to work, it now requires the property package, with a fallback at the moment based on name but which will be removed in the future. This makes it the loading explicit: first add the UIKit as a package dependency, then resolve the resources and copy them. Using the resolver also makes this feature working independent of the package manager.

The next piece of code loading that needs to go via the resolver is the loading of pattern engines. The current code is again scanning the node_modules folder in 2 different locations manually:

const enginesDirectories = [
{
displayName: 'the core',
path: path.resolve(__dirname, '..', '..', 'node_modules'),
},
{
displayName: 'the edition or test directory',
path: path.join(process.cwd(), 'node_modules'),
},
];

It returns every package which matches engine- in the package name:

/**
* Given a path: return the engine name if the path points to a valid engine
* module directory, or false if it doesn't.
* @param filePath
* @returns Engine name if exists or FALSE
*/
function isEngineModule(filePath) {
const baseName = path.basename(filePath);
const engineMatch = baseName.match(engineMatcher);
if (engineMatch) {
return engineMatch[1];
}
return false;
}

Like UIKits, this is not explicit and can lead to incorrect packages being found. If we want to make it explicit, the PatternLab configuration needs to be extended with an explicit mention of the pattern engines which must be loaded. But how should this look?

  • Should the config only specify a single pattern engine or should it be a list?
  • For each of the pattern engines, is more config needed besides the package name?

Any further suggestions?

@ringods ringods self-assigned this Aug 28, 2020
@JosefBredereck
Copy link
Contributor

JosefBredereck commented Aug 29, 2020

I'm completely on your side on this topic. I would recommend defining by a package which engine should be loaded for engines, kits, plugins, and other stuff that we ever plan in the future. Only relying on the name could lead to unintentional errors, because of deep dependencies in other public packages.

Adding also my question from this ticket: #872 (comment) because it also references to the pluing loading by name and not package.

@bmuenzenmeyer
Copy link
Member

bmuenzenmeyer commented Aug 30, 2020 via email

@stale
Copy link

stale bot commented Dec 19, 2020

It's hard to keep track of everything. This issue has been automatically marked as stale because it has not had recent activity, neither from the team nor the community. It will be closed if no further activity occurs. Please consider adding additional info, volunteering to contribute a fix for this issue, or making a further case that this is important to you, the team, and the project as a whole. Thanks!

@stale
Copy link

stale bot commented Jan 9, 2022

It's hard to keep track of everything. This issue has been automatically marked as stale because it has not had recent activity, neither from the team nor the community. It will be closed if no further activity occurs. Please consider adding additional info, volunteering to contribute a fix for this issue, or making a further case that this is important to you, the team, and the project as a whole. Thanks!

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

Successfully merging a pull request may close this issue.

3 participants