Nnodejs

nodejs/import-assertions-to-attributes

Replace `assert` import attribute to the `with` ECMAScript import attribute.

transformationmigration
Public
9 downloads
5 stars
How to Use
Run this codemod on your codebase using one of the following commands

The easiest way to run this codemod without installing anything globally:

Documentation

Import Assertions to Attributes

This recipe converts import assertions (assert syntax) to the standardized import attributes (with syntax). It modifies code like:

ts

Usage

Run this codemod with:

sh

When is it useful?

The import assertions syntax is being deprecated in favor of the standardized import attributes syntax. This codemod helps transition existing codebases to the new syntax, ensuring compatibility with future versions of Node.js.

Node.js drop support of import assertions in favor of import attributes in version 22.0.0
But the support for import attributes was added in Node.js version 18.20.0

Ready to contribute?

Build your own codemod and share it with the community.