From fa092bd51229b657c2023e2174ddd7cd97d0e464 Mon Sep 17 00:00:00 2001 From: cha0s Date: Fri, 18 Mar 2022 00:52:23 -0500 Subject: [PATCH] refactor: API --- packages/core/src/server/flecks.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/core/src/server/flecks.js b/packages/core/src/server/flecks.js index a8d8b98..9c69264 100644 --- a/packages/core/src/server/flecks.js +++ b/packages/core/src/server/flecks.js @@ -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);