pkgbld 1.24.2 → 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 +49 -30
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -294,9 +294,9 @@ async function externals (provider, config, inputs) {
|
|
|
294
294
|
const allowGenericUmd = config.umdInputs.length === 1 && inputs.length === 1;
|
|
295
295
|
if (config.formats.length > 0) {
|
|
296
296
|
const format = (allowGenericUmd ? undefined : config.formats.filter(format => format !== 'umd'));
|
|
297
|
-
provider.provide(() => pluginExternals(config.includeExternals === false
|
|
298
|
-
|
|
299
|
-
|
|
297
|
+
provider.provide(() => pluginExternals(config.includeExternals === false
|
|
298
|
+
? {}
|
|
299
|
+
: (id, external, importer) => includeExternals(importer, external, id, config)), 2000 /* Priority.externals */, { format });
|
|
300
300
|
// for eject config
|
|
301
301
|
provider.globalImport('path', 'path');
|
|
302
302
|
provider.globalSetup(includeExternals);
|
|
@@ -305,9 +305,7 @@ async function externals (provider, config, inputs) {
|
|
|
305
305
|
const curry = (await provider.import('lodash/curry.js'));
|
|
306
306
|
for (const currentInput of config.umdInputs) {
|
|
307
307
|
const isExternal = curry((currentInput, id, external, importer) => includeExternals(importer, external, id, config) || isExternalInput(currentInput, inputs, id, config))(currentInput);
|
|
308
|
-
provider.provide(() => pluginExternals({
|
|
309
|
-
external: isExternal
|
|
310
|
-
}), 2000 /* Priority.externals */, { format: 'umd', inputs: [`./${config.sourceDir}/${currentInput}.ts`] });
|
|
308
|
+
provider.provide(() => pluginExternals(isExternal), 2000 /* Priority.externals */, { format: 'umd', inputs: [`./${config.sourceDir}/${currentInput}.ts`] });
|
|
311
309
|
}
|
|
312
310
|
// for eject config
|
|
313
311
|
if (config.formats.length === 0) {
|
|
@@ -660,7 +658,18 @@ async function getRollupConfigs([provider, plugins$1], inputs, config, helpers,
|
|
|
660
658
|
|
|
661
659
|
const mainLoggerText = (sourceDir, dir, configsCount, startingTime, finishedCount = 0) => (final = false) => `${sourceDir} → ${dir} ${final ? configsCount : finishedCount++} / ${configsCount}${final ? (' in ' + getTimeDiff(startingTime)) : ''}`;
|
|
662
660
|
|
|
661
|
+
const emptySet = new Set;
|
|
663
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(['*']);
|
|
664
673
|
const inputs = [];
|
|
665
674
|
const logger$1 = logger.createLogger();
|
|
666
675
|
const allowEsm = (config.formatsOverridden && config.formats.includes('es') || !config.formatsOverridden);
|
|
@@ -702,9 +711,9 @@ function processPackage(pkg, config, plugins) {
|
|
|
702
711
|
}
|
|
703
712
|
pkg.types = `./${config.dir}/index.d.ts`;
|
|
704
713
|
if (allowUmd && typeof pkg.umd === 'string') {
|
|
705
|
-
pkg.umd = `./${config.dir}/${patternToName(config.umdPattern,
|
|
706
|
-
if (!config.umdInputs.includes(
|
|
707
|
-
config.umdInputs.push(
|
|
714
|
+
pkg.umd = `./${config.dir}/${patternToName(config.umdPattern, indexId)}`;
|
|
715
|
+
if (!config.umdInputs.includes(indexId)) {
|
|
716
|
+
config.umdInputs.push(indexId);
|
|
708
717
|
}
|
|
709
718
|
}
|
|
710
719
|
if (config.bin) {
|
|
@@ -728,45 +737,57 @@ function processPackage(pkg, config, plugins) {
|
|
|
728
737
|
delete pkg.bin;
|
|
729
738
|
}
|
|
730
739
|
if (allowCjs) {
|
|
731
|
-
pkg.main = `./${config.dir}/${patternToName(config.commonjsPattern,
|
|
740
|
+
pkg.main = `./${config.dir}/${patternToName(config.commonjsPattern, indexId)}`;
|
|
732
741
|
}
|
|
733
742
|
if (allowEsm && !allowCjs) {
|
|
734
|
-
pkg.main = `./${config.dir}/${patternToName(config.esPattern,
|
|
743
|
+
pkg.main = `./${config.dir}/${patternToName(config.esPattern, indexId)}`;
|
|
735
744
|
}
|
|
736
745
|
if (allowCjs && pkg.main !== pkg.exports['.'].require) {
|
|
737
746
|
pkg.exports['.'].require = pkg.main;
|
|
738
747
|
}
|
|
739
748
|
if (allowCjs && allowEsm && typeof pkg.module !== 'string') {
|
|
740
|
-
pkg.module = `./${config.dir}/${patternToName(config.esPattern,
|
|
749
|
+
pkg.module = `./${config.dir}/${patternToName(config.esPattern, indexId)}`;
|
|
741
750
|
}
|
|
742
751
|
if (pkg.module !== pkg.exports['.']?.default) {
|
|
743
752
|
pkg.exports['.'].default = pkg.module;
|
|
744
753
|
}
|
|
745
|
-
if (allowUmd && config.umdInputs.includes(
|
|
746
|
-
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['*'] = {};
|
|
747
762
|
}
|
|
748
763
|
for (const id in pkg.exports) {
|
|
749
764
|
if (id === './package.json')
|
|
750
765
|
continue;
|
|
751
|
-
const basename = id == '.' ?
|
|
766
|
+
const basename = id == '.' ? indexId : path.basename(id);
|
|
752
767
|
if (typeof pkg.exports[id] !== 'object') {
|
|
753
768
|
pkg.exports[id] = {};
|
|
754
769
|
}
|
|
755
|
-
pkg.
|
|
770
|
+
pkg.typesVersions['*'][id] = [`${config.dir}/${patternToName(typingsFilePattern, basename)}`];
|
|
771
|
+
pkg.exports[id].types = `./${config.dir}/${patternToName(typingsFilePattern, basename)}`;
|
|
756
772
|
if (allowEsm) {
|
|
757
773
|
pkg.exports[id].import = `./${config.dir}/${patternToName(config.esPattern, basename)}`;
|
|
758
774
|
}
|
|
759
775
|
if (allowCjs) {
|
|
760
776
|
pkg.exports[id].require = `./${config.dir}/${patternToName(config.commonjsPattern, basename)}`;
|
|
761
777
|
}
|
|
762
|
-
pkg.exports[id] = orderFields(pkg.exports[id]);
|
|
763
|
-
if (basename !==
|
|
778
|
+
pkg.exports[id] = orderFields(exportsFields, pkg.exports[id]);
|
|
779
|
+
if (basename !== indexId) {
|
|
764
780
|
if (!pkg.files.includes(basename)) {
|
|
765
781
|
pkg.files.push(basename);
|
|
766
782
|
}
|
|
767
783
|
}
|
|
768
784
|
inputs.push(`./${config.sourceDir}/${basename}.ts`);
|
|
769
785
|
}
|
|
786
|
+
pkg.typesVersions['*']['*'] = [
|
|
787
|
+
`${config.dir}/${patternToName(typingsFilePattern, indexId)}`,
|
|
788
|
+
`${config.dir}/*`
|
|
789
|
+
];
|
|
790
|
+
pkg.typesVersions['*'] = orderFields(emptySet, pkg.typesVersions['*'], typesVersionsLastFields);
|
|
770
791
|
if (allowUmd && config.umdInputs.length > 0 && !config.formats.includes('umd')) {
|
|
771
792
|
config.formats.push('umd');
|
|
772
793
|
}
|
|
@@ -778,22 +799,20 @@ function processPackage(pkg, config, plugins) {
|
|
|
778
799
|
function patternToName(pattern, input) {
|
|
779
800
|
return pattern.replace('[name]', input);
|
|
780
801
|
}
|
|
781
|
-
|
|
782
|
-
'types',
|
|
783
|
-
'import',
|
|
784
|
-
'require',
|
|
785
|
-
'svelte',
|
|
786
|
-
'default'
|
|
787
|
-
]);
|
|
788
|
-
function orderFields(exports) {
|
|
802
|
+
function orderFields(firstFields, exports, lastFields = emptySet) {
|
|
789
803
|
const ordered = {};
|
|
790
|
-
for (const key of
|
|
804
|
+
for (const key of firstFields) {
|
|
791
805
|
if (key in exports) {
|
|
792
806
|
ordered[key] = exports[key];
|
|
793
807
|
}
|
|
794
808
|
}
|
|
795
809
|
for (const key in exports) {
|
|
796
|
-
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) {
|
|
797
816
|
ordered[key] = exports[key];
|
|
798
817
|
}
|
|
799
818
|
}
|
|
@@ -804,7 +823,7 @@ async function writeJson(path, json) {
|
|
|
804
823
|
await fs.writeFile(path, toFormattedJson(json));
|
|
805
824
|
}
|
|
806
825
|
|
|
807
|
-
var version = "1.
|
|
826
|
+
var version = "1.26.0";
|
|
808
827
|
var name = "pkgbld";
|
|
809
828
|
var license = "MIT";
|
|
810
829
|
var author = "Konstantin Shutkin";
|
|
@@ -849,7 +868,7 @@ var dependencies = {
|
|
|
849
868
|
"@rollup/plugin-node-resolve": "^15.2.2",
|
|
850
869
|
"@rollup-extras/plugin-clean": "^1.3.8",
|
|
851
870
|
"@rollup-extras/plugin-binify": "^1.1.9",
|
|
852
|
-
"@rollup-extras/plugin-externals": "^1.
|
|
871
|
+
"@rollup-extras/plugin-externals": "^1.2.0",
|
|
853
872
|
"@slimlib/refine-partition": "^1.0.2",
|
|
854
873
|
"@slimlib/smart-mock": "^0.1.5",
|
|
855
874
|
"is-builtin-module": "^3.2.1",
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.26.0",
|
|
3
3
|
"name": "pkgbld",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Konstantin Shutkin",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@rollup/plugin-node-resolve": "^15.2.2",
|
|
40
40
|
"@rollup-extras/plugin-clean": "^1.3.8",
|
|
41
41
|
"@rollup-extras/plugin-binify": "^1.1.9",
|
|
42
|
-
"@rollup-extras/plugin-externals": "^1.
|
|
42
|
+
"@rollup-extras/plugin-externals": "^1.2.0",
|
|
43
43
|
"@slimlib/refine-partition": "^1.0.2",
|
|
44
44
|
"@slimlib/smart-mock": "^0.1.5",
|
|
45
45
|
"is-builtin-module": "^3.2.1",
|