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
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.