Skip to content

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

Closed
@ringods

Description

@ringods

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?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions