@valbuild/next 0.134.1 → 0.135.0
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/CHANGELOG.md +38 -0
- package/README.md +18 -14
- package/dist/declarations/src/server/index.d.ts +1 -0
- package/dist/valbuild-next.cjs.dev.js +1 -1
- package/dist/valbuild-next.cjs.prod.js +1 -1
- package/dist/valbuild-next.esm.js +1 -1
- package/dist/{version-28baa77f.esm.js → version-12fffb44.esm.js} +1 -1
- package/dist/{version-a3e5a2df.cjs.prod.js → version-58fd6989.cjs.prod.js} +1 -1
- package/dist/{version-ddff5d6a.cjs.dev.js → version-77226c0a.cjs.dev.js} +1 -1
- package/package.json +4 -4
- package/rsc/dist/valbuild-next-rsc.cjs.dev.js +1 -1
- package/rsc/dist/valbuild-next-rsc.cjs.prod.js +1 -1
- package/rsc/dist/valbuild-next-rsc.esm.js +1 -1
- package/server/dist/valbuild-next-server.cjs.dev.js +5 -1
- package/server/dist/valbuild-next-server.cjs.prod.js +5 -1
- package/server/dist/valbuild-next-server.esm.js +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @valbuild/next
|
|
2
2
|
|
|
3
|
+
## 0.135.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#707](https://github.com/valbuild/val/pull/707) [`c9affec`](https://github.com/valbuild/val/commit/c9affece6ae6ba62bd6c1113ed1fdab6317fa112) Thanks [@freekh](https://github.com/freekh)! - `val validate --fix` now formats with your prettier config instead of prettier's defaults
|
|
8
|
+
|
|
9
|
+
`--fix` formatted the files it repaired by calling `prettier.format(code, { filepath })`, which never reads `.prettierrc`: `filepath` picks the parser and nothing else — only `resolveConfig`, `getFileInfo` and prettier's own CLI consult the config. On a project whose style is not prettier's default, a two-line content fix therefore arrived as a whole-file rewrite, and in a repo with a format check in CI it turned a content fix into a red build.
|
|
10
|
+
|
|
11
|
+
There is now one implementation of "format a written file the way this project does", `createPrettierFormatter`, exported from `@valbuild/server` and re-exported by `@valbuild/next/server` and `@valbuild/tanstack/server`. It resolves `.prettierrc` for each file (including any `overrides` that match it), leaves anything in `.prettierignore` untouched, and falls back to prettier's defaults when the project has no config. `val validate --fix` uses it, so the CLI and the Studio can no longer disagree about formatting.
|
|
12
|
+
|
|
13
|
+
Use it for your app's `formatter` too — this is the recommended setup, and it replaces reading `.prettierrc.json` by hand:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import prettier from "prettier";
|
|
17
|
+
import {
|
|
18
|
+
initValServer,
|
|
19
|
+
createPrettierFormatter,
|
|
20
|
+
} from "@valbuild/next/server";
|
|
21
|
+
|
|
22
|
+
const { valNextAppRouter } = initValServer(
|
|
23
|
+
valModules,
|
|
24
|
+
{ ...config },
|
|
25
|
+
{
|
|
26
|
+
draftMode,
|
|
27
|
+
formatter: createPrettierFormatter(prettier, {
|
|
28
|
+
projectRoot: process.cwd(),
|
|
29
|
+
}),
|
|
30
|
+
},
|
|
31
|
+
);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Existing `formatter` callbacks keep working unchanged.
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [[`c9affec`](https://github.com/valbuild/val/commit/c9affece6ae6ba62bd6c1113ed1fdab6317fa112), [`72a7ca7`](https://github.com/valbuild/val/commit/72a7ca78354fff00e37a51359b17fba9334dc5e6)]:
|
|
37
|
+
- @valbuild/server@0.135.0
|
|
38
|
+
- @valbuild/language-server@0.135.0
|
|
39
|
+
- @valbuild/mcp@0.135.0
|
|
40
|
+
|
|
3
41
|
## 0.134.1
|
|
4
42
|
|
|
5
43
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -298,36 +298,30 @@ If you are using `prettier` or another code formatting tool, it is recommended t
|
|
|
298
298
|
- Add a formatter to the `/val/val.server`:
|
|
299
299
|
|
|
300
300
|
```ts
|
|
301
|
-
formatter: (
|
|
302
|
-
return prettier.format(code, {
|
|
303
|
-
filepath: filePath,
|
|
304
|
-
...prettierOptions, // <- use the same rules as in development
|
|
305
|
-
} as prettier.Options);
|
|
306
|
-
},
|
|
301
|
+
formatter: createPrettierFormatter(prettier, { projectRoot: process.cwd() }),
|
|
307
302
|
```
|
|
308
303
|
|
|
309
304
|
Unless you have any modifications in your `val.server` file, the complete file should now look like this:
|
|
310
305
|
|
|
311
306
|
```ts
|
|
312
307
|
import "server-only";
|
|
313
|
-
import {
|
|
308
|
+
import {
|
|
309
|
+
initValServer,
|
|
310
|
+
createPrettierFormatter,
|
|
311
|
+
} from "@valbuild/next/server";
|
|
314
312
|
import { config } from "../val.config";
|
|
315
313
|
import { draftMode } from "next/headers";
|
|
316
314
|
import valModules from "../val.modules";
|
|
317
315
|
import prettier from "prettier";
|
|
318
|
-
import prettierOptions from "../.prettierrc.json";
|
|
319
316
|
|
|
320
317
|
const { valNextAppRouter } = initValServer(
|
|
321
318
|
valModules,
|
|
322
319
|
{ ...config },
|
|
323
320
|
{
|
|
324
321
|
draftMode,
|
|
325
|
-
formatter: (
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
...prettierOptions, // <- use the same rules as in development
|
|
329
|
-
} as prettier.Options);
|
|
330
|
-
},
|
|
322
|
+
formatter: createPrettierFormatter(prettier, {
|
|
323
|
+
projectRoot: process.cwd(),
|
|
324
|
+
}),
|
|
331
325
|
},
|
|
332
326
|
);
|
|
333
327
|
|
|
@@ -336,6 +330,16 @@ If you are using `prettier` or another code formatting tool, it is recommended t
|
|
|
336
330
|
|
|
337
331
|
You should now be able to hit the save button locally and see prettier rules being applied.
|
|
338
332
|
|
|
333
|
+
### Why not just `prettier.format`?
|
|
334
|
+
|
|
335
|
+
Because it does not read your config. `prettier.format(code, { filepath })` — the obvious thing to write — uses `filepath` only to pick the **parser**; `.prettierrc` is read by `resolveConfig`, `getFileInfo` and prettier's own CLI, and by nothing else. A project whose style is not prettier's default therefore gets every file Val touches rewritten in prettier's defaults, which turns a two-line content edit into a whole-file diff and a red `format` job in CI.
|
|
336
|
+
|
|
337
|
+
`createPrettierFormatter` resolves `.prettierrc` for each file (including any `overrides` that match it), skips anything listed in `.prettierignore`, and falls back to prettier's defaults when the project has no config. `val validate --fix` uses the same function, so a fix applied from the CLI and an edit saved from the Studio come out identically formatted.
|
|
338
|
+
|
|
339
|
+
`projectRoot` is what a module path is resolved against, and where `.prettierignore` is looked for. Prettier's config search walks up from the resolved file, so a package inside a monorepo that has its own `.prettierrc` is found without being named here.
|
|
340
|
+
|
|
341
|
+
Pass it to `initValMcp` the same way if you mount the MCP endpoint — an agent's edits are written to the same files.
|
|
342
|
+
|
|
339
343
|
## Other formatters
|
|
340
344
|
|
|
341
345
|
Val is formatter agnostic, so it is possible to use the same flow as the one described for `prettier` above to any formatter you might want to use.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "server-only";
|
|
2
2
|
export { initValServer } from "./initValServer.js";
|
|
3
3
|
export { initValMcp } from "./initValMcp.js";
|
|
4
|
+
export { createPrettierFormatter, type PrettierLike, type ValFormatter, } from "@valbuild/server";
|
|
4
5
|
export type { ValMcp, ValMcpAuthorizationResult, ValMcpMetadataHandlers, ValOAuthConfig, ValToolImpl, } from "@valbuild/mcp";
|
|
@@ -12,7 +12,7 @@ var NextImage = require('next/image');
|
|
|
12
12
|
var jsxRuntime = require('react/jsx-runtime');
|
|
13
13
|
var ValApp = require('./ValApp-294e5b53.cjs.dev.js');
|
|
14
14
|
var ValModulesClient = require('./ValModulesClient-4ecabf99.cjs.dev.js');
|
|
15
|
-
var version = require('./version-
|
|
15
|
+
var version = require('./version-77226c0a.cjs.dev.js');
|
|
16
16
|
var createForOfIteratorHelper = require('./createForOfIteratorHelper-0445603c.cjs.dev.js');
|
|
17
17
|
require('./defineProperty-f90345d7.cjs.dev.js');
|
|
18
18
|
require('./unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
|
|
@@ -12,7 +12,7 @@ var NextImage = require('next/image');
|
|
|
12
12
|
var jsxRuntime = require('react/jsx-runtime');
|
|
13
13
|
var ValApp = require('./ValApp-ab8a96fd.cjs.prod.js');
|
|
14
14
|
var ValModulesClient = require('./ValModulesClient-10c0721c.cjs.prod.js');
|
|
15
|
-
var version = require('./version-
|
|
15
|
+
var version = require('./version-58fd6989.cjs.prod.js');
|
|
16
16
|
var createForOfIteratorHelper = require('./createForOfIteratorHelper-d4afcad8.cjs.prod.js');
|
|
17
17
|
require('./defineProperty-8951f469.cjs.prod.js');
|
|
18
18
|
require('./unsupportedIterableToArray-0d2087a2.cjs.prod.js');
|
|
@@ -11,7 +11,7 @@ import NextImage from 'next/image';
|
|
|
11
11
|
import { jsx } from 'react/jsx-runtime';
|
|
12
12
|
export { ValApp } from './ValApp-3a70afe1.esm.js';
|
|
13
13
|
export { ValModulesClient, useRegisterValModules } from './ValModulesClient-0dd601a1.esm.js';
|
|
14
|
-
import { V as VERSION } from './version-
|
|
14
|
+
import { V as VERSION } from './version-12fffb44.esm.js';
|
|
15
15
|
import { _ as _createForOfIteratorHelper } from './createForOfIteratorHelper-5758a730.esm.js';
|
|
16
16
|
import './defineProperty-cca5affa.esm.js';
|
|
17
17
|
import './unsupportedIterableToArray-5baabfdc.esm.js';
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"next",
|
|
13
13
|
"react"
|
|
14
14
|
],
|
|
15
|
-
"version": "0.
|
|
15
|
+
"version": "0.135.0",
|
|
16
16
|
"main": "dist/valbuild-next.cjs.js",
|
|
17
17
|
"module": "dist/valbuild-next.esm.js",
|
|
18
18
|
"exports": {
|
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
"client-only": "^0.0.1",
|
|
49
49
|
"server-only": "^0.0.1",
|
|
50
50
|
"@valbuild/core": "0.134.0",
|
|
51
|
-
"@valbuild/language-server": "0.
|
|
52
|
-
"@valbuild/mcp": "0.
|
|
53
|
-
"@valbuild/server": "0.134.1",
|
|
51
|
+
"@valbuild/language-server": "0.135.0",
|
|
52
|
+
"@valbuild/mcp": "0.135.0",
|
|
54
53
|
"@valbuild/react": "0.134.1",
|
|
54
|
+
"@valbuild/server": "0.135.0",
|
|
55
55
|
"@valbuild/shared": "0.134.1",
|
|
56
56
|
"@valbuild/ui": "0.134.0"
|
|
57
57
|
},
|
|
@@ -11,7 +11,7 @@ var stega = require('@valbuild/react/stega');
|
|
|
11
11
|
var core = require('@valbuild/core');
|
|
12
12
|
var internal = require('@valbuild/shared/internal');
|
|
13
13
|
var server = require('@valbuild/server');
|
|
14
|
-
var version = require('../../dist/version-
|
|
14
|
+
var version = require('../../dist/version-77226c0a.cjs.dev.js');
|
|
15
15
|
require('../../dist/createForOfIteratorHelper-0445603c.cjs.dev.js');
|
|
16
16
|
require('../../dist/unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
|
|
17
17
|
require('../../dist/slicedToArray-44036a76.cjs.dev.js');
|
|
@@ -11,7 +11,7 @@ var stega = require('@valbuild/react/stega');
|
|
|
11
11
|
var core = require('@valbuild/core');
|
|
12
12
|
var internal = require('@valbuild/shared/internal');
|
|
13
13
|
var server = require('@valbuild/server');
|
|
14
|
-
var version = require('../../dist/version-
|
|
14
|
+
var version = require('../../dist/version-58fd6989.cjs.prod.js');
|
|
15
15
|
require('../../dist/createForOfIteratorHelper-d4afcad8.cjs.prod.js');
|
|
16
16
|
require('../../dist/unsupportedIterableToArray-0d2087a2.cjs.prod.js');
|
|
17
17
|
require('../../dist/slicedToArray-ce613de6.cjs.prod.js');
|
|
@@ -7,7 +7,7 @@ import { SET_RSC, stegaEncode, SET_AUTO_TAG_JSX_ENABLED } from '@valbuild/react/
|
|
|
7
7
|
import { Internal } from '@valbuild/core';
|
|
8
8
|
import { VAL_SESSION_COOKIE } from '@valbuild/shared/internal';
|
|
9
9
|
import { createValServer } from '@valbuild/server';
|
|
10
|
-
import { V as VERSION } from '../../dist/version-
|
|
10
|
+
import { V as VERSION } from '../../dist/version-12fffb44.esm.js';
|
|
11
11
|
import '../../dist/createForOfIteratorHelper-5758a730.esm.js';
|
|
12
12
|
import '../../dist/unsupportedIterableToArray-5baabfdc.esm.js';
|
|
13
13
|
import '../../dist/slicedToArray-aa291011.esm.js';
|
|
@@ -9,7 +9,7 @@ var objectSpread2 = require('../../dist/objectSpread2-58024783.cjs.dev.js');
|
|
|
9
9
|
var core = require('@valbuild/core');
|
|
10
10
|
var server = require('@valbuild/server');
|
|
11
11
|
var server$1 = require('next/server');
|
|
12
|
-
var version = require('../../dist/version-
|
|
12
|
+
var version = require('../../dist/version-77226c0a.cjs.dev.js');
|
|
13
13
|
var mcp = require('@valbuild/mcp');
|
|
14
14
|
require('../../dist/unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
|
|
15
15
|
require('../../dist/defineProperty-f90345d7.cjs.dev.js');
|
|
@@ -147,5 +147,9 @@ function initValMcp(valModules, config, opts) {
|
|
|
147
147
|
}));
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
+
Object.defineProperty(exports, 'createPrettierFormatter', {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function () { return server.createPrettierFormatter; }
|
|
153
|
+
});
|
|
150
154
|
exports.initValMcp = initValMcp;
|
|
151
155
|
exports.initValServer = initValServer;
|
|
@@ -9,7 +9,7 @@ var objectSpread2 = require('../../dist/objectSpread2-13f847a9.cjs.prod.js');
|
|
|
9
9
|
var core = require('@valbuild/core');
|
|
10
10
|
var server = require('@valbuild/server');
|
|
11
11
|
var server$1 = require('next/server');
|
|
12
|
-
var version = require('../../dist/version-
|
|
12
|
+
var version = require('../../dist/version-58fd6989.cjs.prod.js');
|
|
13
13
|
var mcp = require('@valbuild/mcp');
|
|
14
14
|
require('../../dist/unsupportedIterableToArray-0d2087a2.cjs.prod.js');
|
|
15
15
|
require('../../dist/defineProperty-8951f469.cjs.prod.js');
|
|
@@ -147,5 +147,9 @@ function initValMcp(valModules, config, opts) {
|
|
|
147
147
|
}));
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
+
Object.defineProperty(exports, 'createPrettierFormatter', {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function () { return server.createPrettierFormatter; }
|
|
153
|
+
});
|
|
150
154
|
exports.initValMcp = initValMcp;
|
|
151
155
|
exports.initValServer = initValServer;
|
|
@@ -4,8 +4,9 @@ import { _ as _asyncToGenerator, a as _regenerator } from '../../dist/asyncToGen
|
|
|
4
4
|
import { _ as _objectSpread2 } from '../../dist/objectSpread2-60d1bd93.esm.js';
|
|
5
5
|
import { Internal } from '@valbuild/core';
|
|
6
6
|
import { createValApiRouter, createValServer } from '@valbuild/server';
|
|
7
|
+
export { createPrettierFormatter } from '@valbuild/server';
|
|
7
8
|
import { NextResponse } from 'next/server';
|
|
8
|
-
import { V as VERSION } from '../../dist/version-
|
|
9
|
+
import { V as VERSION } from '../../dist/version-12fffb44.esm.js';
|
|
9
10
|
import { initValMcp as initValMcp$1 } from '@valbuild/mcp';
|
|
10
11
|
import '../../dist/unsupportedIterableToArray-5baabfdc.esm.js';
|
|
11
12
|
import '../../dist/defineProperty-cca5affa.esm.js';
|