npm

@shelter/babel-plugin-codemod-script-to-module
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

babel-plugin-codemod-script-to-module

A babel codemod to transform an ECMAScript script to a ECMAScript module while preserving behaviour. This is useful for integrating legacy code with your module bundler.

Usage

This is designed to be used alongside babel-codemod.

yarn add -D @shelter/babel-plugin-codemod-script-to-module babel-codemod

codemod --plugin @shelter/babel-plugin-codemod-script-to-module --source-type script path/to/file.js

After you have finished using the codemod, you can remove the related packages:

yarn remove @shelter/babel-plugin-codemod-script-to-module babel-codemod

Testing

Most testing is done by using the fixtures in the __fixtures__ directory. Their purpose is two-fold. Firstly, we check that input.js compiles to output.js. Secondly, these files contain assertions, and we check that the assertions pass in both the input when interpreted as a script and the output when interpreted as a module. These assertions help ensure that behaviour is preserved during transformation.

Package Sidebar

Install

npm i @shelter/babel-plugin-codemod-script-to-module

Weekly Downloads

1

Version

0.0.4

License

MIT

Unpacked Size

11.9 kB

Total Files

9

Last publish

Collaborators

  • cameron-martin
  • jpdorman
  • shelterci