11# @jbrowse/core Developer Guide
22
3+ ## Package Design
4+
5+ This package has ** no main entry point** . It is designed exclusively for subpath
6+ imports:
7+
8+ ``` typescript
9+ // Correct usage
10+ import PluginManager from ' @jbrowse/core/PluginManager'
11+ import { ConfigurationSchema } from ' @jbrowse/core/configuration'
12+
13+ // This will error - no default export
14+ import ' @jbrowse/core' // ERR_PACKAGE_PATH_NOT_EXPORTED
15+ ` ` `
16+
317## package.json Structure
418
5- This package uses a dual-mode configuration to support both monorepo development and
6- external consumers.
19+ This package uses a dual-mode configuration to support both monorepo development
20+ and external consumers.
721
822### Exports Field
923
10- The ` exports ` field defines subpath imports like ` @jbrowse/core/PluginManager ` . During
11- development, these point to source TypeScript files:
24+ The ` exports ` field defines subpath imports like ` @jbrowse / core / PluginManager ` .
25+ During development, these point to source TypeScript files:
1226
1327` ` ` json
1428" exports" : {
@@ -19,8 +33,8 @@ development, these point to source TypeScript files:
1933
2034### publishConfig
2135
22- When the package is published to npm, the ` publishConfig ` section overrides the exports
23- to point to compiled output:
36+ When the package is published to npm, the ` publishConfig ` section overrides the
37+ exports to point to compiled output:
2438
2539``` json
2640"publishConfig" : {
@@ -35,9 +49,10 @@ to point to compiled output:
3549
3650### typesVersions (for moduleResolution "node" consumers)
3751
38- The ` exports ` field is only supported by TypeScript with ` moduleResolution ` set to
39- ` bundler ` , ` node16 ` , or ` nodenext ` . For consumers using the legacy ` moduleResolution: "node" ` ,
40- we include a ` typesVersions ` field in ` publishConfig ` :
52+ The ` exports ` field is only supported by TypeScript with ` moduleResolution ` set
53+ to ` bundler ` , ` node16 ` , or ` nodenext ` . For consumers using the legacy
54+ ` moduleResolution: "node" ` , we include a ` typesVersions ` field in
55+ ` publishConfig ` :
4156
4257``` json
4358"publishConfig" : {
@@ -49,8 +64,8 @@ we include a `typesVersions` field in `publishConfig`:
4964}
5065```
5166
52- This tells TypeScript where to find type declarations for subpath imports even when
53- the ` exports ` field is not being read.
67+ This tells TypeScript where to find type declarations for subpath imports even
68+ when the ` exports ` field is not being read.
5469
5570## Generating Exports
5671
@@ -61,13 +76,13 @@ auto-generated by scanning the codebase for `@jbrowse/core/*` imports:
6176pnpm generate:exports
6277```
6378
64- This script (` scripts/generateExports.mjs ` ) finds all imports of ` @jbrowse/core/* `
65- across the monorepo and generates the appropriate mappings.
79+ This script (` scripts/generateExports.mjs ` ) finds all imports of
80+ ` @jbrowse/core/* ` across the monorepo and generates the appropriate mappings.
6681
6782## Module Resolution Summary
6883
69- | Consumer Environment | How it resolves ` @jbrowse/core/PluginManager ` |
70- | ---------------------| -----------------------------------------------|
71- | Monorepo (bundler mode) | Uses ` exports ` field pointing to ` src/*.ts ` |
72- | External (bundler/node16/nodenext) | Uses ` publishConfig.exports ` pointing to ` esm/*.js ` |
73- | External (node mode) | Uses ` typesVersions ` for types, ` exports ` for runtime |
84+ | Consumer Environment | How it resolves ` @jbrowse/core/PluginManager ` |
85+ | ---------------------------------- | ----------------------------------------------------- |
86+ | Monorepo (bundler mode) | Uses ` exports ` field pointing to ` src/*.ts ` |
87+ | External (bundler/node16/nodenext) | Uses ` publishConfig.exports ` pointing to ` esm/*.js ` |
88+ | External (node mode) | Uses ` typesVersions ` for types, ` exports ` for runtime |
0 commit comments