Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Require To Import SyntaxNew to Visual Studio Code? Get it now.
Require To Import Syntax

Require To Import Syntax

Bruce

|
11,596 installs
| (5) | Free
Convert require to ES6 import syntax
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

require-to-import

convert require syntax to ES6 import syntax in the current opened file

  • Save the file
  • CTRL+ALT+R

cli tool version of this extension can be found here

Supported conversions

require("things").name(); // => import { name } from "things"; name();

require("things")(); // => import thingsModule from "things"; thingsModule();

const something = require("example"); // => import something from "example";

const Ben = require("person").name; // => import { name as Ben } from "person";

const { something } = require("things"); // => import { something } from "things";

const { something, anotherThing } = require("things"); // => import { something, anotherThing } from "things";

const something = require("things")(); // => import something from "things";

require("things"); // => import "things";

require("../things"); // => import "../things";

const something = require("things").something(); // => import { something } from "things";

const { thing, thingy: anotherThing } = require("module"); // => import { thing, thingy as anotherThing} from "module"

const {
  thing,
  anotherThing,
  widget: renamedWidget,
  shape: anotherShape,
  color,
} = require("module"); // => import { thing, anotherThing, widget as renamedWidget, shape as anotherShape, color } from "module";

License

MIT

Author

Igwaneza Bruce

knowbeeinc@gmail.com

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft