Update @tannin/sprintf to resolve CommonJS error#70799
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
There are more changes here than I would have expected. Running npm install on trunk resulted in the changes not related to @tannin/sprintf. I'm using the latest version of NPM (v11.4.2).
There was a problem hiding this comment.
I've noticed the lockfile seems out of date on trunk lately, npm ci frequently fails. It would be nice if the unrelated changes were pulled out into their own PR to update the lockfile.
|
Size Change: 0 B Total Size: 1.89 MB ℹ️ View Unchanged
|
|
Flaky tests detected in cf10792. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/16391077100
|
|
The lint error is likely due to the removal of the This is related to lack of support for There are a few ways to resolve this:
|
There's at least one instance we have already: gutenberg/packages/vips/src/index.ts Lines 7 to 8 in 362e12d |
|
I pushed the quick fix of disabling the rule via code comment, with an explanation. I think the better long-term solution is to use |
sirreal
left a comment
There was a problem hiding this comment.
I'd prefer to have the lockfile update in its own PR, but these changes seem fine.
If you do extract those changes to another PR, I'll give both a priority review.
There was a problem hiding this comment.
I've noticed the lockfile seems out of date on trunk lately, npm ci frequently fails. It would be nice if the unrelated changes were pulled out into their own PR to update the lockfile.
Sure. Extracted to #70839 . I'll rebase this one when that's merged. |
|
hi @aduth, I found another issue related to typings that being exported in If the type is imported in a typescript file it works as expected but when the gutenberg builds the i18n package the type.d.ts fails to find declaration hence the typings fails. Adding this fixes the issue "exports": {
".": {
"import": "./src/index.js",
"require": "./build/index.js",
"types": "./src/index.d.ts"
},
"./types": {
"types": "./types/index.d.ts",
"default": "./types/index.d.ts"
}
},
"types": "./src/index.d.ts"Screenshotstypes.ts
types.d.ts
|
|
That's a good catch @USERSATOSHI . Personally I wouldn't expect that we should need a separate Alternatively, I wonder if there's a way Gutenberg could avoid relying on the internal type and use |
Yeah made it work with Thank you. Updated typeexport type DistributeSprintfArgs< T extends string > = T extends any
? Parameters< typeof sprintf< T > >[ 1 ]
: never; |
288b8ea to
045bab4
Compare
|
Rebased after merging #70839. The changes are much more reasonable now! |
* Update tannin sprintf to resolve CommonJS error * Disable lint error


What?
Updates
@tannin/sprintfdependency from v1.3.0 to v1.3.1 to incorporate a bug fix which causes errors when importing the module in CommonJS contexts in the current version.See: aduth/tannin#20
Changelog: https://github.com/aduth/tannin/blob/master/packages/sprintf/CHANGELOG.md#131-2025-07-19
Full diff: https://my.diffend.io/npm/@tannin/sprintf/1.3.0/1.3.1
Follow-up to #70434
Why?
Fixes an error when importing any Gutenberg package that depends on
@tannin/sprintf, if imported in a CommonJS project.Example: Automattic/jetpack#44376 (comment)
How?
See changes in aduth/tannin@ee0b6ff
The root of the issue is that because the package is marked as ESM (
"type": "module") and the CommonJS build uses the.jsfile, it is interpreted as ESM, rather than as CommonJS. This is addressed by renaming the built output as.cjsinstead of.js.Testing Instructions
Repeat Testing Instructions from #70434