[Feature Request]: Adjust packages exports to align with the nodejs module resolving logics
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.8k
- Forks
- 285
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 59
Description
Feature Request Description
We are using [rollup](https://rollupjs.org/) as a bundler for our projects. While upgrading one of the plugins, we've discovered the issue already described in their github:
https://github.com/rollup/plugins/issues/684
Practically, the problem is that if the path in the exports of package.json are set in such format as it is in some of the UI5 packages:
"exports": {
"./dist/*": "./dist/*",
"./package.json": "./package.json",
"./*": "./dist/*"
}
then node will recognise the following import
import '@ui5/webcomponents-icons/dist/undo'
as a folder, not a JS module. Since none exists, the builder throws the following error:
[!] (plugin commonjs--resolver) Error: Could not load /SAPDevelop/test-project/node_modules/@ui5/webcomponents-icons/dist/undo: ENOENT: no such file or directory, open '/SAPDevelop/test-project/node_modules/@ui5/webcomponents-icons/dist/undo'
The workaround on our (i.e. consuming) side would be adding a file extension postfix to the export line
import '@ui5/webcomponents-icons/dist/undo.js'
however, it would obviously be easier if the exports would have been set up correctly on the package level.
We are requesting this baring in mind we can be not the only ones coming up with the issue in the future.
Proposed Solution
Not sure what is the best way to resolve the issue. The guide on the webpack page suggests that adding a .js extension to the folder wildcard path is possible.
"exports": {
"./dist/*": "./dist/*.js",
"./package.json": "./package.json",
"./*": "./dist/*.js"
}
Nevertheless, since the exported folders often contains nested folders, it might be reasonable to add some additional path templates.
Proposed Alternatives
No response
Additional Context
No response
Priority
Low
Privacy Policy
- I’m not disclosing any internal or sensitive information.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect the package.json exports in the affected UI5 packages, starting with @ui5/webcomponents-icons, and compare their extensionless paths with Node.js and Rollup resolution behavior. Reproduce the import shown in the issue and define the work as complete when the relevant package exports resolve successfully without requiring a .js suffix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, rollup, typescript
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100