Skip to content
This repository was archived by the owner on May 4, 2024. It is now read-only.

Commit a66a43a

Browse files
authored
fix(types): remove partial/buggy exports support (#105)
1 parent 69a9b56 commit a66a43a

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

read-json.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -521,12 +521,30 @@ function final (file, data, log, strict, cb) {
521521

522522
function fillTypes (file, data, cb) {
523523
var index = data.main ? data.main : 'index.js'
524-
if (data.exports && typeof data.exports === 'string') {
525-
index = data.exports
526-
}
527-
if (data.exports && data.exports['.']) {
528-
index = data.exports['.']
529-
}
524+
525+
// TODO exports is much more complicated than this in verbose format
526+
// We need to support for instance
527+
528+
// "exports": {
529+
// ".": [
530+
// {
531+
// "default": "./lib/npm.js"
532+
// },
533+
// "./lib/npm.js"
534+
// ],
535+
// "./package.json": "./package.json"
536+
// },
537+
// as well as conditional exports
538+
539+
// if (data.exports && typeof data.exports === 'string') {
540+
// index = data.exports
541+
// }
542+
543+
// if (data.exports && data.exports['.']) {
544+
// index = data.exports['.']
545+
// if (typeof index !== 'string') {
546+
// }
547+
// }
530548

531549
var extless =
532550
path.join(path.dirname(index), path.basename(index, path.extname(index)))

test/fill-types.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ t.test('does not add types fields if not present', t => {
6969

7070
// https://nodejs.org/api/esm.html#esm_writing_dual_packages_while_avoiding_or_minimizing_hazards
7171

72-
t.test('handles esm modules', t => {
72+
t.skip('handles esm modules', t => {
7373
const fixture = resolve(__dirname, 'fixtures/types/esmodule-exports/exports.json')
7474
read(fixture, (er, data) => {
7575
if (er) {
@@ -85,7 +85,7 @@ t.test('handles esm modules', t => {
8585

8686
// https://nodejs.org/api/esm.html#esm_exports_sugar
8787

88-
t.test('handles esm modules with sugared exports', t => {
88+
t.skip('handles esm modules with sugared exports', t => {
8989
const fixture = resolve(__dirname, 'fixtures/types/esmodule-exports-sugar/sugar.json')
9090
read(fixture, (er, data) => {
9191
if (er) {

0 commit comments

Comments
 (0)