Skip to content

Commit 0d82405

Browse files
committed
f
1 parent 0040481 commit 0d82405

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,6 @@
9393
"src"
9494
],
9595
"types": "./dist/commonjs/index.d.ts",
96-
"main": "./dist/commonjs/index.js"
96+
"main": "./dist/commonjs/index.js",
97+
"module": "./dist/esm/index.js"
9798
}

src/app/middleware/egg_loader_trace.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default (_: unknown, app: EggCore): MiddlewareFunc => {
99
if (ctx.path !== '/__loader_trace__') {
1010
return await next();
1111
}
12-
const template = await fs.readFile(getSourceFile('lib/loader_trace.html'), 'utf8');
12+
const template = await fs.readFile(getSourceFile('config/loader_trace.html'), 'utf8');
1313
const data = await loadTimingData(app);
1414
ctx.body = template.replace('{{placeholder}}', JSON.stringify(data));
1515
};
File renamed without changes.

src/typings/index.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// make sure to import egg typings and let typescript know about it
2+
// @see https://github.com/whxaxes/blog/issues/11
3+
// and https://www.typescriptlang.org/docs/handbook/declaration-merging.html
4+
import 'egg';

test/override.test.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'node:fs/promises';
22
import { scheduler } from 'node:timers/promises';
33
import { mm, MockApplication } from '@eggjs/mock';
4-
import { escape, getFilepath, DELAY } from './utils.js';
4+
import { escape, getFilepath } from './utils.js';
55

66
describe('test/override.test.ts', () => {
77
let app: MockApplication;
@@ -23,19 +23,19 @@ describe('test/override.test.ts', () => {
2323
it('should reload', async () => {
2424
const filepath = getFilepath('override/app/service/a.js');
2525
await fs.writeFile(filepath, '');
26-
await scheduler.wait(DELAY);
27-
26+
await scheduler.wait(1000);
2827
await fs.unlink(filepath);
28+
await scheduler.wait(5000);
2929
app.expect('stdout', /a\.js/);
3030
});
3131

3232
it('should not reload', async () => {
3333
app.debug();
3434
const filepath = getFilepath('override/app/no-trigger/index.js');
3535
await fs.writeFile(filepath, '');
36-
await scheduler.wait(DELAY);
37-
36+
await scheduler.wait(1000);
3837
await fs.unlink(filepath);
38+
await scheduler.wait(5000);
3939
app.notExpect('stdout', /index\.js/);
4040
});
4141
});
@@ -52,19 +52,19 @@ describe('test/override.test.ts', () => {
5252
it('should reload', async () => {
5353
const filepath = getFilepath('override-ignore/app/web/a.js');
5454
await fs.writeFile(filepath, '');
55-
await scheduler.wait(DELAY);
56-
55+
await scheduler.wait(1000);
5756
await fs.unlink(filepath);
57+
await scheduler.wait(5000);
5858
app.expect('stdout', new RegExp(escape(`reload worker because ${filepath}`)));
5959
});
6060

6161
it('should not reload', async () => {
6262
app.debug();
6363
const filepath = getFilepath('override-ignore/app/public/index.js');
6464
await fs.writeFile(filepath, '');
65-
await scheduler.wait(DELAY);
66-
65+
await scheduler.wait(1000);
6766
await fs.unlink(filepath);
67+
await scheduler.wait(5000);
6868
app.notExpect('stdout', new RegExp(escape(`reload worker because ${filepath} change`)));
6969
});
7070
});

0 commit comments

Comments
 (0)