@sanity/cli-core 3.11.0 → 3.11.1

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,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/cli-core",
3
- "version": "3.11.0",
3
+ "version": "3.11.1",
4
4
  "description": "Sanity CLI core package",
5
5
  "keywords": [
6
6
  "cli",