pkgbld 1.25.0 → 1.26.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/index.js +44 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -658,7 +658,18 @@ async function getRollupConfigs([provider, plugins$1], inputs, config, helpers,
|
|
|
658
658
|
|
|
659
659
|
const mainLoggerText = (sourceDir, dir, configsCount, startingTime, finishedCount = 0) => (final = false) => `${sourceDir} → ${dir} ${final ? configsCount : finishedCount++} / ${configsCount}${final ? (' in ' + getTimeDiff(startingTime)) : ''}`;
|
|
660
660
|
|
|
661
|
+
const emptySet = new Set;
|
|
661
662
|
function processPackage(pkg, config, plugins) {
|
|
663
|
+
const exportsFields = new Set([
|
|
664
|
+
'types',
|
|
665
|
+
'import',
|
|
666
|
+
'require',
|
|
667
|
+
'svelte',
|
|
668
|
+
'default'
|
|
669
|
+
]);
|
|
670
|
+
const typingsFilePattern = '[name].d.ts';
|
|
671
|
+
const indexId = 'index';
|
|
672
|
+
const typesVersionsLastFields = new Set(['*']);
|
|
662
673
|
const inputs = [];
|
|
663
674
|
const logger$1 = logger.createLogger();
|
|
664
675
|
const allowEsm = (config.formatsOverridden && config.formats.includes('es') || !config.formatsOverridden);
|
|
@@ -700,9 +711,9 @@ function processPackage(pkg, config, plugins) {
|
|
|
700
711
|
}
|
|
701
712
|
pkg.types = `./${config.dir}/index.d.ts`;
|
|
702
713
|
if (allowUmd && typeof pkg.umd === 'string') {
|
|
703
|
-
pkg.umd = `./${config.dir}/${patternToName(config.umdPattern,
|
|
704
|
-
if (!config.umdInputs.includes(
|
|
705
|
-
config.umdInputs.push(
|
|
714
|
+
pkg.umd = `./${config.dir}/${patternToName(config.umdPattern, indexId)}`;
|
|
715
|
+
if (!config.umdInputs.includes(indexId)) {
|
|
716
|
+
config.umdInputs.push(indexId);
|
|
706
717
|
}
|
|
707
718
|
}
|
|
708
719
|
if (config.bin) {
|
|
@@ -726,45 +737,57 @@ function processPackage(pkg, config, plugins) {
|
|
|
726
737
|
delete pkg.bin;
|
|
727
738
|
}
|
|
728
739
|
if (allowCjs) {
|
|
729
|
-
pkg.main = `./${config.dir}/${patternToName(config.commonjsPattern,
|
|
740
|
+
pkg.main = `./${config.dir}/${patternToName(config.commonjsPattern, indexId)}`;
|
|
730
741
|
}
|
|
731
742
|
if (allowEsm && !allowCjs) {
|
|
732
|
-
pkg.main = `./${config.dir}/${patternToName(config.esPattern,
|
|
743
|
+
pkg.main = `./${config.dir}/${patternToName(config.esPattern, indexId)}`;
|
|
733
744
|
}
|
|
734
745
|
if (allowCjs && pkg.main !== pkg.exports['.'].require) {
|
|
735
746
|
pkg.exports['.'].require = pkg.main;
|
|
736
747
|
}
|
|
737
748
|
if (allowCjs && allowEsm && typeof pkg.module !== 'string') {
|
|
738
|
-
pkg.module = `./${config.dir}/${patternToName(config.esPattern,
|
|
749
|
+
pkg.module = `./${config.dir}/${patternToName(config.esPattern, indexId)}`;
|
|
739
750
|
}
|
|
740
751
|
if (pkg.module !== pkg.exports['.']?.default) {
|
|
741
752
|
pkg.exports['.'].default = pkg.module;
|
|
742
753
|
}
|
|
743
|
-
if (allowUmd && config.umdInputs.includes(
|
|
744
|
-
pkg.unpkg = `./${config.dir}/${patternToName(config.umdPattern,
|
|
754
|
+
if (allowUmd && config.umdInputs.includes(indexId)) {
|
|
755
|
+
pkg.unpkg = `./${config.dir}/${patternToName(config.umdPattern, indexId)}`;
|
|
756
|
+
}
|
|
757
|
+
if (typeof pkg.typesVersions !== 'object' && pkg.typesVersions !== null) {
|
|
758
|
+
pkg.typesVersions = {};
|
|
759
|
+
}
|
|
760
|
+
if (typeof pkg.typesVersions['*'] !== 'object' && pkg.typesVersions['*'] !== null) {
|
|
761
|
+
pkg.typesVersions['*'] = {};
|
|
745
762
|
}
|
|
746
763
|
for (const id in pkg.exports) {
|
|
747
764
|
if (id === './package.json')
|
|
748
765
|
continue;
|
|
749
|
-
const basename = id == '.' ?
|
|
766
|
+
const basename = id == '.' ? indexId : path.basename(id);
|
|
750
767
|
if (typeof pkg.exports[id] !== 'object') {
|
|
751
768
|
pkg.exports[id] = {};
|
|
752
769
|
}
|
|
753
|
-
pkg.
|
|
770
|
+
pkg.typesVersions['*'][id] = [`${config.dir}/${patternToName(typingsFilePattern, basename)}`];
|
|
771
|
+
pkg.exports[id].types = `./${config.dir}/${patternToName(typingsFilePattern, basename)}`;
|
|
754
772
|
if (allowEsm) {
|
|
755
773
|
pkg.exports[id].import = `./${config.dir}/${patternToName(config.esPattern, basename)}`;
|
|
756
774
|
}
|
|
757
775
|
if (allowCjs) {
|
|
758
776
|
pkg.exports[id].require = `./${config.dir}/${patternToName(config.commonjsPattern, basename)}`;
|
|
759
777
|
}
|
|
760
|
-
pkg.exports[id] = orderFields(pkg.exports[id]);
|
|
761
|
-
if (basename !==
|
|
778
|
+
pkg.exports[id] = orderFields(exportsFields, pkg.exports[id]);
|
|
779
|
+
if (basename !== indexId) {
|
|
762
780
|
if (!pkg.files.includes(basename)) {
|
|
763
781
|
pkg.files.push(basename);
|
|
764
782
|
}
|
|
765
783
|
}
|
|
766
784
|
inputs.push(`./${config.sourceDir}/${basename}.ts`);
|
|
767
785
|
}
|
|
786
|
+
pkg.typesVersions['*']['*'] = [
|
|
787
|
+
`${config.dir}/${patternToName(typingsFilePattern, indexId)}`,
|
|
788
|
+
`${config.dir}/*`
|
|
789
|
+
];
|
|
790
|
+
pkg.typesVersions['*'] = orderFields(emptySet, pkg.typesVersions['*'], typesVersionsLastFields);
|
|
768
791
|
if (allowUmd && config.umdInputs.length > 0 && !config.formats.includes('umd')) {
|
|
769
792
|
config.formats.push('umd');
|
|
770
793
|
}
|
|
@@ -776,22 +799,20 @@ function processPackage(pkg, config, plugins) {
|
|
|
776
799
|
function patternToName(pattern, input) {
|
|
777
800
|
return pattern.replace('[name]', input);
|
|
778
801
|
}
|
|
779
|
-
|
|
780
|
-
'types',
|
|
781
|
-
'import',
|
|
782
|
-
'require',
|
|
783
|
-
'svelte',
|
|
784
|
-
'default'
|
|
785
|
-
]);
|
|
786
|
-
function orderFields(exports) {
|
|
802
|
+
function orderFields(firstFields, exports, lastFields = emptySet) {
|
|
787
803
|
const ordered = {};
|
|
788
|
-
for (const key of
|
|
804
|
+
for (const key of firstFields) {
|
|
789
805
|
if (key in exports) {
|
|
790
806
|
ordered[key] = exports[key];
|
|
791
807
|
}
|
|
792
808
|
}
|
|
793
809
|
for (const key in exports) {
|
|
794
|
-
if (!
|
|
810
|
+
if (!firstFields.has(key) && !lastFields.has(key)) {
|
|
811
|
+
ordered[key] = exports[key];
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
for (const key of lastFields) {
|
|
815
|
+
if (key in exports) {
|
|
795
816
|
ordered[key] = exports[key];
|
|
796
817
|
}
|
|
797
818
|
}
|
|
@@ -802,7 +823,7 @@ async function writeJson(path, json) {
|
|
|
802
823
|
await fs.writeFile(path, toFormattedJson(json));
|
|
803
824
|
}
|
|
804
825
|
|
|
805
|
-
var version = "1.
|
|
826
|
+
var version = "1.26.0";
|
|
806
827
|
var name = "pkgbld";
|
|
807
828
|
var license = "MIT";
|
|
808
829
|
var author = "Konstantin Shutkin";
|
package/package.json
CHANGED