vite-plugin-jsx-source-attrs 0.2.0 → 0.2.2-dev.mr.4.33.5c3d6c43

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.llm.txt CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  - 개발 모드에서 intrinsic JSX 요소에 `data-source-location`을 주입한다.
12
12
  - 프로덕션 빌드에서는 주입하지 않는다.
13
- - 사용자 컴포넌트에는 기본적으로 주입하지 않는다.
13
+ - 사용자 컴포넌트에는 기본적으로 `data-component-source-location`을 주입한다.
14
14
  - 기존 attribute가 있으면 중복 주입하지 않는다.
15
15
  - Vite 가상 모듈 prefix, query/hash, Windows 경로 구분자를 정규화한다.
16
16
 
@@ -55,7 +55,7 @@ Vite React 프로젝트에 `vite-plugin-jsx-source-attrs`를 설치하고 설정
55
55
  vitePluginJsxSourceAttrs({
56
56
  enabled: mode === 'development',
57
57
  attributeName: 'data-source-location',
58
- componentAttributeName: null,
58
+ componentAttributeName: 'data-component-source-location',
59
59
  })
60
60
  ```
61
61
 
@@ -93,7 +93,7 @@ export default defineConfig(({ mode }) => ({
93
93
  vitePluginJsxSourceAttrs({
94
94
  enabled: mode === 'development',
95
95
  attributeName: 'data-source-location',
96
- componentAttributeName: null,
96
+ componentAttributeName: 'data-component-source-location',
97
97
  }),
98
98
  react(),
99
99
  ],
@@ -206,7 +206,7 @@ export default defineConfig(({ mode }) => ({
206
206
  jsxSourceAttrs({
207
207
  enabled: mode === 'development',
208
208
  attributeName: 'data-source-location',
209
- componentAttributeName: null,
209
+ componentAttributeName: 'data-component-source-location',
210
210
  }),
211
211
  ],
212
212
  },
@@ -244,7 +244,7 @@ export default defineConfig(({ mode }) => ({
244
244
  plugins: [
245
245
  jsxSourceAttrs({
246
246
  enabled: mode === 'development',
247
- componentAttributeName: null,
247
+ componentAttributeName: 'data-component-source-location',
248
248
  }),
249
249
  ],
250
250
  },
@@ -276,7 +276,7 @@ react({
276
276
  existingPlugin,
277
277
  jsxSourceAttrs({
278
278
  enabled: mode === 'development',
279
- componentAttributeName: null,
279
+ componentAttributeName: 'data-component-source-location',
280
280
  }),
281
281
  ],
282
282
  },
@@ -295,7 +295,7 @@ export default defineConfig(({ mode }) => ({
295
295
  plugins: [
296
296
  jsxSourceAttrs({
297
297
  enabled: mode === 'development',
298
- componentAttributeName: null,
298
+ componentAttributeName: 'data-component-source-location',
299
299
  }),
300
300
  ],
301
301
  },
@@ -336,7 +336,7 @@ jsxSourceAttrs({
336
336
  jsxSourceAttrs({
337
337
  enabled: mode === 'development',
338
338
  root: process.cwd(),
339
- componentAttributeName: null,
339
+ componentAttributeName: 'data-component-source-location',
340
340
  });
341
341
  ```
342
342
 
@@ -349,7 +349,7 @@ jsxSourceAttrs({
349
349
  enabled: ({ filename }) => {
350
350
  return filename.endsWith('.tsx') && !filename.includes('/node_modules/');
351
351
  },
352
- componentAttributeName: null,
352
+ componentAttributeName: 'data-component-source-location',
353
353
  });
354
354
  ```
355
355
 
@@ -369,7 +369,7 @@ jsxSourceAttrs({
369
369
  1. `vite-plugin-jsx-source-attrs`를 devDependency로 설치한다.
370
370
  2. `vite.config.ts`에서 로컬 `jsx-source-attrs.js` import를 제거한다.
371
371
  3. `import { jsxSourceAttrs } from 'vite-plugin-jsx-source-attrs';`를 추가한다.
372
- 4. `react({ babel: { plugins: [...] } })` 안에 `jsxSourceAttrs({ enabled: mode === 'development', componentAttributeName: null })`를 추가한다.
372
+ 4. `react({ babel: { plugins: [...] } })` 안에 `jsxSourceAttrs({ enabled: mode === 'development', componentAttributeName: 'data-component-source-location' })`를 추가한다.
373
373
  5. 기존 로컬 플러그인 파일은 import가 사라진 뒤 삭제한다.
374
374
  6. `@wix/babel-plugin-jsx-source-attrs`가 더 이상 필요 없다면 dependency/devDependency에서 제거한다.
375
375
 
@@ -457,7 +457,7 @@ export default defineConfig(({ mode }) => ({
457
457
  jsxSourceAttrs({
458
458
  enabled: mode === 'development',
459
459
  attributeName: 'data-source-location',
460
- componentAttributeName: null,
460
+ componentAttributeName: 'data-component-source-location',
461
461
  }),
462
462
  ],
463
463
  },
package/README.md CHANGED
@@ -8,8 +8,8 @@ Vite React 개발 환경에서 JSX 요소에 소스 위치 정보를 담은 attr
8
8
 
9
9
  - 개발 모드 JSX에 `data-source-location` attribute를 주입합니다.
10
10
  - 프로덕션 빌드 또는 비활성화 조건에서는 source attribute를 주입하지 않을 수 있습니다.
11
- - 기본값에서는 intrinsic JSX 요소(`div`, `span`, `my-element`) 대상으로 합니다.
12
- - `componentAttributeName`을 지정하면 사용자 컴포넌트에도 별도 attribute를 주입할 수 있습니다.
11
+ - 기본값에서는 intrinsic JSX 요소(`div`, `span`, `my-element`) `data-source-location`을, 사용자 컴포넌트에 `data-component-source-location`을 주입합니다.
12
+ - `componentAttributeName: null`을 지정하면 사용자 컴포넌트에는 attribute를 주입하지 않습니다.
13
13
  - 파일 경로의 query/hash 제거, Vite 가상 모듈 prefix 제거, OS 경로 구분자 정규화를 제공합니다.
14
14
  - 이미 같은 이름의 attribute가 있으면 중복으로 주입하지 않습니다.
15
15
 
@@ -31,6 +31,59 @@ npm install -D vite-plugin-jsx-source-attrs
31
31
 
32
32
  프로덕션 빌드에서도 `vite.config.ts`를 평가해야 하므로 CI/CD가 `devDependencies`를 포함해 설치해야 합니다. `npm ci --omit=dev`처럼 devDependency를 제외한 상태에서 빌드를 실행하는 환경이라면 이 패키지를 찾을 수 없습니다. 이 경우 빌드 단계에서는 devDependency를 포함해 설치하고, 배포 런타임 이미지나 서버 산출물에서만 devDependency를 제외하세요.
33
33
 
34
+ ### LLM 적용 가이드 프롬프트
35
+
36
+ 다른 Vite React 프로젝트에 이 패키지를 설치하고 `vite.config.ts`까지 자동 반영하려면 아래 프롬프트를 LLM/AI 에이전트에게 그대로 전달하세요. 더 자세한 지침은 [`README.llm.txt`](README.llm.txt)를 참고하세요.
37
+
38
+ ````text
39
+ Vite React 프로젝트에 `vite-plugin-jsx-source-attrs`를 설치하고 설정해줘.
40
+
41
+ 요구사항:
42
+ 1. 프로젝트 루트에서 패키지 매니저를 확인해줘.
43
+ - `packageManager` 필드가 있으면 해당 도구를 우선 사용해줘.
44
+ - `packageManager`가 없으면 lockfile 기준으로 판단해줘: `bun.lock` → Bun, `package-lock.json` → npm, `pnpm-lock.yaml` → pnpm, `yarn.lock` → Yarn.
45
+ - 그래도 판단할 수 없으면 npm을 사용해줘.
46
+ 2. `vite-plugin-jsx-source-attrs`를 devDependency로 설치해줘.
47
+ - stable 검증이면 `vite-plugin-jsx-source-attrs` 또는 `vite-plugin-jsx-source-attrs@latest`를 설치해줘.
48
+ - MR 검증본이 필요하면 `vite-plugin-jsx-source-attrs@dev`를 설치해줘.
49
+ - main prerelease 검증본이 필요하면 `vite-plugin-jsx-source-attrs@pre`를 설치해줘.
50
+ 3. `vite.config.ts` 또는 `vite.config.mts`를 찾아 `@vitejs/plugin-react`보다 앞에 `vitePluginJsxSourceAttrs()`를 추가해줘.
51
+ 4. 기존 `react()` 설정, 기존 Babel plugin, alias, server, build 설정은 보존해줘.
52
+ 5. 이미 `react({ babel: { plugins: [...] } })`를 지원하는 구버전 조합이면 `jsxSourceAttrs()`를 기존 Babel 플러그인 배열 끝에 추가해도 돼.
53
+ 6. Vite 8 + `@vitejs/plugin-react` 6처럼 `babel` 옵션이 없는 조합에서는 `react({ babel: ... })` 형태로 바꾸지 말고 Vite 플러그인 방식을 사용해줘.
54
+ 7. `defineConfig`가 객체 형태이고 `mode`가 필요하면 `defineConfig(({ mode }) => ({ ... }))` 형태로 바꿔줘. 단, 기존 설정 의미는 보존해줘.
55
+ 8. 기본 설정은 아래 값을 사용해줘.
56
+
57
+ ```ts
58
+ vitePluginJsxSourceAttrs({
59
+ enabled: mode === 'development',
60
+ attributeName: 'data-source-location',
61
+ componentAttributeName: 'data-component-source-location',
62
+ })
63
+ ```
64
+
65
+ 9. import를 추가해줘.
66
+
67
+ ```ts
68
+ import { vitePluginJsxSourceAttrs } from 'vite-plugin-jsx-source-attrs';
69
+ ```
70
+
71
+ 10. 기존 로컬 JSX source attrs 플러그인이 있으면 새 패키지로 대체해줘.
72
+ - 제거 후보: `resources/scripts/jsx-source-attrs.js`, `resources/babel/jsx-source-attrs.js`, `src/resources/babel/jsx-source-attrs.js`, `@wix/babel-plugin-jsx-source-attrs` 직접 설정.
73
+ - 단, 실제 import가 제거된 뒤에만 파일/의존성을 삭제해줘.
74
+ 11. 빌드 단계에서는 devDependencies가 설치되어야 한다는 점을 CI 설정에서 확인해줘.
75
+ 12. 변경 후 프로젝트의 기존 검증 스크립트를 실행해줘.
76
+ - 가능한 경우: lint, typecheck, test, build 순서.
77
+ - 없는 스크립트는 억지로 만들지 말고 건너뛰었다고 보고해줘.
78
+ 13. 최종 보고에는 설치한 버전/tag, 수정한 파일, 실행한 검증 명령, 남은 주의사항을 요약해줘.
79
+
80
+ 주의사항:
81
+ - unrelated 파일은 수정하지 마.
82
+ - 기존 변경사항을 되돌리지 마.
83
+ - 문자열/주석에 있는 예시는 실제 import나 실행 코드가 아니면 함부로 삭제하지 마.
84
+ - 프로덕션 빌드 산출물에는 `data-source-location`이 없어야 해.
85
+ ````
86
+
34
87
 
35
88
  ## 사용법
36
89
 
@@ -46,7 +99,7 @@ export default defineConfig(({ mode }) => ({
46
99
  vitePluginJsxSourceAttrs({
47
100
  enabled: mode === 'development',
48
101
  attributeName: 'data-source-location',
49
- componentAttributeName: null,
102
+ componentAttributeName: 'data-component-source-location',
50
103
  }),
51
104
  react(),
52
105
  ],
@@ -68,7 +121,7 @@ export default defineConfig(({ mode }) => ({
68
121
  jsxSourceAttrs({
69
122
  enabled: mode === 'development',
70
123
  attributeName: 'data-source-location',
71
- componentAttributeName: null,
124
+ componentAttributeName: 'data-component-source-location',
72
125
  }),
73
126
  ],
74
127
  },
@@ -95,7 +148,7 @@ const view = <div data-source-location="src/App.tsx:1:14" />;
95
148
  | --- | --- | --- |
96
149
  | `enabled` | Babel: `process.env.NODE_ENV !== 'production'`, Vite: `command === 'serve'` | attribute 주입 여부입니다. boolean 또는 context 기반 함수로 지정할 수 있습니다. |
97
150
  | `attributeName` | `data-source-location` | intrinsic JSX 요소에 주입할 attribute 이름입니다. |
98
- | `componentAttributeName` | `null` | 사용자 컴포넌트에 별도로 주입할 attribute 이름입니다. `null`이면 사용자 컴포넌트에는 주입하지 않습니다. |
151
+ | `componentAttributeName` | `data-component-source-location` | 사용자 컴포넌트에 별도로 주입할 attribute 이름입니다. `null`이면 사용자 컴포넌트에는 주입하지 않습니다. |
99
152
  | `root` | Babel: `process.cwd()`, Vite: `config.root` | 절대 경로를 상대 경로로 바꿀 기준 루트입니다. |
100
153
  | `normalizePath` | 내장 정규화 함수 | 파일 경로를 attribute 값에 맞게 정규화하는 함수입니다. |
101
154
  | `include` | `/\.[jt]sx(?:\?.*)?$/` | `vitePluginJsxSourceAttrs`에서만 사용합니다. 변환할 Vite module id 패턴입니다. |
@@ -110,12 +163,11 @@ jsxSourceAttrs({
110
163
  });
111
164
  ```
112
165
 
113
- ### 사용자 컴포넌트 attribute 예시
166
+ ### 사용자 컴포넌트 attribute 비활성화 예시
114
167
 
115
168
  ```ts
116
169
  jsxSourceAttrs({
117
- attributeName: 'data-source-location',
118
- componentAttributeName: 'data-component-source-location',
170
+ componentAttributeName: null,
119
171
  });
120
172
  ```
121
173
 
package/dist/index.cjs CHANGED
@@ -79,13 +79,14 @@ function normalizeSourcePath(filename, context) {
79
79
 
80
80
  // src/index.ts
81
81
  var DEFAULT_ATTRIBUTE_NAME = "data-source-location";
82
+ var DEFAULT_COMPONENT_ATTRIBUTE_NAME = "data-component-source-location";
82
83
  var DEFAULT_INCLUDE_RE = /\.[jt]sx(?:\?.*)?$/;
83
84
  var DEFAULT_EXCLUDE_RE = /\/node_modules\//;
84
85
  function resolveOptions(options) {
85
86
  return {
86
87
  enabled: options.enabled ?? process.env.NODE_ENV !== "production",
87
88
  attributeName: options.attributeName ?? DEFAULT_ATTRIBUTE_NAME,
88
- componentAttributeName: options.componentAttributeName ?? null,
89
+ componentAttributeName: options.componentAttributeName === void 0 ? DEFAULT_COMPONENT_ATTRIBUTE_NAME : options.componentAttributeName,
89
90
  root: import_node_path2.default.resolve(options.root ?? process.cwd()),
90
91
  normalizePath: options.normalizePath ?? normalizeSourcePath
91
92
  };
package/dist/index.d.cts CHANGED
@@ -20,7 +20,7 @@ interface JsxSourceAttrsOptions {
20
20
  enabled?: boolean | ((context: JsxSourceAttrsContext) => boolean);
21
21
  /** intrinsic JSX 요소에 주입할 attribute 이름입니다. */
22
22
  attributeName?: string;
23
- /** 사용자 컴포넌트에 주입할 attribute 이름입니다. `null`이면 주입하지 않습니다. */
23
+ /** 사용자 컴포넌트에 주입할 attribute 이름입니다. 기본값은 `data-component-source-location`이며, `null`이면 주입하지 않습니다. */
24
24
  componentAttributeName?: string | null;
25
25
  /** 절대 경로를 상대 경로로 바꿀 기준 루트입니다. */
26
26
  root?: string;
package/dist/index.d.ts CHANGED
@@ -20,7 +20,7 @@ interface JsxSourceAttrsOptions {
20
20
  enabled?: boolean | ((context: JsxSourceAttrsContext) => boolean);
21
21
  /** intrinsic JSX 요소에 주입할 attribute 이름입니다. */
22
22
  attributeName?: string;
23
- /** 사용자 컴포넌트에 주입할 attribute 이름입니다. `null`이면 주입하지 않습니다. */
23
+ /** 사용자 컴포넌트에 주입할 attribute 이름입니다. 기본값은 `data-component-source-location`이며, `null`이면 주입하지 않습니다. */
24
24
  componentAttributeName?: string | null;
25
25
  /** 절대 경로를 상대 경로로 바꿀 기준 루트입니다. */
26
26
  root?: string;
package/dist/index.js CHANGED
@@ -42,13 +42,14 @@ function normalizeSourcePath(filename, context) {
42
42
 
43
43
  // src/index.ts
44
44
  var DEFAULT_ATTRIBUTE_NAME = "data-source-location";
45
+ var DEFAULT_COMPONENT_ATTRIBUTE_NAME = "data-component-source-location";
45
46
  var DEFAULT_INCLUDE_RE = /\.[jt]sx(?:\?.*)?$/;
46
47
  var DEFAULT_EXCLUDE_RE = /\/node_modules\//;
47
48
  function resolveOptions(options) {
48
49
  return {
49
50
  enabled: options.enabled ?? process.env.NODE_ENV !== "production",
50
51
  attributeName: options.attributeName ?? DEFAULT_ATTRIBUTE_NAME,
51
- componentAttributeName: options.componentAttributeName ?? null,
52
+ componentAttributeName: options.componentAttributeName === void 0 ? DEFAULT_COMPONENT_ATTRIBUTE_NAME : options.componentAttributeName,
52
53
  root: path2.resolve(options.root ?? process.cwd()),
53
54
  normalizePath: options.normalizePath ?? normalizeSourcePath
54
55
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-jsx-source-attrs",
3
- "version": "0.2.0",
3
+ "version": "0.2.2-dev.mr.4.33.5c3d6c43",
4
4
  "description": "Vite React 개발 환경에서 JSX 요소에 소스 위치 attribute를 주입하는 Vite/Babel 플러그인",
5
5
  "type": "module",
6
6
  "license": "MIT",