Skip to content

Conversation

pcfreak30
Copy link

@pcfreak30 pcfreak30 commented Aug 1, 2025

PR Checklist

Please check if your PR fulfills the following requirements:

Bugs / Features

What is the current behavior?

What is the new behavior?

fixes #6914

Notes for reviewers

Could not use esm module because it hid the plural and singular API's behind a wrapper. So having to use a * import to keep compatibility...

@pcfreak30 pcfreak30 requested a review from a team as a code owner August 1, 2025 08:02
Copy link

changeset-bot bot commented Aug 1, 2025

⚠️ No Changeset found

Latest commit: 1349df3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

netlify bot commented Aug 1, 2025

Deploy Preview for refine-doc-live-previews ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 1349df3
🔍 Latest deploy log https://app.netlify.com/projects/refine-doc-live-previews/deploys/688cb3d16497540008aa94aa
😎 Deploy Preview https://deploy-preview-6915--refine-doc-live-previews.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pcfreak30 pcfreak30 changed the title refactor: switch to pluralize-esm refactor: Use wildcard ESM import for pluralize Aug 1, 2025
@pcfreak30 pcfreak30 marked this pull request as draft August 1, 2025 17:53
@pcfreak30
Copy link
Author

I have made this a draft as this has needed a patch to use the existing library.

diff --git a/pluralize.js b/pluralize.js
index b8f970adc84a99de69f316ac05358130dc7aa0ce..42484a163636ac56970d09758bb7261550fb1832 100644
--- a/pluralize.js
+++ b/pluralize.js
@@ -1,20 +1,23 @@
 /* global define */
 
-(function (root, pluralize) {
+(function(root, pluralize) {
   /* istanbul ignore else */
   if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') {
-    // Node.
+    // Node (CommonJS)
     module.exports = pluralize();
   } else if (typeof define === 'function' && define.amd) {
-    // AMD, registers as an anonymous module.
-    define(function () {
+    // AMD
+    define(function() {
       return pluralize();
     });
+  } else if (typeof import.meta !== 'undefined') {
+    // ESM
+    return pluralize();
   } else {
-    // Browser global.
+    // Browser global
     root.pluralize = pluralize();
   }
-})(this, function () {
+})(this, function() {
   // Rule storage - pluralize and singularize need to be run sequentially,
   // while other rules can be optimized using an object for instant lookups.
   var pluralRules = [];

The crux is still that the vite dev server, for me at-least in vite 6 is not handling this CJS/AMD in dev mode, and ive tried a lot of things...

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.

[BUG] pluralize ESM importing
1 participant