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