refactor: API

This commit is contained in:
cha0s 2022-03-18 00:52:23 -05:00
parent fe6c4cecce
commit fa092bd512

View File

@ -181,13 +181,10 @@ export default class ServerFlecks extends Flecks {
return Mr.call(this, request, options);
};
}
// Flecks that are aliased or symlinked need compilation.
// Compile.
const flecks = {};
const needCompilation = paths
.filter((path) => (
this.fleckIsAliased(resolver, path)
|| this.fleckIsSymlinked(resolver, path)
));
.filter((path) => this.fleckIsCompiled(resolver, path));
if (needCompilation.length > 0) {
const register = R('@babel/register');
// Augment the compiler with babel config from flecksrc.
@ -298,6 +295,14 @@ export default class ServerFlecks extends Flecks {
return fleck !== this.resolve(resolver, fleck);
}
fleckIsCompiled(fleck) {
return this.constructor.fleckIsCompiled(this.resolver, fleck);
}
static fleckIsCompiled(resolver, fleck) {
return this.fleckIsAliased(resolver, fleck) || this.fleckIsSymlinked(resolver, fleck);
}
fleckIsSymlinked(fleck) {
return this.constructor.fleckIsSymlinked(this.resolver, fleck);
}
@ -528,12 +533,9 @@ export default class ServerFlecks extends Flecks {
if (config.module.rules.has('compile')) {
config.module.rules.delete('compile');
}
// Flecks that are aliased or symlinked need compilation.
// Compile.
const needCompilation = Object.entries(resolver)
.filter(([fleck]) => (
this.constructor.fleckIsAliased(resolver, fleck)
|| this.constructor.fleckIsSymlinked(resolver, fleck)
));
.filter(([fleck]) => this.constructor.fleckIsCompiled(resolver, fleck));
if (needCompilation.length > 0) {
const rcBabel = this.babel();
debug('.flecksrc: babel: %O', rcBabel);