@fluojs/vite 1.0.3 → 1.0.4
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 +2 -2
- package/README.md +2 -2
- package/dist/decorators-plugin.d.ts.map +1 -0
- package/dist/{internal/decorators-plugin.js → decorators-plugin.js} +16 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/internal/decorators-plugin.d.ts.map +0 -1
- /package/dist/{internal/decorators-plugin.d.ts → decorators-plugin.d.ts} +0 -0
package/README.ko.md
CHANGED
|
@@ -42,7 +42,7 @@ export default defineConfig({
|
|
|
42
42
|
});
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
이 플러그인은 `.ts` 애플리케이션 파일을 Babel로 변환하며 `2023-11` decorators proposal과 `@babel/preset-typescript`를 사용합니다. 파일 경계를 판단하기 전에 Vite query suffix를 제거한 뒤 declaration 파일,
|
|
45
|
+
이 플러그인은 `.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 경로를 사용합니다.
|
|
46
46
|
|
|
47
47
|
## 공개 API
|
|
48
48
|
|
|
@@ -56,5 +56,5 @@ export default defineConfig({
|
|
|
56
56
|
## 예제 소스
|
|
57
57
|
|
|
58
58
|
- `packages/vite/src/index.ts`
|
|
59
|
-
- `packages/vite/src/
|
|
59
|
+
- `packages/vite/src/decorators-plugin.ts`
|
|
60
60
|
- `packages/cli/src/new/scaffold.ts`
|
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ export default defineConfig({
|
|
|
42
42
|
});
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
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,
|
|
45
|
+
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.
|
|
46
46
|
|
|
47
47
|
## Public API
|
|
48
48
|
|
|
@@ -56,5 +56,5 @@ The plugin transforms `.ts` application files with Babel using the `2023-11` dec
|
|
|
56
56
|
## Example Sources
|
|
57
57
|
|
|
58
58
|
- `packages/vite/src/index.ts`
|
|
59
|
-
- `packages/vite/src/
|
|
59
|
+
- `packages/vite/src/decorators-plugin.ts`
|
|
60
60
|
- `packages/cli/src/new/scaffold.ts`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators-plugin.d.ts","sourceRoot":"","sources":["../src/decorators-plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,MAAM,CAAC;AA8BnD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CA6B7C"}
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { transformAsync } from '@babel/core';
|
|
2
2
|
function readViteFilePath(id) {
|
|
3
|
-
const
|
|
3
|
+
const filePath = id.split(/[?#]/, 1)[0] ?? id;
|
|
4
4
|
return filePath;
|
|
5
5
|
}
|
|
6
|
+
function isNodeModulesPath(filePath) {
|
|
7
|
+
return /(?:^|\/)node_modules(?:\/|$)/u.test(filePath);
|
|
8
|
+
}
|
|
9
|
+
function isTypeScriptTestFile(filePath) {
|
|
10
|
+
return /\.(?:test|spec)\.ts$/u.test(filePath);
|
|
11
|
+
}
|
|
6
12
|
function shouldTransformTypeScriptApplicationFile(id) {
|
|
7
13
|
const normalizedFilePath = readViteFilePath(id).replaceAll('\\', '/');
|
|
8
14
|
if (!normalizedFilePath.endsWith('.ts') || normalizedFilePath.endsWith('.d.ts')) {
|
|
9
15
|
return false;
|
|
10
16
|
}
|
|
11
|
-
return !normalizedFilePath
|
|
17
|
+
return !isNodeModulesPath(normalizedFilePath) && !isTypeScriptTestFile(normalizedFilePath);
|
|
18
|
+
}
|
|
19
|
+
function shouldRequestBabelSourceMaps(config) {
|
|
20
|
+
return config.command === 'serve' || Boolean(config.build.sourcemap);
|
|
12
21
|
}
|
|
13
22
|
|
|
14
23
|
/**
|
|
@@ -28,8 +37,12 @@ function shouldTransformTypeScriptApplicationFile(id) {
|
|
|
28
37
|
* ```
|
|
29
38
|
*/
|
|
30
39
|
export function fluoDecoratorsPlugin() {
|
|
40
|
+
let shouldGenerateSourceMaps = false;
|
|
31
41
|
return {
|
|
32
42
|
name: 'fluo-babel-decorators',
|
|
43
|
+
configResolved(config) {
|
|
44
|
+
shouldGenerateSourceMaps = shouldRequestBabelSourceMaps(config);
|
|
45
|
+
},
|
|
33
46
|
async transform(code, id) {
|
|
34
47
|
if (!shouldTransformTypeScriptApplicationFile(id)) {
|
|
35
48
|
return null;
|
|
@@ -44,7 +57,7 @@ export function fluoDecoratorsPlugin() {
|
|
|
44
57
|
presets: [['@babel/preset-typescript', {
|
|
45
58
|
allowDeclareFields: true
|
|
46
59
|
}]],
|
|
47
|
-
sourceMaps:
|
|
60
|
+
sourceMaps: shouldGenerateSourceMaps
|
|
48
61
|
});
|
|
49
62
|
if (!result?.code) {
|
|
50
63
|
return null;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { fluoDecoratorsPlugin } from './
|
|
1
|
+
export { fluoDecoratorsPlugin } from './decorators-plugin.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { fluoDecoratorsPlugin } from './
|
|
1
|
+
export { fluoDecoratorsPlugin } from './decorators-plugin.js';
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decorators-plugin.d.ts","sourceRoot":"","sources":["../../src/internal/decorators-plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAsBnC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAwB7C"}
|
|
File without changes
|