generator-generator icon indicating copy to clipboard operation
generator-generator copied to clipboard

feat!: switch from CJS to ESM and bump Yeoman packages

Open JoshuaKGoldberg opened this issue 9 months ago • 7 comments

Purpose of this pull request?

Fixes #265.

  • [ ] Documentation update
  • [ ] Bug fix
  • [ ] Enhancement
  • [x] Other, please explain: package dependencies and module update

What changes did you make?

  • Adds "type": "module" to the package.json
  • Bumps all Yeoman dependencies to the latest: in particular the production deps yeoman-generator and yosay
  • Bumps the package.json and build.yml Node.js versions to 18+
  • WIP: Bumps Jest and switches it to its experimental ESM support

Is there anything you'd like reviewers to focus on?

I opted not to update other dependencies such as Chalk to keep the change minimal. I'd suggest we hold off releasing a new major version with these changes until those come in too.

BREAKING CHANGE: Updates the Node.js engine minimum to ^18.17.0 || >=20.5.0 to align with the current "yeoman-generator" minimums.

JoshuaKGoldberg avatar Mar 20 '25 13:03 JoshuaKGoldberg

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​jest/​globals@​26.6.2 ⏵ 29.7.010010060 +397100
Addedcross-env@​7.0.310010010077100

View full report

socket-security[bot] avatar Mar 20 '25 13:03 socket-security[bot]

Partially blocked by #270 -> #271.

JoshuaKGoldberg avatar Mar 20 '25 14:03 JoshuaKGoldberg

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

socket-security[bot] avatar Mar 24 '25 14:03 socket-security[bot]

  ● generator:app › scoped name › fills the README with project data

    TypeError: (intermediate value).resolve is not a function

      65 |     const readmeTpl = _.template(this.fs.read(this.templatePath('README.md')));
      66 |
    > 67 |     this.composeWith(import.meta.resolve('generator-node/generators/app'), {

https://github.com/jestjs/jest/issues/14923, which is now newly available in Jest 30 (still in alpha). Fun timing.

JoshuaKGoldberg avatar May 13 '25 18:05 JoshuaKGoldberg

@mshima I'm having a hard time here. Could I ask for your help, please?

What I'm trying to do is get generator-generator onto the latest yeoman-generator version, to fix #265. I've tried a few strategies and each has test issues I haven't been able to debug:

  • This PR: generally switching the package to full ESM, including "type": "module".
  • #274
  • #275
  • #276

JoshuaKGoldberg avatar Jun 23 '25 20:06 JoshuaKGoldberg

Looks like jest doesn’t support 'node:test' module.

mshima avatar Jun 24 '25 14:06 mshima

Looks like jest doesn’t support 'node:test' module.

Interesting. For visibility, looking at the error in the CI logs:

FAIL __tests__/app.test.js
  ● Test suite failed to run

    Cannot find module 'test' from 'node_modules/yeoman-test/dist/helpers.js'

      at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/index.js:863:11)

That's in yeoman-test's src/helpers.ts:

import { mock } from 'node:test';

...which comes from https://github.com/yeoman/yeoman-test/pull/232: "switch to mock from node:test". Which I'm in the dark on. What was the context there? Should we be switching all tests from Jest to node:test?

JoshuaKGoldberg avatar Aug 21 '25 09:08 JoshuaKGoldberg