@sanity/pkg-utils 1.20.2 → 1.20.4
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/{build-919c8216.js → build-f3246aa2.js} +16 -14
- package/dist/_chunks/build-f3246aa2.js.map +1 -0
- package/dist/_chunks/{buildAction-683ad943.js → buildAction-e3aabe6b.js} +5 -5
- package/dist/_chunks/{buildAction-683ad943.js.map → buildAction-e3aabe6b.js.map} +1 -1
- package/dist/_chunks/{check-1ea361f5.js → check-6c4e87a9.js} +24 -24
- package/dist/_chunks/check-6c4e87a9.js.map +1 -0
- package/dist/_chunks/{checkAction-16be1201.js → checkAction-abd2cc3d.js} +4 -4
- package/dist/_chunks/{checkAction-16be1201.js.map → checkAction-abd2cc3d.js.map} +1 -1
- package/dist/_chunks/handleError-4062ca45.js +17 -0
- package/dist/_chunks/{handleError-65cf3242.js.map → handleError-4062ca45.js.map} +1 -1
- package/dist/_chunks/{index-aa5deb01.js → index-b617f475.js} +95 -78
- package/dist/_chunks/index-b617f475.js.map +1 -0
- package/dist/_chunks/{resolveBuildContext-f2feec19.js → resolveBuildContext-904acf0f.js} +46 -45
- package/dist/_chunks/resolveBuildContext-904acf0f.js.map +1 -0
- package/dist/_chunks/{watch-24b814fa.js → watch-15eb636a.js} +21 -19
- package/dist/_chunks/{watch-24b814fa.js.map → watch-15eb636a.js.map} +1 -1
- package/dist/_chunks/{watchAction-f36fcd0b.js → watchAction-4d513a4c.js} +5 -5
- package/dist/_chunks/{watchAction-f36fcd0b.js.map → watchAction-4d513a4c.js.map} +1 -1
- package/dist/cli.js +8 -8
- package/dist/cli.js.map +1 -1
- package/dist/index.esm.js +38 -22
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +39 -39
- package/src/global.ts +6 -0
- package/src/node/core/config/loadConfig.ts +7 -9
- package/src/node/spinner.ts +1 -1
- package/src/node/tasks/rollup/resolveRollupConfig.ts +8 -8
- package/src/node/tasks/rollup/rollupTask.ts +23 -4
- package/dist/_chunks/build-919c8216.js.map +0 -1
- package/dist/_chunks/check-1ea361f5.js.map +0 -1
- package/dist/_chunks/handleError-65cf3242.js +0 -17
- package/dist/_chunks/index-aa5deb01.js.map +0 -1
- package/dist/_chunks/resolveBuildContext-f2feec19.js.map +0 -1
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sources":["../src/cli/index.ts"],"sourcesContent":["import cac from 'cac'\nimport {version} from '../../package.json'\n\nconst cli = cac()\n\n// default commands checks package status\ncli\n .command('', 'Check')\n .option('--strict', 'Strict mode')\n .option('--tsconfig [tsconfig]', '[string] tsconfig.json')\n .action(async (options) => {\n const {checkAction: statusAction} = await import('./checkAction')\n\n return statusAction(options)\n })\n\ncli\n .command('build', 'Build package')\n .option('--emitDeclarationOnly', 'Emit d.ts only')\n .option('--strict', 'Strict mode')\n .option('--tsconfig [tsconfig]', '[string] tsconfig.json')\n .action(async (options) => {\n const {buildAction} = await import('./buildAction')\n\n return buildAction(options)\n })\n\ncli\n .command('watch', 'Watch package')\n .option('--strict', 'Strict mode')\n .option('--tsconfig [tsconfig]', '[string] tsconfig.json')\n .action(async (options) => {\n const {watchAction} = await import('./watchAction')\n\n return watchAction(options)\n })\n\n// Display help message when `-h` or `--help` appears\ncli.help()\n\n// Display version number when `-v` or `--version` appears\n// It's also used in help message\ncli.version(version)\n\ncli.parse()\n"],"names":["cli","cac","command","option","action","options","checkAction","statusAction","Promise","resolve","then","require","buildAction","watchAction","help","version","parse"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"cli.js","sources":["../src/cli/index.ts"],"sourcesContent":["import cac from 'cac'\nimport {version} from '../../package.json'\n\nconst cli = cac()\n\n// default commands checks package status\ncli\n .command('', 'Check')\n .option('--strict', 'Strict mode')\n .option('--tsconfig [tsconfig]', '[string] tsconfig.json')\n .action(async (options) => {\n const {checkAction: statusAction} = await import('./checkAction')\n\n return statusAction(options)\n })\n\ncli\n .command('build', 'Build package')\n .option('--emitDeclarationOnly', 'Emit d.ts only')\n .option('--strict', 'Strict mode')\n .option('--tsconfig [tsconfig]', '[string] tsconfig.json')\n .action(async (options) => {\n const {buildAction} = await import('./buildAction')\n\n return buildAction(options)\n })\n\ncli\n .command('watch', 'Watch package')\n .option('--strict', 'Strict mode')\n .option('--tsconfig [tsconfig]', '[string] tsconfig.json')\n .action(async (options) => {\n const {watchAction} = await import('./watchAction')\n\n return watchAction(options)\n })\n\n// Display help message when `-h` or `--help` appears\ncli.help()\n\n// Display version number when `-v` or `--version` appears\n// It's also used in help message\ncli.version(version)\n\ncli.parse()\n"],"names":["cli","cac","default","command","option","action","options","checkAction","statusAction","Promise","resolve","then","require","buildAction","watchAction","help","version","parse"],"mappings":";;;;;;;;;;AAGA,MAAMA,MAAMC,YAAI,CAAAC,OAAA,EAAA;AAGhBF,GAAA,CACGG,OAAQ,CAAA,EAAA,EAAI,OAAO,CAAA,CACnBC,OAAO,UAAY,EAAA,aAAa,CAChC,CAAAA,MAAA,CAAO,uBAAyB,EAAA,wBAAwB,CACxD,CAAAC,MAAA,CAAO,MAAOC,OAAY,IAAA;EACzB,MAAM;IAACC,WAAA,EAAaC;EAAY,CAAA,GAAI,MAAMC,OAAA,CAAAC,OAAA,EAAA,CAAAC,IAAA,CAAA,YAAA;IAAA,OAAAC,OAAA,CAAO,mCAAA,CAAA;EAAA,CAAA,CAAA;EAEjD,OAAOJ,aAAaF,OAAO,CAAA;AAC7B,CAAC,CAAA;AAEHN,GAAA,CACGG,QAAQ,OAAS,EAAA,eAAe,EAChCC,MAAO,CAAA,uBAAA,EAAyB,gBAAgB,CAChD,CAAAA,MAAA,CAAO,UAAY,EAAA,aAAa,EAChCA,MAAO,CAAA,uBAAA,EAAyB,wBAAwB,CACxD,CAAAC,MAAA,CAAO,MAAOC,OAAY,IAAA;EACzB,MAAM;IAACO;EAAA,CAAe,GAAA,MAAMJ,OAAA,CAAAC,OAAA,EAAA,CAAAC,IAAA,CAAA,YAAA;IAAA,OAAAC,OAAA,CAAO,mCAAA,CAAA;EAAA,CAAA,CAAA;EAEnC,OAAOC,YAAYP,OAAO,CAAA;AAC5B,CAAC,CAAA;AAEHN,GAAA,CACGG,OAAQ,CAAA,OAAA,EAAS,eAAe,CAAA,CAChCC,OAAO,UAAY,EAAA,aAAa,CAChC,CAAAA,MAAA,CAAO,uBAAyB,EAAA,wBAAwB,CACxD,CAAAC,MAAA,CAAO,MAAOC,OAAY,IAAA;EACzB,MAAM;IAACQ;EAAA,CAAe,GAAA,MAAML,OAAA,CAAAC,OAAA,EAAA,CAAAC,IAAA,CAAA,YAAA;IAAA,OAAAC,OAAA,CAAO,mCAAA,CAAA;EAAA,CAAA,CAAA;EAEnC,OAAOE,YAAYR,OAAO,CAAA;AAC5B,CAAC,CAAA;AAGHN,GAAA,CAAIe,IAAK,EAAA;AAITf,GAAA,CAAIgB,QAAQA,OAAO,CAAA;AAEnBhB,GAAA,CAAIiB,KAAM,EAAA"}
|
package/dist/index.esm.js
CHANGED
|
@@ -3,7 +3,9 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
3
3
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
4
4
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
8
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
9
|
import path from 'path';
|
|
8
10
|
import { register } from 'esbuild-register/dist/node';
|
|
9
11
|
import pkgUp from 'pkg-up';
|
|
@@ -93,18 +95,17 @@ async function loadConfig(options) {
|
|
|
93
95
|
if (!configFile.startsWith(cwd)) {
|
|
94
96
|
return void 0;
|
|
95
97
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
98
|
+
const esbuildOptions = {
|
|
99
|
+
extensions: [".js", ".mjs", ".ts"]
|
|
100
|
+
};
|
|
101
|
+
const {
|
|
102
|
+
unregister
|
|
103
|
+
} = globalThis.__DEV__ ? {
|
|
104
|
+
unregister: () => void 0
|
|
105
|
+
} : register(esbuildOptions);
|
|
106
|
+
const mod = require(configFile);
|
|
107
|
+
unregister();
|
|
108
|
+
return (mod == null ? void 0 : mod.default) || mod || void 0;
|
|
108
109
|
}
|
|
109
110
|
function resolveConfigProperty(prop, initialValue) {
|
|
110
111
|
if (!prop) return initialValue;
|
|
@@ -862,7 +863,7 @@ function resolveRollupConfig(ctx, buildTask) {
|
|
|
862
863
|
console.error("could not find source entry: ".concat(sourcePath));
|
|
863
864
|
return "null";
|
|
864
865
|
}
|
|
865
|
-
return JSON.stringify(path.relative(cwd, path.resolve(outDir, entry.name + outputExt)));
|
|
866
|
+
return JSON.stringify(path.relative(cwd, path.resolve(outDir, entry.name + (outputExt === ".esm.js" ? ".js" : outputExt))));
|
|
866
867
|
},
|
|
867
868
|
"process.env.PKG_FORMAT": JSON.stringify(format),
|
|
868
869
|
"process.env.PKG_RUNTIME": JSON.stringify(runtime),
|
|
@@ -930,11 +931,6 @@ function resolveRollupConfig(ctx, buildTask) {
|
|
|
930
931
|
[entry.name]: entry.source
|
|
931
932
|
});
|
|
932
933
|
}, {}),
|
|
933
|
-
onwarn(warning, rollupWarn) {
|
|
934
|
-
if (!warning.code || !["CIRCULAR_DEPENDENCY"].includes(warning.code)) {
|
|
935
|
-
rollupWarn(warning);
|
|
936
|
-
}
|
|
937
|
-
},
|
|
938
934
|
plugins,
|
|
939
935
|
treeshake: {
|
|
940
936
|
propertyReadSideEffects: false
|
|
@@ -942,10 +938,13 @@ function resolveRollupConfig(ctx, buildTask) {
|
|
|
942
938
|
},
|
|
943
939
|
outputOptions: {
|
|
944
940
|
chunkFileNames: () => "_chunks/[name]-[hash]".concat(outputExt),
|
|
941
|
+
compact: minify,
|
|
945
942
|
dir: outDir,
|
|
946
943
|
entryFileNames: () => outputExt === ".esm.js" ? "[name].js" : "[name]".concat(outputExt),
|
|
944
|
+
esModule: true,
|
|
947
945
|
format,
|
|
948
|
-
|
|
946
|
+
interop: "compat",
|
|
947
|
+
minifyInternalExports: minify,
|
|
949
948
|
sourcemap: (_ref10 = config == null ? void 0 : config.sourcemap) !== null && _ref10 !== void 0 ? _ref10 : true
|
|
950
949
|
}
|
|
951
950
|
};
|
|
@@ -973,14 +972,31 @@ async function execPromise(ctx, task) {
|
|
|
973
972
|
distPath
|
|
974
973
|
} = ctx;
|
|
975
974
|
const outDir = path.relative(ctx.cwd, distPath);
|
|
975
|
+
const _console = {
|
|
976
|
+
log: console.log,
|
|
977
|
+
warn: console.warn,
|
|
978
|
+
error: console.error
|
|
979
|
+
};
|
|
976
980
|
const {
|
|
977
981
|
inputOptions,
|
|
978
982
|
outputOptions
|
|
979
983
|
} = resolveRollupConfig(ctx, task);
|
|
980
|
-
|
|
984
|
+
console.log = () => void 0;
|
|
985
|
+
console.warn = () => void 0;
|
|
986
|
+
console.error = () => void 0;
|
|
987
|
+
const bundle = await rollup(_objectSpread(_objectSpread({}, inputOptions), {}, {
|
|
988
|
+
onwarn(warning) {
|
|
989
|
+
if (!warning.code || !["CIRCULAR_DEPENDENCY"].includes(warning.code)) {
|
|
990
|
+
_console.warn.bind(console)(chalk.yellow("warn "), warning.message);
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
}));
|
|
981
994
|
const {
|
|
982
995
|
output
|
|
983
996
|
} = await bundle.generate(outputOptions);
|
|
997
|
+
console.log = _console.log;
|
|
998
|
+
console.warn = _console.warn;
|
|
999
|
+
console.error = _console.error;
|
|
984
1000
|
for (const chunkOrAsset of output) {
|
|
985
1001
|
if (chunkOrAsset.type === "asset") {
|
|
986
1002
|
files.push({
|
|
@@ -1275,7 +1291,7 @@ async function resolveBuildContext(options) {
|
|
|
1275
1291
|
}
|
|
1276
1292
|
function createSpinner(msg) {
|
|
1277
1293
|
const startTime = Date.now();
|
|
1278
|
-
console.log("".concat(
|
|
1294
|
+
console.log(" ".concat(msg));
|
|
1279
1295
|
return {
|
|
1280
1296
|
complete: () => {
|
|
1281
1297
|
console.log("".concat(chalk.green("ok "), " ").concat(chalk.gray("".concat(Date.now() - startTime, "ms"))));
|