Make .storybook/main valid ESM for Storybook 10

Proprietary

Storybook 10 loads .storybook/main.* as an ES module. Rewrites module.exports = config to export default config and resolves the relative local addons of the addons list with import.meta.resolve(), as Storybook 10 requires. Rewrites top-level const x = require('m') and const {a, b: c} = require('m') to import statements, and an inline require('m') to a default import of m, and __dirname / __filename to import.meta.dirname / import.meta.filename. Marks any other use of require, which is no longer defined: use createRequire(import.meta.url). Extensionless relative imports in .js configs are not changed.

org.openrewrite.nodejs.migrate.storybook.MigrateStorybook10Config
mod run . --recipe=org.openrewrite.nodejs.migrate.storybook.MigrateStorybook10Config

Install it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.