This repository has been archived by the owner on May 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 80
Adds a lookup for type files when generating the package.json #92
Closed
Closed
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e21c154
Emulate the TypeScript and Flow resolvers to determine if there are t…
orta e0b5c2f
README
orta 16c78fe
Fix a resolution bug
orta f693b64
Adds a test to make sure subpaths work, and handling ./ prefixed mains
orta a6c80be
Handle esmodule export resolving too
orta e049d88
Handle short-hand esm syntax
orta 827fabd
Merge branch 'latest' into latest
orta 99096c2
Merge branch 'main' into latest
wraithgar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
const t = require('tap') | ||
const read = require('../') | ||
const { resolve } = require('path') | ||
|
||
t.test('adds types with a custom main field', t => { | ||
const fixture = resolve(__dirname, 'fixtures/types/custom-dts/two-new-fields.json') | ||
read(fixture, (er, data) => { | ||
if (er) { | ||
throw er | ||
} | ||
t.match(data, { | ||
main: './custom-path.js', | ||
types: './custom-path.d.ts', | ||
flow: './custom-path.flow.js' | ||
}) | ||
t.end() | ||
}) | ||
}) | ||
|
||
t.test('handles the inferred index.js', t => { | ||
const fixture = resolve(__dirname, 'fixtures/types/default-dts/inferred.json') | ||
read(fixture, (er, data) => { | ||
if (er) { | ||
throw er | ||
} | ||
t.match(data, { | ||
types: './index.d.ts' | ||
}) | ||
t.end() | ||
}) | ||
}) | ||
|
||
t.test('handles not overwriting existing fields', t => { | ||
const fixture = resolve(__dirname, 'fixtures/types/with-field/has-types-field.json') | ||
read(fixture, (er, data) => { | ||
if (er) { | ||
throw er | ||
} | ||
t.match(data, { | ||
types: '@types/express', | ||
flow: './index.flow.js' | ||
}) | ||
t.end() | ||
}) | ||
}) | ||
|
||
t.test('does not add types fields if not present', t => { | ||
const fixture = resolve(__dirname, 'fixtures/readmes/package.json') | ||
read(fixture, (er, data) => { | ||
if (er) { | ||
throw er | ||
} | ||
t.false(data.types, 'types field should not be added') | ||
t.false(data.flow, 'flow field should not be added') | ||
t.end() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Empty because implementation isn't important |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Empty because implementation isn't important |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/package", | ||
"name": "two-new-fields", | ||
"main": "./custom-path.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Empty because implementation isn't important |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/package", | ||
"name": "no-main" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/package", | ||
"name": "has-types-reference", | ||
"types": "@types/express" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Empty because implementation isn't important |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can totally drop this, but it finalizes the auto-complete in the file