@sanity/pkg-utils 8.1.23 → 8.1.25
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.
|
@@ -11,17 +11,19 @@ function resolveRolldownConfig(ctx, buildTask) {
|
|
|
11
11
|
Object.entries(config?.define || {}).map(([key, val]) => [key, JSON.stringify(val)])
|
|
12
12
|
), entryFileNames = `[name]${outputExt}`, inputOptions = {
|
|
13
13
|
cwd,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
transform: {
|
|
15
|
+
jsx: config?.jsx === "preserve" ? "preserve" : {
|
|
16
|
+
runtime: config?.jsx === "automatic" ? "automatic" : "classic",
|
|
17
|
+
importSource: config?.jsxImportSource,
|
|
18
|
+
pragma: config?.jsxFactory,
|
|
19
|
+
pragmaFrag: config?.jsxFragment
|
|
20
|
+
},
|
|
21
|
+
define: pkg.name === "@sanity/pkg-utils" ? { ...replacements } : {
|
|
22
|
+
"process.env.PKG_FORMAT": JSON.stringify(format),
|
|
23
|
+
"process.env.PKG_RUNTIME": JSON.stringify(runtime),
|
|
24
|
+
"process.env.PKG_VERSION": JSON.stringify(process.env.PKG_VERSION || pkg.version),
|
|
25
|
+
...replacements
|
|
26
|
+
}
|
|
25
27
|
},
|
|
26
28
|
platform: buildTask.type === "rolldown:dts" || runtime === "node" ? "node" : runtime === "browser" ? "browser" : "neutral",
|
|
27
29
|
resolve: {
|
|
@@ -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
|
|
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 transform: {\n jsx:\n config?.jsx === 'preserve'\n ? 'preserve'\n : {\n runtime: config?.jsx === 'automatic' ? 'automatic' : 'classic',\n importSource: config?.jsxImportSource,\n pragma: config?.jsxFactory,\n pragmaFrag: config?.jsxFragment,\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\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 },\n tsconfig: ctx.ts.configPath || 'tsconfig.json',\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(`/node_modules/${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,EAAA,IAElE,CAAA,CAAE,GAEC,YACJ,YAAY,OAAO,KAAK,QAAQ,EAAE,IAAI,CAAC,eAAe,KAAK,KAAK,IAAI,MAAM,UAAU,CAAC,GAEjF,cAAc,YAAY,OAAO,OAAO,QAAQ,EAAE,IAAI,CAAC,MAAM,KAAK,QAAQ,KAAK,EAAE,MAAM,CAAC,GAExF,eAAe,OAAO;AAAA,IAC1B,OAAO,QAAQ,QAAQ,UAAU,CAAA,CAAE,EAAE,IAAI,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,KAAK,UAAU,GAAG,CAAC,CAAC;AAA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|
+
var version = "8.1.25";
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.25",
|
|
4
4
|
"description": "Simple utilities for modern npm packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity-io",
|
|
@@ -100,9 +100,9 @@
|
|
|
100
100
|
"prompts": "^2.4.2",
|
|
101
101
|
"recast": "^0.23.11",
|
|
102
102
|
"rimraf": "^6.0.1",
|
|
103
|
-
"rolldown": "1.0.0-beta.
|
|
104
|
-
"rolldown-plugin-dts": "0.16.
|
|
105
|
-
"rollup": "^4.52.
|
|
103
|
+
"rolldown": "1.0.0-beta.44",
|
|
104
|
+
"rolldown-plugin-dts": "0.16.12",
|
|
105
|
+
"rollup": "^4.52.5",
|
|
106
106
|
"rollup-plugin-esbuild": "^6.2.1",
|
|
107
107
|
"rxjs": "^7.8.2",
|
|
108
108
|
"treeify": "^1.1.0",
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"@types/prompts": "^2.4.9",
|
|
124
124
|
"@types/semver": "^7.7.1",
|
|
125
125
|
"@types/treeify": "^1.0.3",
|
|
126
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
126
|
+
"@typescript/native-preview": "7.0.0-dev.20251019.1",
|
|
127
127
|
"babel-plugin-react-compiler": "1.0.0",
|
|
128
128
|
"browserslist-to-esbuild": "2.1.1",
|
|
129
129
|
"commitizen": "^4.3.1",
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
"ts-node": "^10.9.2",
|
|
140
140
|
"typescript": "5.9.3",
|
|
141
141
|
"vitest": "^3.2.4",
|
|
142
|
-
"@sanity/pkg-utils": "8.1.
|
|
142
|
+
"@sanity/pkg-utils": "8.1.25"
|
|
143
143
|
},
|
|
144
144
|
"peerDependencies": {
|
|
145
145
|
"babel-plugin-react-compiler": "*",
|