vite-pug-static-builder 1.1.0 → 1.1.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/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;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,CAiDzB,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,CAgDzB,CAAA"}
package/dist/pug.js CHANGED
@@ -55,10 +55,9 @@ export const compilePug = async (moduleGraph, url, pugPath, options, locals) =>
55
55
  compiledModule.file = pugPath;
56
56
  // Vite 7ではModuleGraphが自動的にfileToModulesMapを管理
57
57
  }
58
- // モジュールが無効化されていない場合はスキップ
59
- if (compiledModule.transformResult) {
60
- return true;
61
- }
58
+ // 開発モードではtransformResultの有無に関わらず常に最新のコンパイルを実行
59
+ // これによりファイル変更時の内容更新を確実にする
60
+ // (本番ビルド時はこの関数は使用されないため性能に影響しない)
62
61
  // コンパイル開始
63
62
  const map = null;
64
63
  const compiledTemplate = compileFile(pugPath, options);
@@ -1 +1 @@
1
- {"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAC1B,OAAO,KAAK,EAAE,MAAM,EAAiB,OAAO,EAAE,MAAM,MAAM,CAAA;AAE1D,OAAO,KAAK,SAAS,MAAM,WAAW,CAAA;AAKtC;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,oBAAoB;IACpB,QAAQ,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,OAAO,CAAA;IAC9B,sBAAsB;IACtB,QAAQ,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,YAAY,CAAA;IAClC,4BAA4B;IAC5B,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,CAAC,IAAI,CAAA;IACvC,2BAA2B;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CACvB,GAAG,EAAE,OAAO,CAAC,eAAe,EAC5B,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,IAAI,EAAE,OAAO,CAAC,YAAY,KACvB,IAAI,GAAG,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,CAAA;AA+FrE;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,WAAW,aAAa,KAAG,MAiC7D,CAAA"}
1
+ {"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAC1B,OAAO,KAAK,EAAE,MAAM,EAAiB,OAAO,EAAE,MAAM,MAAM,CAAA;AAE1D,OAAO,KAAK,SAAS,MAAM,WAAW,CAAA;AAKtC;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,oBAAoB;IACpB,QAAQ,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,OAAO,CAAA;IAC9B,sBAAsB;IACtB,QAAQ,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,YAAY,CAAA;IAClC,4BAA4B;IAC5B,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,CAAC,IAAI,CAAA;IACvC,2BAA2B;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CACvB,GAAG,EAAE,OAAO,CAAC,eAAe,EAC5B,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,IAAI,EAAE,OAAO,CAAC,YAAY,KACvB,IAAI,GAAG,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,CAAA;AA+FrE;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,WAAW,aAAa,KAAG,MAuE7D,CAAA"}
package/dist/serve.js CHANGED
@@ -85,21 +85,47 @@ export const vitePluginPugServe = (settings) => {
85
85
  server = _server;
86
86
  server.middlewares.use(createMiddleware(settings ?? {}, server));
87
87
  },
88
- handleHotUpdate(context) {
89
- const fileModules = server.moduleGraph.getModulesByFile(context.file);
88
+ // Vite 7の新しいhotUpdateフックを使用してより効率的な処理を実装
89
+ hotUpdate(context) {
90
+ const { file, timestamp } = context;
91
+ const { environment } = this;
92
+ // Pugファイル自体が変更された場合
93
+ if (path.extname(file) === '.pug') {
94
+ // 対応するHTMLモジュールのURLを生成
95
+ const parsedPath = path.parse(file);
96
+ const htmlUrl = path.posix.format({
97
+ dir: parsedPath.dir.replace(server.config.root, '').replace(/\\/g, '/'),
98
+ name: parsedPath.name,
99
+ ext: '.html',
100
+ });
101
+ // Environment APIを使用してモジュールを取得・無効化(非同期処理を修正)
102
+ environment.moduleGraph.getModuleByUrl(htmlUrl).then((htmlModule) => {
103
+ if (htmlModule) {
104
+ // モジュールを適切に無効化(Vite 7の新しいAPI)
105
+ environment.moduleGraph.invalidateModule(htmlModule, new Set(), timestamp, true // HMRフラグを明示的にtrue
106
+ );
107
+ }
108
+ }).catch(() => {
109
+ // モジュールが見つからない場合は無視
110
+ });
111
+ }
112
+ // 従来のファイルモジュール無効化処理
113
+ const fileModules = environment.moduleGraph.getModulesByFile(file);
90
114
  if (fileModules) {
115
+ const invalidatedModules = new Set(); // 型を明示的に指定
91
116
  for (const fileModule of fileModules) {
92
117
  for (const importer of fileModule.importers) {
93
118
  if (importer.file && path.extname(importer.file) === '.pug') {
94
- server.moduleGraph.invalidateModule(importer);
119
+ environment.moduleGraph.invalidateModule(importer, invalidatedModules, timestamp, true);
95
120
  }
96
121
  }
97
122
  }
98
123
  }
99
124
  // リロード設定に基づいてフルリロードを実行
100
125
  if (reload !== false) {
101
- context.server.ws.send({ type: 'full-reload' });
126
+ environment.hot.send({ type: 'full-reload' });
102
127
  }
103
128
  },
129
+ // 古いhandleHotUpdateフックは削除(Vite 7では非推奨)
104
130
  };
105
131
  };
package/package.json CHANGED
@@ -1,70 +1,70 @@
1
- {
2
- "name": "vite-pug-static-builder",
3
- "version": "1.1.0",
4
- "description": "Vite + Pugを使用した静的サイトビルダー - 複数のPugファイルを静的HTMLとしてビルドするViteプラグイン",
5
- "author": "maigo999",
6
- "license": "MIT",
7
- "homepage": "https://github.com/ozekimasaki/vite-pug-static-builder#readme",
8
- "repository": {
9
- "type": "git",
10
- "url": "https://github.com/ozekimasaki/vite-pug-static-builder.git"
11
- },
12
- "bugs": {
13
- "url": "https://github.com/ozekimasaki/vite-pug-static-builder/issues"
14
- },
15
- "keywords": [
16
- "vite",
17
- "vite-plugin",
18
- "static",
19
- "pug",
20
- "static-site",
21
- "site-builder",
22
- "html-generator"
23
- ],
24
- "files": [
25
- "dist"
26
- ],
27
- "type": "module",
28
- "main": "./dist/index.js",
29
- "types": "./dist/index.d.ts",
30
- "exports": {
31
- ".": {
32
- "import": "./dist/index.js",
33
- "types": "./dist/index.d.ts"
34
- }
35
- },
36
- "scripts": {
37
- "clean": "rimraf ./dist",
38
- "type-check": "tsc --noEmit -p .",
39
- "test:vite6": "cross-env VITE_MAJOR_VERSION=6 vitest run",
40
- "test:vite7": "cross-env VITE_MAJOR_VERSION=7 vitest run",
41
- "test": "pnpm test:vite7",
42
- "test:update": "vitest run -u",
43
- "test:watch": "vitest",
44
- "coverage": "cross-env VITE_MAJOR_VERSION=7 vitest run --coverage",
45
- "tsc": "tsc -p .",
46
- "build": "pnpm clean && pnpm tsc",
47
- "prepublishOnly": "pnpm build"
48
- },
49
- "dependencies": {
50
- "ansis": "^3.2.0",
51
- "picomatch": "^4.0.2",
52
- "pug": "^3.0.3"
53
- },
54
- "peerDependencies": {
55
- "pug": "^3.0.0",
56
- "vite": "^6.0.0 || ^7.0.0"
57
- },
58
- "devDependencies": {
59
- "@types/picomatch": "^2.3.3",
60
- "@types/pug": "^2.0.10",
61
- "@vitest/coverage-v8": "^3.2.1",
62
- "axios": "^1.7.9",
63
- "cross-env": "^7.0.3",
64
- "fs-extra": "^11.3.0",
65
- "rimraf": "^6.0.1",
66
- "typescript": "^5.6.3",
67
- "vite": "^7.0.0",
68
- "vitest": "^3.2.1"
69
- }
70
- }
1
+ {
2
+ "name": "vite-pug-static-builder",
3
+ "version": "1.1.2",
4
+ "description": "Vite + Pugを使用した静的サイトビルダー - 複数のPugファイルを静的HTMLとしてビルドするViteプラグイン",
5
+ "author": "maigo999",
6
+ "license": "MIT",
7
+ "homepage": "https://github.com/ozekimasaki/vite-pug-static-builder#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/ozekimasaki/vite-pug-static-builder.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/ozekimasaki/vite-pug-static-builder/issues"
14
+ },
15
+ "keywords": [
16
+ "vite",
17
+ "vite-plugin",
18
+ "static",
19
+ "pug",
20
+ "static-site",
21
+ "site-builder",
22
+ "html-generator"
23
+ ],
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "type": "module",
28
+ "main": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "import": "./dist/index.js",
33
+ "types": "./dist/index.d.ts"
34
+ }
35
+ },
36
+ "scripts": {
37
+ "clean": "rimraf ./dist",
38
+ "type-check": "tsc --noEmit -p .",
39
+ "test:vite6": "cross-env VITE_MAJOR_VERSION=6 vitest run",
40
+ "test:vite7": "cross-env VITE_MAJOR_VERSION=7 vitest run",
41
+ "test": "pnpm test:vite7",
42
+ "test:update": "vitest run -u",
43
+ "test:watch": "vitest",
44
+ "coverage": "cross-env VITE_MAJOR_VERSION=7 vitest run --coverage",
45
+ "tsc": "tsc -p .",
46
+ "build": "pnpm clean && pnpm tsc",
47
+ "prepublishOnly": "pnpm build"
48
+ },
49
+ "dependencies": {
50
+ "ansis": "^3.2.0",
51
+ "picomatch": "^4.0.2",
52
+ "pug": "^3.0.3"
53
+ },
54
+ "peerDependencies": {
55
+ "pug": "^3.0.0",
56
+ "vite": "^6.0.0 || ^7.0.0"
57
+ },
58
+ "devDependencies": {
59
+ "@types/picomatch": "^2.3.3",
60
+ "@types/pug": "^2.0.10",
61
+ "@vitest/coverage-v8": "^3.2.1",
62
+ "axios": "^1.7.9",
63
+ "cross-env": "^7.0.3",
64
+ "fs-extra": "^11.3.0",
65
+ "rimraf": "^6.0.1",
66
+ "typescript": "^5.6.3",
67
+ "vite": "^7.0.5",
68
+ "vitest": "^3.2.1"
69
+ }
70
+ }