From b4971dc9023f84c56d99486c216347aceff9652c Mon Sep 17 00:00:00 2001 From: riccardoperra Date: Mon, 4 Nov 2024 23:13:03 +0100 Subject: [PATCH] cleanup code --- packages/state/vite/autoKey.ts | 2 +- packages/state/vite/{internal => babel}/astAutoNaming.ts | 0 .../{internal => babel}/replaceStateProviderDirective.ts | 5 +++++ packages/state/vite/index.ts | 2 +- packages/state/vite/stateProviderDirective.ts | 2 +- 5 files changed, 8 insertions(+), 3 deletions(-) rename packages/state/vite/{internal => babel}/astAutoNaming.ts (100%) rename packages/state/vite/{internal => babel}/replaceStateProviderDirective.ts (95%) diff --git a/packages/state/vite/autoKey.ts b/packages/state/vite/autoKey.ts index b6c3609..382863c 100644 --- a/packages/state/vite/autoKey.ts +++ b/packages/state/vite/autoKey.ts @@ -1,5 +1,5 @@ import { Plugin } from 'vite'; -import { astAddAutoNaming } from './internal/astAutoNaming'; +import { astAddAutoNaming } from './babel/astAutoNaming'; import { parseModule } from 'magicast'; interface StatebuilderAutonamingOptions { diff --git a/packages/state/vite/internal/astAutoNaming.ts b/packages/state/vite/babel/astAutoNaming.ts similarity index 100% rename from packages/state/vite/internal/astAutoNaming.ts rename to packages/state/vite/babel/astAutoNaming.ts diff --git a/packages/state/vite/internal/replaceStateProviderDirective.ts b/packages/state/vite/babel/replaceStateProviderDirective.ts similarity index 95% rename from packages/state/vite/internal/replaceStateProviderDirective.ts rename to packages/state/vite/babel/replaceStateProviderDirective.ts index 028fcaf..76cb282 100644 --- a/packages/state/vite/internal/replaceStateProviderDirective.ts +++ b/packages/state/vite/babel/replaceStateProviderDirective.ts @@ -1,6 +1,11 @@ import * as t from '@babel/types'; import type * as babel from '@babel/core'; +/** + * @experimental + * + * Search for components that use `use stateprovider` directive, then wrap them into StateProvider. + */ export function babelReplaceStateProviderDirective(): babel.PluginObj { return { name: 'statebuilder:stateprovider-directive', diff --git a/packages/state/vite/index.ts b/packages/state/vite/index.ts index 9638fbb..7340894 100644 --- a/packages/state/vite/index.ts +++ b/packages/state/vite/index.ts @@ -26,7 +26,7 @@ export interface StateBuilderPluginOptions { /** * Transform components that make use of 'use stateprovider'. */ - transformStateProviderDirective: boolean; + transformStateProviderDirective?: boolean; }; } diff --git a/packages/state/vite/stateProviderDirective.ts b/packages/state/vite/stateProviderDirective.ts index b1443a4..39827fd 100644 --- a/packages/state/vite/stateProviderDirective.ts +++ b/packages/state/vite/stateProviderDirective.ts @@ -1,7 +1,7 @@ import * as babel from '@babel/core'; import { basename } from 'node:path'; import { Plugin } from 'vite'; -import { babelReplaceStateProviderDirective } from './internal/replaceStateProviderDirective'; +import { babelReplaceStateProviderDirective } from './babel/replaceStateProviderDirective'; export function stateProviderDirective(): Plugin { return {