Add support for exports string
MODIFY
packages/@romejs/codec-js-manifest/index.ts
packages/@romejs/codec-js-manifest/index.ts
@@ -405,7 +405,10 @@ function normalizeRepo(
}
function normalizeExports(consumer: Consumer): boolean | ManifestExports {
- if (typeof consumer.asUnknown() === 'boolean') {
+ const unknown = consumer.asUnknown();
+
+ // "exports": false
+ if (typeof unknown === 'boolean') {
return consumer.asBoolean();
}
@@ -415,6 +418,20 @@ function normalizeExports(consumer: Consumer): boolean | ManifestExports {
const exports: ManifestExports = new RelativeFilePathMap();
+ // "exports": "./index.js"
+ if (typeof unknown === 'string') {
+ exports.set(createRelativeFilePath('.'), new Map([
+ [
+ 'default',
+ {
+ consumer,
+ relative: consumer.asExplicitRelativeFilePath(),
+ },
+ ],
+ ]));
+ return exports;
+ }
+
const dotConditions: ManifestExportConditions = new Map();
for (const [relative, value] of consumer.asMap()) {
@@ -426,6 +443,10 @@ function normalizeExports(consumer: Consumer): boolean | ManifestExports {
);
}
+ if (dotConditions.size === 0) {
+ exports.set(createRelativeFilePath('.'), dotConditions);
+ }
+
dotConditions.set(relative, {
consumer: value,
relative: value.asExplicitRelativeFilePath(),
@@ -440,11 +461,6 @@ function normalizeExports(consumer: Consumer): boolean | ManifestExports {
}
const conditions = normalizeExportsConditions(value);
-
- if (dotConditions.size > 0) {
- exports.set(createRelativeFilePath('.'), dotConditions);
- }
-
exports.set(value.getKey().asExplicitRelativeFilePath(), conditions);
}

Add support for exports string