Skip to content

Commit c182c3f

Browse files
committed
fix: time and package module
1 parent c4a7e0d commit c182c3f

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
"format": "prettier --write examples src",
9494
"release": "bumpp package.json examples/*/package.json --commit --push --tag && pnpm publish",
9595
"test": "vitest",
96+
"test:ci": "vitest --run",
9697
"typecheck": "tsc --noEmit",
9798
"preversion": "pnpm typecheck && pnpm build"
9899
},

src/core/index.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import { BuildPackageModule } from './modules/package';
1515
export * from './types';
1616

1717
export const UnpluginInfo = createUnplugin<Options | undefined>((options = {}) => {
18-
let now: Date;
19-
2018
const root = path.resolve(options?.root ?? process.cwd());
2119

2220
const modules = {
@@ -30,8 +28,11 @@ export const UnpluginInfo = createUnplugin<Options | undefined>((options = {}) =
3028

3129
return {
3230
name: 'unplugin-info',
33-
buildStart() {
34-
now = new Date();
31+
async buildStart() {
32+
await Promise.all(Object.values(modules).map((mod) => mod.buildStart(this)));
33+
},
34+
async buildEnd() {
35+
await Promise.all(Object.values(modules).map((mod) => mod.buildEnd(this)));
3536
},
3637
resolveId(id) {
3738
if (
@@ -69,7 +70,7 @@ export const UnpluginInfo = createUnplugin<Options | undefined>((options = {}) =
6970
handleHotUpdate({ file, server }) {
7071
// HMR: package.json
7172
if (file === normalizePath(path.resolve(root, 'package.json'))) {
72-
const module = server.moduleGraph.getModuleById('\0' + modules.Package);
73+
const module = server.moduleGraph.getModuleById('\0' + modules.Package.name);
7374
if (module) {
7475
// Invalidate module for reloading
7576
server.moduleGraph.invalidateModule(module);

src/core/modules/info.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ import { BuildGitModule } from './git';
55
export class LegacyInfoModule extends BuildGitModule {
66
constructor(root: string, options: Options) {
77
super(root, options);
8-
this.name = `${options.prefix}/info`;
8+
this.name = `${options.prefix ?? '~build'}/info`;
99
}
1010
}

0 commit comments

Comments
 (0)