Skip to content

Commit c7d614c

Browse files
committed
fix: reload Rstack config without module cache
1 parent 39c5335 commit c7d614c

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

packages/rstack/src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export const loadRstackConfig = async (): Promise<Configs> => {
109109
await loadConfig({
110110
loader: 'native',
111111
exportName: false,
112+
fresh: true,
112113
...(state.configPath !== undefined
113114
? { path: state.configPath }
114115
: {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { define } from 'rstack';
2+
3+
define.app({});

packages/rstack/test/config/load-state/index.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@ import path from 'node:path';
22
import { expect, test } from 'rstack/test';
33
import { getConfigState, loadRstackConfig } from '../../../src/config.ts';
44

5-
test('should reset config state before and after loading', async () => {
5+
test('should load config with fresh state', async () => {
66
const state = getConfigState();
77
state.configs = { app: {} };
8-
state.configPath = path.join(import.meta.dirname, 'rstack.config.ts');
8+
state.configPath = path.join(import.meta.dirname, 'fresh.config.ts');
99

1010
try {
11-
await expect(loadRstackConfig()).rejects.toThrow('test config error');
11+
expect(await loadRstackConfig()).toHaveProperty('app');
12+
expect(await loadRstackConfig()).toHaveProperty('app');
13+
14+
state.configs = { app: {} };
15+
state.configPath = path.join(import.meta.dirname, 'rstack.config.ts');
16+
17+
await expect(loadRstackConfig()).rejects.toThrow();
1218
expect(state.configs).toEqual({});
1319
} finally {
1420
state.configs = {};

0 commit comments

Comments
 (0)