Skip to content

Commit 0ff3fd8

Browse files
authored
Merge branch 'next' into shilman/first-load-new-user
2 parents ac21b0a + df41f2e commit 0ff3fd8

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

code/core/src/common/utils/validate-config.test.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { afterEach, describe, expect, it, vi } from 'vitest';
22

3+
import { resolveModulePath } from 'exsolve';
4+
35
import { validateFrameworkName } from './validate-config';
46

7+
// mock exsolve to spy
8+
vi.mock('exsolve', { spy: true });
9+
510
describe('validateFrameworkName', () => {
611
afterEach(() => {
712
vi.resetAllMocks();
@@ -20,15 +25,20 @@ describe('validateFrameworkName', () => {
2025
});
2126

2227
it('should not throw if framework is unknown (community) but can be resolved', () => {
23-
// mock require.resolve to return a value
24-
vi.spyOn(require, 'resolve').mockReturnValue('some-community-framework');
25-
expect(() => validateFrameworkName('some-community-framework')).toThrow();
28+
vi.mocked(resolveModulePath).mockImplementation(() => {});
29+
30+
expect(() => validateFrameworkName('some-community-framework')).not.toThrow();
31+
});
32+
33+
it('should not throw if scoped framework is unknown (community) but can be resolved', () => {
34+
vi.mocked(resolveModulePath).mockImplementation(() => {});
35+
36+
expect(() => validateFrameworkName('@some-community/framework')).not.toThrow();
2637
});
2738

2839
it('should throw if framework is unknown and cannot be resolved', () => {
29-
// mock require.resolve to fail
30-
vi.spyOn(require, 'resolve').mockImplementation(() => {
31-
throw new Error('Cannot resolve');
40+
vi.mocked(resolveModulePath).mockImplementation(() => {
41+
throw new Error('cannot resolve');
3242
});
3343

3444
expect(() => validateFrameworkName('foo')).toThrow();

code/core/src/common/utils/validate-config.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { join } from 'node:path';
2-
31
import {
42
CouldNotEvaluateFrameworkError,
53
InvalidFrameworkNameError,
@@ -35,7 +33,7 @@ export function validateFrameworkName(
3533

3634
// If it's not a known framework, we need to validate that it's a valid package at least
3735
try {
38-
resolveModulePath(join(frameworkName, 'preset'), {
36+
resolveModulePath(`${frameworkName}/preset`, {
3937
extensions: ['.mjs', '.js', '.cjs'],
4038
conditions: ['node', 'import', 'require'],
4139
});

docs/addons/addon-migration-guide.mdx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,20 @@ Next, update the `exports` field in your `package.json` to remove mentions of CJ
220220
},
221221
```
222222

223-
Update `tsconfig.json` to use `esnext` modules.
223+
Update `tsconfig.json`.
224224

225225
```diff title="tsconfig.json"
226226
{
227227
"compilerOptions": {
228228
// ...
229-
- "module": "preserve",
230-
+ "module": "esnext",
229+
- "target": "es2023",
230+
+ "target": "esnext",
231231
// ...
232232
- "lib": ["es2023", "dom", "dom.iterable"],
233233
+ "lib": ["esnext", "dom", "dom.iterable"],
234+
// ...
235+
- "rootDir": "./src",
236+
+ "rootDir": ".",
234237
},
235238
- "include": ["src/**/*"]
236239
+ "include": ["src/**/*", "tsup.config.ts"]

0 commit comments

Comments
 (0)