vite-pug-static-builder 1.0.0 → 1.0.1

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/dist/pug.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pug.d.ts","sourceRoot":"","sources":["../src/pug.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAE1B,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,MAAM,CAAA;AAkCnD;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,GACrB,aAAa,WAAW,EACxB,KAAK,MAAM,EACX,SAAS,MAAM,EACf,UAAU,GAAG,CAAC,OAAO,EACrB,SAAS,GAAG,CAAC,YAAY,KACxB,OAAO,CAAC,OAAO,GAAG,KAAK,CAoDzB,CAAA"}
1
+ {"version":3,"file":"pug.d.ts","sourceRoot":"","sources":["../src/pug.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAE1B,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,MAAM,CAAA;AA+CnD;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,GACrB,aAAa,WAAW,EACxB,KAAK,MAAM,EACX,SAAS,MAAM,EACf,UAAU,GAAG,CAAC,OAAO,EACrB,SAAS,GAAG,CAAC,YAAY,KACxB,OAAO,CAAC,OAAO,GAAG,KAAK,CAsDzB,CAAA"}
package/dist/pug.js CHANGED
@@ -10,11 +10,26 @@ import { outputLog } from './utils.js';
10
10
  const reflectAncestorsIntoModuleMap = (moduleGraph, compiledModule, ancestors) => {
11
11
  // モジュールマップに祖先を追加
12
12
  for (const ancestor of ancestors) {
13
- const ancestorModules = moduleGraph.getModulesByFile(ancestor);
14
- const ancestorModule = (ancestorModules && [...ancestorModules][0]) ||
15
- moduleGraph.createFileOnlyEntry(ancestor);
16
- ancestorModule.importers.add(compiledModule); // TODO: 依存関係から削除された場合の処理
17
- compiledModule.importedModules.add(ancestorModule); // オプション
13
+ try {
14
+ const ancestorModules = moduleGraph.getModulesByFile(ancestor);
15
+ let ancestorModule;
16
+ if (ancestorModules && ancestorModules.size > 0) {
17
+ ancestorModule = [...ancestorModules][0];
18
+ }
19
+ else {
20
+ // Vite 7では createFileOnlyEntry の代わりに ensureEntryFromUrl を使用
21
+ const ancestorUrl = ancestor.replace(process.cwd(), '').replace(/\\/g, '/');
22
+ ancestorModule = moduleGraph.getModuleById(ancestorUrl) || undefined;
23
+ }
24
+ if (ancestorModule) {
25
+ ancestorModule.importers.add(compiledModule); // TODO: 依存関係から削除された場合の処理
26
+ compiledModule.importedModules.add(ancestorModule); // オプション
27
+ }
28
+ }
29
+ catch (error) {
30
+ // 祖先モジュールの処理に失敗した場合はログを出力して続行
31
+ outputLog('warn', 'ancestor module processing failed:', ancestor);
32
+ }
18
33
  }
19
34
  };
20
35
  /**
@@ -32,11 +47,13 @@ export const compilePug = async (moduleGraph, url, pugPath, options, locals) =>
32
47
  (await moduleGraph.ensureEntryFromUrl(url));
33
48
  // 作成時の初期化
34
49
  if (compiledModule.file !== pugPath) {
50
+ // Vite 7では直接fileToModulesMapを操作できないため、
51
+ // モジュールの無効化を通じてファイルパスを更新
35
52
  if (compiledModule.file) {
36
- moduleGraph.fileToModulesMap.delete(compiledModule.file);
53
+ moduleGraph.invalidateModule(compiledModule);
37
54
  }
38
55
  compiledModule.file = pugPath;
39
- moduleGraph.fileToModulesMap.set(pugPath, new Set([compiledModule]));
56
+ // Vite 7ではModuleGraphが自動的にfileToModulesMapを管理
40
57
  }
41
58
  // モジュールが無効化されていない場合はスキップ
42
59
  if (compiledModule.transformResult) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-pug-static-builder",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Vite + Pugを使用した静的サイトビルダー - 複数のPugファイルを静的HTMLとしてビルドするViteプラグイン",
5
5
  "author": "maigo999",
6
6
  "license": "MIT",