Skip to content

Conversation

@shadowspawn
Copy link
Member

@shadowspawn shadowspawn commented Jun 14, 2025

Stop shipping dual esm/cjs. Ship just esm and rely on require(esm) support in recent versions of node to support CJS users.

Following yargs moving from dual CJS/ESM to ESM-only: yargs/yargs#2451

Rework lint setup to closely follow setup in yargs/yarg: essentially switching from standardx to gts.

Lots of noise in "Files changed" due to linting changes, but can look at the first commit for the bulk of the esm changes.

Includes fix for module entry point:

@shadowspawn

This comment was marked as outdated.

@shadowspawn
Copy link
Member Author

The rimraf interface changed from rimraf@3 to rimraf@6. The tests were failing because the cleanup of fr_FR.json was not working. Silly problem! After mucking about, I switched to using built-in plain fs.rmSync.

Next: sort out the linting... standardx not recognising esm syntax?

standardx: Use JavaScript Standard Style (tweaked by standardx) (https://github.com/standard/standardx)
  /Users/john/Documents/Sandpits/yargs/y18n/my-fork/test/y18n-test.mjs:10:46: Parsing error: Unexpected token import

@shadowspawn

This comment was marked as resolved.

Switch from rimraf to simple built-in rmSync
Switch from standardx to gts for linting
@shadowspawn
Copy link
Member Author

shadowspawn commented Jun 27, 2025

Two of the less trivial changes prompted by linter were:

Replace use of arguments with using rest ...args parameter.

Replace in _taggedLiteral:

- return this.__.apply(this, [str].concat([].slice.call(args, 1)))
+ return this.__(str, ...args.slice(1));

@shadowspawn shadowspawn marked this pull request as ready for review July 11, 2025 04:04
@shadowspawn
Copy link
Member Author

I reworked README for esm.

Similar to yargs, code examples use y18n for the factory function and do not have a variable for the y18n instance created by the factory function. I explicitly talk about the factory function to distinguish it from the methods on a y18n instance. See how it scans for you.

@shadowspawn
Copy link
Member Author

(I pushed a dummy commit to see if cleans up the CI status, but still have some stale jobs listed.)

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.

The files specified in module and exports are mismatched.

1 participant