@picked/vite-plugin-picked 0.0.107-next.2 → 0.0.107-next.4
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/README.md +19 -9
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/index.js +26 -7
- package/dist/esm/index.js +283 -232
- package/dist/types/index.d.ts +15 -15
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/virtual-module/snapshot.d.ts +31 -0
- package/dist/types/virtual-module/snapshot.d.ts.map +1 -0
- package/package.json +9 -8
package/dist/types/index.d.ts
CHANGED
|
@@ -24,28 +24,28 @@ export interface PickedPluginOptions {
|
|
|
24
24
|
/** Generate TypeScript types from the workspace schema on dev/build. Defaults to true. */
|
|
25
25
|
generateTypes?: boolean;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* emits a module that registers itself with the SDK. `'api'` skips the prefetch altogether —
|
|
31
|
-
* no build-time dependency on the Picked API and no `.picked/` directory — and emits a module
|
|
32
|
-
* the SDK's shape guard refuses, which leaves every read on the API path.
|
|
27
|
+
* @deprecated Set `data` in `picked.config` instead, which the CLI and the type generator
|
|
28
|
+
* read from too. Still honoured when `picked.config` omits `data`, and a future release
|
|
29
|
+
* drops it. Setting both to different values is an error.
|
|
33
30
|
*/
|
|
34
31
|
mode?: 'bundle' | 'api';
|
|
35
32
|
}
|
|
36
33
|
/**
|
|
37
|
-
* Vite plugin that
|
|
38
|
-
*
|
|
34
|
+
* Vite plugin that exposes Picked project config + per-experience CMS content via the
|
|
35
|
+
* `virtual:picked/data` virtual module.
|
|
39
36
|
*
|
|
40
|
-
*
|
|
41
|
-
* to `<root>/.picked/`, and synthesises a virtual module that statically
|
|
42
|
-
* project config (so it's bundled) and lazily imports each experience's content on
|
|
37
|
+
* Under `data: 'bundle'`, build mode (`vite build`) prefetches every CMS-using experience,
|
|
38
|
+
* writes JSON artefacts to `<root>/.picked/`, and synthesises a virtual module that statically
|
|
39
|
+
* imports the project config (so it's bundled) and lazily imports each experience's content on
|
|
40
|
+
* demand. Dev mode (`vite serve`) writes nothing to disk; the synthesised virtual module inlines
|
|
41
|
+
* the config the plugin fetched and fetches content per call.
|
|
43
42
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
43
|
+
* Under `data: 'snapshot'`, build and dev serve the committed `picked.snapshot.json` and fetch
|
|
44
|
+
* nothing. Under `data: 'api'`, nothing is fetched or embedded.
|
|
46
45
|
*
|
|
47
|
-
* Project identity — `projectId` and `apiUrl` —
|
|
48
|
-
* project root, which the CLI and the type generator read
|
|
46
|
+
* Project identity — `projectId` and `apiUrl` — and the data mode come from
|
|
47
|
+
* `picked.config.{ts,js,json}` at the project root, which the CLI and the type generator read
|
|
48
|
+
* from the same place.
|
|
49
49
|
*
|
|
50
50
|
* @param {PickedPluginOptions} options - Plugin configuration.
|
|
51
51
|
* @returns {Plugin} A Vite plugin instance.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAqB,MAAM,EAAU,MAAM,MAAM,CAAA;AAqb7D,MAAM,WAAW,mBAAmB;IAClC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,qFAAqF;IACrF,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,0FAA0F;IAC1F,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;;;OAIG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAA;CACxB;AA+BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,MAAM,CAAC,OAAO,GAAE,mBAAwB,GAAG,MAAM,CAuUhE"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Synthesis for `virtual:picked/data` when `picked.config` sets `data: 'snapshot'`.
|
|
3
|
+
*
|
|
4
|
+
* The module inlines the snapshot's project config and reaches each experience's content
|
|
5
|
+
* through its own virtual module, so build output keeps content in lazy chunks and nothing is
|
|
6
|
+
* written to disk. The same source serves build and serve.
|
|
7
|
+
*/
|
|
8
|
+
import type { PickedSnapshot } from '@picked/config';
|
|
9
|
+
/** Prefix of the per-experience content modules the snapshot module imports. */
|
|
10
|
+
export declare const SNAPSHOT_EXPERIENCE_MODULE_PREFIX = "virtual:picked/data/experience/";
|
|
11
|
+
/**
|
|
12
|
+
* Synthesises the snapshot-mode `virtual:picked/data` module.
|
|
13
|
+
*
|
|
14
|
+
* @param {PickedSnapshot} snapshot - The snapshot the build serves.
|
|
15
|
+
* @returns {string} JavaScript source for Vite's `load` hook.
|
|
16
|
+
* @example
|
|
17
|
+
* const source = snapshotVirtualModuleSource(snapshot)
|
|
18
|
+
*/
|
|
19
|
+
export declare function snapshotVirtualModuleSource(snapshot: PickedSnapshot): string;
|
|
20
|
+
/**
|
|
21
|
+
* Synthesises the module that exports the content of the experience at a position in
|
|
22
|
+
* `snapshot.experiences`.
|
|
23
|
+
*
|
|
24
|
+
* @param {PickedSnapshot} snapshot - The snapshot the build serves.
|
|
25
|
+
* @param {string} position - The module id's position segment.
|
|
26
|
+
* @returns {string} JavaScript source for Vite's `load` hook; it exports `null` for a position the snapshot does not hold.
|
|
27
|
+
* @example
|
|
28
|
+
* snapshotExperienceModuleSource(snapshot, '0')
|
|
29
|
+
*/
|
|
30
|
+
export declare function snapshotExperienceModuleSource(snapshot: PickedSnapshot, position: string): string;
|
|
31
|
+
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../../src/virtual-module/snapshot.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAGpD,gFAAgF;AAChF,eAAO,MAAM,iCAAiC,oCAAoC,CAAA;AAElF;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAmC5E;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQjG"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picked/vite-plugin-picked",
|
|
3
3
|
"description": "Vite plugin for build-time config injection",
|
|
4
|
-
"version": "0.0.107-next.
|
|
4
|
+
"version": "0.0.107-next.4",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@picked/client": "0.0.107-next.
|
|
7
|
-
"@picked/config": "0.0.107-next.
|
|
8
|
-
"@picked/delivery-api-client": "0.0.107-next.
|
|
9
|
-
"@picked/telemetry": "0.0.107-next.
|
|
10
|
-
"@picked/typegen": "0.0.107-next.
|
|
6
|
+
"@picked/client": "0.0.107-next.4",
|
|
7
|
+
"@picked/config": "0.0.107-next.4",
|
|
8
|
+
"@picked/delivery-api-client": "0.0.107-next.4",
|
|
9
|
+
"@picked/telemetry": "0.0.107-next.4",
|
|
10
|
+
"@picked/typegen": "0.0.107-next.4"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"@repo/eslint-config": "workspace:*",
|
|
@@ -47,14 +47,15 @@
|
|
|
47
47
|
"@picked/client",
|
|
48
48
|
"@picked/delivery-api-client",
|
|
49
49
|
"@picked/typegen",
|
|
50
|
+
"@picked/telemetry",
|
|
50
51
|
"@picked/config",
|
|
51
52
|
"@repo/eslint-config",
|
|
52
53
|
"@repo/typescript-config",
|
|
53
|
-
"@vitest/coverage-v8",
|
|
54
54
|
"@repo/vitest-config"
|
|
55
55
|
],
|
|
56
56
|
"ignore": [
|
|
57
|
-
"eslint.config.js"
|
|
57
|
+
"eslint.config.js",
|
|
58
|
+
"src/__fixtures__/sdk-stub.ts"
|
|
58
59
|
]
|
|
59
60
|
},
|
|
60
61
|
"license": "SEE LICENSE IN LICENSE",
|