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

subpath exports for large packages #130

Closed
fuxingloh opened this issue Apr 17, 2021 · 1 comment · Fixed by #168
Closed

subpath exports for large packages #130

fuxingloh opened this issue Apr 17, 2021 · 1 comment · Fixed by #168
Labels
kind/feature New feature request triage/accepted Triage has been accepted

Comments

@fuxingloh
Copy link
Contributor

What would you like to be added:

Available in NPM >v12.7.0

Custom subpaths can be defined along with the main entry point by treating the main entry point as the "." subpath:

{
  "main": "./dist/index.js",
  "exports": {
    ".": "./dist/index.js",
    "./submodule": "./dist/bech32.js"
  }
}

This allow loading a sub path

import submodule from '@defichain/jellyfish-crypto/bech32';
// Loads ./node_modules/@defichain/jellyfish-crypto/dist/bech32.js

Why is this needed:

As the modules and packages grows, it is becoming increasingly complex to manage imports and exports. Bundling all exports into one index.js file for small modules make senses but for large more complex modules it is harder to effectively manage conflicts. E.g. jellyfish-api-core, hence it is wise to implement subpath exports vs named exports for larger packages.

@fuxingloh fuxingloh added kind/feature New feature request triage/accepted Triage has been accepted area/core labels Apr 17, 2021
@fuxingloh fuxingloh added the priority/important-soon Will be important soon label Apr 20, 2021
@fuxingloh
Copy link
Contributor Author

Subpath exports is not yet supported in typescript, and it seems like it will be part of TypeScript 4.3, May 25 final release.
Let's wait for that.

microsoft/TypeScript#42762

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature request triage/accepted Triage has been accepted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant