@fluojs/vite 1.0.5 → 1.0.7

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
@@ -8,7 +8,9 @@ fluo 프로젝트를 위한 Vite 플러그인과 빌드 유틸리티입니다.
8
8
 
9
9
  - [설치](#설치)
10
10
  - [사용 시점](#사용-시점)
11
+ - [런타임 및 peer 계약](#런타임-및-peer-계약)
11
12
  - [빠른 시작](#빠른-시작)
13
+ - [데코레이터 변환 경계](#데코레이터-변환-경계)
12
14
  - [공개 API](#공개-api)
13
15
  - [관련 패키지](#관련-패키지)
14
16
  - [예제 소스](#예제-소스)
@@ -27,6 +29,12 @@ npm install --save-dev @fluojs/vite vite @babel/core @babel/plugin-proposal-deco
27
29
  - starter 프로젝트가 Babel 설정을 inline으로 복사하지 않고 유지보수되는 decorator transform을 import해야 할 때
28
30
  - 향후 Vite 대상 fluo 빌드 유틸리티에 독립적인 public package 경계가 필요할 때
29
31
 
32
+ ## 런타임 및 peer 계약
33
+
34
+ `@fluojs/vite`는 `engines.node` 하한을 `>=20.0.0`으로 두는 Node.js 패키지입니다. 생성된 non-Deno starter는 이 Node 기준선과 Vite `>=6.2.0`, 그리고 위에 나열한 Babel peer를 함께 사용합니다.
35
+
36
+ 패키지 root는 Babel이 설치되거나 해석되기 전에 import해도 안전합니다. `@fluojs/vite`를 import하거나 `fluoDecoratorsPlugin()`을 생성해도 `@babel/core`를 로드하지 않습니다. Babel은 eligible 애플리케이션 `.ts` 파일에 대한 Vite `transform` hook에서만 lazy load되며, 누락된 Babel peer도 plugin 생성 시점이 아니라 이 transform 경계에서 보고됩니다.
37
+
30
38
  ## 빠른 시작
31
39
 
32
40
  ```ts
@@ -44,6 +52,16 @@ export default defineConfig({
44
52
 
45
53
  이 플러그인은 `.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
54
 
55
+ ## 데코레이터 변환 경계
56
+
57
+ `@fluojs/vite`는 Vitest 테스트 변환이 아니라 애플리케이션 빌드 변환을 소유합니다. 생성된 non-Deno starter는 파일 경계 분리를 명시적으로 유지합니다:
58
+
59
+ 1. `vite.config.ts`는 `@fluojs/vite`에서 `fluoDecoratorsPlugin()`을 import합니다.
60
+ 2. Vite 플러그인은 query suffix를 제거하고 애플리케이션 `.ts` 파일만 허용하며, 첫 eligible transform 시점에 Babel을 lazy load한 뒤 `@babel/plugin-proposal-decorators`의 `{ version: '2023-11' }` 설정과 `@babel/preset-typescript`를 실행합니다.
61
+ 3. `vitest.config.ts`는 `@fluojs/testing/vitest`에서 `fluoBabelDecoratorsPlugin()`을 import하므로 `*.test.ts`와 `*.spec.ts` 파일은 testing-specific transform 경로에 남습니다.
62
+
63
+ 생성 프로젝트를 커스터마이즈할 때도 이 경계를 분리하세요. `experimentalDecorators`를 다시 활성화하거나, direct esbuild decorator handling에 의존하거나, 테스트 파일을 Vite 애플리케이션 transform으로 보내는 방식은 문서화된 fluo 지원 계약 밖에 있습니다.
64
+
47
65
  ## 공개 API
48
66
 
49
67
  - `fluoDecoratorsPlugin()` — 생성된 fluo starter 프로젝트가 사용하는 Vite 플러그인을 만듭니다.
package/README.md CHANGED
@@ -8,7 +8,9 @@ Vite plugin and build utilities for fluo projects.
8
8
 
9
9
  - [Installation](#installation)
10
10
  - [When to Use](#when-to-use)
11
+ - [Runtime and Peer Contract](#runtime-and-peer-contract)
11
12
  - [Quick Start](#quick-start)
13
+ - [Decorator Transform Boundary](#decorator-transform-boundary)
12
14
  - [Public API](#public-api)
13
15
  - [Related Packages](#related-packages)
14
16
  - [Example Sources](#example-sources)
@@ -27,6 +29,12 @@ npm install --save-dev @fluojs/vite vite @babel/core @babel/plugin-proposal-deco
27
29
  - when starter projects should import the maintained decorator transform instead of copying Babel configuration inline
28
30
  - when future Vite-facing fluo build utilities need a dedicated public package boundary
29
31
 
32
+ ## Runtime and Peer Contract
33
+
34
+ `@fluojs/vite` is a Node.js package with an `engines.node` floor of `>=20.0.0`. Generated non-Deno starters pair that Node baseline with Vite `>=6.2.0` and the Babel peers listed above.
35
+
36
+ The package root is safe to import before Babel is installed or resolved: importing `@fluojs/vite` and creating `fluoDecoratorsPlugin()` do not load `@babel/core`. Babel is loaded lazily only from Vite's `transform` hook for eligible application `.ts` files, and missing Babel peers are reported from that transform boundary instead of plugin creation.
37
+
30
38
  ## Quick Start
31
39
 
32
40
  ```ts
@@ -44,6 +52,16 @@ export default defineConfig({
44
52
 
45
53
  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
54
 
55
+ ## Decorator Transform Boundary
56
+
57
+ `@fluojs/vite` owns application build transforms, not Vitest test transforms. Generated non-Deno starters keep the file-boundary split explicit:
58
+
59
+ 1. `vite.config.ts` imports `fluoDecoratorsPlugin()` from `@fluojs/vite`.
60
+ 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`.
61
+ 3. `vitest.config.ts` imports `fluoBabelDecoratorsPlugin()` from `@fluojs/testing/vitest`, so `*.test.ts` and `*.spec.ts` files stay on the testing-specific transform path.
62
+
63
+ 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.
64
+
47
65
  ## Public API
48
66
 
49
67
  - `fluoDecoratorsPlugin()` — creates the Vite plugin used by generated fluo starter projects.
@@ -1,19 +1,9 @@
1
1
  import type { Plugin } from 'vite';
2
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.
3
+ * Creates the Vite plugin used by generated fluo starter projects to transform
4
+ * TypeScript application files that contain TC39 standard decorators.
5
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
- * ```
6
+ * @returns A Vite plugin that lazily loads Babel for eligible application `.ts` files.
17
7
  */
18
8
  export declare function fluoDecoratorsPlugin(): Plugin;
19
9
  //# 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;AAiJnD;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C"}
@@ -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,9 +68,9 @@ function shouldRequestBabelSourceMaps(config) {
65
68
  * });
66
69
  * ```
67
70
  */
68
- export function fluoDecoratorsPlugin() {
71
+ function createFluoDecoratorsPlugin(importBabelCoreModule) {
69
72
  let shouldGenerateSourceMaps = false;
70
- let babelCorePromise;
73
+ let babelCore;
71
74
  return {
72
75
  name: 'fluo-babel-decorators',
73
76
  configResolved(config) {
@@ -78,9 +81,9 @@ export function fluoDecoratorsPlugin() {
78
81
  return null;
79
82
  }
80
83
  const filePath = readViteFilePath(id);
81
- babelCorePromise ??= loadBabelCore(filePath);
82
- const babelCore = await babelCorePromise;
83
- const result = await babelCore.transformAsync(code, {
84
+ const loadedBabelCore = babelCore ?? (await loadBabelCore(filePath, importBabelCoreModule));
85
+ babelCore = loadedBabelCore;
86
+ const result = await loadedBabelCore.transformAsync(code, {
84
87
  babelrc: false,
85
88
  configFile: false,
86
89
  filename: filePath,
@@ -103,4 +106,25 @@ export function fluoDecoratorsPlugin() {
103
106
  };
104
107
  }
105
108
  };
109
+ }
110
+
111
+ /**
112
+ * Creates the Vite plugin used by generated fluo starter projects to transform
113
+ * TypeScript application files that contain TC39 standard decorators.
114
+ *
115
+ * @returns A Vite plugin that lazily loads Babel for eligible application `.ts` files.
116
+ */
117
+ export function fluoDecoratorsPlugin() {
118
+ return createFluoDecoratorsPlugin(importBabelCore);
119
+ }
120
+
121
+ /**
122
+ * Creates the fluo Vite decorators plugin with an injected Babel importer for regression tests.
123
+ *
124
+ * @internal
125
+ * @param importBabelCoreModule - Async loader used instead of the production `@babel/core` dynamic import.
126
+ * @returns A Vite plugin that preserves the production transform boundary while allowing tests to control Babel loading.
127
+ */
128
+ export function createFluoDecoratorsPluginForTesting(importBabelCoreModule) {
129
+ return createFluoDecoratorsPlugin(importBabelCoreModule);
106
130
  }
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.7",
12
12
  "private": false,
13
13
  "license": "MIT",
14
14
  "repository": {