Skip to content

pixelastic/import2require

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
bin
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Import2require

Command-line tool to convert import and export statements in JavaScript files to require and module.exports instead.

This tool is meant to be used when you need to convert a codebase from one style to the other.

Example

// This code...
import absalom from 'absalom';
import westcrown from './westcrown.js';
import { sandpoint, magnimar } from 'varisia';
import { nisroch, ridwan } from 'nidal';

export default {
  world: 'golarion',
};

// ...will be converted to
const absalom = require('absalom');
const westcrown = require('./westcrown.js');
const { sandpoint, magnimar } = require('varisia');
const { nisroch, ridwan } = require('nidal');

module.exports = {
  world: 'golarion',
};

Usage

Install import2require locally or globally, then run import2require ./path/to/files.js. Make sure you backup your files before running it, just in case.

About

Convert `import foo from 'foo'` to `const foo = require('foo')` from the command line

Resources

License

Stars

Watchers

Forks

Packages

No packages published