@sanity/pkg-utils 1.13.0 → 1.14.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/{build-36a16057.js → build-83c36253.js} +2 -2
- package/dist/_chunks/build-83c36253.js.map +1 -0
- package/dist/_chunks/{buildAction-d4c2a5d2.js → buildAction-19b87a46.js} +3 -3
- package/dist/_chunks/{buildAction-d4c2a5d2.js.map → buildAction-19b87a46.js.map} +1 -1
- package/dist/_chunks/{index-340fbb6a.js → index-33f2afe8.js} +40 -25
- package/dist/_chunks/index-33f2afe8.js.map +1 -0
- package/dist/_chunks/{watch-41c2ea71.js → watch-12e6eafa.js} +2 -2
- package/dist/_chunks/{watch-41c2ea71.js.map → watch-12e6eafa.js.map} +1 -1
- package/dist/_chunks/{watchAction-fea46c01.js → watchAction-d4ae9e80.js} +3 -3
- package/dist/_chunks/{watchAction-fea46c01.js.map → watchAction-d4ae9e80.js.map} +1 -1
- package/dist/cli.js +3 -3
- package/dist/index.d.ts +35 -1
- package/dist/index.esm.js +47 -33
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/node/_core/config/types.ts +10 -0
- package/src/node/_tasks/dts/_doExtract.ts +1 -0
- package/src/node/_tasks/dts/_extractTypes.ts +16 -85
- package/src/node/_tasks/dts/_getExtractMessagesConfig.ts +87 -0
- package/src/node/_tasks/dts/index.ts +1 -0
- package/src/node/_tasks/rollup/_resolveRollupConfig.ts +6 -1
- package/src/node/build.ts +19 -1
- package/dist/_chunks/build-36a16057.js.map +0 -1
- package/dist/_chunks/index-340fbb6a.js.map +0 -1
package/dist/index.esm.js
CHANGED
|
@@ -621,27 +621,17 @@ const _LOG_LEVELS = {
|
|
|
621
621
|
warn: "warning"
|
|
622
622
|
};
|
|
623
623
|
|
|
624
|
-
|
|
624
|
+
function _getExtractMessagesConfig(options) {
|
|
625
625
|
const {
|
|
626
|
-
|
|
627
|
-
exportPath,
|
|
628
|
-
files,
|
|
629
|
-
filePath,
|
|
630
|
-
projectPath,
|
|
631
|
-
rules,
|
|
632
|
-
sourceTypesPath,
|
|
633
|
-
tsconfigPath
|
|
626
|
+
rules
|
|
634
627
|
} = options;
|
|
635
|
-
const tsdocConfigFile = await _createTSDocConfig({
|
|
636
|
-
customTags: []
|
|
637
|
-
});
|
|
638
628
|
|
|
639
629
|
function _ruleToLogLevel(key, defaultLevel) {
|
|
640
630
|
const r = rules == null ? void 0 : rules[key];
|
|
641
631
|
return r ? _LOG_LEVELS[r] : defaultLevel || "warning";
|
|
642
632
|
}
|
|
643
633
|
|
|
644
|
-
|
|
634
|
+
return {
|
|
645
635
|
compilerMessageReporting: {
|
|
646
636
|
default: {
|
|
647
637
|
logLevel: "warning"
|
|
@@ -692,12 +682,31 @@ async function _extractTypes(options) {
|
|
|
692
682
|
}
|
|
693
683
|
}
|
|
694
684
|
};
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
async function _extractTypes(options) {
|
|
688
|
+
const {
|
|
689
|
+
customTags,
|
|
690
|
+
distPath,
|
|
691
|
+
exportPath,
|
|
692
|
+
files,
|
|
693
|
+
filePath,
|
|
694
|
+
projectPath,
|
|
695
|
+
rules,
|
|
696
|
+
sourceTypesPath,
|
|
697
|
+
tsconfigPath
|
|
698
|
+
} = options;
|
|
699
|
+
const tsdocConfigFile = await _createTSDocConfig({
|
|
700
|
+
customTags: customTags || []
|
|
701
|
+
});
|
|
695
702
|
const extractorConfig = ExtractorConfig.prepare({
|
|
696
703
|
configObject: _createApiExtractorConfig({
|
|
697
704
|
distPath,
|
|
698
705
|
exportPath,
|
|
699
706
|
filePath,
|
|
700
|
-
messages:
|
|
707
|
+
messages: _getExtractMessagesConfig({
|
|
708
|
+
rules
|
|
709
|
+
}),
|
|
701
710
|
projectFolder: projectPath,
|
|
702
711
|
mainEntryPointFilePath: sourceTypesPath,
|
|
703
712
|
tsconfigPath
|
|
@@ -737,7 +746,7 @@ async function _extractTypes(options) {
|
|
|
737
746
|
const rimraf = promisify(rimrafCallback);
|
|
738
747
|
|
|
739
748
|
async function _doExtract(ctx, task) {
|
|
740
|
-
var _a;
|
|
749
|
+
var _a, _b;
|
|
741
750
|
|
|
742
751
|
const {
|
|
743
752
|
config,
|
|
@@ -777,12 +786,13 @@ async function _doExtract(ctx, task) {
|
|
|
777
786
|
const sourceTypesPath = path.resolve(tmpPath, path.relative(rootDir, path.resolve(cwd, entry.sourcePath)).replace(/\.ts$/, ".d.ts"));
|
|
778
787
|
const targetPath = path.resolve(cwd, entry.targetPath);
|
|
779
788
|
const result = await _extractTypes({
|
|
789
|
+
customTags: (_a = config == null ? void 0 : config.extract) == null ? void 0 : _a.customTags,
|
|
780
790
|
cwd,
|
|
781
791
|
exportPath,
|
|
782
792
|
files,
|
|
783
793
|
filePath: path.relative(outDir, targetPath),
|
|
784
794
|
projectPath: cwd,
|
|
785
|
-
rules: (
|
|
795
|
+
rules: (_b = config == null ? void 0 : config.extract) == null ? void 0 : _b.rules,
|
|
786
796
|
sourceTypesPath,
|
|
787
797
|
tsconfigPath: path.resolve(cwd, ts.configPath || "tsconfig.json"),
|
|
788
798
|
distPath: outDir
|
|
@@ -869,7 +879,7 @@ const _dtsWatchTask = {
|
|
|
869
879
|
};
|
|
870
880
|
|
|
871
881
|
function _resolveRollupConfig(ctx, buildTask) {
|
|
872
|
-
var _ref2,
|
|
882
|
+
var _ref2, _ref5, _ref6, _ref7, _ref8, _ref9;
|
|
873
883
|
|
|
874
884
|
var _a, _b;
|
|
875
885
|
|
|
@@ -908,6 +918,10 @@ function _resolveRollupConfig(ctx, buildTask) {
|
|
|
908
918
|
|
|
909
919
|
const sourcePaths = _exports && Object.values(_exports).map(e => path.resolve(cwd, e.source));
|
|
910
920
|
|
|
921
|
+
const replacements = Object.fromEntries(Object.entries((config == null ? void 0 : config.define) || {}).map(_ref4 => {
|
|
922
|
+
let [key, val] = _ref4;
|
|
923
|
+
return [key, JSON.stringify(val)];
|
|
924
|
+
}));
|
|
911
925
|
return {
|
|
912
926
|
inputOptions: {
|
|
913
927
|
context: cwd,
|
|
@@ -948,7 +962,7 @@ function _resolveRollupConfig(ctx, buildTask) {
|
|
|
948
962
|
|
|
949
963
|
plugins: [replace({
|
|
950
964
|
preventAssignment: true,
|
|
951
|
-
values: _objectSpread({}, pkg.name === "@sanity/pkg-utils" ? {} : {
|
|
965
|
+
values: _objectSpread({}, pkg.name === "@sanity/pkg-utils" ? _objectSpread({}, replacements) : _objectSpread({
|
|
952
966
|
"process.env.PKG_FILE_PATH": arg => {
|
|
953
967
|
const sourcePath = "./" + path.relative(cwd, arg);
|
|
954
968
|
const entry = entries.find(e => e.source === sourcePath);
|
|
@@ -962,7 +976,7 @@ function _resolveRollupConfig(ctx, buildTask) {
|
|
|
962
976
|
"process.env.PKG_FORMAT": JSON.stringify(format),
|
|
963
977
|
"process.env.PKG_RUNTIME": JSON.stringify(runtime),
|
|
964
978
|
"process.env.PKG_VERSION": JSON.stringify(process.env.PKG_VERSION || pkg.version)
|
|
965
|
-
})
|
|
979
|
+
}, replacements))
|
|
966
980
|
}), alias({
|
|
967
981
|
entries: _objectSpread({}, pathAliases)
|
|
968
982
|
}), nodeResolve({
|
|
@@ -973,10 +987,10 @@ function _resolveRollupConfig(ctx, buildTask) {
|
|
|
973
987
|
esmExternals: false,
|
|
974
988
|
extensions: [".js"]
|
|
975
989
|
}), json(), esbuild({
|
|
976
|
-
jsx: (
|
|
977
|
-
jsxFactory: (
|
|
978
|
-
jsxFragment: (
|
|
979
|
-
jsxImportSource: (
|
|
990
|
+
jsx: (_ref5 = config == null ? void 0 : config.jsx) !== null && _ref5 !== void 0 ? _ref5 : "automatic",
|
|
991
|
+
jsxFactory: (_ref6 = config == null ? void 0 : config.jsxFactory) !== null && _ref6 !== void 0 ? _ref6 : "createElement",
|
|
992
|
+
jsxFragment: (_ref7 = config == null ? void 0 : config.jsxFragment) !== null && _ref7 !== void 0 ? _ref7 : "Fragment",
|
|
993
|
+
jsxImportSource: (_ref8 = config == null ? void 0 : config.jsxImportSource) !== null && _ref8 !== void 0 ? _ref8 : "react",
|
|
980
994
|
target,
|
|
981
995
|
tsconfig: ctx.ts.configPath || "tsconfig.json"
|
|
982
996
|
}), getBabelOutputPlugin({
|
|
@@ -1009,7 +1023,7 @@ function _resolveRollupConfig(ctx, buildTask) {
|
|
|
1009
1023
|
entryFileNames: () => outputExt === ".esm.js" ? "[name].js" : "[name]".concat(outputExt),
|
|
1010
1024
|
format,
|
|
1011
1025
|
exports: "auto",
|
|
1012
|
-
sourcemap: (
|
|
1026
|
+
sourcemap: (_ref9 = config == null ? void 0 : config.sourcemap) !== null && _ref9 !== void 0 ? _ref9 : true
|
|
1013
1027
|
}
|
|
1014
1028
|
};
|
|
1015
1029
|
}
|
|
@@ -1298,7 +1312,7 @@ function _createLogger() {
|
|
|
1298
1312
|
}
|
|
1299
1313
|
|
|
1300
1314
|
async function _resolveBuildContext(options) {
|
|
1301
|
-
var
|
|
1315
|
+
var _ref10;
|
|
1302
1316
|
|
|
1303
1317
|
const {
|
|
1304
1318
|
config,
|
|
@@ -1391,7 +1405,7 @@ async function _resolveBuildContext(options) {
|
|
|
1391
1405
|
files: [],
|
|
1392
1406
|
logger,
|
|
1393
1407
|
pkg,
|
|
1394
|
-
runtime: (
|
|
1408
|
+
runtime: (_ref10 = config == null ? void 0 : config.runtime) !== null && _ref10 !== void 0 ? _ref10 : "*",
|
|
1395
1409
|
target,
|
|
1396
1410
|
ts: {
|
|
1397
1411
|
config: tsconfig,
|
|
@@ -1511,11 +1525,11 @@ function _printPackageTree(ctx) {
|
|
|
1511
1525
|
return "".concat(file, " ").concat(chalk.gray(info.size));
|
|
1512
1526
|
}
|
|
1513
1527
|
|
|
1514
|
-
tree.exports = Object.fromEntries(Object.entries(exports).filter(
|
|
1515
|
-
let [, entry] =
|
|
1528
|
+
tree.exports = Object.fromEntries(Object.entries(exports).filter(_ref11 => {
|
|
1529
|
+
let [, entry] = _ref11;
|
|
1516
1530
|
return entry._exported;
|
|
1517
|
-
}).map(
|
|
1518
|
-
let [exportPath, entry] =
|
|
1531
|
+
}).map(_ref12 => {
|
|
1532
|
+
let [exportPath, entry] = _ref12;
|
|
1519
1533
|
const exp = {
|
|
1520
1534
|
source: entry.source,
|
|
1521
1535
|
types: void 0,
|
|
@@ -1713,8 +1727,8 @@ function _resolveWatchTasks(ctx) {
|
|
|
1713
1727
|
target
|
|
1714
1728
|
} = ctx;
|
|
1715
1729
|
const tasks = [];
|
|
1716
|
-
const exports = Object.entries(ctx.exports || {}).map(
|
|
1717
|
-
let [_path, exp] =
|
|
1730
|
+
const exports = Object.entries(ctx.exports || {}).map(_ref13 => {
|
|
1731
|
+
let [_path, exp] = _ref13;
|
|
1718
1732
|
return _objectSpread({
|
|
1719
1733
|
_path
|
|
1720
1734
|
}, exp);
|
|
@@ -1927,5 +1941,5 @@ async function watch(options) {
|
|
|
1927
1941
|
});
|
|
1928
1942
|
}
|
|
1929
1943
|
|
|
1930
|
-
export { _DEFAULTS, _MODULE_EXT, _buildTaskHandlers, _dtsTask, _dtsWatchTask, _isRecord, _loadConfig, _loadPkg, _loadPkgWithReporting, _loadTSConfig, _parseExports, _resolveBuildTasks, _resolveConfigProperty, _rollupTask, _rollupWatchTask, _watchTaskHandlers, build, check, defineConfig, watch };
|
|
1944
|
+
export { _DEFAULTS, _MODULE_EXT, _buildTaskHandlers, _dtsTask, _dtsWatchTask, _getExtractMessagesConfig, _isRecord, _loadConfig, _loadPkg, _loadPkgWithReporting, _loadTSConfig, _parseExports, _resolveBuildTasks, _resolveConfigProperty, _rollupTask, _rollupWatchTask, _watchTaskHandlers, build, check, defineConfig, watch };
|
|
1931
1945
|
//# sourceMappingURL=index.esm.js.map
|