@sanity/pkg-utils 7.11.2 → 7.11.3-canary.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.
@@ -32,24 +32,28 @@ function resolveRolldownConfig(ctx, buildTask) {
32
32
  tsconfigFilename: ctx.ts.configPath || "tsconfig.json"
33
33
  },
34
34
  experimental: {
35
- attachDebugInfo: "none"
35
+ attachDebugInfo: "full"
36
36
  },
37
37
  external: (id, importer) => {
38
- if (buildTask.type === "rolldown:dts" && ctx.bundledPackages.length > 0 && !id.startsWith(".") && (id.includes("/node_modules/") || id.split("/").length < 3))
39
- return ctx.bundledPackages.some((name) => name === id || id.includes(`/${name}/`)) === !1;
40
- if (exportIds?.includes(id))
41
- return !0;
42
- if (importer && (id.startsWith(".") || id.startsWith("/"))) {
43
- const idPath = path__default.default.resolve(path__default.default.dirname(importer), id);
44
- if (sourcePaths?.includes(idPath))
45
- return logger.warn(
46
- `detected self-referencing import \u2013 treating as external: ${path__default.default.relative(
47
- cwd,
48
- idPath
49
- )}`
50
- ), !0;
38
+ function scope() {
39
+ if (buildTask.type === "rolldown:dts" && ctx.bundledPackages.length > 0 && !id.startsWith(".") && (id.includes("/node_modules/") || id.split("/").length < 3))
40
+ return ctx.bundledPackages.some((name) => name === id || id.includes(`/${name}/`)) === !1;
41
+ if (exportIds?.includes(id))
42
+ return !0;
43
+ if (importer && (id.startsWith(".") || id.startsWith("/"))) {
44
+ const idPath = path__default.default.resolve(path__default.default.dirname(importer), id);
45
+ if (sourcePaths?.includes(idPath))
46
+ return logger.warn(
47
+ `detected self-referencing import \u2013 treating as external: ${path__default.default.relative(
48
+ cwd,
49
+ idPath
50
+ )}`
51
+ ), !0;
52
+ }
53
+ return external.some((name) => name === id || id.includes(`/${name}/`));
51
54
  }
52
- return external.some((name) => name === id || id.includes(`/${name}/`));
55
+ const result = scope();
56
+ return logger.info(`external: (id: ${id}, importer: ${importer}) -> ${result}`), result;
53
57
  },
54
58
  input: entries.reduce(
55
59
  (acc, entry) => Object.assign(acc, { [entry.name]: entry.source }),
@@ -1 +1 @@
1
- {"version":3,"file":"resolveRolldownConfig.cjs","sources":["../../src/node/tasks/rolldown/resolveRolldownConfig.ts"],"sourcesContent":["import path from 'node:path'\nimport type {InputOptions, OutputOptions} from 'rolldown'\nimport {dts as dtsPlugin} from 'rolldown-plugin-dts'\nimport type {BuildContext} from '../../core/contexts/buildContext'\nimport {pkgExtMap as extMap} from '../../core/pkg/pkgExt'\nimport type {RolldownDtsTask} from '../types'\n\nexport interface RolldownConfig {\n inputOptions: InputOptions\n outputOptions: OutputOptions\n}\n\nexport function resolveRolldownConfig(\n ctx: BuildContext,\n buildTask: RolldownDtsTask,\n): RolldownConfig {\n const {format, runtime} = buildTask\n const {config, cwd, exports: _exports, external, distPath, logger, pkg, ts} = ctx\n const outputExt = extMap[pkg.type || 'commonjs'][format]\n const outDir = path.relative(cwd, distPath)\n\n const pathAliases = Object.fromEntries(\n Object.entries(ts.config?.options.paths || {}).map(([key, val]) => {\n return [key, path.resolve(cwd, ts.config?.options.baseUrl || '.', val[0]!)]\n }),\n )\n\n const entries = buildTask.entries.map((entry) => {\n return {\n ...entry,\n name: path.relative(outDir, entry.output).replace(/\\.[^/.]+$/, ''),\n }\n }, {})\n\n const exportIds =\n _exports && Object.keys(_exports).map((exportPath) => path.join(pkg.name, exportPath))\n\n const sourcePaths = _exports && Object.values(_exports).map((e) => path.resolve(cwd, e.source))\n\n const replacements = Object.fromEntries(\n Object.entries(config?.define || {}).map(([key, val]) => [key, JSON.stringify(val)]),\n )\n\n const entryFileNames = `[name]${outputExt}`\n\n const inputOptions = {\n cwd,\n jsx: {\n mode:\n config?.jsx === 'automatic'\n ? 'automatic'\n : config?.jsx === 'preserve'\n ? 'preserve'\n : config?.jsx === 'transform'\n ? 'classic'\n : 'automatic',\n factory: config?.jsxFactory,\n fragment: config?.jsxFragment,\n importSource: config?.jsxImportSource,\n },\n define:\n pkg.name === '@sanity/pkg-utils'\n ? {...replacements}\n : {\n 'process.env.PKG_FORMAT': JSON.stringify(format),\n 'process.env.PKG_RUNTIME': JSON.stringify(runtime),\n 'process.env.PKG_VERSION': JSON.stringify(process.env['PKG_VERSION'] || pkg.version),\n ...replacements,\n },\n\n platform:\n buildTask.type === 'rolldown:dts'\n ? 'node'\n : runtime === 'node'\n ? 'node'\n : runtime === 'browser'\n ? 'browser'\n : 'neutral',\n\n resolve: {\n alias: pathAliases,\n tsconfigFilename: ctx.ts.configPath || 'tsconfig.json',\n },\n experimental: {\n attachDebugInfo: 'none',\n },\n\n external: (id, importer) => {\n if (\n buildTask.type === 'rolldown:dts' &&\n ctx.bundledPackages.length > 0 &&\n !id.startsWith('.') &&\n (id.includes('/node_modules/') || id.split('/').length < 3)\n ) {\n return ctx.bundledPackages.some((name) => name === id || id.includes(`/${name}/`)) === false\n }\n\n // Check if the id is a self-referencing import\n if (exportIds?.includes(id)) {\n return true\n }\n\n // Check if the id is a file path that points to an exported source file\n if (importer && (id.startsWith('.') || id.startsWith('/'))) {\n const idPath = path.resolve(path.dirname(importer), id)\n\n if (sourcePaths?.includes(idPath)) {\n logger.warn(\n `detected self-referencing import – treating as external: ${path.relative(\n cwd,\n idPath,\n )}`,\n )\n\n return true\n }\n }\n\n return external.some((name) => name === id || id.includes(`/${name}/`))\n },\n\n input: entries.reduce<{[entryAlias: string]: string}>(\n (acc, entry) => Object.assign(acc, {[entry.name]: entry.source}),\n {},\n ),\n\n plugins: [\n dtsPlugin({\n emitDtsOnly: true,\n tsconfig: ctx.ts.configPath || 'tsconfig.json',\n tsgo:\n typeof pkg.devDependencies === 'object' &&\n '@typescript/native-preview' in pkg.devDependencies,\n // Enable the resolver by giving an allow list of packages to dig through node_modules.\n // If there are none that should be resolved, then this process is skipped and our build is faster.\n // If there's a match then it'll call the resolver function defined on `inputOptions.external`\n resolve: ctx.bundledPackages,\n // Always create dts from scratch, don't reuse contexts from previous builds\n newContext: true,\n }),\n ],\n\n treeshake: {\n moduleSideEffects: 'no-external',\n unknownGlobalSideEffects: false,\n annotations: true,\n },\n } satisfies InputOptions\n const outputOptions = {\n dir: outDir,\n entryFileNames,\n chunkFileNames:\n buildTask.type === 'rolldown:dts' ? `_chunks-dts/[name]${outputExt}` : undefined,\n esModule: true,\n format: buildTask.type === 'rolldown:dts' ? 'es' : format,\n sourcemap: buildTask.type === 'rolldown:dts' ? false : (config?.sourcemap ?? true),\n hoistTransitiveImports: false,\n /**\n * rolldown doesn't permit disabling chunks, we can only choose between automatic chunking (the default)\n * and manual chunking (using advancedChunks).\n * This matters for how we generate dts files.\n * While we use rolldown for dts generation, and rollup for the rest, we want to reduce the amount of dts files emitted as chunks,\n * and to make them predictable in how they're generated.\n */\n // @TODO the following breaks the dts generation, report bug to rolldown\n // advancedChunks:\n // buildTask.type === 'rolldown:dts'\n // ? {\n // groups: [\n // {\n // /**\n // * Groups all inlined typings specified by bundledPackages in extract.bundledPackages to its own chunk.\n // */\n // name: 'bundled-packages',\n // test: (id) => ctx.bundledPackages.includes(id),\n // priority: 1,\n // },\n // {\n // /**\n // * Put all other shared chunks into a single chunk.\n // */\n // name: 'shared',\n // minShareCount: 1,\n // },\n // ],\n // }\n // : {},\n } satisfies OutputOptions\n\n return {inputOptions, outputOptions}\n}\n"],"names":["extMap","path","dtsPlugin"],"mappings":";;;;;;AAYO,SAAS,sBACd,KACA,WACgB;AAChB,QAAM,EAAC,QAAQ,QAAA,IAAW,WACpB,EAAC,QAAQ,KAAK,SAAS,UAAU,UAAU,UAAU,QAAQ,KAAK,GAAA,IAAM,KACxE,YAAYA,MAAAA,UAAO,IAAI,QAAQ,UAAU,EAAE,MAAM,GACjD,SAASC,cAAAA,QAAK,SAAS,KAAK,QAAQ,GAEpC,cAAc,OAAO;AAAA,IACzB,OAAO,QAAQ,GAAG,QAAQ,QAAQ,SAAS,CAAA,CAAE,EAAE,IAAI,CAAC,CAAC,KAAK,GAAG,MACpD,CAAC,KAAKA,sBAAK,QAAQ,KAAK,GAAG,QA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AA0B;AAAA,MAC1B,aAAa;AAAA,IAAA;AAAA,EACf,GAEI,gBAAgB;AAAA,IACpB,KAAK;AAAA,IACL;AAAA,IACA,gBACE,UAAU,SAAS,iBAAiB,qBAAqB,SAAS,KAAK;AAAA,IACzE,UAAU;AAAA,IACV,QAAQ,UAAU,SAAS,iBAAiB,OAAO;AAAA,IACnD,WAAW,UAAU,SAAS,iBAAiB,KAAS,QAAQ,aAAa;AAAA,IAC7E,wBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA;AAiC1B,SAAO,EAAC,cAAc,cAAA;AACxB;;"}
1
+ {"version":3,"file":"resolveRolldownConfig.cjs","sources":["../../src/node/tasks/rolldown/resolveRolldownConfig.ts"],"sourcesContent":["import path from 'node:path'\nimport type {InputOptions, OutputOptions} from 'rolldown'\nimport {dts as dtsPlugin} from 'rolldown-plugin-dts'\nimport type {BuildContext} from '../../core/contexts/buildContext'\nimport {pkgExtMap as extMap} from '../../core/pkg/pkgExt'\nimport type {RolldownDtsTask} from '../types'\n\nexport interface RolldownConfig {\n inputOptions: InputOptions\n outputOptions: OutputOptions\n}\n\nexport function resolveRolldownConfig(\n ctx: BuildContext,\n buildTask: RolldownDtsTask,\n): RolldownConfig {\n const {format, runtime} = buildTask\n const {config, cwd, exports: _exports, external, distPath, logger, pkg, ts} = ctx\n const outputExt = extMap[pkg.type || 'commonjs'][format]\n const outDir = path.relative(cwd, distPath)\n\n const pathAliases = Object.fromEntries(\n Object.entries(ts.config?.options.paths || {}).map(([key, val]) => {\n return [key, path.resolve(cwd, ts.config?.options.baseUrl || '.', val[0]!)]\n }),\n )\n\n const entries = buildTask.entries.map((entry) => {\n return {\n ...entry,\n name: path.relative(outDir, entry.output).replace(/\\.[^/.]+$/, ''),\n }\n }, {})\n\n const exportIds =\n _exports && Object.keys(_exports).map((exportPath) => path.join(pkg.name, exportPath))\n\n const sourcePaths = _exports && Object.values(_exports).map((e) => path.resolve(cwd, e.source))\n\n const replacements = Object.fromEntries(\n Object.entries(config?.define || {}).map(([key, val]) => [key, JSON.stringify(val)]),\n )\n\n const entryFileNames = `[name]${outputExt}`\n\n const inputOptions = {\n cwd,\n jsx: {\n mode:\n config?.jsx === 'automatic'\n ? 'automatic'\n : config?.jsx === 'preserve'\n ? 'preserve'\n : config?.jsx === 'transform'\n ? 'classic'\n : 'automatic',\n factory: config?.jsxFactory,\n fragment: config?.jsxFragment,\n importSource: config?.jsxImportSource,\n },\n define:\n pkg.name === '@sanity/pkg-utils'\n ? {...replacements}\n : {\n 'process.env.PKG_FORMAT': JSON.stringify(format),\n 'process.env.PKG_RUNTIME': JSON.stringify(runtime),\n 'process.env.PKG_VERSION': JSON.stringify(process.env['PKG_VERSION'] || pkg.version),\n ...replacements,\n },\n\n platform:\n buildTask.type === 'rolldown:dts'\n ? 'node'\n : runtime === 'node'\n ? 'node'\n : runtime === 'browser'\n ? 'browser'\n : 'neutral',\n\n resolve: {\n alias: pathAliases,\n tsconfigFilename: ctx.ts.configPath || 'tsconfig.json',\n },\n experimental: {\n attachDebugInfo: 'full',\n },\n\n external: (id, importer) => {\n function scope() {\n if (\n buildTask.type === 'rolldown:dts' &&\n ctx.bundledPackages.length > 0 &&\n !id.startsWith('.') &&\n (id.includes('/node_modules/') || id.split('/').length < 3)\n ) {\n return (\n ctx.bundledPackages.some((name) => name === id || id.includes(`/${name}/`)) === false\n )\n }\n\n // Check if the id is a self-referencing import\n if (exportIds?.includes(id)) {\n return true\n }\n\n // Check if the id is a file path that points to an exported source file\n if (importer && (id.startsWith('.') || id.startsWith('/'))) {\n const idPath = path.resolve(path.dirname(importer), id)\n\n if (sourcePaths?.includes(idPath)) {\n logger.warn(\n `detected self-referencing import – treating as external: ${path.relative(\n cwd,\n idPath,\n )}`,\n )\n\n return true\n }\n }\n\n return external.some((name) => name === id || id.includes(`/${name}/`))\n }\n const result = scope()\n logger.info(`external: (id: ${id}, importer: ${importer}) -> ${result}`)\n return result\n },\n\n input: entries.reduce<{[entryAlias: string]: string}>(\n (acc, entry) => Object.assign(acc, {[entry.name]: entry.source}),\n {},\n ),\n\n plugins: [\n dtsPlugin({\n emitDtsOnly: true,\n tsconfig: ctx.ts.configPath || 'tsconfig.json',\n tsgo:\n typeof pkg.devDependencies === 'object' &&\n '@typescript/native-preview' in pkg.devDependencies,\n // Enable the resolver by giving an allow list of packages to dig through node_modules.\n // If there are none that should be resolved, then this process is skipped and our build is faster.\n // If there's a match then it'll call the resolver function defined on `inputOptions.external`\n resolve: ctx.bundledPackages,\n // Always create dts from scratch, don't reuse contexts from previous builds\n newContext: true,\n }),\n ],\n\n treeshake: {\n moduleSideEffects: 'no-external',\n unknownGlobalSideEffects: false,\n annotations: true,\n },\n } satisfies InputOptions\n const outputOptions = {\n dir: outDir,\n entryFileNames,\n chunkFileNames:\n buildTask.type === 'rolldown:dts' ? `_chunks-dts/[name]${outputExt}` : undefined,\n esModule: true,\n format: buildTask.type === 'rolldown:dts' ? 'es' : format,\n sourcemap: buildTask.type === 'rolldown:dts' ? false : (config?.sourcemap ?? true),\n hoistTransitiveImports: false,\n /**\n * rolldown doesn't permit disabling chunks, we can only choose between automatic chunking (the default)\n * and manual chunking (using advancedChunks).\n * This matters for how we generate dts files.\n * While we use rolldown for dts generation, and rollup for the rest, we want to reduce the amount of dts files emitted as chunks,\n * and to make them predictable in how they're generated.\n */\n // @TODO the following breaks the dts generation, report bug to rolldown\n // advancedChunks:\n // buildTask.type === 'rolldown:dts'\n // ? {\n // groups: [\n // {\n // /**\n // * Groups all inlined typings specified by bundledPackages in extract.bundledPackages to its own chunk.\n // */\n // name: 'bundled-packages',\n // test: (id) => ctx.bundledPackages.includes(id),\n // priority: 1,\n // },\n // {\n // /**\n // * Put all other shared chunks into a single chunk.\n // */\n // name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x, buildTask) {
29
29
  tsconfigFilename: ctx.ts.configPath || "tsconfig.json"
30
30
  },
31
31
  experimental: {
32
- attachDebugInfo: "none"
32
+ attachDebugInfo: "full"
33
33
  },
34
34
  external: (id, importer) => {
35
- if (buildTask.type === "rolldown:dts" && ctx.bundledPackages.length > 0 && !id.startsWith(".") && (id.includes("/node_modules/") || id.split("/").length < 3))
36
- return ctx.bundledPackages.some((name) => name === id || id.includes(`/${name}/`)) === !1;
37
- if (exportIds?.includes(id))
38
- return !0;
39
- if (importer && (id.startsWith(".") || id.startsWith("/"))) {
40
- const idPath = path.resolve(path.dirname(importer), id);
41
- if (sourcePaths?.includes(idPath))
42
- return logger.warn(
43
- `detected self-referencing import \u2013 treating as external: ${path.relative(
44
- cwd,
45
- idPath
46
- )}`
47
- ), !0;
35
+ function scope() {
36
+ if (buildTask.type === "rolldown:dts" && ctx.bundledPackages.length > 0 && !id.startsWith(".") && (id.includes("/node_modules/") || id.split("/").length < 3))
37
+ return ctx.bundledPackages.some((name) => name === id || id.includes(`/${name}/`)) === !1;
38
+ if (exportIds?.includes(id))
39
+ return !0;
40
+ if (importer && (id.startsWith(".") || id.startsWith("/"))) {
41
+ const idPath = path.resolve(path.dirname(importer), id);
42
+ if (sourcePaths?.includes(idPath))
43
+ return logger.warn(
44
+ `detected self-referencing import \u2013 treating as external: ${path.relative(
45
+ cwd,
46
+ idPath
47
+ )}`
48
+ ), !0;
49
+ }
50
+ return external.some((name) => name === id || id.includes(`/${name}/`));
48
51
  }
49
- return external.some((name) => name === id || id.includes(`/${name}/`));
52
+ const result = scope();
53
+ return logger.info(`external: (id: ${id}, importer: ${importer}) -> ${result}`), result;
50
54
  },
51
55
  input: entries.reduce(
52
56
  (acc, entry) => Object.assign(acc, { [entry.name]: entry.source }),
@@ -1 +1 @@
1
- {"version":3,"file":"resolveRolldownConfig.js","sources":["../../src/node/tasks/rolldown/resolveRolldownConfig.ts"],"sourcesContent":["import path from 'node:path'\nimport type {InputOptions, OutputOptions} from 'rolldown'\nimport {dts as dtsPlugin} from 'rolldown-plugin-dts'\nimport type {BuildContext} from '../../core/contexts/buildContext'\nimport {pkgExtMap as extMap} from '../../core/pkg/pkgExt'\nimport type {RolldownDtsTask} from '../types'\n\nexport interface RolldownConfig {\n inputOptions: InputOptions\n outputOptions: OutputOptions\n}\n\nexport function resolveRolldownConfig(\n ctx: BuildContext,\n buildTask: RolldownDtsTask,\n): RolldownConfig {\n const {format, runtime} = buildTask\n const {config, cwd, exports: _exports, external, distPath, logger, pkg, ts} = ctx\n const outputExt = extMap[pkg.type || 'commonjs'][format]\n const outDir = path.relative(cwd, distPath)\n\n const pathAliases = Object.fromEntries(\n Object.entries(ts.config?.options.paths || {}).map(([key, val]) => {\n return [key, path.resolve(cwd, ts.config?.options.baseUrl || '.', val[0]!)]\n }),\n )\n\n const entries = buildTask.entries.map((entry) => {\n return {\n ...entry,\n name: path.relative(outDir, entry.output).replace(/\\.[^/.]+$/, ''),\n }\n }, {})\n\n const exportIds =\n _exports && Object.keys(_exports).map((exportPath) => path.join(pkg.name, exportPath))\n\n const sourcePaths = _exports && Object.values(_exports).map((e) => path.resolve(cwd, e.source))\n\n const replacements = Object.fromEntries(\n Object.entries(config?.define || {}).map(([key, val]) => [key, JSON.stringify(val)]),\n )\n\n const entryFileNames = `[name]${outputExt}`\n\n const inputOptions = {\n cwd,\n jsx: {\n mode:\n config?.jsx === 'automatic'\n ? 'automatic'\n : config?.jsx === 'preserve'\n ? 'preserve'\n : config?.jsx === 'transform'\n ? 'classic'\n : 'automatic',\n factory: config?.jsxFactory,\n fragment: config?.jsxFragment,\n importSource: config?.jsxImportSource,\n },\n define:\n pkg.name === '@sanity/pkg-utils'\n ? {...replacements}\n : {\n 'process.env.PKG_FORMAT': JSON.stringify(format),\n 'process.env.PKG_RUNTIME': JSON.stringify(runtime),\n 'process.env.PKG_VERSION': JSON.stringify(process.env['PKG_VERSION'] || pkg.version),\n ...replacements,\n },\n\n platform:\n buildTask.type === 'rolldown:dts'\n ? 'node'\n : runtime === 'node'\n ? 'node'\n : runtime === 'browser'\n ? 'browser'\n : 'neutral',\n\n resolve: {\n alias: pathAliases,\n tsconfigFilename: ctx.ts.configPath || 'tsconfig.json',\n },\n experimental: {\n attachDebugInfo: 'none',\n },\n\n external: (id, importer) => {\n if (\n buildTask.type === 'rolldown:dts' &&\n ctx.bundledPackages.length > 0 &&\n !id.startsWith('.') &&\n (id.includes('/node_modules/') || id.split('/').length < 3)\n ) {\n return ctx.bundledPackages.some((name) => name === id || id.includes(`/${name}/`)) === false\n }\n\n // Check if the id is a self-referencing import\n if (exportIds?.includes(id)) {\n return true\n }\n\n // Check if the id is a file path that points to an exported source file\n if (importer && (id.startsWith('.') || id.startsWith('/'))) {\n const idPath = path.resolve(path.dirname(importer), id)\n\n if (sourcePaths?.includes(idPath)) {\n logger.warn(\n `detected self-referencing import – treating as external: ${path.relative(\n cwd,\n idPath,\n )}`,\n )\n\n return true\n }\n }\n\n return external.some((name) => name === id || id.includes(`/${name}/`))\n },\n\n input: entries.reduce<{[entryAlias: string]: string}>(\n (acc, entry) => Object.assign(acc, {[entry.name]: entry.source}),\n {},\n ),\n\n plugins: [\n dtsPlugin({\n emitDtsOnly: true,\n tsconfig: ctx.ts.configPath || 'tsconfig.json',\n tsgo:\n typeof pkg.devDependencies === 'object' &&\n '@typescript/native-preview' in pkg.devDependencies,\n // Enable the resolver by giving an allow list of packages to dig through node_modules.\n // If there are none that should be resolved, then this process is skipped and our build is faster.\n // If there's a match then it'll call the resolver function defined on `inputOptions.external`\n resolve: ctx.bundledPackages,\n // Always create dts from scratch, don't reuse contexts from previous builds\n newContext: true,\n }),\n ],\n\n treeshake: {\n moduleSideEffects: 'no-external',\n unknownGlobalSideEffects: false,\n annotations: true,\n },\n } satisfies InputOptions\n const outputOptions = {\n dir: outDir,\n entryFileNames,\n chunkFileNames:\n buildTask.type === 'rolldown:dts' ? `_chunks-dts/[name]${outputExt}` : undefined,\n esModule: true,\n format: buildTask.type === 'rolldown:dts' ? 'es' : format,\n sourcemap: buildTask.type === 'rolldown:dts' ? false : (config?.sourcemap ?? true),\n hoistTransitiveImports: false,\n /**\n * rolldown doesn't permit disabling chunks, we can only choose between automatic chunking (the default)\n * and manual chunking (using advancedChunks).\n * This matters for how we generate dts files.\n * While we use rolldown for dts generation, and rollup for the rest, we want to reduce the amount of dts files emitted as chunks,\n * and to make them predictable in how they're generated.\n */\n // @TODO the following breaks the dts generation, report bug to rolldown\n // advancedChunks:\n // buildTask.type === 'rolldown:dts'\n // ? {\n // groups: [\n // {\n // /**\n // * Groups all inlined typings specified by bundledPackages in extract.bundledPackages to its own chunk.\n // */\n // name: 'bundled-packages',\n // test: (id) => ctx.bundledPackages.includes(id),\n // priority: 1,\n // },\n // {\n // /**\n // * Put all other shared chunks into a single chunk.\n // */\n // name: 'shared',\n // minShareCount: 1,\n // },\n // ],\n // }\n // : {},\n } satisfies OutputOptions\n\n return {inputOptions, outputOptions}\n}\n"],"names":["extMap","dtsPlugin"],"mappings":";;;AAYO,SAAS,sBACd,KACA,WACgB;AAChB,QAAM,EAAC,QAAQ,QAAA,IAAW,WACpB,EAAC,QAAQ,KAAK,SAAS,UAAU,UAAU,UAAU,QAAQ,KAAK,GAAA,IAAM,KACxE,YAAYA,UAAO,IAAI,QAAQ,UAAU,EAAE,MAAM,GACjD,SAAS,KAAK,SAAS,KAAK,QAAQ,GAEpC,cAAc,OAAO;AAAA,IACzB,OAAO,QAAQ,GAAG,QAAQ,QAAQ,SAAS,CAAA,CAAE,EAAE,IAAI,CAAC,CAAC,KAAK,GAAG,MACpD,CAAC,KAAK,KAAK,QAAQ,KAAK,GAAG,QAAQ,QAAQ,WAAW,KAAK,IAAI,CAAC,CAAE,CAAC,CAC3E;AAAA,EAAA,GAGG,UAAU,UAAU,QAAQ,IAAI,CAAC,WAC9B;AAAA,IACL,GAAG;AAAA,IACH,MAAM,KAAK,SAAS,QAAQ,MAAM,MAAM,EAAE,QAAQ,aAAa,EAAE;AAAA,EA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Q,aAAa;AAAA,IAC7E,wBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA;AAiC1B,SAAO,EAAC,cAAc,cAAA;AACxB;"}
1
+ {"version":3,"file":"resolveRolldownConfig.js","sources":["../../src/node/tasks/rolldown/resolveRolldownConfig.ts"],"sourcesContent":["import path from 'node:path'\nimport type {InputOptions, OutputOptions} from 'rolldown'\nimport {dts as dtsPlugin} from 'rolldown-plugin-dts'\nimport type {BuildContext} from '../../core/contexts/buildContext'\nimport {pkgExtMap as extMap} from '../../core/pkg/pkgExt'\nimport type {RolldownDtsTask} from '../types'\n\nexport interface RolldownConfig {\n inputOptions: InputOptions\n outputOptions: OutputOptions\n}\n\nexport function resolveRolldownConfig(\n ctx: BuildContext,\n buildTask: RolldownDtsTask,\n): RolldownConfig {\n const {format, runtime} = buildTask\n const {config, cwd, exports: _exports, external, distPath, logger, pkg, ts} = ctx\n const outputExt = extMap[pkg.type || 'commonjs'][format]\n const outDir = path.relative(cwd, distPath)\n\n const pathAliases = Object.fromEntries(\n Object.entries(ts.config?.options.paths || {}).map(([key, val]) => {\n return [key, path.resolve(cwd, ts.config?.options.baseUrl || '.', val[0]!)]\n }),\n )\n\n const entries = buildTask.entries.map((entry) => {\n return {\n ...entry,\n name: path.relative(outDir, entry.output).replace(/\\.[^/.]+$/, ''),\n }\n }, {})\n\n const exportIds =\n _exports && Object.keys(_exports).map((exportPath) => path.join(pkg.name, exportPath))\n\n const sourcePaths = _exports && Object.values(_exports).map((e) => path.resolve(cwd, e.source))\n\n const replacements = Object.fromEntries(\n Object.entries(config?.define || {}).map(([key, val]) => [key, JSON.stringify(val)]),\n )\n\n const entryFileNames = `[name]${outputExt}`\n\n const inputOptions = {\n cwd,\n jsx: {\n mode:\n config?.jsx === 'automatic'\n ? 'automatic'\n : config?.jsx === 'preserve'\n ? 'preserve'\n : config?.jsx === 'transform'\n ? 'classic'\n : 'automatic',\n factory: config?.jsxFactory,\n fragment: config?.jsxFragment,\n importSource: config?.jsxImportSource,\n },\n define:\n pkg.name === '@sanity/pkg-utils'\n ? {...replacements}\n : {\n 'process.env.PKG_FORMAT': JSON.stringify(format),\n 'process.env.PKG_RUNTIME': JSON.stringify(runtime),\n 'process.env.PKG_VERSION': JSON.stringify(process.env['PKG_VERSION'] || pkg.version),\n ...replacements,\n },\n\n platform:\n buildTask.type === 'rolldown:dts'\n ? 'node'\n : runtime === 'node'\n ? 'node'\n : runtime === 'browser'\n ? 'browser'\n : 'neutral',\n\n resolve: {\n alias: pathAliases,\n tsconfigFilename: ctx.ts.configPath || 'tsconfig.json',\n },\n experimental: {\n attachDebugInfo: 'full',\n },\n\n external: (id, importer) => {\n function scope() {\n if (\n buildTask.type === 'rolldown:dts' &&\n ctx.bundledPackages.length > 0 &&\n !id.startsWith('.') &&\n (id.includes('/node_modules/') || id.split('/').length < 3)\n ) {\n return (\n ctx.bundledPackages.some((name) => name === id || id.includes(`/${name}/`)) === false\n )\n }\n\n // Check if the id is a self-referencing import\n if (exportIds?.includes(id)) {\n return true\n }\n\n // Check if the id is a file path that points to an exported source file\n if (importer && (id.startsWith('.') || id.startsWith('/'))) {\n const idPath = path.resolve(path.dirname(importer), id)\n\n if (sourcePaths?.includes(idPath)) {\n logger.warn(\n `detected self-referencing import – treating as external: ${path.relative(\n cwd,\n idPath,\n )}`,\n )\n\n return true\n }\n }\n\n return external.some((name) => name === id || id.includes(`/${name}/`))\n }\n const result = scope()\n logger.info(`external: (id: ${id}, importer: ${importer}) -> ${result}`)\n return result\n },\n\n input: entries.reduce<{[entryAlias: string]: string}>(\n (acc, entry) => Object.assign(acc, {[entry.name]: entry.source}),\n {},\n ),\n\n plugins: [\n dtsPlugin({\n emitDtsOnly: true,\n tsconfig: ctx.ts.configPath || 'tsconfig.json',\n tsgo:\n typeof pkg.devDependencies === 'object' &&\n '@typescript/native-preview' in pkg.devDependencies,\n // Enable the resolver by giving an allow list of packages to dig through node_modules.\n // If there are none that should be resolved, then this process is skipped and our build is faster.\n // If there's a match then it'll call the resolver function defined on `inputOptions.external`\n resolve: ctx.bundledPackages,\n // Always create dts from scratch, don't reuse contexts from previous builds\n newContext: true,\n }),\n ],\n\n treeshake: {\n moduleSideEffects: 'no-external',\n unknownGlobalSideEffects: false,\n annotations: true,\n },\n } satisfies InputOptions\n const outputOptions = {\n dir: outDir,\n entryFileNames,\n chunkFileNames:\n buildTask.type === 'rolldown:dts' ? `_chunks-dts/[name]${outputExt}` : undefined,\n esModule: true,\n format: buildTask.type === 'rolldown:dts' ? 'es' : format,\n sourcemap: buildTask.type === 'rolldown:dts' ? false : (config?.sourcemap ?? true),\n hoistTransitiveImports: false,\n /**\n * rolldown doesn't permit disabling chunks, we can only choose between automatic chunking (the default)\n * and manual chunking (using advancedChunks).\n * This matters for how we generate dts files.\n * While we use rolldown for dts generation, and rollup for the rest, we want to reduce the amount of dts files emitted as chunks,\n * and to make them predictable in how they're generated.\n */\n // @TODO the following breaks the dts generation, report bug to rolldown\n // advancedChunks:\n // buildTask.type === 'rolldown:dts'\n // ? {\n // groups: [\n // {\n // /**\n // * Groups all inlined typings specified by bundledPackages in extract.bundledPackages to its own chunk.\n // */\n // name: 'bundled-packages',\n // test: (id) => ctx.bundledPackages.includes(id),\n // priority: 1,\n // },\n // {\n // /**\n // * Put all other shared chunks into a single chunk.\n // */\n // name: 'shared',\n // minShareCount: 1,\n // },\n // ],\n // }\n // : {},\n } satisfies OutputOptions\n\n return {inputOptions, outputOptions}\n}\n"],"names":["extMap","dtsPlugin"],"mappings":";;;AAYO,SAAS,sBACd,KACA,WACgB;AAChB,QAAM,EAAC,QAAQ,QAAA,IAAW,WACpB,EAAC,QAAQ,KAAK,SAAS,UAAU,UAAU,UAAU,QAAQ,KAAK,GAAA,IAAM,KAC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,QAAO;AAAA,MAC/D,CAAA;AAAA,IAAC;AAAA,IAGH,SAAS;AAAA,MACPC,IAAU;AAAA,QACR,aAAa;AAAA,QACb,UAAU,IAAI,GAAG,cAAc;AAAA,QAC/B,MACE,OAAO,IAAI,mBAAoB,YAC/B,gCAAgC,IAAI;AAAA;AAAA;AAAA;AAAA,QAItC,SAAS,IAAI;AAAA;AAAA,QAEb,YAAY;AAAA,MAAA,CACb;AAAA,IAAA;AAAA,IAGH,WAAW;AAAA,MACT,mBAAmB;AAAA,MACnB,0BAA0B;AAAA,MAC1B,aAAa;AAAA,IAAA;AAAA,EACf,GAEI,gBAAgB;AAAA,IACpB,KAAK;AAAA,IACL;AAAA,IACA,gBACE,UAAU,SAAS,iBAAiB,qBAAqB,SAAS,KAAK;AAAA,IACzE,UAAU;AAAA,IACV,QAAQ,UAAU,SAAS,iBAAiB,OAAO;AAAA,IACnD,WAAW,UAAU,SAAS,iBAAiB,KAAS,QAAQ,aAAa;AAAA,IAC7E,wBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA;AAiC1B,SAAO,EAAC,cAAc,cAAA;AACxB;"}
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { cac } from "cac";
2
- var version = "7.11.2";
2
+ var version = "7.11.3-canary.0";
3
3
  const cli = cac();
4
4
  cli.command("", "Check").alias("check").option("--strict", "Strict mode").option("--tsconfig [tsconfig]", "[string] tsconfig.json").action(async (options) => {
5
5
  const { checkAction } = await import("./_chunks-es/checkAction.js");
package/dist/index.d.cts CHANGED
@@ -1,8 +1,12 @@
1
+ //! User-defined Entry: [Entry-Module-Id: src/node/index.d.ts] [Name: Some("index.d")]
1
2
  import { PluginItem } from "@babel/core";
2
3
  import { OptimizeLodashOptions } from "@optimize-lodash/rollup-plugin";
3
4
  import { Options } from "@vanilla-extract/rollup-plugin";
4
5
  import { NormalizedOutputOptions, Plugin, Plugin as RollupPlugin, TreeshakingOptions } from "rollup";
5
6
  import { IExtractorMessagesConfig } from "@microsoft/api-extractor";
7
+
8
+ //#region src/node/build.d.ts
9
+
6
10
  /**
7
11
  * Build the distribution files of a npm package.
8
12
  *
@@ -30,12 +34,16 @@ declare function build(options: {
30
34
  clean?: boolean;
31
35
  quiet?: boolean;
32
36
  }): Promise<void>;
37
+ //#endregion
38
+ //#region src/node/check.d.ts
33
39
  /** @public */
34
40
  declare function check(options: {
35
41
  cwd: string;
36
42
  strict?: boolean;
37
43
  tsconfig?: string;
38
44
  }): Promise<void>;
45
+ //#endregion
46
+ //#region src/node/strict.d.ts
39
47
  type ToggleType = 'error' | 'warn' | 'off';
40
48
  /**
41
49
  * @public
@@ -83,6 +91,8 @@ interface StrictOptions {
83
91
  }
84
92
  /** @alpha */
85
93
  declare function parseStrictOptions(input: unknown): StrictOptions;
94
+ //#endregion
95
+ //#region src/node/core/config/types.d.ts
86
96
  /** @public */
87
97
  type PkgFormat = 'commonjs' | 'esm';
88
98
  /** @public */
@@ -376,14 +386,22 @@ interface PkgConfigOptions {
376
386
  */
377
387
  dts?: DtsType;
378
388
  }
389
+ //#endregion
390
+ //#region src/node/core/config/defineConfig.d.ts
379
391
  /** @public */
380
392
  declare function defineConfig<const T extends PkgConfigOptions>(configOptions: T): T;
393
+ //#endregion
394
+ //#region src/node/core/config/loadConfig.d.ts
381
395
  /** @alpha */
382
396
  declare function loadConfig(options: {
383
397
  cwd: string;
384
398
  }): Promise<PkgConfigOptions | undefined>;
399
+ //#endregion
400
+ //#region src/node/core/defaults.d.ts
385
401
  /** @public */
386
402
  declare const DEFAULT_BROWSERSLIST_QUERY: string[];
403
+ //#endregion
404
+ //#region src/node/core/pkg/types.d.ts
387
405
  /** @alpha */
388
406
  interface PackageJSON {
389
407
  type?: 'commonjs' | 'module' | undefined;
@@ -448,10 +466,14 @@ interface PackageJSON {
448
466
  homepage?: string;
449
467
  license?: string;
450
468
  }
469
+ //#endregion
470
+ //#region src/node/core/pkg/loadPkg.d.ts
451
471
  /** @internal */
452
472
  declare function loadPkg(options: {
453
473
  cwd: string;
454
474
  }): Promise<PackageJSON>;
475
+ //#endregion
476
+ //#region src/node/logger.d.ts
455
477
  /** @alpha */
456
478
  interface Logger {
457
479
  log: (...args: unknown[]) => void;
@@ -462,12 +484,16 @@ interface Logger {
462
484
  }
463
485
  /** @alpha */
464
486
  declare function createLogger(quiet?: boolean): Logger;
487
+ //#endregion
488
+ //#region src/node/core/pkg/loadPkgWithReporting.d.ts
465
489
  /** @alpha */
466
490
  declare function loadPkgWithReporting(options: {
467
491
  cwd: string;
468
492
  logger: Logger;
469
493
  strict: boolean;
470
494
  }): Promise<PackageJSON>;
495
+ //#endregion
496
+ //#region src/node/core/pkg/parseExports.d.ts
471
497
  /** @alpha */
472
498
  declare function parseExports(options: {
473
499
  cwd: string;
@@ -478,6 +504,8 @@ declare function parseExports(options: {
478
504
  }): (PkgExport & {
479
505
  _path: string;
480
506
  })[];
507
+ //#endregion
508
+ //#region src/node/core/template/types.d.ts
481
509
  /** @public */
482
510
  interface PkgTemplateFile {
483
511
  name: string;
@@ -513,22 +541,31 @@ type PkgTemplateResolver = (options: {
513
541
  }) => PkgTemplateDefinition | Promise<PkgTemplateDefinition>;
514
542
  /** @public */
515
543
  type PkgTemplate = PkgTemplateDefinition | PkgTemplateResolver;
544
+ //#endregion
545
+ //#region src/node/core/template/define.d.ts
516
546
  /** @public */
517
547
  declare function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T>;
548
+ //#endregion
549
+ //#region src/node/init.d.ts
518
550
  /** @public */
519
551
  declare function init(options: {
520
552
  cwd: string;
521
553
  path: string;
522
554
  }): Promise<void>;
555
+ //#endregion
556
+ //#region src/node/tasks/dts/getExtractMessagesConfig.d.ts
523
557
  /** @alpha */
524
558
  declare function getExtractMessagesConfig(options: {
525
559
  rules: NonNullable<PkgConfigOptions['extract']>['rules'];
526
560
  disabled?: boolean;
527
561
  }): IExtractorMessagesConfig;
562
+ //#endregion
563
+ //#region src/node/watch.d.ts
528
564
  /** @public */
529
565
  declare function watch(options: {
530
566
  cwd: string;
531
567
  strict?: boolean;
532
568
  tsconfig?: string;
533
569
  }): Promise<void>;
570
+ //#endregion
534
571
  export { DEFAULT_BROWSERSLIST_QUERY, PackageJSON, type PkgBundle, type PkgConfigOptions, type PkgConfigProperty, type PkgConfigPropertyResolver, type PkgExport, type PkgExports, type PkgFormat, type PkgRuleLevel, type PkgRuntime, type PkgTemplate, type PkgTemplateDefinition, type PkgTemplateFile, type PkgTemplateOption, type PkgTemplateResolver, type PkgTemplateStringOption, type ReactCompilerLogger, type ReactCompilerLoggerEvent, type ReactCompilerOptions, type RollupPlugin, type TSDocCustomTag, build, check, createLogger, defineConfig, defineTemplateOption, getExtractMessagesConfig, init, loadConfig, loadPkg, loadPkgWithReporting, parseExports, parseStrictOptions, watch };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,12 @@
1
+ //! User-defined Entry: [Entry-Module-Id: src/node/index.d.ts] [Name: Some("index.d")]
1
2
  import { PluginItem } from "@babel/core";
2
3
  import { OptimizeLodashOptions } from "@optimize-lodash/rollup-plugin";
3
4
  import { Options } from "@vanilla-extract/rollup-plugin";
4
5
  import { NormalizedOutputOptions, Plugin, Plugin as RollupPlugin, TreeshakingOptions } from "rollup";
5
6
  import { IExtractorMessagesConfig } from "@microsoft/api-extractor";
7
+
8
+ //#region src/node/build.d.ts
9
+
6
10
  /**
7
11
  * Build the distribution files of a npm package.
8
12
  *
@@ -30,12 +34,16 @@ declare function build(options: {
30
34
  clean?: boolean;
31
35
  quiet?: boolean;
32
36
  }): Promise<void>;
37
+ //#endregion
38
+ //#region src/node/check.d.ts
33
39
  /** @public */
34
40
  declare function check(options: {
35
41
  cwd: string;
36
42
  strict?: boolean;
37
43
  tsconfig?: string;
38
44
  }): Promise<void>;
45
+ //#endregion
46
+ //#region src/node/strict.d.ts
39
47
  type ToggleType = 'error' | 'warn' | 'off';
40
48
  /**
41
49
  * @public
@@ -83,6 +91,8 @@ interface StrictOptions {
83
91
  }
84
92
  /** @alpha */
85
93
  declare function parseStrictOptions(input: unknown): StrictOptions;
94
+ //#endregion
95
+ //#region src/node/core/config/types.d.ts
86
96
  /** @public */
87
97
  type PkgFormat = 'commonjs' | 'esm';
88
98
  /** @public */
@@ -376,14 +386,22 @@ interface PkgConfigOptions {
376
386
  */
377
387
  dts?: DtsType;
378
388
  }
389
+ //#endregion
390
+ //#region src/node/core/config/defineConfig.d.ts
379
391
  /** @public */
380
392
  declare function defineConfig<const T extends PkgConfigOptions>(configOptions: T): T;
393
+ //#endregion
394
+ //#region src/node/core/config/loadConfig.d.ts
381
395
  /** @alpha */
382
396
  declare function loadConfig(options: {
383
397
  cwd: string;
384
398
  }): Promise<PkgConfigOptions | undefined>;
399
+ //#endregion
400
+ //#region src/node/core/defaults.d.ts
385
401
  /** @public */
386
402
  declare const DEFAULT_BROWSERSLIST_QUERY: string[];
403
+ //#endregion
404
+ //#region src/node/core/pkg/types.d.ts
387
405
  /** @alpha */
388
406
  interface PackageJSON {
389
407
  type?: 'commonjs' | 'module' | undefined;
@@ -448,10 +466,14 @@ interface PackageJSON {
448
466
  homepage?: string;
449
467
  license?: string;
450
468
  }
469
+ //#endregion
470
+ //#region src/node/core/pkg/loadPkg.d.ts
451
471
  /** @internal */
452
472
  declare function loadPkg(options: {
453
473
  cwd: string;
454
474
  }): Promise<PackageJSON>;
475
+ //#endregion
476
+ //#region src/node/logger.d.ts
455
477
  /** @alpha */
456
478
  interface Logger {
457
479
  log: (...args: unknown[]) => void;
@@ -462,12 +484,16 @@ interface Logger {
462
484
  }
463
485
  /** @alpha */
464
486
  declare function createLogger(quiet?: boolean): Logger;
487
+ //#endregion
488
+ //#region src/node/core/pkg/loadPkgWithReporting.d.ts
465
489
  /** @alpha */
466
490
  declare function loadPkgWithReporting(options: {
467
491
  cwd: string;
468
492
  logger: Logger;
469
493
  strict: boolean;
470
494
  }): Promise<PackageJSON>;
495
+ //#endregion
496
+ //#region src/node/core/pkg/parseExports.d.ts
471
497
  /** @alpha */
472
498
  declare function parseExports(options: {
473
499
  cwd: string;
@@ -478,6 +504,8 @@ declare function parseExports(options: {
478
504
  }): (PkgExport & {
479
505
  _path: string;
480
506
  })[];
507
+ //#endregion
508
+ //#region src/node/core/template/types.d.ts
481
509
  /** @public */
482
510
  interface PkgTemplateFile {
483
511
  name: string;
@@ -513,22 +541,31 @@ type PkgTemplateResolver = (options: {
513
541
  }) => PkgTemplateDefinition | Promise<PkgTemplateDefinition>;
514
542
  /** @public */
515
543
  type PkgTemplate = PkgTemplateDefinition | PkgTemplateResolver;
544
+ //#endregion
545
+ //#region src/node/core/template/define.d.ts
516
546
  /** @public */
517
547
  declare function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T>;
548
+ //#endregion
549
+ //#region src/node/init.d.ts
518
550
  /** @public */
519
551
  declare function init(options: {
520
552
  cwd: string;
521
553
  path: string;
522
554
  }): Promise<void>;
555
+ //#endregion
556
+ //#region src/node/tasks/dts/getExtractMessagesConfig.d.ts
523
557
  /** @alpha */
524
558
  declare function getExtractMessagesConfig(options: {
525
559
  rules: NonNullable<PkgConfigOptions['extract']>['rules'];
526
560
  disabled?: boolean;
527
561
  }): IExtractorMessagesConfig;
562
+ //#endregion
563
+ //#region src/node/watch.d.ts
528
564
  /** @public */
529
565
  declare function watch(options: {
530
566
  cwd: string;
531
567
  strict?: boolean;
532
568
  tsconfig?: string;
533
569
  }): Promise<void>;
570
+ //#endregion
534
571
  export { DEFAULT_BROWSERSLIST_QUERY, PackageJSON, type PkgBundle, type PkgConfigOptions, type PkgConfigProperty, type PkgConfigPropertyResolver, type PkgExport, type PkgExports, type PkgFormat, type PkgRuleLevel, type PkgRuntime, type PkgTemplate, type PkgTemplateDefinition, type PkgTemplateFile, type PkgTemplateOption, type PkgTemplateResolver, type PkgTemplateStringOption, type ReactCompilerLogger, type ReactCompilerLoggerEvent, type ReactCompilerOptions, type RollupPlugin, type TSDocCustomTag, build, check, createLogger, defineConfig, defineTemplateOption, getExtractMessagesConfig, init, loadConfig, loadPkg, loadPkgWithReporting, parseExports, parseStrictOptions, watch };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/pkg-utils",
3
- "version": "7.11.2",
3
+ "version": "7.11.3-canary.0",
4
4
  "description": "Simple utilities for modern npm packages.",
5
5
  "keywords": [
6
6
  "sanity-io",
@@ -142,7 +142,7 @@
142
142
  "tsx": "^4.20.3",
143
143
  "typescript": "5.9.2",
144
144
  "vitest": "^3.2.4",
145
- "@sanity/pkg-utils": "7.11.2"
145
+ "@sanity/pkg-utils": "7.11.3-canary.0"
146
146
  },
147
147
  "peerDependencies": {
148
148
  "babel-plugin-react-compiler": "*",