@sanity/pkg-utils 7.4.1-canary.0 → 7.5.1-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.
- package/dist/_chunks-cjs/index.cjs +2022 -260
- package/dist/_chunks-cjs/index.cjs.map +1 -1
- package/dist/_chunks-es/build.js +106 -17
- package/dist/_chunks-es/build.js.map +1 -1
- package/dist/_chunks-es/check.js +125 -37
- package/dist/_chunks-es/check.js.map +1 -1
- package/dist/_chunks-es/consoleSpy.js +541 -0
- package/dist/_chunks-es/consoleSpy.js.map +1 -0
- package/dist/_chunks-es/index.js +774 -180
- package/dist/_chunks-es/index.js.map +1 -1
- package/dist/_chunks-es/init.js +493 -9
- package/dist/_chunks-es/init.js.map +1 -1
- package/dist/_chunks-es/{logger.js → isRecord.js} +15 -2
- package/dist/_chunks-es/isRecord.js.map +1 -0
- package/dist/_chunks-es/resolveRolldownConfig.js +1 -1
- package/dist/_chunks-es/spinner.js +16 -0
- package/dist/_chunks-es/spinner.js.map +1 -0
- package/dist/_chunks-es/watch.js +115 -9
- package/dist/_chunks-es/watch.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.d.cts +421 -487
- package/dist/index.d.ts +421 -487
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/dist/_chunks-cjs/findConfigFile.cjs +0 -24
- package/dist/_chunks-cjs/findConfigFile.cjs.map +0 -1
- package/dist/_chunks-cjs/index2.cjs +0 -781
- package/dist/_chunks-cjs/index2.cjs.map +0 -1
- package/dist/_chunks-cjs/index3.cjs +0 -50
- package/dist/_chunks-cjs/index3.cjs.map +0 -1
- package/dist/_chunks-cjs/printPackageTree.cjs +0 -42
- package/dist/_chunks-cjs/printPackageTree.cjs.map +0 -1
- package/dist/_chunks-cjs/resolveBuildContext.cjs +0 -176
- package/dist/_chunks-cjs/resolveBuildContext.cjs.map +0 -1
- package/dist/_chunks-cjs/resolveBuildTasks.cjs +0 -111
- package/dist/_chunks-cjs/resolveBuildTasks.cjs.map +0 -1
- package/dist/_chunks-cjs/resolveConfigProperty.cjs +0 -6
- package/dist/_chunks-cjs/resolveConfigProperty.cjs.map +0 -1
- package/dist/_chunks-cjs/resolveWatchTasks.cjs +0 -79
- package/dist/_chunks-cjs/resolveWatchTasks.cjs.map +0 -1
- package/dist/_chunks-cjs/template.cjs +0 -446
- package/dist/_chunks-cjs/template.cjs.map +0 -1
- package/dist/_chunks-cjs/validatePkg.cjs +0 -71
- package/dist/_chunks-cjs/validatePkg.cjs.map +0 -1
- package/dist/_chunks-cjs/watchConfigFiles.cjs +0 -59
- package/dist/_chunks-cjs/watchConfigFiles.cjs.map +0 -1
- package/dist/_chunks-es/fileExists.js +0 -12
- package/dist/_chunks-es/fileExists.js.map +0 -1
- package/dist/_chunks-es/findConfigFile.js +0 -23
- package/dist/_chunks-es/findConfigFile.js.map +0 -1
- package/dist/_chunks-es/index2.js +0 -769
- package/dist/_chunks-es/index2.js.map +0 -1
- package/dist/_chunks-es/index3.js +0 -51
- package/dist/_chunks-es/index3.js.map +0 -1
- package/dist/_chunks-es/loadPkgWithReporting.js +0 -100
- package/dist/_chunks-es/loadPkgWithReporting.js.map +0 -1
- package/dist/_chunks-es/logger.js.map +0 -1
- package/dist/_chunks-es/printPackageTree.js +0 -44
- package/dist/_chunks-es/printPackageTree.js.map +0 -1
- package/dist/_chunks-es/resolveBuildContext.js +0 -177
- package/dist/_chunks-es/resolveBuildContext.js.map +0 -1
- package/dist/_chunks-es/resolveBuildTasks.js +0 -109
- package/dist/_chunks-es/resolveBuildTasks.js.map +0 -1
- package/dist/_chunks-es/resolveConfigProperty.js +0 -7
- package/dist/_chunks-es/resolveConfigProperty.js.map +0 -1
- package/dist/_chunks-es/resolveWatchTasks.js +0 -77
- package/dist/_chunks-es/resolveWatchTasks.js.map +0 -1
- package/dist/_chunks-es/template.js +0 -449
- package/dist/_chunks-es/template.js.map +0 -1
- package/dist/_chunks-es/validatePkg.js +0 -72
- package/dist/_chunks-es/validatePkg.js.map +0 -1
- package/dist/_chunks-es/watchConfigFiles.js +0 -45
- package/dist/_chunks-es/watchConfigFiles.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveBuildContext.js","sources":["../../node_modules/.pnpm/browserslist-to-esbuild@2.1.1_browserslist@4.25.0/node_modules/browserslist-to-esbuild/src/index.js","../../src/node/core/findCommonPath.ts","../../src/node/core/ts/loadTSConfig.ts","../../src/node/resolveBrowserTarget.ts","../../src/node/resolveNodeTarget.ts","../../src/node/resolveBuildContext.ts"],"sourcesContent":["import browserslist from 'browserslist'\n\n// convert the browserslist field in package.json to\n// esbuild compatible array of browsers\nexport default function browserslistToEsbuild(browserslistConfig, options = {}) {\n if (!browserslistConfig) {\n // the path from where the script is run\n const path = process.cwd()\n\n // read config if none is passed\n browserslistConfig = browserslist.loadConfig({ path, ...options })\n }\n\n const SUPPORTED_ESBUILD_TARGETS = [\n 'es',\n 'chrome',\n 'edge',\n 'firefox',\n 'ios',\n 'node',\n 'safari',\n 'opera',\n 'ie',\n ]\n\n // https://github.com/eBay/browserslist-config/issues/16#issuecomment-863870093\n const UNSUPPORTED = ['android 4']\n\n const replaces = {\n ios_saf: 'ios',\n android: 'chrome',\n }\n\n const separator = ' '\n\n return (\n browserslist(browserslistConfig, options)\n // filter out the unsupported ones\n .filter((b) => !UNSUPPORTED.some((u) => b.startsWith(u)))\n // replaces safari TP with latest safari version\n .map((b) => {\n if (b === 'safari TP') {\n return browserslist('last 1 safari version')[0]\n }\n\n return b\n })\n // transform into ['chrome', '88']\n .map((b) => b.split(separator))\n // replace the similar browser\n .map((b) => {\n if (replaces[b[0]]) {\n b[0] = replaces[b[0]]\n }\n\n return b\n })\n // 11.0-12.0 --> 11.0\n .map((b) => {\n if (b[1].includes('-')) {\n b[1] = b[1].slice(0, b[1].indexOf('-'))\n }\n\n return b\n })\n // 11.0 --> 11\n .map((b) => {\n if (b[1].endsWith('.0')) {\n b[1] = b[1].slice(0, -2)\n }\n\n return b\n })\n // removes invalid versions that will break esbuild\n // https://github.com/evanw/esbuild/blob/35c0d65b9d4f29a26176404d2890d1b499634e9f/compat-table/src/caniuse.ts#L119-L122\n .filter((b) => /^\\d+(\\.\\d+)*$/.test(b[1]))\n // only get the targets supported by esbuild\n .filter((b) => SUPPORTED_ESBUILD_TARGETS.includes(b[0]))\n // only get the oldest version, assuming that the older version\n // is last in the array\n .reduce((acc, b) => {\n const existingIndex = acc.findIndex((br) => br[0] === b[0])\n\n if (existingIndex !== -1) {\n acc[existingIndex][1] = b[1]\n } else {\n acc.push(b)\n }\n return acc\n }, [])\n // remove separator\n .map((b) => b.join(''))\n )\n}\n","import path from 'node:path'\n\nexport function pathContains(containerPath: string, itemPath: string): boolean {\n return !path.relative(containerPath, itemPath).startsWith('..')\n}\n\nexport function findCommonDirPath(filePaths: string[]): string | undefined {\n let ret: string | undefined = undefined\n\n for (const filePath of filePaths) {\n let dirPath = path.dirname(filePath)\n\n if (!ret) {\n ret = dirPath\n continue\n }\n\n while (dirPath !== ret) {\n dirPath = path.dirname(dirPath)\n\n if (dirPath === ret) {\n break\n }\n\n if (pathContains(dirPath, ret)) {\n ret = dirPath\n break\n }\n\n if (dirPath === '.') return undefined\n }\n }\n\n return ret\n}\n","import ts from 'typescript'\n\n/** @internal */\nexport async function loadTSConfig(options: {\n cwd: string\n tsconfigPath: string\n}): Promise<ts.ParsedCommandLine | undefined> {\n const {cwd, tsconfigPath} = options\n\n const configPath = ts.findConfigFile(cwd, ts.sys.fileExists, tsconfigPath)\n\n if (!configPath) {\n return undefined\n }\n\n const configFile = ts.readConfigFile(configPath, ts.sys.readFile)\n\n return ts.parseJsonConfigFileContent(configFile.config, ts.sys, cwd)\n}\n","export function resolveBrowserTarget(versions: string[]): string[] | undefined {\n const target: string[] = versions.filter(\n (version) =>\n version.startsWith('chrome') ||\n version.startsWith('edge') ||\n version.startsWith('firefox') ||\n version.startsWith('ios') ||\n version.startsWith('safari') ||\n version.startsWith('opera'),\n )\n\n if (target.length === 0) {\n return undefined\n }\n\n return target\n}\n","export function resolveNodeTarget(versions: string[]): string[] | undefined {\n const target: string[] = versions.filter((version) => version.startsWith('node'))\n\n if (target.length === 0) {\n return undefined\n }\n\n return target\n}\n","import path from 'node:path'\nimport browserslistToEsbuild from 'browserslist-to-esbuild'\nimport {resolveConfigProperty} from './core/config/resolveConfigProperty'\nimport {type PkgConfigOptions, type PkgExports, type PkgRuntime} from './core/config/types'\nimport type {BuildContext} from './core/contexts/buildContext'\nimport {DEFAULT_BROWSERSLIST_QUERY} from './core/defaults'\nimport {findCommonDirPath, pathContains} from './core/findCommonPath'\nimport {parseExports} from './core/pkg/parseExports'\nimport type {PackageJSON} from './core/pkg/types'\nimport {loadTSConfig} from './core/ts/loadTSConfig'\nimport type {Logger} from './logger'\nimport {resolveBrowserTarget} from './resolveBrowserTarget'\nimport {resolveNodeTarget} from './resolveNodeTarget'\nimport {parseStrictOptions} from './strict'\n\nexport async function resolveBuildContext(options: {\n config?: PkgConfigOptions\n cwd: string\n emitDeclarationOnly?: boolean\n logger: Logger\n pkg: PackageJSON\n strict: boolean\n tsconfig: string\n}): Promise<BuildContext> {\n const {\n config,\n cwd,\n emitDeclarationOnly = false,\n logger,\n pkg,\n strict,\n tsconfig: tsconfigPath,\n } = options\n const tsconfig = await loadTSConfig({cwd, tsconfigPath})\n const strictOptions = parseStrictOptions(config?.strictOptions ?? {})\n\n let browserslist = pkg.browserslist\n if (!browserslist) {\n if (strict && strictOptions.noImplicitBrowsersList !== 'off') {\n if (strictOptions.noImplicitBrowsersList === 'error') {\n throw new Error(\n '\\n- ' +\n `package.json: \"browserslist\" is missing, set it to \\`\"browserslist\": \"extends @sanity/browserslist-config\"\\``,\n )\n } else {\n logger.warn(\n 'Could not detect a `browserslist` property in `package.json`, using default configuration. Add `\"browserslist\": \"extends @sanity/browserslist-config\"` to silence this warning.',\n )\n }\n }\n browserslist = DEFAULT_BROWSERSLIST_QUERY\n }\n const targetVersions = browserslistToEsbuild(browserslist)\n\n if (\n strict &&\n strictOptions.noImplicitSideEffects !== 'off' &&\n typeof pkg.sideEffects === 'undefined'\n ) {\n const msg =\n 'package.json: `sideEffects` is missing, see https://webpack.js.org/guides/tree-shaking/#clarifying-tree-shaking-and-sideeffects for how to define `sideEffects`'\n\n if (strictOptions.noImplicitSideEffects === 'error') {\n throw new Error(msg)\n } else {\n logger.warn(msg)\n }\n }\n\n const nodeTarget = resolveNodeTarget(targetVersions)\n const webTarget = resolveBrowserTarget(targetVersions)\n\n if (!nodeTarget) {\n throw new Error('no matching `node` target')\n }\n\n if (!webTarget) {\n throw new Error('no matching `web` target')\n }\n\n const target: Record<PkgRuntime, string[]> = {\n '*': webTarget.concat(nodeTarget),\n 'browser': webTarget,\n 'node': nodeTarget,\n }\n\n const parsedExports = parseExports({\n cwd,\n pkg,\n strict,\n strictOptions,\n logger,\n }).reduce<PkgExports>(\n (acc, {_path: exportPath, ...exportEntry}) => Object.assign(acc, {[exportPath]: exportEntry}),\n {},\n )\n\n const exports = resolveConfigProperty(config?.exports, parsedExports)\n\n const parsedExternal = [\n ...(pkg.dependencies ? Object.keys(pkg.dependencies) : []),\n ...(pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : []),\n ]\n\n // Merge externals if an array is provided, replace if it's a function\n const external =\n config && Array.isArray(config.external)\n ? [...parsedExternal, ...config.external]\n : resolveConfigProperty(config?.external, parsedExternal)\n // Merge bundledPackages with dev deps, replace if it's a function\n const externalWithTypes = new Set([pkg.name, ...external, ...external.map(transformPackageName)])\n const bundledDependencies = (pkg.devDependencies ? Object.keys(pkg.devDependencies) : []).filter(\n // Do not bundle anything that is marked as external\n (_) => !externalWithTypes.has(_),\n )\n const bundledPackages =\n config && Array.isArray(config.extract?.bundledPackages)\n ? [...bundledDependencies, ...config.extract.bundledPackages]\n : resolveConfigProperty(config?.extract?.bundledPackages, bundledDependencies)\n\n const outputPaths = Object.values(exports)\n .flatMap((exportEntry) => {\n return [\n exportEntry.import,\n exportEntry.require,\n exportEntry.browser?.import,\n exportEntry.browser?.require,\n exportEntry.node?.source && exportEntry.node.import,\n exportEntry.node?.source && exportEntry.node.require,\n ].filter(Boolean) as string[]\n })\n .map((p) => path.resolve(cwd, p))\n\n const commonDistPath = findCommonDirPath(outputPaths)\n\n if (commonDistPath === cwd) {\n throw new Error(\n 'all output files must share a common parent directory which is not the root package directory',\n )\n }\n\n if (commonDistPath && !pathContains(cwd, commonDistPath)) {\n throw new Error('all output files must be located within the package')\n }\n\n const configDistPath = config?.dist ? path.resolve(cwd, config.dist) : undefined\n\n if (\n configDistPath &&\n commonDistPath &&\n configDistPath !== commonDistPath &&\n !pathContains(configDistPath, commonDistPath)\n ) {\n logger.log(`did you mean to configure \\`dist: './${path.relative(cwd, commonDistPath)}'\\`?`)\n\n throw new Error('all output files must be located with the configured `dist` path')\n }\n\n const distPath = configDistPath || commonDistPath\n\n if (!distPath) {\n throw new Error('could not detect `dist` path')\n }\n\n const ctx: BuildContext = {\n config,\n cwd,\n distPath,\n emitDeclarationOnly,\n exports,\n external,\n bundledPackages,\n files: [],\n logger,\n pkg,\n runtime: config?.runtime ?? '*',\n strict,\n target,\n ts: {\n config: tsconfig,\n configPath: tsconfigPath,\n },\n dts: config?.dts === 'rolldown' ? 'rolldown' : 'api-extractor',\n }\n\n return ctx\n}\n\nfunction transformPackageName(packageName: string): string {\n if (packageName.startsWith('@types/')) {\n // If it already starts with @types, return it as is\n return packageName\n } else if (packageName.startsWith('@')) {\n // Handle scoped packages\n const [scope, name] = packageName.split('/')\n\n return `@types/${scope.slice(1)}__${name}`\n } else {\n // Handle regular packages\n return `@types/${packageName}`\n }\n}\n"],"names":["path","browserslist"],"mappings":";;;;;AAIe,SAAS,sBAAsB,oBAAoB,UAAU,IAAI;AAC9E,MAAI,CAAC,oBAAoB;AAEvB,UAAMA,QAAO,QAAQ,IAAG;AAGxB,yBAAqB,aAAa,WAAW,EA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AEvE,MACE,kBACA,kBACA,mBAAmB,kBACnB,CAAC,aAAa,gBAAgB,cAAc;AAErC,UAAA,OAAA,IAAI,wCAAwC,KAAK,SAAS,KAAK,cAAc,CAAC,MAAM,GAErF,IAAI,MAAM,kEAAkE;AAGpF,QAAM,WAAW,kBAAkB;AAEnC,MAAI,CAAC;AACG,UAAA,IAAI,MAAM,8BAA8B;AAGtB,SAAA;AAAA,IACxB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,CAAC;AAAA,IACR;AAAA,IACA;AAAA,IACA,SAAS,QAAQ,WAAW;AAAA,IAC5B;AAAA,IACA;AAAA,IACA,IAAI;AAAA,MACF,QAAQ;AAAA,MACR,YAAY;AAAA,IACd;AAAA,IACA,KAAK,QAAQ,QAAQ,aAAa,aAAa;AAAA,EACjD;AAGF;AAEA,SAAS,qBAAqB,aAA6B;AACrD,MAAA,YAAY,WAAW,SAAS;AAE3B,WAAA;AACE,MAAA,YAAY,WAAW,GAAG,GAAG;AAEtC,UAAM,CAAC,OAAO,IAAI,IAAI,YAAY,MAAM,GAAG;AAE3C,WAAO,UAAU,MAAM,MAAM,CAAC,CAAC,KAAK,IAAI;AAAA,EAC1C;AAEE,WAAO,UAAU,WAAW;AAEhC;","x_google_ignoreList":[0]}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { getTargetPaths } from "./index.js";
|
|
3
|
-
function resolveBuildTasks(ctx) {
|
|
4
|
-
const { config, pkg, target } = ctx, bundles = config?.bundles || [], tasks = [], exports = Object.entries(ctx.exports || {}).map(
|
|
5
|
-
([_path, exp]) => ({ _path, ...exp })
|
|
6
|
-
), dtsTask = {
|
|
7
|
-
type: "build:dts",
|
|
8
|
-
entries: []
|
|
9
|
-
}, rolldownDtsTask = {}, rollupTasks = {};
|
|
10
|
-
function addRollupTaskEntry(format, runtime, entry) {
|
|
11
|
-
const buildId = `${format}:${runtime}`;
|
|
12
|
-
ctx.dts === "rolldown" && (rolldownDtsTask[buildId] ? rolldownDtsTask[buildId].entries.push(entry) : rolldownDtsTask[buildId] = {
|
|
13
|
-
type: "rolldown:dts",
|
|
14
|
-
buildId,
|
|
15
|
-
entries: [entry],
|
|
16
|
-
runtime,
|
|
17
|
-
format,
|
|
18
|
-
target: target[runtime]
|
|
19
|
-
}), ctx.emitDeclarationOnly || (rollupTasks[buildId] ? rollupTasks[buildId].entries.push(entry) : rollupTasks[buildId] = {
|
|
20
|
-
type: "build:js",
|
|
21
|
-
buildId,
|
|
22
|
-
entries: [entry],
|
|
23
|
-
runtime,
|
|
24
|
-
format,
|
|
25
|
-
target: target[runtime]
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
if (ctx.dts === "api-extractor") {
|
|
29
|
-
for (const exp of exports) {
|
|
30
|
-
const importId = path.join(pkg.name, exp._path);
|
|
31
|
-
exp.source?.endsWith(".ts") && dtsTask.entries.push({
|
|
32
|
-
importId,
|
|
33
|
-
exportPath: exp._path,
|
|
34
|
-
sourcePath: exp.source,
|
|
35
|
-
targetPaths: getTargetPaths(pkg.type, exp)
|
|
36
|
-
}), exp.browser?.source?.endsWith(".ts") && dtsTask.entries.push({
|
|
37
|
-
importId,
|
|
38
|
-
exportPath: exp._path,
|
|
39
|
-
sourcePath: exp.browser.source,
|
|
40
|
-
targetPaths: getTargetPaths(pkg.type, exp.browser)
|
|
41
|
-
}), exp.node?.source?.endsWith(".ts") && dtsTask.entries.push({
|
|
42
|
-
importId,
|
|
43
|
-
exportPath: exp._path,
|
|
44
|
-
sourcePath: exp.node.source,
|
|
45
|
-
targetPaths: getTargetPaths(pkg.type, exp.node)
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
for (const bundle of bundles)
|
|
49
|
-
if (bundle.source?.endsWith(".ts")) {
|
|
50
|
-
const exportPath = (bundle.import || bundle.require).replace(/\.[mc]?js$/, ""), importId = path.join(pkg.name, exportPath);
|
|
51
|
-
dtsTask.entries.push({
|
|
52
|
-
importId,
|
|
53
|
-
exportPath,
|
|
54
|
-
sourcePath: bundle.source,
|
|
55
|
-
targetPaths: getTargetPaths(pkg.type, bundle)
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
dtsTask.entries.length && tasks.push(dtsTask);
|
|
59
|
-
}
|
|
60
|
-
for (const exp of exports) {
|
|
61
|
-
const output = exp.require;
|
|
62
|
-
output && addRollupTaskEntry("commonjs", ctx.runtime, {
|
|
63
|
-
path: exp._path,
|
|
64
|
-
source: exp.source,
|
|
65
|
-
output
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
for (const exp of exports) {
|
|
69
|
-
const output = exp.import;
|
|
70
|
-
output && addRollupTaskEntry("esm", ctx.runtime, {
|
|
71
|
-
path: exp._path,
|
|
72
|
-
source: exp.source,
|
|
73
|
-
output
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
for (const exp of exports) {
|
|
77
|
-
const output = exp.browser?.require;
|
|
78
|
-
output && addRollupTaskEntry("commonjs", "browser", {
|
|
79
|
-
path: exp._path,
|
|
80
|
-
source: exp.browser?.source || exp.source,
|
|
81
|
-
output
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
for (const exp of exports) {
|
|
85
|
-
const output = exp.browser?.import;
|
|
86
|
-
output && addRollupTaskEntry("esm", "browser", {
|
|
87
|
-
path: exp._path,
|
|
88
|
-
source: exp.browser?.source || exp.source,
|
|
89
|
-
output
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
for (const bundle of bundles) {
|
|
93
|
-
const idx = bundles.indexOf(bundle);
|
|
94
|
-
bundle.require && addRollupTaskEntry("commonjs", bundle.runtime || ctx.runtime, {
|
|
95
|
-
path: `__$$bundle_cjs_${idx}$$__`,
|
|
96
|
-
source: bundle.source,
|
|
97
|
-
output: bundle.require
|
|
98
|
-
}), bundle.import && addRollupTaskEntry("esm", bundle.runtime || ctx.runtime, {
|
|
99
|
-
path: `__$$bundle_esm_${idx}$$__`,
|
|
100
|
-
source: bundle.source,
|
|
101
|
-
output: bundle.import
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
return tasks.push(...Object.values(rolldownDtsTask)), tasks.push(...Object.values(rollupTasks)), tasks;
|
|
105
|
-
}
|
|
106
|
-
export {
|
|
107
|
-
resolveBuildTasks
|
|
108
|
-
};
|
|
109
|
-
//# sourceMappingURL=resolveBuildTasks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveBuildTasks.js","sources":["../../src/node/resolveBuildTasks.ts"],"sourcesContent":["import path from 'node:path'\nimport type {PkgExport, PkgFormat, PkgRuntime} from './core/config/types'\nimport type {BuildContext} from './core/contexts/buildContext'\nimport {getTargetPaths} from './tasks/dts/getTargetPaths'\nimport type {DtsTask} from './tasks/dts/types'\nimport type {BuildTask, RolldownDtsTask, RollupTask, RollupTaskEntry} from './tasks/types'\n\n/** @internal */\nexport function resolveBuildTasks(ctx: BuildContext): BuildTask[] {\n const {config, pkg, target} = ctx\n\n const bundles = config?.bundles || []\n\n const tasks: BuildTask[] = []\n\n const exports = Object.entries(ctx.exports || {}).map(\n ([_path, exp]) => ({_path, ...exp}) as PkgExport & {_path: string},\n )\n\n const dtsTask: DtsTask = {\n type: 'build:dts',\n entries: [],\n }\n\n const rolldownDtsTask: Record<string, RolldownDtsTask> = {}\n const rollupTasks: Record<string, RollupTask> = {}\n\n function addRollupTaskEntry(format: PkgFormat, runtime: PkgRuntime, entry: RollupTaskEntry) {\n const buildId = `${format}:${runtime}`\n\n if (ctx.dts === 'rolldown') {\n if (rolldownDtsTask[buildId]) {\n rolldownDtsTask[buildId].entries.push(entry)\n } else {\n rolldownDtsTask[buildId] = {\n type: 'rolldown:dts',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n\n if (!ctx.emitDeclarationOnly) {\n if (rollupTasks[buildId]) {\n rollupTasks[buildId].entries.push(entry)\n } else {\n rollupTasks[buildId] = {\n type: 'build:js',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n }\n\n if (ctx.dts === 'api-extractor') {\n // Parse `dts` tasks\n for (const exp of exports) {\n const importId = path.join(pkg.name, exp._path)\n\n if (exp.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.source,\n targetPaths: getTargetPaths(pkg.type, exp),\n })\n }\n\n if (exp.browser?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.browser.source,\n targetPaths: getTargetPaths(pkg.type, exp.browser),\n })\n }\n\n if (exp.node?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.node.source,\n targetPaths: getTargetPaths(pkg.type, exp.node),\n })\n }\n }\n\n // Handle dts tasks for bundles\n for (const bundle of bundles) {\n if (bundle.source?.endsWith('.ts')) {\n // importId needs to be how the bundle is used, like `@sanity/pkg-utils/dist/cli`\n // exportPath needs to be the path to the bundle, like `./dist/cli`\n // targetPaths is then: [./dist/cli.d.ts, ./dist/cli.d.cts]\n const exportPath = (bundle.import || bundle.require)!.replace(/\\.[mc]?js$/, '')\n const importId = path.join(pkg.name, exportPath)\n\n dtsTask.entries.push({\n importId,\n exportPath,\n sourcePath: bundle.source,\n targetPaths: getTargetPaths(pkg.type, bundle),\n })\n }\n }\n\n // Add dts task\n if (dtsTask.entries.length) {\n tasks.push(dtsTask)\n }\n }\n\n // Parse rollup:commonjs:* tasks\n for (const exp of exports) {\n const output = exp.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:* tasks\n for (const exp of exports) {\n const output = exp.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:commonjs:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n for (const bundle of bundles) {\n const idx = bundles.indexOf(bundle)\n\n if (bundle.require) {\n addRollupTaskEntry('commonjs', bundle.runtime || ctx.runtime, {\n path: `__$$bundle_cjs_${idx}$$__`,\n source: bundle.source,\n output: bundle.require,\n })\n }\n\n if (bundle.import) {\n addRollupTaskEntry('esm', bundle.runtime || ctx.runtime, {\n path: `__$$bundle_esm_${idx}$$__`,\n source: bundle.source,\n output: bundle.import,\n })\n }\n }\n\n // Perform rolldown dts tasks first, as they have special logic for removing non .d.ts chunks\n tasks.push(...Object.values(rolldownDtsTask))\n // Then run api-extractor tsdoc release tag checking (if rolldown is used for dts bundling, otherwise api-extractor performs both in the build:dts task)\n // @TODO\n // Then run rollup tasks\n tasks.push(...Object.values(rollupTasks))\n\n return tasks\n}\n"],"names":[],"mappings":";;AAQO,SAAS,kBAAkB,KAAgC;AAC1D,QAAA,EAAC,QAAQ,KAAK,OAAA,IAAU,KAExB,UAAU,QAAQ,WAAW,CAAA,GAE7B,QAAqB,IAErB,UAAU,OAAO,QAAQ,IAAI,WAAW,CAAE,CAAA,EAAE;AAAA,IAChD,CAAC,CAAC,OAAO,GAAG,OAAO,EAAC,OAAO,GAAG,IAAG;AAAA,KAG7B,UAAmB;AAAA,IACvB,MAAM;AAAA,IACN,SAAS,CAAA;AAAA,EAAC,GAGN,kBAAmD,IACnD,cAA0C,CAAC;AAExC,WAAA,mBAAmB,QAAmB,SAAqB,OAAwB;AAC1F,UAAM,UAAU,GAAG,MAAM,IAAI,OAAO;AAEhC,QAAI,QAAQ,eACV,gBAAgB,OAA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GAGC,OAAO,UACT,mBAAmB,OAAO,OAAO,WAAW,IAAI,SAAS;AAAA,MACvD,MAAM,kBAAkB,GAAG;AAAA,MAC3B,QAAQ,OAAO;AAAA,MACf,QAAQ,OAAO;AAAA,IAAA,CAChB;AAAA,EAAA;AAKL,SAAA,MAAM,KAAK,GAAG,OAAO,OAAO,eAAe,CAAC,GAI5C,MAAM,KAAK,GAAG,OAAO,OAAO,WAAW,CAAC,GAEjC;AACT;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveConfigProperty.js","sources":["../../src/node/core/config/resolveConfigProperty.ts"],"sourcesContent":["import type {PkgConfigProperty, PkgConfigPropertyResolver} from './types'\n\n/** @internal */\nexport function resolveConfigProperty<T>(\n prop: PkgConfigProperty<T> | undefined,\n initialValue: T,\n): T {\n if (!prop) return initialValue\n\n if (typeof prop === 'function') {\n return (prop as PkgConfigPropertyResolver<T>)(initialValue)\n }\n\n return prop\n}\n"],"names":[],"mappings":"AAGgB,SAAA,sBACd,MACA,cACG;AACH,SAAK,OAED,OAAO,QAAS,aACV,KAAsC,YAAY,IAGrD,OANW;AAOpB;"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { getTargetPaths } from "./index.js";
|
|
3
|
-
function resolveWatchTasks(ctx) {
|
|
4
|
-
const { pkg, target } = ctx, tasks = [], exports = Object.entries(ctx.exports || {}).map(
|
|
5
|
-
([_path, exp]) => ({ _path, ...exp })
|
|
6
|
-
), dtsTask = {
|
|
7
|
-
type: "watch:dts",
|
|
8
|
-
entries: []
|
|
9
|
-
}, rollupTasks = {};
|
|
10
|
-
function addRollupTaskEntry(format, runtime, entry) {
|
|
11
|
-
const buildId = `${format}:${runtime}`;
|
|
12
|
-
rollupTasks[buildId] ? rollupTasks[buildId].entries.push(entry) : rollupTasks[buildId] = {
|
|
13
|
-
type: "watch:js",
|
|
14
|
-
buildId,
|
|
15
|
-
entries: [entry],
|
|
16
|
-
runtime,
|
|
17
|
-
format,
|
|
18
|
-
target: target[runtime]
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
for (const exp of exports) {
|
|
22
|
-
const importId = path.join(pkg.name, exp._path);
|
|
23
|
-
exp.source?.endsWith(".ts") && dtsTask.entries.push({
|
|
24
|
-
importId,
|
|
25
|
-
exportPath: exp._path,
|
|
26
|
-
sourcePath: exp.source,
|
|
27
|
-
targetPaths: getTargetPaths(pkg.type, exp)
|
|
28
|
-
}), exp.browser?.source?.endsWith(".ts") && dtsTask.entries.push({
|
|
29
|
-
importId,
|
|
30
|
-
exportPath: exp._path,
|
|
31
|
-
sourcePath: exp.browser.source,
|
|
32
|
-
targetPaths: getTargetPaths(pkg.type, exp.browser)
|
|
33
|
-
}), exp.node?.source?.endsWith(".ts") && dtsTask.entries.push({
|
|
34
|
-
importId,
|
|
35
|
-
exportPath: exp._path,
|
|
36
|
-
sourcePath: exp.node.source,
|
|
37
|
-
targetPaths: getTargetPaths(pkg.type, exp.node)
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
for (const exp of exports) {
|
|
41
|
-
const output = exp.require;
|
|
42
|
-
output && addRollupTaskEntry("commonjs", ctx.runtime, {
|
|
43
|
-
path: exp._path,
|
|
44
|
-
source: exp.source,
|
|
45
|
-
output
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
for (const exp of exports) {
|
|
49
|
-
const output = exp.browser?.require;
|
|
50
|
-
output && addRollupTaskEntry("commonjs", "browser", {
|
|
51
|
-
path: exp._path,
|
|
52
|
-
source: exp.browser?.source || exp.source,
|
|
53
|
-
output
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
for (const exp of exports) {
|
|
57
|
-
const output = exp.import;
|
|
58
|
-
output && addRollupTaskEntry("esm", ctx.runtime, {
|
|
59
|
-
path: exp._path,
|
|
60
|
-
source: exp.source,
|
|
61
|
-
output
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
for (const exp of exports) {
|
|
65
|
-
const output = exp.browser?.import;
|
|
66
|
-
output && addRollupTaskEntry("esm", "browser", {
|
|
67
|
-
path: exp._path,
|
|
68
|
-
source: exp.browser?.source || exp.source,
|
|
69
|
-
output
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
return dtsTask.entries.length && tasks.push(dtsTask), tasks.push(...Object.values(rollupTasks)), tasks;
|
|
73
|
-
}
|
|
74
|
-
export {
|
|
75
|
-
resolveWatchTasks
|
|
76
|
-
};
|
|
77
|
-
//# sourceMappingURL=resolveWatchTasks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveWatchTasks.js","sources":["../../src/node/resolveWatchTasks.ts"],"sourcesContent":["import path from 'node:path'\nimport type {PkgExport, PkgFormat, PkgRuntime} from './core/config/types'\nimport type {BuildContext} from './core/contexts/buildContext'\nimport {getTargetPaths} from './tasks/dts/getTargetPaths'\nimport type {DtsWatchTask} from './tasks/dts/types'\nimport type {RollupTaskEntry, RollupWatchTask, WatchTask} from './tasks/types'\n\n/** @internal */\nexport function resolveWatchTasks(ctx: BuildContext): WatchTask[] {\n const {pkg, target} = ctx\n const tasks: WatchTask[] = []\n\n const exports = Object.entries(ctx.exports || {}).map(\n ([_path, exp]) => ({_path, ...exp}) as PkgExport & {_path: string},\n )\n\n const dtsTask: DtsWatchTask = {\n type: 'watch:dts',\n entries: [],\n }\n\n const rollupTasks: Record<string, RollupWatchTask> = {}\n\n function addRollupTaskEntry(format: PkgFormat, runtime: PkgRuntime, entry: RollupTaskEntry) {\n const buildId = `${format}:${runtime}`\n\n if (rollupTasks[buildId]) {\n rollupTasks[buildId].entries.push(entry)\n } else {\n rollupTasks[buildId] = {\n type: 'watch:js',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n\n // Parse `dts` tasks\n for (const exp of exports) {\n const importId = path.join(pkg.name, exp._path)\n\n if (exp.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.source,\n targetPaths: getTargetPaths(pkg.type, exp),\n })\n }\n\n if (exp.browser?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.browser.source,\n targetPaths: getTargetPaths(pkg.type, exp.browser),\n })\n }\n\n if (exp.node?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.node.source,\n targetPaths: getTargetPaths(pkg.type, exp.node),\n })\n }\n }\n\n // Parse rollup:commonjs:* tasks\n for (const exp of exports) {\n const output = exp.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:commonjs:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:* tasks\n for (const exp of exports) {\n const output = exp.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n if (dtsTask.entries.length) {\n tasks.push(dtsTask)\n }\n\n tasks.push(...Object.values(rollupTasks))\n\n return tasks\n}\n"],"names":[],"mappings":";;AAQO,SAAS,kBAAkB,KAAgC;AAChE,QAAM,EAAC,KAAK,OAAM,IAAI,KAChB,QAAqB,CAErB,GAAA,UAAU,OAAO,QAAQ,IAAI,WAAW,CAAA,CAAE,EAAE;AAAA,IAChD,CAAC,CAAC,OAAO,GAAG,OAAO,EAAC,OAAO,GAAG,IAAG;AAAA,KAG7B,UAAwB;AAAA,IAC5B,MAAM;AAAA,IACN,SAAS,CAA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