-
Notifications
You must be signed in to change notification settings - Fork 20
Fix source map resolution for bundlers #63
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
base: main
Are you sure you want to change the base?
Conversation
Changed module entry point from root to dist/node/ where source maps have correct relative paths. Previously, the prepack script copied files to root, breaking source map paths that expected to be two directories deep (../../src/). Changes: - Set main/module/types to dist/node/web-eid.js - Add exports field for clean subpath imports - Include src/**/* and dist/node/**/* in package files - Update README import examples - Remove npm link "Cons" section (exports field fixes this) The prepack/postpack scripts are kept for backwards compatibility with direct file imports like '@web-eid/web-eid-library/web-eid'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes source map resolution warnings when using the library with modern bundlers like webpack. The fix restructures the package.json module entry points to use the dist/node/ directory, adds comprehensive subpath exports, and includes source files in the published package for proper source map resolution.
- Updated
main,module, andtypesfields to point todist/node/web-eid.jsinstead of root-level files - Added
exportsfield with wildcard patterns for clean subpath imports of models, errors, services, and utilities - Included
src/**/*in the files array to enable source map resolution by bundlers
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| package.json | Restructured module entry points to use dist/node/, added exports field for subpath imports, and included source files for source map support |
| README.md | Updated import examples to use the new simplified import paths (direct package import instead of /web-eid subpath) and removed outdated npm link documentation about longer import paths |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…claration - Add "type": "module" to clarify ES module intent - Change "main" to point to UMD build for CommonJS consumers - Add "require" condition to exports for CommonJS support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Rename UMD bundle outputs from .js to .cjs extension - Update main and exports to reference .cjs files - Add exports for dist bundles (es, umd, iife) for direct imports This ensures Node.js correctly parses UMD as CommonJS while the package is declared as ESM.
Summary
Fixes "Failed to parse source map" warnings when using the library with bundlers like webpack that use source-map-loader.
The root cause was that the
modulefield pointed toweb-eid.jsat package root, where source map paths (../../src/) were invalid after being copied fromdist/node/by the prepack script.Changes
main,module, andtypestodist/node/web-eid.jsexportsfield for clean subpath imports (e.g.,@web-eid/web-eid-library/models/ActionOptions)src/**/*for source map resolution anddist/node/**/*for the entry pointsBackwards Compatibility
Direct file imports like
@web-eid/web-eid-library/web-eidstill work because prepack copies files to root.Test Plan
npm run buildsucceedsnpm packcreates valid packageimport { authenticate } from '@web-eid/web-eid-library'import ActionOptions from '@web-eid/web-eid-library/models/ActionOptions'Signed-off-by: Erko Risthein erko@risthein.ee