Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript not taking into account new exports field of package.json #35290

Closed
5 tasks done
lcswillems opened this issue Nov 22, 2019 · 1 comment
Closed
5 tasks done

Comments

@lcswillems
Copy link

lcswillems commented Nov 22, 2019

Search Terms

typescript
package.json
exports field
package resolution

Suggestion

The version 13.2 of Node.js allows ESM modules and a new package.json field, called exports, to select and rewrite exported files.

However, TypeScript doesn't take it into account.

Use Cases

For example, I have a library with a dist folder. And I only want to export this folder.

Currently, I have to add a bunch of files at the root of the package to include those in the dist folder.

Examples

I add:

exports: {
    "./": "./dist/"
}

to my package.json and want to be able to import my scripts with:

import myscript from "mylibrary/myscript";

instead of:

import myscript from "mylibrary/dist/myscript";

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.
@lcswillems
Copy link
Author

This is a duplicate of #33079

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant