@fluojs/vite 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.ko.md CHANGED
@@ -9,6 +9,7 @@ fluo 프로젝트를 위한 Vite 플러그인과 빌드 유틸리티입니다.
9
9
  - [설치](#설치)
10
10
  - [사용 시점](#사용-시점)
11
11
  - [빠른 시작](#빠른-시작)
12
+ - [데코레이터 변환 경계](#데코레이터-변환-경계)
12
13
  - [공개 API](#공개-api)
13
14
  - [관련 패키지](#관련-패키지)
14
15
  - [예제 소스](#예제-소스)
@@ -44,6 +45,16 @@ export default defineConfig({
44
45
 
45
46
  이 플러그인은 `.ts` 애플리케이션 파일을 Babel로 변환하며 `2023-11` decorators proposal과 `@babel/preset-typescript`를 사용합니다. 파일 경계를 판단하기 전에 Vite query suffix를 제거한 뒤 declaration 파일, `*.test.ts` 또는 `*.spec.ts` 파일, `node_modules`, `.ts`가 아닌 파일은 건너뛰므로 생성된 Vitest 테스트 파일은 계속 전용 `@fluojs/testing/vitest` transform 경로를 사용합니다. `@fluojs/vite`를 import하거나 `fluoDecoratorsPlugin()`을 생성하는 시점에는 `@babel/core`를 로드하지 않으며, 누락된 Babel peer는 Vite가 변환 중인 소스 파일에 대한 transform-time 진단으로 표시됩니다.
46
47
 
48
+ ## 데코레이터 변환 경계
49
+
50
+ `@fluojs/vite`는 Vitest 테스트 변환이 아니라 애플리케이션 빌드 변환을 소유합니다. 생성된 non-Deno starter는 파일 경계 분리를 명시적으로 유지합니다:
51
+
52
+ 1. `vite.config.ts`는 `@fluojs/vite`에서 `fluoDecoratorsPlugin()`을 import합니다.
53
+ 2. Vite 플러그인은 query suffix를 제거하고 애플리케이션 `.ts` 파일만 허용하며, 첫 eligible transform 시점에 Babel을 lazy load한 뒤 `@babel/plugin-proposal-decorators`의 `{ version: '2023-11' }` 설정과 `@babel/preset-typescript`를 실행합니다.
54
+ 3. `vitest.config.ts`는 `@fluojs/testing/vitest`에서 `fluoBabelDecoratorsPlugin()`을 import하므로 `*.test.ts`와 `*.spec.ts` 파일은 testing-specific transform 경로에 남습니다.
55
+
56
+ 생성 프로젝트를 커스터마이즈할 때도 이 경계를 분리하세요. `experimentalDecorators`를 다시 활성화하거나, direct esbuild decorator handling에 의존하거나, 테스트 파일을 Vite 애플리케이션 transform으로 보내는 방식은 문서화된 fluo 지원 계약 밖에 있습니다.
57
+
47
58
  ## 공개 API
48
59
 
49
60
  - `fluoDecoratorsPlugin()` — 생성된 fluo starter 프로젝트가 사용하는 Vite 플러그인을 만듭니다.
package/README.md CHANGED
@@ -9,6 +9,7 @@ Vite plugin and build utilities for fluo projects.
9
9
  - [Installation](#installation)
10
10
  - [When to Use](#when-to-use)
11
11
  - [Quick Start](#quick-start)
12
+ - [Decorator Transform Boundary](#decorator-transform-boundary)
12
13
  - [Public API](#public-api)
13
14
  - [Related Packages](#related-packages)
14
15
  - [Example Sources](#example-sources)
@@ -44,6 +45,16 @@ export default defineConfig({
44
45
 
45
46
  The plugin transforms `.ts` application files with Babel using the `2023-11` decorators proposal and `@babel/preset-typescript`. It strips Vite query suffixes before deciding the file boundary, then skips declaration files, `*.test.ts` or `*.spec.ts` files, `node_modules`, and non-`.ts` files so generated Vitest test files continue to use the dedicated `@fluojs/testing/vitest` transform path. Importing `@fluojs/vite` or creating `fluoDecoratorsPlugin()` does not load `@babel/core`; missing Babel peers are surfaced as transform-time diagnostics for the source file Vite is transforming.
46
47
 
48
+ ## Decorator Transform Boundary
49
+
50
+ `@fluojs/vite` owns application build transforms, not Vitest test transforms. Generated non-Deno starters keep the file-boundary split explicit:
51
+
52
+ 1. `vite.config.ts` imports `fluoDecoratorsPlugin()` from `@fluojs/vite`.
53
+ 2. The Vite plugin strips query suffixes, accepts only application `.ts` files, lazily loads Babel on the first eligible transform, and runs `@babel/plugin-proposal-decorators` with `{ version: '2023-11' }` plus `@babel/preset-typescript`.
54
+ 3. `vitest.config.ts` imports `fluoBabelDecoratorsPlugin()` from `@fluojs/testing/vitest`, so `*.test.ts` and `*.spec.ts` files stay on the testing-specific transform path.
55
+
56
+ Keep those boundaries separate when customizing generated projects. Re-enabling `experimentalDecorators`, relying on direct esbuild decorator handling, or routing test files through the Vite application transform is outside the documented fluo support contract.
57
+
47
58
  ## Public API
48
59
 
49
60
  - `fluoDecoratorsPlugin()` — creates the Vite plugin used by generated fluo starter projects.
@@ -1,19 +1,7 @@
1
1
  import type { Plugin } from 'vite';
2
- /**
3
- * Creates the Vite transform plugin used by fluo starter projects to compile
4
- * TC39 standard decorator syntax through Babel before Vite bundles the app.
5
- *
6
- * @returns A Vite plugin that transforms TypeScript application files and skips test files.
7
- *
8
- * @example
9
- * ```ts
10
- * import { fluoDecoratorsPlugin } from '@fluojs/vite';
11
- * import { defineConfig } from 'vite';
12
- *
13
- * export default defineConfig({
14
- * plugins: [fluoDecoratorsPlugin()],
15
- * });
16
- * ```
17
- */
2
+ type BabelCoreModule = Pick<typeof import('@babel/core'), 'transformAsync'>;
3
+ type BabelCoreImporter = () => Promise<BabelCoreModule>;
18
4
  export declare function fluoDecoratorsPlugin(): Plugin;
5
+ export declare function createFluoDecoratorsPluginForTesting(importBabelCoreModule: BabelCoreImporter): Plugin;
6
+ export {};
19
7
  //# sourceMappingURL=decorators-plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decorators-plugin.d.ts","sourceRoot":"","sources":["../src/decorators-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,MAAM,CAAC;AAoFnD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAsC7C"}
1
+ {"version":3,"file":"decorators-plugin.d.ts","sourceRoot":"","sources":["../src/decorators-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,MAAM,CAAC;AAEnD,KAAK,eAAe,GAAG,IAAI,CAAC,cAAc,aAAa,CAAC,EAAE,gBAAgB,CAAC,CAAC;AAC5E,KAAK,iBAAiB,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;AA8IxD,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED,wBAAgB,oCAAoC,CAAC,qBAAqB,EAAE,iBAAiB,GAAG,MAAM,CAErG"}
@@ -21,9 +21,12 @@ function createBabelTransformDiagnostic(error, filePath) {
21
21
  }
22
22
  return new Error(`[fluo-babel-decorators] Failed to resolve a Babel peer dependency while transforming ${filePath}. ` + 'Install @babel/core, @babel/plugin-proposal-decorators, and @babel/preset-typescript in the Vite project. ' + `Original error: ${message}`);
23
23
  }
24
- async function loadBabelCore(filePath) {
24
+ async function importBabelCore() {
25
+ return await import('@babel/core');
26
+ }
27
+ async function loadBabelCore(filePath, importBabelCoreModule) {
25
28
  try {
26
- return await import('@babel/core');
29
+ return await importBabelCoreModule();
27
30
  } catch (error) {
28
31
  throw createBabelTransformDiagnostic(error, filePath);
29
32
  }
@@ -65,7 +68,7 @@ function shouldRequestBabelSourceMaps(config) {
65
68
  * });
66
69
  * ```
67
70
  */
68
- export function fluoDecoratorsPlugin() {
71
+ function createFluoDecoratorsPlugin(importBabelCoreModule) {
69
72
  let shouldGenerateSourceMaps = false;
70
73
  let babelCorePromise;
71
74
  return {
@@ -78,7 +81,7 @@ export function fluoDecoratorsPlugin() {
78
81
  return null;
79
82
  }
80
83
  const filePath = readViteFilePath(id);
81
- babelCorePromise ??= loadBabelCore(filePath);
84
+ babelCorePromise ??= loadBabelCore(filePath, importBabelCoreModule);
82
85
  const babelCore = await babelCorePromise;
83
86
  const result = await babelCore.transformAsync(code, {
84
87
  babelrc: false,
@@ -103,4 +106,10 @@ export function fluoDecoratorsPlugin() {
103
106
  };
104
107
  }
105
108
  };
109
+ }
110
+ export function fluoDecoratorsPlugin() {
111
+ return createFluoDecoratorsPlugin(importBabelCore);
112
+ }
113
+ export function createFluoDecoratorsPluginForTesting(importBabelCoreModule) {
114
+ return createFluoDecoratorsPlugin(importBabelCoreModule);
106
115
  }
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "babel",
9
9
  "build-tooling"
10
10
  ],
11
- "version": "1.0.5",
11
+ "version": "1.0.6",
12
12
  "private": false,
13
13
  "license": "MIT",
14
14
  "repository": {