@fluojs/vite 1.0.0-beta.2
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/LICENSE +21 -0
- package/README.ko.md +59 -0
- package/README.md +59 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 fluo contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.ko.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @fluojs/vite
|
|
2
|
+
|
|
3
|
+
<p><a href="./README.md"><kbd>English</kbd></a> <strong><kbd>한국어</kbd></strong></p>
|
|
4
|
+
|
|
5
|
+
fluo 프로젝트를 위한 Vite 플러그인과 빌드 유틸리티입니다.
|
|
6
|
+
|
|
7
|
+
## 목차
|
|
8
|
+
|
|
9
|
+
- [설치](#설치)
|
|
10
|
+
- [사용 시점](#사용-시점)
|
|
11
|
+
- [빠른 시작](#빠른-시작)
|
|
12
|
+
- [공개 API](#공개-api)
|
|
13
|
+
- [관련 패키지](#관련-패키지)
|
|
14
|
+
- [예제 소스](#예제-소스)
|
|
15
|
+
|
|
16
|
+
## 설치
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install --save-dev @fluojs/vite vite @babel/core @babel/plugin-proposal-decorators @babel/preset-typescript
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`@babel/core`와 `vite`는 peer dependency입니다. `fluoDecoratorsPlugin()`이 Vite transform 시점에 decorator plugin과 TypeScript preset을 해석하므로 consuming project에는 `@babel/plugin-proposal-decorators`와 `@babel/preset-typescript`도 필요합니다.
|
|
23
|
+
|
|
24
|
+
## 사용 시점
|
|
25
|
+
|
|
26
|
+
- fluo 애플리케이션이 TC39 표준 데코레이터가 포함된 TypeScript를 Vite로 빌드할 때
|
|
27
|
+
- starter 프로젝트가 Babel 설정을 inline으로 복사하지 않고 유지보수되는 decorator transform을 import해야 할 때
|
|
28
|
+
- 향후 Vite 대상 fluo 빌드 유틸리티에 독립적인 public package 경계가 필요할 때
|
|
29
|
+
|
|
30
|
+
## 빠른 시작
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { fluoDecoratorsPlugin } from '@fluojs/vite';
|
|
34
|
+
import { defineConfig } from 'vite';
|
|
35
|
+
|
|
36
|
+
export default defineConfig({
|
|
37
|
+
plugins: [fluoDecoratorsPlugin()],
|
|
38
|
+
build: {
|
|
39
|
+
ssr: 'src/main.ts',
|
|
40
|
+
target: 'node20',
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
이 플러그인은 `.ts` 애플리케이션 파일을 Babel로 변환하며 `2023-11` decorators proposal과 `@babel/preset-typescript`를 사용합니다. 경로에 `.test.`가 포함된 파일은 건너뛰므로 생성된 Vitest 테스트 파일은 계속 전용 `@fluojs/testing/vitest` transform 경로를 사용합니다.
|
|
46
|
+
|
|
47
|
+
## 공개 API
|
|
48
|
+
|
|
49
|
+
- `fluoDecoratorsPlugin()` — 생성된 fluo starter 프로젝트가 사용하는 Vite 플러그인을 만듭니다.
|
|
50
|
+
|
|
51
|
+
## 관련 패키지
|
|
52
|
+
|
|
53
|
+
- [`@fluojs/cli`](../cli/README.ko.md): 이 Vite 플러그인을 import하는 starter 프로젝트를 생성합니다.
|
|
54
|
+
- [`@fluojs/testing`](../testing/README.ko.md): Vitest 전용 decorator transform entrypoint를 제공합니다.
|
|
55
|
+
|
|
56
|
+
## 예제 소스
|
|
57
|
+
|
|
58
|
+
- `packages/vite/src/index.ts`
|
|
59
|
+
- `packages/cli/src/new/scaffold.ts`
|
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @fluojs/vite
|
|
2
|
+
|
|
3
|
+
<p><strong><kbd>English</kbd></strong> <a href="./README.ko.md"><kbd>한국어</kbd></a></p>
|
|
4
|
+
|
|
5
|
+
Vite plugin and build utilities for fluo projects.
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
|
|
9
|
+
- [Installation](#installation)
|
|
10
|
+
- [When to Use](#when-to-use)
|
|
11
|
+
- [Quick Start](#quick-start)
|
|
12
|
+
- [Public API](#public-api)
|
|
13
|
+
- [Related Packages](#related-packages)
|
|
14
|
+
- [Example Sources](#example-sources)
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install --save-dev @fluojs/vite vite @babel/core @babel/plugin-proposal-decorators @babel/preset-typescript
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`@babel/core` and `vite` are peer dependencies. The decorator plugin and TypeScript preset must also be available in the consuming project because `fluoDecoratorsPlugin()` resolves them when Vite transforms source files.
|
|
23
|
+
|
|
24
|
+
## When to Use
|
|
25
|
+
|
|
26
|
+
- when a fluo application uses Vite to build TypeScript that contains TC39 standard decorators
|
|
27
|
+
- when starter projects should import the maintained decorator transform instead of copying Babel configuration inline
|
|
28
|
+
- when future Vite-facing fluo build utilities need a dedicated public package boundary
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { fluoDecoratorsPlugin } from '@fluojs/vite';
|
|
34
|
+
import { defineConfig } from 'vite';
|
|
35
|
+
|
|
36
|
+
export default defineConfig({
|
|
37
|
+
plugins: [fluoDecoratorsPlugin()],
|
|
38
|
+
build: {
|
|
39
|
+
ssr: 'src/main.ts',
|
|
40
|
+
target: 'node20',
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The plugin transforms `.ts` application files with Babel using the `2023-11` decorators proposal and `@babel/preset-typescript`. It skips files whose path includes `.test.` so generated Vitest test files continue to use the dedicated `@fluojs/testing/vitest` transform path.
|
|
46
|
+
|
|
47
|
+
## Public API
|
|
48
|
+
|
|
49
|
+
- `fluoDecoratorsPlugin()` — creates the Vite plugin used by generated fluo starter projects.
|
|
50
|
+
|
|
51
|
+
## Related Packages
|
|
52
|
+
|
|
53
|
+
- [`@fluojs/cli`](../cli/README.md): generates starter projects that import this Vite plugin.
|
|
54
|
+
- [`@fluojs/testing`](../testing/README.md): provides the Vitest-specific decorator transform entrypoint.
|
|
55
|
+
|
|
56
|
+
## Example Sources
|
|
57
|
+
|
|
58
|
+
- `packages/vite/src/index.ts`
|
|
59
|
+
- `packages/cli/src/new/scaffold.ts`
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
*/
|
|
18
|
+
export declare function fluoDecoratorsPlugin(): Plugin;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAwB7C"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { transformAsync } from '@babel/core';
|
|
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
|
+
*/
|
|
18
|
+
export function fluoDecoratorsPlugin() {
|
|
19
|
+
return {
|
|
20
|
+
name: 'fluo-babel-decorators',
|
|
21
|
+
async transform(code, id) {
|
|
22
|
+
if (!id.endsWith('.ts') || id.includes('.test.')) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const result = await transformAsync(code, {
|
|
26
|
+
babelrc: false,
|
|
27
|
+
configFile: false,
|
|
28
|
+
filename: id,
|
|
29
|
+
plugins: [['@babel/plugin-proposal-decorators', {
|
|
30
|
+
version: '2023-11'
|
|
31
|
+
}]],
|
|
32
|
+
presets: [['@babel/preset-typescript', {
|
|
33
|
+
allowDeclareFields: true
|
|
34
|
+
}]],
|
|
35
|
+
sourceMaps: true
|
|
36
|
+
});
|
|
37
|
+
if (!result?.code) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
code: result.code,
|
|
42
|
+
map: result.map ?? null
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fluojs/vite",
|
|
3
|
+
"description": "Vite plugin and build utilities for fluo projects.",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"fluo",
|
|
6
|
+
"vite",
|
|
7
|
+
"decorators",
|
|
8
|
+
"babel",
|
|
9
|
+
"build-tooling"
|
|
10
|
+
],
|
|
11
|
+
"version": "1.0.0-beta.2",
|
|
12
|
+
"private": false,
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/fluojs/fluo.git",
|
|
17
|
+
"directory": "packages/vite"
|
|
18
|
+
},
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=20.0.0"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"type": "module",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"main": "./dist/index.js",
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"files": [
|
|
35
|
+
"dist"
|
|
36
|
+
],
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@babel/core": ">=7.0.0",
|
|
39
|
+
"vite": ">=5.0.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"vitest": "^3.2.4"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"prebuild": "node ../../tooling/scripts/clean-dist.mjs",
|
|
46
|
+
"build": "pnpm exec babel src --extensions .ts --ignore 'src/**/*.test.ts' --out-dir dist --config-file ../../tooling/babel/babel.config.cjs && pnpm exec tsc -p tsconfig.build.json",
|
|
47
|
+
"typecheck": "pnpm exec tsc -p tsconfig.json --noEmit",
|
|
48
|
+
"test": "pnpm exec vitest run -c vitest.config.ts",
|
|
49
|
+
"test:watch": "pnpm exec vitest -c vitest.config.ts"
|
|
50
|
+
}
|
|
51
|
+
}
|