Skip to content

Conversation

@kevinchappell
Copy link
Collaborator

resolves #396

Copilot AI review requested due to automatic review settings July 22, 2025 12:40
Copy link
Contributor

Copilot AI left a 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 resolve function 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'),
Copy link

Copilot AI Jul 22, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines 16 to 18
const localSpriteUrl = typeof resolve === 'function'
? resolve(`../../lib/icons/${formeoSpriteId}.svg`)
: `../../lib/icons/${formeoSpriteId}.svg`
Copy link

Copilot AI Jul 22, 2025

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.

Suggested change
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`;

Copilot uses AI. Check for mistakes.
@kevinchappell kevinchappell merged commit 3dd40a1 into master Jul 22, 2025
1 check passed
@kevinchappell kevinchappell deleted the fix/396-resolve-not-function branch July 22, 2025 12:44
@kevinchappell
Copy link
Collaborator Author

🎉 This PR is included in version 3.1.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Uncaught TypeError: g is not a function

2 participants