@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 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 파일, `.test.` 또는 `.spec.` 파일, `node_modules`, `.ts`가 아닌 파일은 건너뛰므로 생성된 Vitest 테스트 파일은 계속 전용 `@fluojs/testing/vitest` transform 경로를 사용합니다.
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/internal/decorators-plugin.ts`
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, `.test.` or `.spec.` files, `node_modules`, and non-`.ts` files so generated Vitest test files continue to use the dedicated `@fluojs/testing/vitest` transform path.
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/internal/decorators-plugin.ts`
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 [filePath] = id.split('?', 1);
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.includes('/node_modules/') && !normalizedFilePath.includes('.test.') && !normalizedFilePath.includes('.spec.');
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: true
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 './internal/decorators-plugin.js';
1
+ export { fluoDecoratorsPlugin } from './decorators-plugin.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC"}
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 './internal/decorators-plugin.js';
1
+ export { fluoDecoratorsPlugin } from './decorators-plugin.js';
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "babel",
9
9
  "build-tooling"
10
10
  ],
11
- "version": "1.0.3",
11
+ "version": "1.0.4",
12
12
  "private": false,
13
13
  "license": "MIT",
14
14
  "repository": {
@@ -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"}