@sanity/cli-build 6.4.0 → 6.4.2
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import {
|
|
2
|
+
import { buildFederatedApp } from '@sanity/workbench-cli/build';
|
|
3
|
+
import { build } from 'vite';
|
|
3
4
|
import { copyDir } from '../../util/copyDir.js';
|
|
4
5
|
import { buildDebug } from './buildDebug.js';
|
|
5
6
|
import { getAppEnvironmentVariables, getStudioEnvironmentVariables } from './getEnvironmentVariables.js';
|
|
@@ -86,8 +87,10 @@ import { resolveEntries, writeSanityRuntime } from './writeSanityRuntime.js';
|
|
|
86
87
|
await writeFavicons(faviconBasePath, staticPath);
|
|
87
88
|
}
|
|
88
89
|
buildDebug('Bundling federation environment');
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
await buildFederatedApp(viteConfig, {
|
|
91
|
+
// Custom Vite hooks can resolve different dependencies in the two environments.
|
|
92
|
+
reuseStandaloneBuild: emitSpa && !extendViteConfig
|
|
93
|
+
});
|
|
91
94
|
buildDebug('Bundling complete');
|
|
92
95
|
// TODO: add stats here
|
|
93
96
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/build/buildStaticFiles.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {type CliConfig, type UserViteConfig} from '@sanity/cli-core/types'\nimport {type WorkbenchExposes} from '@sanity/workbench-cli/build'\nimport {build, createBuilder} from 'vite'\n\nimport {copyDir} from '../../util/copyDir.js'\nimport {type AutoUpdatesBuildConfig} from './autoUpdates.js'\nimport {buildDebug} from './buildDebug.js'\nimport {\n getAppEnvironmentVariables,\n getStudioEnvironmentVariables,\n} from './getEnvironmentVariables.js'\nimport {extendViteConfigWithUserConfig, finalizeViteConfig, getViteConfig} from './getViteConfig.js'\nimport {writeFavicons} from './writeFavicons.js'\nimport {resolveEntries, writeSanityRuntime} from './writeSanityRuntime.js'\n\nexport interface ChunkModule {\n name: string\n renderedLength: number\n}\n\nexport interface ChunkStats {\n modules: ChunkModule[]\n name: string\n}\n\ninterface StaticBuildOptions {\n basePath: string\n cwd: string\n outputDir: string\n\n appTitle?: string\n autoUpdates?: AutoUpdatesBuildConfig\n entry?: string\n exposes?: WorkbenchExposes\n isApp?: boolean\n /** Blueprints build (via `@sanity/runtime-cli`) — emit the resource-bindings module. */\n isBlueprints?: boolean\n /** Workbench app (opted in via `defineApplication`) — drives the federation build. */\n isWorkbenchApp?: boolean\n minify?: boolean\n profile?: boolean\n reactCompiler?: CliConfig['reactCompiler']\n schemaExtraction?: CliConfig['schemaExtraction']\n sourceMap?: boolean\n vite?: UserViteConfig\n /** The workbench app's bus identity (`__SANITY_APP_ID__`). */\n workbenchAppId?: string\n}\n\n/**\n * Builds static files\n *\n * @internal\n */\nexport async function buildStaticFiles(\n options: StaticBuildOptions,\n): Promise<{chunks: ChunkStats[]}> {\n const {\n appTitle,\n autoUpdates,\n basePath,\n cwd,\n entry,\n exposes,\n isApp,\n isBlueprints,\n isWorkbenchApp,\n minify = true,\n outputDir,\n reactCompiler,\n schemaExtraction,\n sourceMap = false,\n vite: extendViteConfig,\n workbenchAppId,\n } = options\n\n const mode = 'production'\n\n /* Federation builds only produce the federation environment\n * (remote-entry, mf-manifest) — skip client-specific steps like\n * runtime generation, static file copies, and favicons.\n */\n if (isWorkbenchApp) {\n // Every federated app and studio also serves itself standalone: emit an SPA\n // (index.html + bootstrap + favicons) into the same `dist` as the federation\n // output via a dedicated `client` environment (see plugin-sanity-environment).\n // Skipped for a dock-only app (no `./App` to mount), matching `exposesApp` in\n // plugin.ts.\n const emitSpa = !(isApp && !entry)\n\n let entries: Awaited<ReturnType<typeof resolveEntries>>\n if (emitSpa) {\n buildDebug('Writing Sanity runtime files (standalone SPA)')\n ;({entries} = await writeSanityRuntime({\n appTitle,\n basePath,\n cwd,\n entry,\n isApp,\n isBlueprints,\n isWorkbenchApp,\n reactStrictMode: false,\n watch: false,\n }))\n } else {\n buildDebug('Resolving entries for federation build')\n entries = await resolveEntries({cwd, entry, isApp, isWorkbenchApp})\n }\n\n buildDebug('Resolving vite config (federation)')\n let viteConfig = await getViteConfig({\n basePath,\n cwd,\n entries,\n exposes,\n getEnvironmentVariables,\n isApp,\n isBlueprints,\n isWorkbenchApp,\n minify,\n mode,\n outputDir,\n reactCompiler,\n // Schema extraction is a build-time artifact, not a client-specific step,\n // so a federated studio extracts its schema like the legacy studio build.\n schemaExtraction,\n sourceMap,\n workbenchAppId,\n })\n\n // Apply the user's Vite config so plugins like `@vanilla-extract/vite-plugin`\n // transform source files before the federation environment is bundled.\n // `finalizeViteConfig` is intentionally skipped: the federation environment\n // has its own entry and does not use `.sanity/runtime/app.js`.\n if (extendViteConfig) {\n viteConfig = await extendViteConfigWithUserConfig(\n {command: 'build', mode},\n viteConfig,\n extendViteConfig,\n )\n }\n\n if (emitSpa) {\n const fromPath = path.join(cwd, 'static')\n const staticPath = path.join(outputDir, 'static')\n buildDebug(`Copying static files from ${fromPath} to output dir`)\n await copyDir(fromPath, staticPath)\n buildDebug('Writing favicons to output dir')\n const faviconBasePath = `${basePath.replace(/\\/+$/, '')}/static`\n await writeFavicons(faviconBasePath, staticPath)\n }\n\n buildDebug('Bundling federation environment')\n const builder = await createBuilder(viteConfig)\n await builder.buildApp()\n buildDebug('Bundling complete')\n // TODO: add stats here\n return {chunks: []}\n }\n\n buildDebug('Writing Sanity runtime files')\n const {entries} = await writeSanityRuntime({\n appTitle,\n basePath,\n cwd,\n entry,\n isApp,\n isBlueprints,\n isWorkbenchApp,\n reactStrictMode: false,\n watch: false,\n })\n\n function getEnvironmentVariables() {\n return isApp\n ? getAppEnvironmentVariables({jsonEncode: true, prefix: 'process.env.'})\n : getStudioEnvironmentVariables({jsonEncode: true, prefix: 'process.env.'})\n }\n\n buildDebug('Resolving vite config')\n let viteConfig = await getViteConfig({\n autoUpdates,\n basePath,\n cwd,\n entries,\n getEnvironmentVariables,\n isApp,\n isBlueprints,\n isWorkbenchApp,\n minify,\n mode,\n outputDir,\n reactCompiler,\n schemaExtraction,\n sourceMap,\n })\n\n if (extendViteConfig) {\n const defaultViteConfig = viteConfig\n viteConfig = await extendViteConfigWithUserConfig(\n {command: 'build', mode},\n viteConfig,\n extendViteConfig,\n )\n viteConfig = await finalizeViteConfig(viteConfig, defaultViteConfig)\n }\n\n const fromPath = path.join(cwd, 'static')\n // Copy files placed in /static to the built /static\n buildDebug(`Copying static files from ${fromPath} to output dir`)\n const staticPath = path.join(outputDir, 'static')\n await copyDir(fromPath, staticPath)\n\n // Write favicons, not overwriting ones that already exist, to static folder\n buildDebug('Writing favicons to output dir')\n const faviconBasePath = `${basePath.replace(/\\/+$/, '')}/static`\n await writeFavicons(faviconBasePath, staticPath)\n\n buildDebug('Bundling using vite')\n const bundle = await build(viteConfig)\n buildDebug('Bundling complete')\n\n // For typescript only - this shouldn't ever be the case given we're not watching\n if (Array.isArray(bundle) || !('output' in bundle)) {\n return {chunks: []}\n }\n\n const stats: ChunkStats[] = []\n for (const chunk of bundle.output) {\n if (chunk.type !== 'chunk') {\n continue\n }\n\n stats.push({\n modules: Object.entries(chunk.modules).map(([rawFilePath, chunkModule]) => {\n const filePath = rawFilePath.startsWith('\\u0000')\n ? rawFilePath.slice('\\u0000'.length)\n : rawFilePath\n\n return {\n name: path.isAbsolute(filePath) ? path.relative(cwd, filePath) : filePath,\n renderedLength: chunkModule.renderedLength,\n }\n }),\n name: chunk.name,\n })\n }\n\n return {chunks: stats}\n}\n"],"names":["path","build","createBuilder","copyDir","buildDebug","getAppEnvironmentVariables","getStudioEnvironmentVariables","extendViteConfigWithUserConfig","finalizeViteConfig","getViteConfig","writeFavicons","resolveEntries","writeSanityRuntime","buildStaticFiles","options","appTitle","autoUpdates","basePath","cwd","entry","exposes","isApp","isBlueprints","isWorkbenchApp","minify","outputDir","reactCompiler","schemaExtraction","sourceMap","vite","extendViteConfig","workbenchAppId","mode","emitSpa","entries","reactStrictMode","watch","viteConfig","getEnvironmentVariables","command","fromPath","join","staticPath","faviconBasePath","replace","builder","buildApp","chunks","jsonEncode","prefix","defaultViteConfig","bundle","Array","isArray","stats","chunk","output","type","push","modules","Object","map","rawFilePath","chunkModule","filePath","startsWith","slice","length","name","isAbsolute","relative","renderedLength"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAI5B,SAAQC,KAAK,EAAEC,aAAa,QAAO,OAAM;AAEzC,SAAQC,OAAO,QAAO,wBAAuB;AAE7C,SAAQC,UAAU,QAAO,kBAAiB;AAC1C,SACEC,0BAA0B,EAC1BC,6BAA6B,QACxB,+BAA8B;AACrC,SAAQC,8BAA8B,EAAEC,kBAAkB,EAAEC,aAAa,QAAO,qBAAoB;AACpG,SAAQC,aAAa,QAAO,qBAAoB;AAChD,SAAQC,cAAc,EAAEC,kBAAkB,QAAO,0BAAyB;AAoC1E;;;;CAIC,GACD,OAAO,eAAeC,iBACpBC,OAA2B;IAE3B,MAAM,EACJC,QAAQ,EACRC,WAAW,EACXC,QAAQ,EACRC,GAAG,EACHC,KAAK,EACLC,OAAO,EACPC,KAAK,EACLC,YAAY,EACZC,cAAc,EACdC,SAAS,IAAI,EACbC,SAAS,EACTC,aAAa,EACbC,gBAAgB,EAChBC,YAAY,KAAK,EACjBC,MAAMC,gBAAgB,EACtBC,cAAc,EACf,GAAGjB;IAEJ,MAAMkB,OAAO;IAEb;;;GAGC,GACD,IAAIT,gBAAgB;QAClB,4EAA4E;QAC5E,6EAA6E;QAC7E,+EAA+E;QAC/E,8EAA8E;QAC9E,aAAa;QACb,MAAMU,UAAU,CAAEZ,CAAAA,SAAS,CAACF,KAAI;QAEhC,IAAIe;QACJ,IAAID,SAAS;YACX7B,WAAW;YACT,CAAA,EAAC8B,OAAO,EAAC,GAAG,MAAMtB,mBAAmB;gBACrCG;gBACAE;gBACAC;gBACAC;gBACAE;gBACAC;gBACAC;gBACAY,iBAAiB;gBACjBC,OAAO;YACT,EA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O,gBAAgBR,YAAYQ,cAAc;gBAC5C;YACF;YACAH,MAAMb,MAAMa,IAAI;QAClB;IACF;IAEA,OAAO;QAACrB,QAAQO;IAAK;AACvB"}
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/build/buildStaticFiles.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {type CliConfig, type UserViteConfig} from '@sanity/cli-core/types'\nimport {buildFederatedApp, type WorkbenchExposes} from '@sanity/workbench-cli/build'\nimport {build} from 'vite'\n\nimport {copyDir} from '../../util/copyDir.js'\nimport {type AutoUpdatesBuildConfig} from './autoUpdates.js'\nimport {buildDebug} from './buildDebug.js'\nimport {\n getAppEnvironmentVariables,\n getStudioEnvironmentVariables,\n} from './getEnvironmentVariables.js'\nimport {extendViteConfigWithUserConfig, finalizeViteConfig, getViteConfig} from './getViteConfig.js'\nimport {writeFavicons} from './writeFavicons.js'\nimport {resolveEntries, writeSanityRuntime} from './writeSanityRuntime.js'\n\nexport interface ChunkModule {\n name: string\n renderedLength: number\n}\n\nexport interface ChunkStats {\n modules: ChunkModule[]\n name: string\n}\n\ninterface StaticBuildOptions {\n basePath: string\n cwd: string\n outputDir: string\n\n appTitle?: string\n autoUpdates?: AutoUpdatesBuildConfig\n entry?: string\n exposes?: WorkbenchExposes\n isApp?: boolean\n /** Blueprints build (via `@sanity/runtime-cli`) — emit the resource-bindings module. */\n isBlueprints?: boolean\n /** Workbench app (opted in via `defineApplication`) — drives the federation build. */\n isWorkbenchApp?: boolean\n minify?: boolean\n profile?: boolean\n reactCompiler?: CliConfig['reactCompiler']\n schemaExtraction?: CliConfig['schemaExtraction']\n sourceMap?: boolean\n vite?: UserViteConfig\n /** The workbench app's bus identity (`__SANITY_APP_ID__`). */\n workbenchAppId?: string\n}\n\n/**\n * Builds static files\n *\n * @internal\n */\nexport async function buildStaticFiles(\n options: StaticBuildOptions,\n): Promise<{chunks: ChunkStats[]}> {\n const {\n appTitle,\n autoUpdates,\n basePath,\n cwd,\n entry,\n exposes,\n isApp,\n isBlueprints,\n isWorkbenchApp,\n minify = true,\n outputDir,\n reactCompiler,\n schemaExtraction,\n sourceMap = false,\n vite: extendViteConfig,\n workbenchAppId,\n } = options\n\n const mode = 'production'\n\n /* Federation builds only produce the federation environment\n * (remote-entry, mf-manifest) — skip client-specific steps like\n * runtime generation, static file copies, and favicons.\n */\n if (isWorkbenchApp) {\n // Every federated app and studio also serves itself standalone: emit an SPA\n // (index.html + bootstrap + favicons) into the same `dist` as the federation\n // output via a dedicated `client` environment (see plugin-sanity-environment).\n // Skipped for a dock-only app (no `./App` to mount), matching `exposesApp` in\n // plugin.ts.\n const emitSpa = !(isApp && !entry)\n\n let entries: Awaited<ReturnType<typeof resolveEntries>>\n if (emitSpa) {\n buildDebug('Writing Sanity runtime files (standalone SPA)')\n ;({entries} = await writeSanityRuntime({\n appTitle,\n basePath,\n cwd,\n entry,\n isApp,\n isBlueprints,\n isWorkbenchApp,\n reactStrictMode: false,\n watch: false,\n }))\n } else {\n buildDebug('Resolving entries for federation build')\n entries = await resolveEntries({cwd, entry, isApp, isWorkbenchApp})\n }\n\n buildDebug('Resolving vite config (federation)')\n let viteConfig = await getViteConfig({\n basePath,\n cwd,\n entries,\n exposes,\n getEnvironmentVariables,\n isApp,\n isBlueprints,\n isWorkbenchApp,\n minify,\n mode,\n outputDir,\n reactCompiler,\n // Schema extraction is a build-time artifact, not a client-specific step,\n // so a federated studio extracts its schema like the legacy studio build.\n schemaExtraction,\n sourceMap,\n workbenchAppId,\n })\n\n // Apply the user's Vite config so plugins like `@vanilla-extract/vite-plugin`\n // transform source files before the federation environment is bundled.\n // `finalizeViteConfig` is intentionally skipped: the federation environment\n // has its own entry and does not use `.sanity/runtime/app.js`.\n if (extendViteConfig) {\n viteConfig = await extendViteConfigWithUserConfig(\n {command: 'build', mode},\n viteConfig,\n extendViteConfig,\n )\n }\n\n if (emitSpa) {\n const fromPath = path.join(cwd, 'static')\n const staticPath = path.join(outputDir, 'static')\n buildDebug(`Copying static files from ${fromPath} to output dir`)\n await copyDir(fromPath, staticPath)\n buildDebug('Writing favicons to output dir')\n const faviconBasePath = `${basePath.replace(/\\/+$/, '')}/static`\n await writeFavicons(faviconBasePath, staticPath)\n }\n\n buildDebug('Bundling federation environment')\n await buildFederatedApp(viteConfig, {\n // Custom Vite hooks can resolve different dependencies in the two environments.\n reuseStandaloneBuild: emitSpa && !extendViteConfig,\n })\n buildDebug('Bundling complete')\n // TODO: add stats here\n return {chunks: []}\n }\n\n buildDebug('Writing Sanity runtime files')\n const {entries} = await writeSanityRuntime({\n appTitle,\n basePath,\n cwd,\n entry,\n isApp,\n isBlueprints,\n isWorkbenchApp,\n reactStrictMode: false,\n watch: false,\n })\n\n function getEnvironmentVariables() {\n return isApp\n ? getAppEnvironmentVariables({jsonEncode: true, prefix: 'process.env.'})\n : getStudioEnvironmentVariables({jsonEncode: true, prefix: 'process.env.'})\n }\n\n buildDebug('Resolving vite config')\n let viteConfig = await getViteConfig({\n autoUpdates,\n basePath,\n cwd,\n entries,\n getEnvironmentVariables,\n isApp,\n isBlueprints,\n isWorkbenchApp,\n minify,\n mode,\n outputDir,\n reactCompiler,\n schemaExtraction,\n sourceMap,\n })\n\n if (extendViteConfig) {\n const defaultViteConfig = viteConfig\n viteConfig = await extendViteConfigWithUserConfig(\n {command: 'build', mode},\n viteConfig,\n extendViteConfig,\n )\n viteConfig = await finalizeViteConfig(viteConfig, defaultViteConfig)\n }\n\n const fromPath = path.join(cwd, 'static')\n // Copy files placed in /static to the built /static\n buildDebug(`Copying static files from ${fromPath} to output dir`)\n const staticPath = path.join(outputDir, 'static')\n await copyDir(fromPath, staticPath)\n\n // Write favicons, not overwriting ones that already exist, to static folder\n buildDebug('Writing favicons to output dir')\n const faviconBasePath = `${basePath.replace(/\\/+$/, '')}/static`\n await writeFavicons(faviconBasePath, staticPath)\n\n buildDebug('Bundling using vite')\n const bundle = await build(viteConfig)\n buildDebug('Bundling complete')\n\n // For typescript only - this shouldn't ever be the case given we're not watching\n if (Array.isArray(bundle) || !('output' in bundle)) {\n return {chunks: []}\n }\n\n const stats: ChunkStats[] = []\n for (const chunk of bundle.output) {\n if (chunk.type !== 'chunk') {\n continue\n }\n\n stats.push({\n modules: Object.entries(chunk.modules).map(([rawFilePath, chunkModule]) => {\n const filePath = rawFilePath.startsWith('\\u0000')\n ? rawFilePath.slice('\\u0000'.length)\n : rawFilePath\n\n return {\n name: path.isAbsolute(filePath) ? path.relative(cwd, filePath) : filePath,\n renderedLength: chunkModule.renderedLength,\n }\n }),\n name: chunk.name,\n })\n }\n\n return {chunks: stats}\n}\n"],"names":["path","buildFederatedApp","build","copyDir","buildDebug","getAppEnvironmentVariables","getStudioEnvironmentVariables","extendViteConfigWithUserConfig","finalizeViteConfig","getViteConfig","writeFavicons","resolveEntries","writeSanityRuntime","buildStaticFiles","options","appTitle","autoUpdates","basePath","cwd","entry","exposes","isApp","isBlueprints","isWorkbenchApp","minify","outputDir","reactCompiler","schemaExtraction","sourceMap","vite","extendViteConfig","workbenchAppId","mode","emitSpa","entries","reactStrictMode","watch","viteConfig","getEnvironmentVariables","command","fromPath","join","staticPath","faviconBasePath","replace","reuseStandaloneBuild","chunks","jsonEncode","prefix","defaultViteConfig","bundle","Array","isArray","stats","chunk","output","type","push","modules","Object","map","rawFilePath","chunkModule","filePath","startsWith","slice","length","name","isAbsolute","relative","renderedLength"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAG5B,SAAQC,iBAAiB,QAA8B,8BAA6B;AACpF,SAAQC,KAAK,QAAO,OAAM;AAE1B,SAAQC,OAAO,QAAO,wBAAuB;AAE7C,SAAQC,UAAU,QAAO,kBAAiB;AAC1C,SACEC,0BAA0B,EAC1BC,6BAA6B,QACxB,+BAA8B;AACrC,SAAQC,8BAA8B,EAAEC,kBAAkB,EAAEC,aAAa,QAAO,qBAAoB;AACpG,SAAQC,aAAa,QAAO,qBAAoB;AAChD,SAAQC,cAAc,EAAEC,kBAAkB,QAAO,0BAAyB;AAoC1E;;;;CAI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I,OAAO,CAAC;IAChE,MAAMlC,cAAciC,iBAAiBD;IAErCtC,WAAW;IACX,MAAM8C,SAAS,MAAMhD,MAAMmC;IAC3BjC,WAAW;IAEX,iFAAiF;IACjF,IAAI+C,MAAMC,OAAO,CAACF,WAAW,CAAE,CAAA,YAAYA,MAAK,GAAI;QAClD,OAAO;YAACJ,QAAQ,EAAE;QAAA;IACpB;IAEA,MAAMO,QAAsB,EAAE;IAC9B,KAAK,MAAMC,SAASJ,OAAOK,MAAM,CAAE;QACjC,IAAID,MAAME,IAAI,KAAK,SAAS;YAC1B;QACF;QAEAH,MAAMI,IAAI,CAAC;YACTC,SAASC,OAAOzB,OAAO,CAACoB,MAAMI,OAAO,EAAEE,GAAG,CAAC,CAAC,CAACC,aAAaC,YAAY;gBACpE,MAAMC,WAAWF,YAAYG,UAAU,CAAC,YACpCH,YAAYI,KAAK,CAAC,SAASC,MAAM,IACjCL;gBAEJ,OAAO;oBACLM,MAAMnE,KAAKoE,UAAU,CAACL,YAAY/D,KAAKqE,QAAQ,CAACnD,KAAK6C,YAAYA;oBACjEO,gBAAgBR,YAAYQ,cAAc;gBAC5C;YACF;YACAH,MAAMb,MAAMa,IAAI;QAClB;IACF;IAEA,OAAO;QAACrB,QAAQO;IAAK;AACvB"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { RESOURCE_BINDINGS_ENTRY_IMPORT } from '@sanity/workbench-cli/build';
|
|
2
|
+
// The user module (`sanity.config.*`, or the app's `App`) is the first import
|
|
3
|
+
// after resource bindings. ESM evaluates static imports in source order, and
|
|
4
|
+
// `react-dom` reads `__REACT_DEVTOOLS_GLOBAL_HOOK__` once at module init, so a
|
|
5
|
+
// side-effect import at the top of the user module (for example
|
|
6
|
+
// `react-devtools-cdt-mcp/register`) only runs before react-dom if the user
|
|
7
|
+
// module is requested before `sanity` / `react-dom/client`.
|
|
2
8
|
const entryModule = `
|
|
3
9
|
// This file is auto-generated on 'sanity dev'
|
|
4
10
|
// Modifications to this file is automatically discarded
|
|
5
|
-
%RESOURCE_BINDINGS_IMPORT%import
|
|
6
|
-
import
|
|
11
|
+
%RESOURCE_BINDINGS_IMPORT%import studioConfig from %STUDIO_CONFIG_LOCATION%
|
|
12
|
+
import {renderStudio} from "sanity"
|
|
7
13
|
|
|
8
14
|
renderStudio(
|
|
9
15
|
document.getElementById("sanity"),
|
|
@@ -27,9 +33,9 @@ renderStudio(
|
|
|
27
33
|
const appEntryModule = `
|
|
28
34
|
// This file is auto-generated on 'sanity dev'
|
|
29
35
|
// Modifications to this file is automatically discarded
|
|
30
|
-
%RESOURCE_BINDINGS_IMPORT%import
|
|
36
|
+
%RESOURCE_BINDINGS_IMPORT%import App from %ENTRY%
|
|
37
|
+
import {createRoot} from 'react-dom/client'
|
|
31
38
|
import {createElement} from 'react'
|
|
32
|
-
import App from %ENTRY%
|
|
33
39
|
|
|
34
40
|
const root = createRoot(document.getElementById('root'))
|
|
35
41
|
const element = createElement(App)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/build/getEntryModule.ts"],"sourcesContent":["import {RESOURCE_BINDINGS_ENTRY_IMPORT} from '@sanity/workbench-cli/build'\n\nconst entryModule = `\n// This file is auto-generated on 'sanity dev'\n// Modifications to this file is automatically discarded\n%RESOURCE_BINDINGS_IMPORT%import {renderStudio} from \"sanity\"\
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/build/getEntryModule.ts"],"sourcesContent":["import {RESOURCE_BINDINGS_ENTRY_IMPORT} from '@sanity/workbench-cli/build'\n\n// The user module (`sanity.config.*`, or the app's `App`) is the first import\n// after resource bindings. ESM evaluates static imports in source order, and\n// `react-dom` reads `__REACT_DEVTOOLS_GLOBAL_HOOK__` once at module init, so a\n// side-effect import at the top of the user module (for example\n// `react-devtools-cdt-mcp/register`) only runs before react-dom if the user\n// module is requested before `sanity` / `react-dom/client`.\nconst entryModule = `\n// This file is auto-generated on 'sanity dev'\n// Modifications to this file is automatically discarded\n%RESOURCE_BINDINGS_IMPORT%import studioConfig from %STUDIO_CONFIG_LOCATION%\nimport {renderStudio} from \"sanity\"\n\nrenderStudio(\n document.getElementById(\"sanity\"),\n studioConfig,\n {reactStrictMode: %STUDIO_REACT_STRICT_MODE%, basePath: %STUDIO_BASE_PATH%}\n)\n`\n\nconst noConfigEntryModule = `\n// This file is auto-generated on 'sanity dev'\n// Modifications to this file is automatically discarded\n%RESOURCE_BINDINGS_IMPORT%import {renderStudio} from \"sanity\"\n\nconst studioConfig = {missingConfigFile: true}\n\nrenderStudio(\n document.getElementById(\"sanity\"),\n studioConfig,\n {reactStrictMode: %STUDIO_REACT_STRICT_MODE%, basePath: %STUDIO_BASE_PATH%}\n)\n`\n\nconst appEntryModule = `\n// This file is auto-generated on 'sanity dev'\n// Modifications to this file is automatically discarded\n%RESOURCE_BINDINGS_IMPORT%import App from %ENTRY%\nimport {createRoot} from 'react-dom/client'\nimport {createElement} from 'react'\n\nconst root = createRoot(document.getElementById('root'))\nconst element = createElement(App)\nroot.render(element)\n`\n\n// A branded app with no \\`entry\\` (sanity-io/workbench spec 002-workbench-extension-api, US5) has no navigable app view, so there's no\n// \\`App\\` to import or render standalone — it contributes panels/services to the\n// workbench instead. The page stays valid (no broken import) for the dev server.\nconst noAppViewEntryModule = `\n// This file is auto-generated on 'sanity dev'\n// Modifications to this file is automatically discarded\n%RESOURCE_BINDINGS_IMPORT%const root = document.getElementById('root')\nif (root) {\n root.textContent = 'This application has no app view.'\n}\n`\n\nexport function getEntryModule(options: {\n basePath?: string\n entry?: string\n isApp?: boolean\n isBlueprints?: boolean\n reactStrictMode: boolean | undefined\n relativeConfigLocation: string | null\n}): string {\n const {basePath, entry, isApp, isBlueprints, reactStrictMode, relativeConfigLocation} = options\n\n // Under Blueprints the entry statically imports the resource-bindings module\n // first (writeSanityRuntime emits it); otherwise the placeholder resolves to\n // nothing so the import — and the module — are absent.\n const withBindings = (module: string): string =>\n module.replace(\n /%RESOURCE_BINDINGS_IMPORT%/,\n isBlueprints ? `${RESOURCE_BINDINGS_ENTRY_IMPORT}\\n` : '',\n )\n\n if (isApp) {\n return withBindings(\n entry ? appEntryModule.replace(/%ENTRY%/, JSON.stringify(entry)) : noAppViewEntryModule,\n )\n }\n\n const sourceModule = relativeConfigLocation ? entryModule : noConfigEntryModule\n\n return withBindings(\n sourceModule\n .replace(\n /%STUDIO_REACT_STRICT_MODE%/,\n reactStrictMode === undefined ? 'undefined' : JSON.stringify(reactStrictMode),\n )\n .replace(/%STUDIO_CONFIG_LOCATION%/, JSON.stringify(relativeConfigLocation))\n .replace(/%STUDIO_BASE_PATH%/, JSON.stringify(basePath || '/')),\n )\n}\n"],"names":["RESOURCE_BINDINGS_ENTRY_IMPORT","entryModule","noConfigEntryModule","appEntryModule","noAppViewEntryModule","getEntryModule","options","basePath","entry","isApp","isBlueprints","reactStrictMode","relativeConfigLocation","withBindings","module","replace","JSON","stringify","sourceModule","undefined"],"mappings":"AAAA,SAAQA,8BAA8B,QAAO,8BAA6B;AAE1E,8EAA8E;AAC9E,6EAA6E;AAC7E,+EAA+E;AAC/E,gEAAgE;AAChE,4EAA4E;AAC5E,4DAA4D;AAC5D,MAAMC,cAAc,CAAC;;;;;;;;;;;AAWrB,CAAC;AAED,MAAMC,sBAAsB,CAAC;;;;;;;;;;;;AAY7B,CAAC;AAED,MAAMC,iBAAiB,CAAC;;;;;;;;;;AAUxB,CAAC;AAED,uIAAuI;AACvI,iFAAiF;AACjF,iFAAiF;AACjF,MAAMC,uBAAuB,CAAC;;;;;;;AAO9B,CAAC;AAED,OAAO,SAASC,eAAeC,OAO9B;IACC,MAAM,EAACC,QAAQ,EAAEC,KAAK,EAAEC,KAAK,EAAEC,YAAY,EAAEC,eAAe,EAAEC,sBAAsB,EAAC,GAAGN;IAExF,6EAA6E;IAC7E,6EAA6E;IAC7E,uDAAuD;IACvD,MAAMO,eAAe,CAACC,SACpBA,OAAOC,OAAO,CACZ,8BACAL,eAAe,GAAGV,+BAA+B,EAAE,CAAC,GAAG;IAG3D,IAAIS,OAAO;QACT,OAAOI,aACLL,QAAQL,eAAeY,OAAO,CAAC,WAAWC,KAAKC,SAAS,CAACT,UAAUJ;IAEvE;IAEA,MAAMc,eAAeN,yBAAyBX,cAAcC;IAE5D,OAAOW,aACLK,aACGH,OAAO,CACN,8BACAJ,oBAAoBQ,YAAY,cAAcH,KAAKC,SAAS,CAACN,kBAE9DI,OAAO,CAAC,4BAA4BC,KAAKC,SAAS,CAACL,yBACnDG,OAAO,CAAC,sBAAsBC,KAAKC,SAAS,CAACV,YAAY;AAEhE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/cli-build",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.2",
|
|
4
4
|
"description": "Internal Sanity package for building studios and apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@oclif/core": "^4.11.14",
|
|
54
54
|
"@rolldown/plugin-babel": "^0.2.3",
|
|
55
|
-
"@sanity/cli-core": "^3.8.
|
|
55
|
+
"@sanity/cli-core": "^3.8.1",
|
|
56
56
|
"@sanity/generate-help-url": "^4.0.0",
|
|
57
57
|
"@sanity/schema": "^6.15.0",
|
|
58
58
|
"@sanity/telemetry": "^1.1.0",
|
|
59
59
|
"@sanity/types": "^6.15.0",
|
|
60
|
-
"@sanity/workbench-cli": "^2.
|
|
60
|
+
"@sanity/workbench-cli": "^2.8.0",
|
|
61
61
|
"@vitejs/plugin-react": "^6.1.1",
|
|
62
62
|
"chokidar": "^5.0.0",
|
|
63
63
|
"cjs-module-lexer": "^2.2.1",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"@eslint/compat": "^2.1.0",
|
|
80
80
|
"@repo/package.config": "0.0.1",
|
|
81
81
|
"@repo/tsconfig": "3.70.0",
|
|
82
|
-
"@sanity/cli-test": "18.0.
|
|
82
|
+
"@sanity/cli-test": "18.0.1",
|
|
83
83
|
"@sanity/eslint-config-cli": "^1.1.3",
|
|
84
84
|
"@sanity/pkg-utils": "^12.3.4",
|
|
85
85
|
"@sanity/ui": "^4.2.1",
|