Skip to content

feat: Add manifests to exports map#118

Merged
43081j merged 1 commit intoe18e:mainfrom
rschristian:rschristian-patch-1
Jul 27, 2024
Merged

feat: Add manifests to exports map#118
43081j merged 1 commit intoe18e:mainfrom
rschristian:rschristian-patch-1

Conversation

@rschristian
Copy link
Copy Markdown
Contributor

Adds the manifests to the export map so they can be accessed by tools that utilize Node's module resolution. For example, if you tried to run this:

import nativeReplacements from 'module-replacements/manifests/native.json' with { type: 'json' };

console.log(nativeReplacements);

You'd see this:

node:internal/modules/esm/resolve:299
  return new ERR_PACKAGE_PATH_NOT_EXPORTED(
         ^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './manifests/native.json' is not defined by "exports" in /home/ryun/Projects/deptree/node_modules/module-replacements/package.json imported from /home/ryun/Projects/deptree/index.js

Also adds package.json to the exports map too -- it's a handy thing that many other libraries offer. Never know, someone might want to access it in a script for some reason.

@43081j
Copy link
Copy Markdown
Contributor

43081j commented Jul 27, 2024

makes sense to me 👍

@43081j 43081j merged commit 01d55f6 into e18e:main Jul 27, 2024
@rschristian rschristian deleted the rschristian-patch-1 branch July 27, 2024 08:26
@rschristian
Copy link
Copy Markdown
Contributor Author

@43081j It looks like this got stripped out of the 2.3.0 publish, I'm assuming this isn't intentional?

https://www.runpkg.com/?module-replacements@2.3.0/package.json

@43081j
Copy link
Copy Markdown
Contributor

43081j commented Aug 2, 2024

good catch. this is because tshy generates the export map for us, so we should've actually added it to the tshy config rather than directly to the map

have opened #131 to fix

@rschristian
Copy link
Copy Markdown
Contributor Author

Gotcha. Sorry, was not/am not familiar with tshy, I assumed I could just add it directly to the export map (did it from the web interface IIRC, didn't even pull locally)

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

Successfully merging this pull request may close these issues.

2 participants