Migrate AMD modules to ES modules

Proprietary

Replaces a RequireJS or Dojo define module with ES module syntax: each dependency becomes an import, the factory body becomes the module body, and the value the factory returns becomes the default export. Module specifiers are kept as written, so a bundler or an import map has to resolve them as the AMD loader's configuration did. A module is only converted when every AMD module, require call or loader plugin in the repository that loads it is converted too, since an AMD consumer of an ES module receives its namespace object rather than its value. Shapes without an exact ES module equivalent, such as named modules, loader plugins and CommonJS-style AMD, are left unchanged, as are factories that are not strict mode code unless convertNonStrict is set.

org.openrewrite.javascript.migrate.es6.MigrateAmdToEsModules

Optional

Also convert factories that are not strict mode code. An ES module is always strict, so code relying on sloppy mode, such as assigning to an undeclared variable, changes behavior. Default is false.

mod run . --recipe=org.openrewrite.javascript.migrate.es6.MigrateAmdToEsModules

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