@sanity/cli-build 0.2.1 → 1.0.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/dist/_exports/_internal/build.d.ts +1 -2222
- package/dist/actions/build/buildVendorDependencies.js +42 -12
- package/dist/actions/build/buildVendorDependencies.js.map +1 -1
- package/dist/actions/build/createExternalFromImportMap.js +2 -2
- package/dist/actions/build/createExternalFromImportMap.js.map +1 -1
- package/dist/actions/build/getCjsNamedExports.js +39 -0
- package/dist/actions/build/getCjsNamedExports.js.map +1 -0
- package/dist/actions/build/getViteConfig.js +31 -23
- package/dist/actions/build/getViteConfig.js.map +1 -1
- package/dist/actions/build/vite/injectNamedExports.js +96 -0
- package/dist/actions/build/vite/injectNamedExports.js.map +1 -0
- package/dist/actions/build/vite/plugin-sanity-vendor-named-exports.js +53 -0
- package/dist/actions/build/vite/plugin-sanity-vendor-named-exports.js.map +1 -0
- package/package.json +29 -17
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/build/vite/plugin-sanity-vendor-named-exports.ts"],"sourcesContent":["import {type Plugin} from 'vite'\n\nimport {injectNamedExports} from './injectNamedExports.js'\n\n/**\n * Creates a Vite (Rolldown) plugin for the vendor build that ensures each\n * emitted CommonJS-derived entry chunk (`react`, `react-dom`, and friends)\n * exposes real ESM named exports in addition to its `export default`.\n *\n * ## Why\n * Vite 8 bundles with Rolldown, which lowers a CommonJS entry to an ESM chunk\n * that only emits a default export (the wrapped `module.exports`); it does not\n * re-emit the `exports.foo = ...` assignments as named ESM exports. The\n * vendored `.mjs` files are loaded directly by the browser via an import map,\n * so a named import such as `useState` from `react` is a live binding lookup\n * that crashes without them.\n *\n * ## Why this approach\n * Vite 8 no longer ships `@rollup/plugin-commonjs` (its `commonjsOptions` are a\n * no-op), and adding it back deadlocks under Rolldown — it relies on\n * `syntheticNamedExports` and `this.load()` in `transform`, which Rolldown does\n * not support. A generated proxy-entry module was the other option; instead we\n * complete the transform on the real emitted chunk: in `renderChunk` we parse\n * the output with `this.parse` and append the named exports using the native\n * MagicString (`meta.magicString`, enabled via `experimental.nativeMagicString`\n * on the vendor build).\n *\n * @param namesByChunkName - Map of entry chunk name (e.g. `react/index`) to the\n * named exports its CommonJS source declares (see `getCjsNamedExports`).\n * @internal\n */\nexport function createVendorNamedExportsPlugin(\n namesByChunkName: Record<string, readonly string[]>,\n): Plugin {\n return {\n apply: 'build',\n name: 'sanity/vendor-named-exports',\n\n renderChunk(code, chunk, _outputOptions, meta) {\n const names = chunk.isEntry ? namesByChunkName[chunk.name] : undefined\n if (!names || names.length === 0) {\n return null\n }\n\n const {magicString} = meta\n if (!magicString) {\n throw new Error(\n `[vendor-named-exports] Native MagicString unavailable while rendering chunk '${chunk.name}'. ` +\n `Ensure 'experimental.nativeMagicString' is enabled for the vendor build.`,\n )\n }\n\n injectNamedExports({\n chunkName: chunk.name,\n exports: chunk.exports,\n magicString,\n names,\n program: this.parse(code),\n })\n\n return magicString\n },\n }\n}\n"],"names":["injectNamedExports","createVendorNamedExportsPlugin","namesByChunkName","apply","name","renderChunk","code","chunk","_outputOptions","meta","names","isEntry","undefined","length","magicString","Error","chunkName","exports","program","parse"],"mappings":"AAEA,SAAQA,kBAAkB,QAAO,0BAAyB;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BC,GACD,OAAO,SAASC,+BACdC,gBAAmD;IAEnD,OAAO;QACLC,OAAO;QACPC,MAAM;QAENC,aAAYC,IAAI,EAAEC,KAAK,EAAEC,cAAc,EAAEC,IAAI;YAC3C,MAAMC,QAAQH,MAAMI,OAAO,GAAGT,gBAAgB,CAACK,MAAMH,IAAI,CAAC,GAAGQ;YAC7D,IAAI,CAACF,SAASA,MAAMG,MAAM,KAAK,GAAG;gBAChC,OAAO;YACT;YAEA,MAAM,EAACC,WAAW,EAAC,GAAGL;YACtB,IAAI,CAACK,aAAa;gBAChB,MAAM,IAAIC,MACR,CAAC,6EAA6E,EAAER,MAAMH,IAAI,CAAC,GAAG,CAAC,GAC7F,CAAC,wEAAwE,CAAC;YAEhF;YAEAJ,mBAAmB;gBACjBgB,WAAWT,MAAMH,IAAI;gBACrBa,SAASV,MAAMU,OAAO;gBACtBH;gBACAJ;gBACAQ,SAAS,IAAI,CAACC,KAAK,CAACb;YACtB;YAEA,OAAOQ;QACT;IACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/cli-build",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Internal Sanity package for building studios and apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -42,28 +42,30 @@
|
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@oclif/core": "^4.11.
|
|
45
|
+
"@oclif/core": "^4.11.4",
|
|
46
|
+
"@rolldown/plugin-babel": "^0.2.3",
|
|
46
47
|
"@sanity/generate-help-url": "^4.0.0",
|
|
47
|
-
"@sanity/schema": "^5.
|
|
48
|
-
"@sanity/telemetry": "^
|
|
49
|
-
"@sanity/types": "^5.
|
|
50
|
-
"@vitejs/plugin-react": "^
|
|
48
|
+
"@sanity/schema": "^5.30.0",
|
|
49
|
+
"@sanity/telemetry": "^1.1.0",
|
|
50
|
+
"@sanity/types": "^5.30.0",
|
|
51
|
+
"@vitejs/plugin-react": "^6.0.2",
|
|
51
52
|
"chokidar": "^5.0.0",
|
|
53
|
+
"cjs-module-lexer": "^2.2.0",
|
|
52
54
|
"debug": "^4.4.3",
|
|
53
55
|
"lodash-es": "^4.18.1",
|
|
54
56
|
"node-html-parser": "^7.1.0",
|
|
55
57
|
"picomatch": "^4.0.4",
|
|
56
|
-
"react": "^19.2.
|
|
57
|
-
"react-dom": "^19.2.
|
|
58
|
+
"react": "^19.2.6",
|
|
59
|
+
"react-dom": "^19.2.6",
|
|
58
60
|
"read-package-up": "^12.0.0",
|
|
59
61
|
"semver": "^7.7.4",
|
|
60
|
-
"vite": "^
|
|
62
|
+
"vite": "^8.0.16",
|
|
61
63
|
"zod": "^4.3.6",
|
|
62
|
-
"@sanity/cli-core": "^
|
|
64
|
+
"@sanity/cli-core": "^2.0.0"
|
|
63
65
|
},
|
|
64
66
|
"devDependencies": {
|
|
65
67
|
"@eslint/compat": "^2.0.5",
|
|
66
|
-
"@sanity/pkg-utils": "^10.
|
|
68
|
+
"@sanity/pkg-utils": "^10.5.2",
|
|
67
69
|
"@swc/cli": "^0.8.1",
|
|
68
70
|
"@swc/core": "^1.15.33",
|
|
69
71
|
"@types/debug": "^4.1.13",
|
|
@@ -71,22 +73,32 @@
|
|
|
71
73
|
"@types/lodash-es": "^4.17.12",
|
|
72
74
|
"@types/node": "^20.19.41",
|
|
73
75
|
"@types/picomatch": "^4.0.3",
|
|
74
|
-
"@types/react": "^19.2.
|
|
76
|
+
"@types/react": "^19.2.16",
|
|
75
77
|
"@types/react-dom": "^19.2.3",
|
|
76
78
|
"@types/semver": "^7.7.1",
|
|
77
|
-
"@vitest/coverage-istanbul": "^4.1.
|
|
79
|
+
"@vitest/coverage-istanbul": "^4.1.8",
|
|
78
80
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
79
81
|
"eslint": "^10.2.1",
|
|
80
82
|
"jsdom": "^29.1.1",
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
+
"magic-string": "^0.30.21",
|
|
84
|
+
"publint": "^0.3.21",
|
|
85
|
+
"sanity": "^5.30.0",
|
|
86
|
+
"styled-components": "^6.4.0",
|
|
83
87
|
"typescript": "^5.9.3",
|
|
84
|
-
"vitest": "^4.1.
|
|
88
|
+
"vitest": "^4.1.8",
|
|
85
89
|
"@repo/package.config": "0.0.1",
|
|
86
90
|
"@repo/tsconfig": "3.70.0",
|
|
87
|
-
"@sanity/cli-test": "0.
|
|
91
|
+
"@sanity/cli-test": "1.0.0",
|
|
88
92
|
"@sanity/eslint-config-cli": "^1.1.1"
|
|
89
93
|
},
|
|
94
|
+
"peerDependencies": {
|
|
95
|
+
"babel-plugin-react-compiler": "*"
|
|
96
|
+
},
|
|
97
|
+
"peerDependenciesMeta": {
|
|
98
|
+
"babel-plugin-react-compiler": {
|
|
99
|
+
"optional": true
|
|
100
|
+
}
|
|
101
|
+
},
|
|
90
102
|
"engines": {
|
|
91
103
|
"node": ">=20.19.1 <22 || >=22.12"
|
|
92
104
|
},
|