-
Notifications
You must be signed in to change notification settings - Fork 206
fix: g is not a function #400
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
Conversation
resolves #396
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 a "g is not a function" error by modifying the build configuration to generate both minified and unminified library builds, and updating the SVG sprite URL resolution to handle environments where the resolve function may not be available.
- Splits the library build process into separate minified and unminified builds with different file naming conventions
- Updates the SVG sprite URL logic to check if
resolvefunction exists before using it - Modifies asset copying configuration to handle the new build structure
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| vite.config.lib.mjs | Converts static config to function that conditionally applies minification based on build mode |
| tools/copy-assets.mjs | Updates asset copying paths and uses glob pattern for JS files |
| src/lib/js/constants.js | Adds function existence check for resolve and changes environment condition from PROD to DEV |
| package.json | Splits build:lib into separate clean, unminified, and minified build commands |
| src: resolve(projectRoot, 'dist/formeo.umd.js'), | ||
| dest: resolve(projectRoot, 'dist/'), | ||
| rename: 'formeo.min.js', | ||
| src: resolve(projectRoot, 'dist/*.js'), |
Copilot
AI
Jul 22, 2025
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.
Using a glob pattern in the src path may not work as expected with the copy function. Consider explicitly listing the files or verify that your copy utility supports glob patterns.
src/lib/js/constants.js
Outdated
| const localSpriteUrl = typeof resolve === 'function' | ||
| ? resolve(`../../lib/icons/${formeoSpriteId}.svg`) | ||
| : `../../lib/icons/${formeoSpriteId}.svg` |
Copilot
AI
Jul 22, 2025
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.
The function existence check for resolve suggests an inconsistent runtime environment. Consider documenting when resolve might not be available or using a more explicit module detection pattern.
| const localSpriteUrl = typeof resolve === 'function' | |
| ? resolve(`../../lib/icons/${formeoSpriteId}.svg`) | |
| : `../../lib/icons/${formeoSpriteId}.svg` | |
| // Check if `resolve` is available and is a function; fallback to a relative path otherwise. | |
| const localSpriteUrl = (typeof resolve !== 'undefined' && typeof resolve === 'function') | |
| ? resolve(`../../lib/icons/${formeoSpriteId}.svg`) | |
| : `../../lib/icons/${formeoSpriteId}.svg`; |
|
🎉 This PR is included in version 3.1.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
resolves #396