From 4b170d78c6c08edf65b59c79a631608d9e68e619 Mon Sep 17 00:00:00 2001 From: Kelly Mears Date: Sun, 8 Dec 2024 22:43:56 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20fix(minor):=20root=20only=20serv?= =?UTF-8?q?ices=20always=20resolve=20to=20root?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bud-framework/src/bootstrap/index.ts | 64 +++++++++++-------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/sources/@roots/bud-framework/src/bootstrap/index.ts b/sources/@roots/bud-framework/src/bootstrap/index.ts index 980b092ad4..926ef64170 100644 --- a/sources/@roots/bud-framework/src/bootstrap/index.ts +++ b/sources/@roots/bud-framework/src/bootstrap/index.ts @@ -85,30 +85,30 @@ export const bootstrap = async (bud: Bud) => { bud.hooks .fromMap({ - 'location.@dist': bud.context.paths.output, - 'location.@modules': bud.context.paths.modules, - 'location.@src': bud.context.paths.input, - 'location.@storage': bud.context.paths.storage, - 'pattern.css': /^(?!.*\.module\.css$).*\.css$/, - 'pattern.cssModule': /\.module\.css$/, - 'pattern.csv': /\.(csv|tsv)$/, - 'pattern.font': /\.(ttf|otf|eot|woff2?|ico)$/, - 'pattern.html': /\.(html?)$/, - 'pattern.image': /\.(png|jpe?g|gif|webp)$/, - 'pattern.js': /\.(mjs|jsx?)$/, - 'pattern.json': /\.json$/, - 'pattern.json5': /\.json5$/, - 'pattern.md': /\.md$/, - 'pattern.modules': /(node_modules|bower_components|vendor)/, - 'pattern.sass': /^(?!.*\.module\.s[ac]ss$).*\.s[ac]ss$/, - 'pattern.sassModule': /\.module\.s[ac]ss$/, - 'pattern.svg': /\.svg$/, - 'pattern.toml': /\.toml$/, - 'pattern.ts': /\.(m?tsx?)$/, - 'pattern.vue': /\.vue$/, - 'pattern.webp': /\.webp$/, - 'pattern.xml': /\.xml$/, - 'pattern.yml': /\.ya?ml$/, + [`location.@dist`]: bud.context.paths.output, + [`location.@modules`]: bud.context.paths.modules, + [`location.@src`]: bud.context.paths.input, + [`location.@storage`]: bud.context.paths.storage, + [`pattern.css`]: /^(?!.*\.module\.css$).*\.css$/, + [`pattern.cssModule`]: /\.module\.css$/, + [`pattern.csv`]: /\.(csv|tsv)$/, + [`pattern.font`]: /\.(ttf|otf|eot|woff2?|ico)$/, + [`pattern.html`]: /\.(html?)$/, + [`pattern.image`]: /\.(png|jpe?g|gif|webp)$/, + [`pattern.js`]: /\.(mjs|jsx?)$/, + [`pattern.json`]: /\.json$/, + [`pattern.json5`]: /\.json5$/, + [`pattern.md`]: /\.md$/, + [`pattern.modules`]: /(node_modules|bower_components|vendor)/, + [`pattern.sass`]: /^(?!.*\.module\.s[ac]ss$).*\.s[ac]ss$/, + [`pattern.sassModule`]: /\.module\.s[ac]ss$/, + [`pattern.svg`]: /\.svg$/, + [`pattern.toml`]: /\.toml$/, + [`pattern.ts`]: /\.(m?tsx?)$/, + [`pattern.vue`]: /\.vue$/, + [`pattern.webp`]: /\.webp$/, + [`pattern.xml`]: /\.xml$/, + [`pattern.yml`]: /\.ya?ml$/, }) .when(bud.isDevelopment, ({hooks}) => hooks.fromMap({ @@ -135,7 +135,21 @@ export const bootstrap = async (bud: Bud) => { }), ) - bud.isRoot && bud.after(bud.module.after) + /** + * Certain services are only available via the root instance of {@link Bud}. + * Ensure that they always refer to the parent instance. + */ + if (!bud.isRoot) { + bud.set(`compiler`, bud.root.compiler) + bud.set(`dashboard`, bud.root.dashboard) + if (bud.isDevelopment) { + bud.set(`server`, bud.root.server) + } + } + + if (bud.isRoot) { + bud.after(bud.module.after) + } await bud.executeServiceCallbacks(`bootstrap`) await bud.executeServiceCallbacks(`register`)