From 40204dba65468899087480a6288d116ccf83b083 Mon Sep 17 00:00:00 2001 From: Kelly Mears Date: Sat, 9 Sep 2023 17:25:03 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=81=20types(patch):=20improve=20typing?= =?UTF-8?q?s=20(@roots/bud-react)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/@roots/bud-react/package.json | 41 +---- .../bud-react/src/babel-refresh/extension.ts | 28 ---- .../bud-react/src/babel-refresh/index.ts | 34 ++-- .../bud-react/src/extension/extension.ts | 92 ----------- .../@roots/bud-react/src/extension/index.ts | 95 ++++++++++- sources/@roots/bud-react/src/index.ts | 37 ++++- .../bud-react/src/react-refresh/extension.ts | 146 ----------------- .../bud-react/src/react-refresh/index.ts | 148 +++++++++++++++++- sources/@roots/bud-react/src/types.ts | 35 ----- .../src/typescript-refresh/extension.ts | 42 ----- .../bud-react/src/typescript-refresh/index.ts | 48 ++++-- .../test/babel-refresh/extension.test.ts | 3 +- .../@roots/bud-react/test/extension.test.ts | 3 +- .../test/extension/extension.test.ts | 6 +- .../test/react-refresh/extension.test.ts | 5 +- .../test/swc-refresh/extension.test.ts | 5 +- .../test/typescript-refresh/extension.test.ts | 6 +- 17 files changed, 351 insertions(+), 423 deletions(-) delete mode 100644 sources/@roots/bud-react/src/babel-refresh/extension.ts delete mode 100644 sources/@roots/bud-react/src/extension/extension.ts delete mode 100644 sources/@roots/bud-react/src/react-refresh/extension.ts delete mode 100644 sources/@roots/bud-react/src/types.ts delete mode 100644 sources/@roots/bud-react/src/typescript-refresh/extension.ts diff --git a/sources/@roots/bud-react/package.json b/sources/@roots/bud-react/package.json index 679a94a7e5..840f8e712a 100644 --- a/sources/@roots/bud-react/package.json +++ b/sources/@roots/bud-react/package.json @@ -49,34 +49,12 @@ ], "type": "module", "exports": { - ".": { - "import": "./lib/index.js", - "default": "./lib/index.js" - }, - "./babel-refresh": { - "import": "./lib/babel-refresh/index.js", - "default": "./lib/babel-refresh/index.js" - }, - "./extension": { - "import": "./lib/extension.js", - "default": "./lib/extension.js" - }, - "./react-refresh": { - "import": "./lib/react-refresh/index.js", - "default": "./lib/react-refresh/index.js" - }, - "./swc-refresh": { - "import": "./lib/swc-refresh/index.js", - "default": "./lib/swc-refresh/index.js" - }, - "./typescript-refresh": { - "import": "./lib/typescript-refresh/index.js", - "default": "./lib/typescript-refresh/index.js" - }, - "./types": { - "import": "./lib/types.js", - "default": "./lib/types.js" - } + ".": "./lib/index.js", + "./babel-refresh": "./lib/babel-refresh/index.js", + "./extension": "./lib/extension/index.js", + "./react-refresh": "./lib/react-refresh/index.js", + "./swc-refresh": "./lib/swc-refresh/index.js", + "./typescript-refresh": "./lib/typescript-refresh/index.js" }, "typesVersions": { "*": { @@ -87,7 +65,7 @@ "./lib/babel-refresh/index.d.ts" ], "extension": [ - "./lib/extension.d.ts" + "./lib/extension/index.d.ts" ], "react-refresh": [ "./lib/react-refresh/index.d.ts" @@ -97,9 +75,6 @@ ], "typescript-refresh": [ "./lib/typescript-refresh/index.d.ts" - ], - "types": [ - "./lib/types.d.ts" ] } }, @@ -108,6 +83,7 @@ "devDependencies": { "@babel/core": "7.22.11", "@roots/bud": "workspace:*", + "@roots/bud-babel": "workspace:*", "@roots/bud-esbuild": "workspace:*", "@roots/bud-swc": "workspace:*", "@roots/bud-typescript": "workspace:*", @@ -120,7 +96,6 @@ "dependencies": { "@babel/preset-react": "7.22.5", "@pmmmwh/react-refresh-webpack-plugin": "0.5.11", - "@roots/bud-babel": "workspace:*", "@roots/bud-framework": "workspace:*", "@roots/bud-support": "workspace:*", "react": "18.2.0", diff --git a/sources/@roots/bud-react/src/babel-refresh/extension.ts b/sources/@roots/bud-react/src/babel-refresh/extension.ts deleted file mode 100644 index c199cc4b80..0000000000 --- a/sources/@roots/bud-react/src/babel-refresh/extension.ts +++ /dev/null @@ -1,28 +0,0 @@ -import type {Bud} from '@roots/bud-framework' - -import {Extension} from '@roots/bud-framework/extension' -import { - bind, - development, - label, -} from '@roots/bud-framework/extension/decorators' - -/** - * Register `react-refresh-typescript` transform with TSC compiler - */ -@label(`@roots/bud-react/babel-refresh`) -@development -export default class BudBabelRefresh extends Extension { - /** - * {@link Extension.register} - */ - @bind - public override async register(bud: Bud) { - this.logger.log(`Registering react-refresh-babel transformer`) - - bud.babel.setPlugin( - `react-refresh/babel`, - await this.resolve(`react-refresh/babel`, import.meta.url), - ) - } -} diff --git a/sources/@roots/bud-react/src/babel-refresh/index.ts b/sources/@roots/bud-react/src/babel-refresh/index.ts index d4b5b3e9e1..c199cc4b80 100644 --- a/sources/@roots/bud-react/src/babel-refresh/index.ts +++ b/sources/@roots/bud-react/src/babel-refresh/index.ts @@ -1,14 +1,28 @@ -// Copyright © Roots Software Foundation LLC -// Licensed under the MIT license. +import type {Bud} from '@roots/bud-framework' + +import {Extension} from '@roots/bud-framework/extension' +import { + bind, + development, + label, +} from '@roots/bud-framework/extension/decorators' /** - * Adds TypeScript react-refresh transform - * - * @see https://bud.js.org - * @see https://github.com/roots/bud - * - * @packageDocumentation + * Register `react-refresh-typescript` transform with TSC compiler */ +@label(`@roots/bud-react/babel-refresh`) +@development +export default class BudBabelRefresh extends Extension { + /** + * {@link Extension.register} + */ + @bind + public override async register(bud: Bud) { + this.logger.log(`Registering react-refresh-babel transformer`) -import BudBabelRefresh from './extension.js' -export default BudBabelRefresh + bud.babel.setPlugin( + `react-refresh/babel`, + await this.resolve(`react-refresh/babel`, import.meta.url), + ) + } +} diff --git a/sources/@roots/bud-react/src/extension/extension.ts b/sources/@roots/bud-react/src/extension/extension.ts deleted file mode 100644 index 18dcb914b8..0000000000 --- a/sources/@roots/bud-react/src/extension/extension.ts +++ /dev/null @@ -1,92 +0,0 @@ -import type {Bud} from '@roots/bud-framework' - -import {Extension} from '@roots/bud-framework/extension' -import { - bind, - dependsOn, - expose, - label, -} from '@roots/bud-framework/extension/decorators' -import merge from '@roots/bud-support/lodash/merge' - -import type BudReactRefresh from '../react-refresh/index.js' - -/** - * React configuration - */ -@label(`@roots/bud-react`) -@dependsOn([`@roots/bud-react/react-refresh`]) -@expose(`react`) -export default class BudReact extends Extension { - /** - * {@link Extension.configAfter} - * - */ - @bind - public override async boot(bud: Bud) { - if ( - ![this.useSWC, this.useTypeScript, this.useBabel].some( - t => t === true, - ) - ) { - this.logger.warn(`No supported compiler found.`) - } - - if (this.useSWC) { - bud.swc.setJsc( - merge(bud.swc.jsc, {transform: {react: {runtime: `automatic`}}}), - ) - } - - if (this.useBabel) { - this.app.babel.setPreset( - `@babel/preset-react`, - await this.resolve(`@babel/preset-react`, import.meta.url), - ) - } - } - - /** - * Accessor for `@roots/bud-react/react-refresh` - * - * @readonly - */ - public get refresh(): BudReactRefresh { - return this.app.extensions.get(`@roots/bud-react/react-refresh`) - } - - /** - * Use babel - * - * @readonly - */ - public get useBabel(): boolean { - if (this.useTypeScript) return false - if (this.useSWC) return false - return this.app.extensions.has(`@roots/bud-babel`) - } - - /** - * Use SWC - * - * @readonly - */ - public get useSWC(): boolean { - return this.app.extensions.has(`@roots/bud-swc`) - } - - /** - * Use TypeScript - * - * @readonly - */ - public get useTypeScript(): boolean { - if (this.useSWC) return false - - if (this.app.extensions.has(`@roots/bud-typescript`)) { - return !this.app.extensions.get(`@roots/bud-typescript`).get(`babel`) - } - - return false - } -} diff --git a/sources/@roots/bud-react/src/extension/index.ts b/sources/@roots/bud-react/src/extension/index.ts index 9198a81177..d85e2461ed 100644 --- a/sources/@roots/bud-react/src/extension/index.ts +++ b/sources/@roots/bud-react/src/extension/index.ts @@ -1,2 +1,93 @@ -import BudReact from './extension.js' -export default BudReact +import type {Bud} from '@roots/bud-framework' + +import {Extension} from '@roots/bud-framework/extension' +import { + bind, + dependsOn, + expose, + label, +} from '@roots/bud-framework/extension/decorators' +import merge from '@roots/bud-support/lodash/merge' + +import type BudReactRefresh from '../react-refresh/index.js' + +/** + * React configuration + */ +@label(`@roots/bud-react`) +@dependsOn([`@roots/bud-react/react-refresh`]) +@expose(`react`) +export default class BudReact extends Extension { + /** + * {@link Extension.configAfter} + * + */ + @bind + public override async boot(bud: Bud) { + if ( + ![this.useSWC, this.useTypeScript, this.useBabel].some( + t => t === true, + ) + ) { + this.logger.warn(`No supported compiler found.`) + } + + if (this.useSWC) { + bud.swc.setJsc( + merge(bud.swc.jsc, {transform: {react: {runtime: `automatic`}}}), + ) + } + + if (this.useBabel) { + const babelPluginUrl = await this.resolve(`@babel/preset-react`, import.meta.url).catch(bud.catch) + this.app.babel.setPreset( + `@babel/preset-react`, + babelPluginUrl, + ) + } + } + + /** + * Accessor for `@roots/bud-react/react-refresh` + * + * @readonly + */ + public get refresh(): BudReactRefresh { + return this.app.extensions.get(`@roots/bud-react/react-refresh`) + } + + /** + * Use babel + * + * @readonly + */ + public get useBabel(): boolean { + if (this.useTypeScript) return false + if (this.useSWC) return false + return this.app.extensions.has(`@roots/bud-babel`) + } + + /** + * Use SWC + * + * @readonly + */ + public get useSWC(): boolean { + return this.app.extensions.has(`@roots/bud-swc`) + } + + /** + * Use TypeScript + * + * @readonly + */ + public get useTypeScript(): boolean { + if (this.useSWC) return false + + if (this.app.extensions.has(`@roots/bud-typescript`)) { + return !this.app.extensions.get(`@roots/bud-typescript`).get(`babel`) + } + + return false + } +} diff --git a/sources/@roots/bud-react/src/index.ts b/sources/@roots/bud-react/src/index.ts index 4da1554f90..4cef570b63 100644 --- a/sources/@roots/bud-react/src/index.ts +++ b/sources/@roots/bud-react/src/index.ts @@ -8,7 +8,40 @@ * @see https://github.com/roots/bud */ -import BudReact from './extension/index.js' -import './types.js' +import type { + Extension, + PublicExtensionApi, +} from '@roots/bud-framework/extension' +import type BudBabelRefresh from '@roots/bud-react/babel-refresh' +import type BudReactRefresh from '@roots/bud-react/react-refresh' +import type BudSWCRefresh from '@roots/bud-react/swc-refresh' +import type BudTypeScriptRefresh from '@roots/bud-react/typescript-refresh' + +import BudReact from '@roots/bud-react/extension' + +interface PublicBudReactRefresh extends PublicExtensionApi { + setTransformExtension(extension: Extension): void +} + +interface PublicBudReact extends PublicExtensionApi { + refresh: PublicBudReactRefresh + useBabel: boolean + useSWC: boolean + useTypeScript: boolean +} + +declare module '@roots/bud-framework' { + interface Bud { + react: PublicBudReact + } + + interface Modules { + '@roots/bud-react': BudReact + '@roots/bud-react/babel-refresh': BudBabelRefresh + '@roots/bud-react/react-refresh': BudReactRefresh + '@roots/bud-react/swc-refresh': BudSWCRefresh + '@roots/bud-react/typescript-refresh': BudTypeScriptRefresh + } +} export default BudReact diff --git a/sources/@roots/bud-react/src/react-refresh/extension.ts b/sources/@roots/bud-react/src/react-refresh/extension.ts deleted file mode 100644 index 1cfa8b3b45..0000000000 --- a/sources/@roots/bud-react/src/react-refresh/extension.ts +++ /dev/null @@ -1,146 +0,0 @@ -import type {ReactRefreshPluginOptions as Options} from '@pmmmwh/react-refresh-webpack-plugin/types/lib/types.js' -import type {Bud} from '@roots/bud-framework' - -import RefreshPlugin from '@pmmmwh/react-refresh-webpack-plugin' -import {DynamicOption, Extension} from '@roots/bud-framework/extension' -import { - bind, - development, - label, - options, - plugin, -} from '@roots/bud-framework/extension/decorators' -import {ExtensionError} from '@roots/bud-support/errors' -import isBoolean from '@roots/bud-support/lodash/isBoolean' -import isUndefined from '@roots/bud-support/lodash/isUndefined' - -/** - * @pmmmwh/react-refresh-webpack-plugin configuration - */ -@label(`@roots/bud-react/react-refresh`) -@plugin(RefreshPlugin) -@options({ - esModule: DynamicOption.make( - ({context}) => context.manifest?.type === `module`, - ), - overlay: false, -}) -@development -export default class BudReactRefresh extends Extension< - Options, - RefreshPlugin -> { - /** - * Extension to handle transformer - */ - public transformExtension?: Extension - - /** - * {@link Extension.configAfter} - */ - @bind - public override async configAfter(bud: Bud) { - if (!this.isEnabled()) return - if (bud.context.mode !== `development`) return - if (bud.context.hot === false) return - - if (!this.transformExtension) { - const signifier = bud.react.useBabel - ? `@roots/bud-react/babel-refresh` - : bud.react.useSWC - ? `@roots/bud-react/swc-refresh` - : bud.react.useTypeScript - ? `@roots/bud-react/typescript-refresh` - : null - - if (signifier === null) { - throw new ExtensionError( - `@roots/bud-react/react-refresh: no transformer found`, - { - details: `Install @roots/bud-swc, @roots/bud-typescript or @roots/bud-babel`, - }, - ) - } - - await bud.extensions.add(signifier) - - this.setTransformExtension(bud.extensions.get(signifier)) - - this.logger.info( - `Registered transformer`, - this.transformExtension.label, - ) - } - } - - /** - * Configure react-refresh-webpack-plugin - * - * @example - * Add react-refresh-webpack-plugin - * - * ```ts - * bud.react.refresh(true) - * ``` - * - * @example - * Remove react-refresh-webpack-plugin - * - * ```ts - * bud.react.refresh(false) - * ``` - * - * @example - * Configure react-refresh-webpack-plugin - * - * ```ts - * bud.react.refresh({ - * overlay: true, - * }) - * ``` - * - * @remarks - * Configuration takes place during the `config.after` event - */ - @bind - public configure(userOptions?: false | Options): this { - this.app.hooks.action( - `config.after`, - this.makeReactRefreshCallback(userOptions), - ) - - return this - } - - /** - * Callback handling react-refresh-webpack-plugin configuration - */ - @bind - protected makeReactRefreshCallback( - userOptions?: false | Options, - ): (bud: Bud) => Promise { - return async () => { - if (!this.app.isDevelopment) return - - userOptions === false ? this.enable(false) : this.enable() - - if (isUndefined(userOptions) || isBoolean(userOptions)) return - - this.setOptions(userOptions) - - return this - } - } - - /** - * Explicitly set extension to handle react-refresh code transforms - * - * @remarks - * By default the extension will be set automatically based on the - * presence of `@roots/bud-swc`, `@roots/bud-typescript` or `@roots/bud-babel` - * (listed in order of preference). - */ - public setTransformExtension(extension: Extension) { - this.transformExtension = extension - } -} diff --git a/sources/@roots/bud-react/src/react-refresh/index.ts b/sources/@roots/bud-react/src/react-refresh/index.ts index fcdf037538..1cfa8b3b45 100644 --- a/sources/@roots/bud-react/src/react-refresh/index.ts +++ b/sources/@roots/bud-react/src/react-refresh/index.ts @@ -1,2 +1,146 @@ -import BudReactRefresh from './extension.js' -export default BudReactRefresh +import type {ReactRefreshPluginOptions as Options} from '@pmmmwh/react-refresh-webpack-plugin/types/lib/types.js' +import type {Bud} from '@roots/bud-framework' + +import RefreshPlugin from '@pmmmwh/react-refresh-webpack-plugin' +import {DynamicOption, Extension} from '@roots/bud-framework/extension' +import { + bind, + development, + label, + options, + plugin, +} from '@roots/bud-framework/extension/decorators' +import {ExtensionError} from '@roots/bud-support/errors' +import isBoolean from '@roots/bud-support/lodash/isBoolean' +import isUndefined from '@roots/bud-support/lodash/isUndefined' + +/** + * @pmmmwh/react-refresh-webpack-plugin configuration + */ +@label(`@roots/bud-react/react-refresh`) +@plugin(RefreshPlugin) +@options({ + esModule: DynamicOption.make( + ({context}) => context.manifest?.type === `module`, + ), + overlay: false, +}) +@development +export default class BudReactRefresh extends Extension< + Options, + RefreshPlugin +> { + /** + * Extension to handle transformer + */ + public transformExtension?: Extension + + /** + * {@link Extension.configAfter} + */ + @bind + public override async configAfter(bud: Bud) { + if (!this.isEnabled()) return + if (bud.context.mode !== `development`) return + if (bud.context.hot === false) return + + if (!this.transformExtension) { + const signifier = bud.react.useBabel + ? `@roots/bud-react/babel-refresh` + : bud.react.useSWC + ? `@roots/bud-react/swc-refresh` + : bud.react.useTypeScript + ? `@roots/bud-react/typescript-refresh` + : null + + if (signifier === null) { + throw new ExtensionError( + `@roots/bud-react/react-refresh: no transformer found`, + { + details: `Install @roots/bud-swc, @roots/bud-typescript or @roots/bud-babel`, + }, + ) + } + + await bud.extensions.add(signifier) + + this.setTransformExtension(bud.extensions.get(signifier)) + + this.logger.info( + `Registered transformer`, + this.transformExtension.label, + ) + } + } + + /** + * Configure react-refresh-webpack-plugin + * + * @example + * Add react-refresh-webpack-plugin + * + * ```ts + * bud.react.refresh(true) + * ``` + * + * @example + * Remove react-refresh-webpack-plugin + * + * ```ts + * bud.react.refresh(false) + * ``` + * + * @example + * Configure react-refresh-webpack-plugin + * + * ```ts + * bud.react.refresh({ + * overlay: true, + * }) + * ``` + * + * @remarks + * Configuration takes place during the `config.after` event + */ + @bind + public configure(userOptions?: false | Options): this { + this.app.hooks.action( + `config.after`, + this.makeReactRefreshCallback(userOptions), + ) + + return this + } + + /** + * Callback handling react-refresh-webpack-plugin configuration + */ + @bind + protected makeReactRefreshCallback( + userOptions?: false | Options, + ): (bud: Bud) => Promise { + return async () => { + if (!this.app.isDevelopment) return + + userOptions === false ? this.enable(false) : this.enable() + + if (isUndefined(userOptions) || isBoolean(userOptions)) return + + this.setOptions(userOptions) + + return this + } + } + + /** + * Explicitly set extension to handle react-refresh code transforms + * + * @remarks + * By default the extension will be set automatically based on the + * presence of `@roots/bud-swc`, `@roots/bud-typescript` or `@roots/bud-babel` + * (listed in order of preference). + */ + public setTransformExtension(extension: Extension) { + this.transformExtension = extension + } +} diff --git a/sources/@roots/bud-react/src/types.ts b/sources/@roots/bud-react/src/types.ts deleted file mode 100644 index fae8f61a6e..0000000000 --- a/sources/@roots/bud-react/src/types.ts +++ /dev/null @@ -1,35 +0,0 @@ -import type { - Extension, - PublicExtensionApi, -} from '@roots/bud-framework/extension' - -import type BudBabelRefresh from './babel-refresh/index.js' -import type BudReact from './extension/extension.js' -import type BudReactRefresh from './react-refresh/index.js' -import type BudSWCRefresh from './swc-refresh/index.js' -import type BudTypeScriptRefresh from './typescript-refresh/index.js' - -interface PublicBudReactRefresh extends PublicExtensionApi { - setTransformExtension(extension: Extension): void -} - -interface PublicBudReact extends PublicExtensionApi { - refresh: PublicBudReactRefresh - useBabel: boolean - useSWC: boolean - useTypeScript: boolean -} - -declare module '@roots/bud-framework' { - interface Bud { - react: PublicBudReact - } - - interface Modules { - '@roots/bud-react': BudReact - '@roots/bud-react/babel-refresh': BudBabelRefresh - '@roots/bud-react/react-refresh': BudReactRefresh - '@roots/bud-react/swc-refresh': BudSWCRefresh - '@roots/bud-react/typescript-refresh': BudTypeScriptRefresh - } -} diff --git a/sources/@roots/bud-react/src/typescript-refresh/extension.ts b/sources/@roots/bud-react/src/typescript-refresh/extension.ts deleted file mode 100644 index dcd894b048..0000000000 --- a/sources/@roots/bud-react/src/typescript-refresh/extension.ts +++ /dev/null @@ -1,42 +0,0 @@ -import type {Bud} from '@roots/bud-framework' - -import {Extension} from '@roots/bud-framework/extension' -import { - bind, - development, - label, -} from '@roots/bud-framework/extension/decorators' - -/** - * Typescript react-refresh configuration - */ -@label(`@roots/bud-react/typescript-refresh`) -@development -export default class BudTypeScriptRefresh extends Extension { - /** - * {@link Extension.buildBefore} - */ - @bind - public override async buildBefore(bud: Bud) { - this.registerTransform(bud) - } - - /** - * Register tsc react-refresh transform - */ - @bind - public async registerTransform(bud: Bud) { - this.logger.log(`Registering react-refresh-typescript transformer`) - - const transform = await this.import( - `react-refresh-typescript`, - import.meta.url, - ) - - bud.extensions - .get(`@roots/bud-typescript`) - .set(`getCustomTransformers`, () => ({ - before: [transform()], - })) - } -} diff --git a/sources/@roots/bud-react/src/typescript-refresh/index.ts b/sources/@roots/bud-react/src/typescript-refresh/index.ts index 81b7ee296b..dcd894b048 100644 --- a/sources/@roots/bud-react/src/typescript-refresh/index.ts +++ b/sources/@roots/bud-react/src/typescript-refresh/index.ts @@ -1,14 +1,42 @@ -// Copyright © Roots Software Foundation LLC -// Licensed under the MIT license. +import type {Bud} from '@roots/bud-framework' + +import {Extension} from '@roots/bud-framework/extension' +import { + bind, + development, + label, +} from '@roots/bud-framework/extension/decorators' /** - * Adds TypeScript react-refresh transform - * - * @see https://bud.js.org - * @see https://github.com/roots/bud - * - * @packageDocumentation + * Typescript react-refresh configuration */ +@label(`@roots/bud-react/typescript-refresh`) +@development +export default class BudTypeScriptRefresh extends Extension { + /** + * {@link Extension.buildBefore} + */ + @bind + public override async buildBefore(bud: Bud) { + this.registerTransform(bud) + } + + /** + * Register tsc react-refresh transform + */ + @bind + public async registerTransform(bud: Bud) { + this.logger.log(`Registering react-refresh-typescript transformer`) + + const transform = await this.import( + `react-refresh-typescript`, + import.meta.url, + ) -import BudTypeScriptRefresh from './extension.js' -export default BudTypeScriptRefresh + bud.extensions + .get(`@roots/bud-typescript`) + .set(`getCustomTransformers`, () => ({ + before: [transform()], + })) + } +} diff --git a/sources/@roots/bud-react/test/babel-refresh/extension.test.ts b/sources/@roots/bud-react/test/babel-refresh/extension.test.ts index 128295bad9..5e9b09fdd2 100644 --- a/sources/@roots/bud-react/test/babel-refresh/extension.test.ts +++ b/sources/@roots/bud-react/test/babel-refresh/extension.test.ts @@ -1,7 +1,6 @@ +import Extension from '@roots/bud-react/babel-refresh' import {describe, expect, it} from 'vitest' -import Extension from '../../src/index.js' - describe(`@roots/bud-react/babel-refresh`, () => { it(`should be constructable`, () => { expect(Extension).toBeInstanceOf(Function) diff --git a/sources/@roots/bud-react/test/extension.test.ts b/sources/@roots/bud-react/test/extension.test.ts index 612d669cdc..8697d19d49 100644 --- a/sources/@roots/bud-react/test/extension.test.ts +++ b/sources/@roots/bud-react/test/extension.test.ts @@ -1,7 +1,6 @@ +import Extension from '@roots/bud-react/extension' import {describe, expect, it} from 'vitest' -import Extension from '../src/extension/extension.js' - describe(`@roots/bud-react`, () => { it(`should be constructable`, () => { expect(Extension).toBeInstanceOf(Function) diff --git a/sources/@roots/bud-react/test/extension/extension.test.ts b/sources/@roots/bud-react/test/extension/extension.test.ts index 51b1a764b7..b7e8c107a4 100644 --- a/sources/@roots/bud-react/test/extension/extension.test.ts +++ b/sources/@roots/bud-react/test/extension/extension.test.ts @@ -1,9 +1,7 @@ -import '@roots/bud-react/types' - +import '@roots/bud-react' +import Extension from '@roots/bud-react/extension' import {describe, expect, it} from 'vitest' -import Extension from '../../src/index' - describe(`@roots/bud-react`, () => { it(`should be constructable`, () => { expect(Extension).toBeInstanceOf(Function) diff --git a/sources/@roots/bud-react/test/react-refresh/extension.test.ts b/sources/@roots/bud-react/test/react-refresh/extension.test.ts index ad216f8ef1..f3754c6781 100644 --- a/sources/@roots/bud-react/test/react-refresh/extension.test.ts +++ b/sources/@roots/bud-react/test/react-refresh/extension.test.ts @@ -1,9 +1,6 @@ -import '@roots/bud-react/types' - +import Extension from '@roots/bud-react/react-refresh' import {describe, expect, it} from 'vitest' -import Extension from '../../src/extension/index.js' - describe(`@roots/bud-react/react-refresh`, () => { it(`should be constructable`, () => { expect(Extension).toBeInstanceOf(Function) diff --git a/sources/@roots/bud-react/test/swc-refresh/extension.test.ts b/sources/@roots/bud-react/test/swc-refresh/extension.test.ts index dfb92ab2aa..2b189b64da 100644 --- a/sources/@roots/bud-react/test/swc-refresh/extension.test.ts +++ b/sources/@roots/bud-react/test/swc-refresh/extension.test.ts @@ -1,9 +1,6 @@ -import '@roots/bud-react' - +import Extension from '@roots/bud-react/swc-refresh' import {describe, expect, it} from 'vitest' -import Extension from '../../src/index.js' - describe(`@roots/bud-react/swc-refresh`, () => { it(`should be constructable`, () => { expect(Extension).toBeInstanceOf(Function) diff --git a/sources/@roots/bud-react/test/typescript-refresh/extension.test.ts b/sources/@roots/bud-react/test/typescript-refresh/extension.test.ts index d5ad35ed8a..24453d1c08 100644 --- a/sources/@roots/bud-react/test/typescript-refresh/extension.test.ts +++ b/sources/@roots/bud-react/test/typescript-refresh/extension.test.ts @@ -1,10 +1,6 @@ -import '@roots/bud-react/types' -import '@roots/bud-typescript/types' - +import Extension from '@roots/bud-react/typescript-refresh' import {describe, expect, it} from 'vitest' -import Extension from '../../src/index.js' - describe(`@roots/bud-react/typescript-refresh`, () => { it(`should be constructable`, () => { expect(Extension).toBeInstanceOf(Function)