@sanity/cli-core 3.11.0 → 3.12.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.
@@ -14,7 +14,7 @@ import { i as isNotFoundError, n as isProjectRootNotFoundError, r as NotFoundErr
14
14
  import { exitCodes } from "../exitCodes.js";
15
15
  import { n as createStudioWorker, r as studioWorkerTask, t as tsxWorkerTask } from "../tsxWorkerTask-DQQSOYCZ.js";
16
16
  import { a as getCliTelemetry, i as clearCliTelemetry, n as getTelemetryBaseInfo, o as reportCliTraceError, r as CLI_TELEMETRY_SYMBOL, s as setCliTelemetry, t as noopLogger } from "../noopTelemetry-BJRIvASI.js";
17
- import { a as isCi, i as isInteractive, n as normalizePath, o as importModule, r as isStaging, s as doImport, t as safeStructuredClone } from "../safeStructuredClone-DAFcnqtc.js";
17
+ import { a as isCi, i as isInteractive, n as normalizePath, o as importModule, r as isStaging, s as doImport, t as safeStructuredClone } from "../safeStructuredClone-BixYyg4K.js";
18
18
  import { a as getLocalPackageVersion, i as getLocalPackageDir, n as resolveLocalPackageFrom, r as resolveLocalPackagePath, t as resolveLocalPackage } from "../resolveLocalPackage-Dr-TNTyk.js";
19
19
  import { n as ReadPackageJsonOptions, r as readPackageJson, t as PackageJson } from "../readPackageJson-Cr_lbjVR.js";
20
20
  import { n as colorizeJson, t as getTimer } from "../timer-Dwu2TIgB.js";
@@ -1,5 +1,5 @@
1
1
  import { a as getSanityDataDir, i as getSanityConfigDir, n as getSanityUrl, r as getSanityEnvVar, t as getWorkspace } from "../getWorkspace-CU32E6Uo.js";
2
- import { a as isCi, i as isInteractive$1, n as normalizePath, o as importModule, r as isStaging, s as doImport, t as safeStructuredClone } from "../safeStructuredClone-DAFcnqtc.js";
2
+ import { a as isCi, i as isInteractive$1, n as normalizePath, o as importModule, r as isStaging, s as doImport, t as safeStructuredClone } from "../safeStructuredClone-BixYyg4K.js";
3
3
  declare function getCoreAppUrl(organizationId: string, appId: string): string;
4
4
  /**
5
5
  * Checks if the given value is a record (javascript objectish)
@@ -1,7 +1,5 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  const DEPENDENCY_SCRIPT_RE = /[\\/]node_modules[\\/].+\.[cm]?js$/;
3
- // Mirrors the `//# sourceMappingURL=` form Vite itself strips (via `convert-source-map`)
4
- const SOURCEMAP_COMMENT_RE = /^[ \t]*\/\/[#@][ \t]+sourceMappingURL=[^\s'"`]+[ \t]*$/gm;
5
3
  /**
6
4
  * Loads plain JavaScript files from `node_modules` without their source maps.
7
5
  *
@@ -12,11 +10,11 @@ const SOURCEMAP_COMMENT_RE = /^[ \t]*\/\/[#@][ \t]+sourceMappingURL=[^\s'"`]+[ \
12
10
  * For a studio that imports `sanity` this means thousands of modules and tens of
13
11
  * megabytes of source maps, which roughly doubles the worker's peak memory.
14
12
  *
15
- * Returning `map: {mappings: ''}` from `load` tells Vite there is no source map
16
- * to preserve, so none of that work happens for dependencies. User code (the
17
- * studio config, schema files, plugins outside `node_modules`) keeps full source
18
- * maps. Stack frames inside dependencies still name the file, through a
19
- * `sourceURL` comment, but their line numbers refer to the transformed code.
13
+ * Returning `map: {mappings: ''}` from `load` skips Vite's source map handling.
14
+ * Keep the source intact: sourceMappingURL text can also appear inside strings.
15
+ * User code (the studio config, schema files, plugins outside `node_modules`)
16
+ * keeps full source maps. A `sourceURL` comment keeps dependency file names in
17
+ * stack traces.
20
18
  *
21
19
  * @internal
22
20
  */ export function skipDependencySourcemapsPlugin() {
@@ -35,7 +33,7 @@ const SOURCEMAP_COMMENT_RE = /^[ \t]*\/\/[#@][ \t]+sourceMappingURL=[^\s'"`]+[ \
35
33
  return null;
36
34
  }
37
35
  return {
38
- code: `${code.replaceAll(SOURCEMAP_COMMENT_RE, '')}\n//# sourceURL=${id.replaceAll(/\s/g, encodeURIComponent)}\n`,
36
+ code: `${code}\n//# sourceURL=${id.replaceAll(/\s/g, encodeURIComponent)}\n`,
39
37
  map: {
40
38
  mappings: ''
41
39
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/loaders/studio/skipDependencySourcemapsPlugin.ts"],"sourcesContent":["import {readFile} from 'node:fs/promises'\n\nimport {type Plugin} from 'vite'\n\nconst DEPENDENCY_SCRIPT_RE = /[\\\\/]node_modules[\\\\/].+\\.[cm]?js$/\n// Mirrors the `//# sourceMappingURL=` form Vite itself strips (via `convert-source-map`)\nconst SOURCEMAP_COMMENT_RE = /^[ \\t]*\\/\\/[#@][ \\t]+sourceMappingURL=[^\\s'\"`]+[ \\t]*$/gm\n\n/**\n * Loads plain JavaScript files from `node_modules` without their source maps.\n *\n * The studio worker runs every dependency through Vite's SSR transform\n * (`ssr.noExternal: true`). By default Vite reads each dependency's `.js.map`,\n * combines it with the SSR transform's own map, inlines the result as a base64\n * comment and the module runner then has Node parse it again for stack traces.\n * For a studio that imports `sanity` this means thousands of modules and tens of\n * megabytes of source maps, which roughly doubles the worker's peak memory.\n *\n * Returning `map: {mappings: ''}` from `load` tells Vite there is no source map\n * to preserve, so none of that work happens for dependencies. User code (the\n * studio config, schema files, plugins outside `node_modules`) keeps full source\n * maps. Stack frames inside dependencies still name the file, through a\n * `sourceURL` comment, but their line numbers refer to the transformed code.\n *\n * @internal\n */\nexport function skipDependencySourcemapsPlugin(): Plugin {\n return {\n // Run after other plugins' `load` hooks so user plugins can still claim these files\n enforce: 'post',\n async load(id) {\n if (id.startsWith('\\0') || id.includes('?') || !DEPENDENCY_SCRIPT_RE.test(id)) {\n return null\n }\n\n let code: string\n try {\n code = await readFile(id, 'utf8')\n } catch {\n // Let Vite's own loader produce its usual error\n return null\n }\n\n return {\n code: `${code.replaceAll(SOURCEMAP_COMMENT_RE, '')}\\n//# sourceURL=${id.replaceAll(/\\s/g, encodeURIComponent)}\\n`,\n map: {mappings: ''},\n }\n },\n name: 'sanity:studio-worker-skip-dependency-sourcemaps',\n }\n}\n"],"names":["readFile","DEPENDENCY_SCRIPT_RE","SOURCEMAP_COMMENT_RE","skipDependencySourcemapsPlugin","enforce","load","id","startsWith","includes","test","code","replaceAll","encodeURIComponent","map","mappings","name"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,mBAAkB;AAIzC,MAAMC,uBAAuB;AAC7B,yFAAyF;AACzF,MAAMC,uBAAuB;AAE7B;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,SAASC;IACd,OAAO;QACL,oFAAoF;QACpFC,SAAS;QACT,MAAMC,MAAKC,EAAE;YACX,IAAIA,GAAGC,UAAU,CAAC,SAASD,GAAGE,QAAQ,CAAC,QAAQ,CAACP,qBAAqBQ,IAAI,CAACH,KAAK;gBAC7E,OAAO;YACT;YAEA,IAAII;YACJ,IAAI;gBACFA,OAAO,MAAMV,SAASM,IAAI;YAC5B,EAAE,OAAM;gBACN,gDAAgD;gBAChD,OAAO;YACT;YAEA,OAAO;gBACLI,MAAM,GAAGA,KAAKC,UAAU,CAACT,sBAAsB,IAAI,gBAAgB,EAAEI,GAAGK,UAAU,CAAC,OAAOC,oBAAoB,EAAE,CAAC;gBACjHC,KAAK;oBAACC,UAAU;gBAAE;YACpB;QACF;QACAC,MAAM;IACR;AACF"}
1
+ {"version":3,"sources":["../../../src/loaders/studio/skipDependencySourcemapsPlugin.ts"],"sourcesContent":["import {readFile} from 'node:fs/promises'\n\nimport {type Plugin} from 'vite'\n\nconst DEPENDENCY_SCRIPT_RE = /[\\\\/]node_modules[\\\\/].+\\.[cm]?js$/\n\n/**\n * Loads plain JavaScript files from `node_modules` without their source maps.\n *\n * The studio worker runs every dependency through Vite's SSR transform\n * (`ssr.noExternal: true`). By default Vite reads each dependency's `.js.map`,\n * combines it with the SSR transform's own map, inlines the result as a base64\n * comment and the module runner then has Node parse it again for stack traces.\n * For a studio that imports `sanity` this means thousands of modules and tens of\n * megabytes of source maps, which roughly doubles the worker's peak memory.\n *\n * Returning `map: {mappings: ''}` from `load` skips Vite's source map handling.\n * Keep the source intact: sourceMappingURL text can also appear inside strings.\n * User code (the studio config, schema files, plugins outside `node_modules`)\n * keeps full source maps. A `sourceURL` comment keeps dependency file names in\n * stack traces.\n *\n * @internal\n */\nexport function skipDependencySourcemapsPlugin(): Plugin {\n return {\n // Run after other plugins' `load` hooks so user plugins can still claim these files\n enforce: 'post',\n async load(id) {\n if (id.startsWith('\\0') || id.includes('?') || !DEPENDENCY_SCRIPT_RE.test(id)) {\n return null\n }\n\n let code: string\n try {\n code = await readFile(id, 'utf8')\n } catch {\n // Let Vite's own loader produce its usual error\n return null\n }\n\n return {\n code: `${code}\\n//# sourceURL=${id.replaceAll(/\\s/g, encodeURIComponent)}\\n`,\n map: {mappings: ''},\n }\n },\n name: 'sanity:studio-worker-skip-dependency-sourcemaps',\n }\n}\n"],"names":["readFile","DEPENDENCY_SCRIPT_RE","skipDependencySourcemapsPlugin","enforce","load","id","startsWith","includes","test","code","replaceAll","encodeURIComponent","map","mappings","name"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,mBAAkB;AAIzC,MAAMC,uBAAuB;AAE7B;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,SAASC;IACd,OAAO;QACL,oFAAoF;QACpFC,SAAS;QACT,MAAMC,MAAKC,EAAE;YACX,IAAIA,GAAGC,UAAU,CAAC,SAASD,GAAGE,QAAQ,CAAC,QAAQ,CAACN,qBAAqBO,IAAI,CAACH,KAAK;gBAC7E,OAAO;YACT;YAEA,IAAII;YACJ,IAAI;gBACFA,OAAO,MAAMT,SAASK,IAAI;YAC5B,EAAE,OAAM;gBACN,gDAAgD;gBAChD,OAAO;YACT;YAEA,OAAO;gBACLI,MAAM,GAAGA,KAAK,gBAAgB,EAAEJ,GAAGK,UAAU,CAAC,OAAOC,oBAAoB,EAAE,CAAC;gBAC5EC,KAAK;oBAACC,UAAU;gBAAE;YACpB;QACF;QACAC,MAAM;IACR;AACF"}
@@ -11,6 +11,12 @@ interface ImportModuleOptions {
11
11
  * Default: true
12
12
  */
13
13
  default?: boolean;
14
+ /**
15
+ * Whether to transform JSX in the imported module (and anything it imports).
16
+ * Required for `.tsx`/`.jsx` modules — without it they fail to parse.
17
+ * Default: false
18
+ */
19
+ jsx?: boolean;
14
20
  /**
15
21
  * Path to the tsconfig file to use for the import. If not provided, the tsconfig
16
22
  * will be inferred from the nearest `tsconfig.json` file.
@@ -54,4 +60,4 @@ declare function normalizePath(path: string): string;
54
60
  */
55
61
  declare function safeStructuredClone<T>(obj: T): T;
56
62
  export { isCi as a, isInteractive as i, normalizePath as n, importModule as o, isStaging as r, doImport as s, safeStructuredClone as t };
57
- //# sourceMappingURL=safeStructuredClone-DAFcnqtc.d.ts.map
63
+ //# sourceMappingURL=safeStructuredClone-BixYyg4K.d.ts.map
@@ -11,9 +11,10 @@ const debug = subdebug('importModule');
11
11
  *
12
12
  * @internal
13
13
  */ export async function importModule(filePath, options = {}) {
14
- const { default: returnDefault = true, tsconfigPath } = options;
14
+ const { default: returnDefault = true, jsx = false, tsconfigPath } = options;
15
15
  const jiti = createJiti(import.meta.url, {
16
16
  debug: debug.enabled,
17
+ jsx,
17
18
  tsconfigPaths: typeof tsconfigPath === 'string' ? tsconfigPath : true
18
19
  });
19
20
  const fileURL = typeof filePath === 'string' ? pathToFileURL(filePath) : filePath;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/util/importModule.ts"],"sourcesContent":["import {fileURLToPath, pathToFileURL} from 'node:url'\n\nimport {createJiti, type JitiResolveOptions} from 'jiti'\n\nimport {subdebug} from '../_exports/debug.js'\n\ninterface ImportModuleOptions {\n /**\n * Whether to return the default export of the module.\n * Default: true\n */\n default?: boolean\n\n /**\n * Path to the tsconfig file to use for the import. If not provided, the tsconfig\n * will be inferred from the nearest `tsconfig.json` file.\n */\n tsconfigPath?: string\n}\n\nconst debug = subdebug('importModule')\n\n/**\n * Imports a module using Jiti and returns its exports.\n *\n * @param filePath - Path to the module to import.\n * @param options - Options for the importModule function.\n * @returns The exported module.\n *\n * @internal\n */\nexport async function importModule<T = unknown>(\n filePath: string | URL,\n options: ImportModuleOptions = {},\n): Promise<T> {\n const {default: returnDefault = true, tsconfigPath} = options\n\n const jiti = createJiti(import.meta.url, {\n debug: debug.enabled,\n tsconfigPaths: typeof tsconfigPath === 'string' ? tsconfigPath : true,\n })\n\n const fileURL = typeof filePath === 'string' ? pathToFileURL(filePath) : filePath\n\n debug(`Loading module: ${fileURLToPath(fileURL)}`, {tsconfigPath})\n\n const jitiOptions: JitiResolveOptions & {default?: true} = {}\n\n // If the default option is true, add it to the jiti options\n if (returnDefault) {\n jitiOptions.default = true\n }\n\n return jiti.import<T>(fileURLToPath(fileURL), jitiOptions)\n}\n"],"names":["fileURLToPath","pathToFileURL","createJiti","subdebug","debug","importModule","filePath","options","default","returnDefault","tsconfigPath","jiti","url","enabled","tsconfigPaths","fileURL","jitiOptions","import"],"mappings":"AAAA,SAAQA,aAAa,EAAEC,aAAa,QAAO,WAAU;AAErD,SAAQC,UAAU,QAAgC,OAAM;AAExD,SAAQC,QAAQ,QAAO,uBAAsB;AAgB7C,MAAMC,QAAQD,SAAS;AAEvB;;;;;;;;CAQC,GACD,OAAO,eAAeE,aACpBC,QAAsB,EACtBC,UAA+B,CAAC,CAAC;IAEjC,MAAM,EAACC,SAASC,gBAAgB,IAAI,EAAEC,YAAY,EAAC,GAAGH;IAEtD,MAAMI,OAAOT,WAAW,YAAYU,GAAG,EAAE;QACvCR,OAAOA,MAAMS,OAAO;QACpBC,eAAe,OAAOJ,iBAAiB,WAAWA,eAAe;IACnE;IAEA,MAAMK,UAAU,OAAOT,aAAa,WAAWL,cAAcK,YAAYA;IAEzEF,MAAM,CAAC,gBAAgB,EAAEJ,cAAce,UAAU,EAAE;QAACL;IAAY;IAEhE,MAAMM,cAAqD,CAAC;IAE5D,4DAA4D;IAC5D,IAAIP,eAAe;QACjBO,YAAYR,OAAO,GAAG;IACxB;IAEA,OAAOG,KAAKM,MAAM,CAAIjB,cAAce,UAAUC;AAChD"}
1
+ {"version":3,"sources":["../../src/util/importModule.ts"],"sourcesContent":["import {fileURLToPath, pathToFileURL} from 'node:url'\n\nimport {createJiti, type JitiResolveOptions} from 'jiti'\n\nimport {subdebug} from '../_exports/debug.js'\n\ninterface ImportModuleOptions {\n /**\n * Whether to return the default export of the module.\n * Default: true\n */\n default?: boolean\n\n /**\n * Whether to transform JSX in the imported module (and anything it imports).\n * Required for `.tsx`/`.jsx` modules — without it they fail to parse.\n * Default: false\n */\n jsx?: boolean\n\n /**\n * Path to the tsconfig file to use for the import. If not provided, the tsconfig\n * will be inferred from the nearest `tsconfig.json` file.\n */\n tsconfigPath?: string\n}\n\nconst debug = subdebug('importModule')\n\n/**\n * Imports a module using Jiti and returns its exports.\n *\n * @param filePath - Path to the module to import.\n * @param options - Options for the importModule function.\n * @returns The exported module.\n *\n * @internal\n */\nexport async function importModule<T = unknown>(\n filePath: string | URL,\n options: ImportModuleOptions = {},\n): Promise<T> {\n const {default: returnDefault = true, jsx = false, tsconfigPath} = options\n\n const jiti = createJiti(import.meta.url, {\n debug: debug.enabled,\n jsx,\n tsconfigPaths: typeof tsconfigPath === 'string' ? tsconfigPath : true,\n })\n\n const fileURL = typeof filePath === 'string' ? pathToFileURL(filePath) : filePath\n\n debug(`Loading module: ${fileURLToPath(fileURL)}`, {tsconfigPath})\n\n const jitiOptions: JitiResolveOptions & {default?: true} = {}\n\n // If the default option is true, add it to the jiti options\n if (returnDefault) {\n jitiOptions.default = true\n }\n\n return jiti.import<T>(fileURLToPath(fileURL), jitiOptions)\n}\n"],"names":["fileURLToPath","pathToFileURL","createJiti","subdebug","debug","importModule","filePath","options","default","returnDefault","jsx","tsconfigPath","jiti","url","enabled","tsconfigPaths","fileURL","jitiOptions","import"],"mappings":"AAAA,SAAQA,aAAa,EAAEC,aAAa,QAAO,WAAU;AAErD,SAAQC,UAAU,QAAgC,OAAM;AAExD,SAAQC,QAAQ,QAAO,uBAAsB;AAuB7C,MAAMC,QAAQD,SAAS;AAEvB;;;;;;;;CAQC,GACD,OAAO,eAAeE,aACpBC,QAAsB,EACtBC,UAA+B,CAAC,CAAC;IAEjC,MAAM,EAACC,SAASC,gBAAgB,IAAI,EAAEC,MAAM,KAAK,EAAEC,YAAY,EAAC,GAAGJ;IAEnE,MAAMK,OAAOV,WAAW,YAAYW,GAAG,EAAE;QACvCT,OAAOA,MAAMU,OAAO;QACpBJ;QACAK,eAAe,OAAOJ,iBAAiB,WAAWA,eAAe;IACnE;IAEA,MAAMK,UAAU,OAAOV,aAAa,WAAWL,cAAcK,YAAYA;IAEzEF,MAAM,CAAC,gBAAgB,EAAEJ,cAAcgB,UAAU,EAAE;QAACL;IAAY;IAEhE,MAAMM,cAAqD,CAAC;IAE5D,4DAA4D;IAC5D,IAAIR,eAAe;QACjBQ,YAAYT,OAAO,GAAG;IACxB;IAEA,OAAOI,KAAKM,MAAM,CAAIlB,cAAcgB,UAAUC;AAChD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/cli-core",
3
- "version": "3.11.0",
3
+ "version": "3.12.0",
4
4
  "description": "Sanity CLI core package",
5
5
  "keywords": [
6
6
  "cli",